using FWindSoft.SystemExtensions; using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using FWindSoft.Data.Builder; using FWindSoft.Tools; using Test.Enumerator; namespace Test.CalcTrans { public class EvnetTest { public event Action DD; public void Show() { DD?.Invoke(); } } /// /// WinCalc.xaml 的交互逻辑 /// public partial class WinCalc : Window { public WinCalc() { InitializeComponent(); //var filePath = FileUtil.GetFilePath(typeof(ReflectTest), ".xml"); //double max = Double.MaxValue; //double max2 = 200d* 1000 * 1000 ; //var aa = 10.GetDigit(); //var aa2 = 0.GetDigit(); //var cc1 = 1345.GetDigit(); //TimeKeyBuilder key = new TimeKeyBuilder(); //for (int j = 0; j < 10; j++) //{ // Trace.WriteLine(key.CreateKey()); //} this.Loaded += WinCalc_Loaded; //EvnetTest test = new EvnetTest(); //test.DD += () => { MessageBox.Show("dd"); }; //test.Show(); //var useEvent = typeof(EvnetTest).GetEvent("DD"); //var fileds = useEvent.DeclaringType.GetFields( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.Static); //if (fileds != null) //{ // fileds[0].SetValue(test, null); //} //test.Show(); //test.DD += () => { MessageBox.Show("cc");}; //test.Show(); //List list = new List(); //for (int j = 0; j < 15; j++) //{ // list.Add(j); //} //var result1 = list.SplitBlock(10); //var result2 = list.SplitBlock(15); //var result3 = list.SplitBlock(11); //var result4 = list.SplitBlock(5); //var result5 = list.SplitBlock(6); EnumeratorTest test = new EnumeratorTest(); int c = 0; foreach (var item in test) { if (c++ >=10) { break; } } // this.AddHandler(,,) //Hashtable table = new Hashtable(); //table.Remove("dd"); //ReflectTest.Test(); } private void WinCalc_Loaded(object sender, RoutedEventArgs e) { throw new NotImplementedException(); } public double GetCoeff(double total) { if (total <= 100 || total >= 400) { return 1; } if (total > 100 && total <=150) { return 0.8; } if (total > 150 && total < 400) { return 0.5; } return 1; } public double OffValue(double payValue) { return Math.Min(1, payValue * 0.2); } public List CalcPay(double originPay,int times) { double totalOrigin = 0; double totalUse = 0; for (int i = 1; i <= times; i++) { var coeff = GetCoeff(totalOrigin); var payValue = originPay * coeff; var useValue = payValue - OffValue(payValue); totalOrigin = totalOrigin + payValue; totalUse = totalUse + useValue; } return new List() {totalOrigin, totalUse}; } private int i = 0; private void Button_Click(object sender, RoutedEventArgs e) { var originPay = OriginPayValue.Text.ToDouble(); var payTimes = (int) PayTime.Text.ToDouble(); var list=CalcPay(originPay, payTimes); OriginValue.Text = list[0].ToString(); RealValue.Text = list[1].ToString(); if (i / 2 == 0) { TestBinding.Click += (sen, ee) => { MessageBox.Show(ee.ToString()); }; } else { //匿名方法不能取消 TestBinding.Click -= (sen, ee) => { MessageBox.Show(ee.ToString()); }; } } } }