WinCalc.xaml.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using FWindSoft.SystemExtensions;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Reflection;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Shapes;
  18. using FWindSoft.Data.Builder;
  19. using FWindSoft.Tools;
  20. using Test.Enumerator;
  21. namespace Test.CalcTrans
  22. {
  23. public class EvnetTest
  24. {
  25. public event Action DD;
  26. public void Show()
  27. {
  28. DD?.Invoke();
  29. }
  30. }
  31. /// <summary>
  32. /// WinCalc.xaml 的交互逻辑
  33. /// </summary>
  34. public partial class WinCalc : Window
  35. {
  36. public WinCalc()
  37. {
  38. InitializeComponent();
  39. //var filePath = FileUtil.GetFilePath(typeof(ReflectTest), ".xml");
  40. //double max = Double.MaxValue;
  41. //double max2 = 200d* 1000 * 1000 ;
  42. //var aa = 10.GetDigit();
  43. //var aa2 = 0.GetDigit();
  44. //var cc1 = 1345.GetDigit();
  45. //TimeKeyBuilder key = new TimeKeyBuilder();
  46. //for (int j = 0; j < 10; j++)
  47. //{
  48. // Trace.WriteLine(key.CreateKey());
  49. //}
  50. this.Loaded += WinCalc_Loaded;
  51. //EvnetTest test = new EvnetTest();
  52. //test.DD += () => { MessageBox.Show("dd"); };
  53. //test.Show();
  54. //var useEvent = typeof(EvnetTest).GetEvent("DD");
  55. //var fileds = useEvent.DeclaringType.GetFields( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.Static);
  56. //if (fileds != null)
  57. //{
  58. // fileds[0].SetValue(test, null);
  59. //}
  60. //test.Show();
  61. //test.DD += () => { MessageBox.Show("cc");};
  62. //test.Show();
  63. //List<int> list = new List<int>();
  64. //for (int j = 0; j < 15; j++)
  65. //{
  66. // list.Add(j);
  67. //}
  68. //var result1 = list.SplitBlock(10);
  69. //var result2 = list.SplitBlock(15);
  70. //var result3 = list.SplitBlock(11);
  71. //var result4 = list.SplitBlock(5);
  72. //var result5 = list.SplitBlock(6);
  73. EnumeratorTest test = new EnumeratorTest();
  74. int c = 0;
  75. foreach (var item in test)
  76. {
  77. if (c++ >=10)
  78. {
  79. break;
  80. }
  81. }
  82. // this.AddHandler(,,)
  83. //Hashtable table = new Hashtable();
  84. //table.Remove("dd");
  85. //ReflectTest.Test();
  86. }
  87. private void WinCalc_Loaded(object sender, RoutedEventArgs e)
  88. {
  89. throw new NotImplementedException();
  90. }
  91. public double GetCoeff(double total)
  92. {
  93. if (total <= 100 || total >= 400)
  94. {
  95. return 1;
  96. }
  97. if (total > 100 && total <=150)
  98. {
  99. return 0.8;
  100. }
  101. if (total > 150 && total < 400)
  102. {
  103. return 0.5;
  104. }
  105. return 1;
  106. }
  107. public double OffValue(double payValue)
  108. {
  109. return Math.Min(1, payValue * 0.2);
  110. }
  111. public List<double> CalcPay(double originPay,int times)
  112. {
  113. double totalOrigin = 0;
  114. double totalUse = 0;
  115. for (int i = 1; i <= times; i++)
  116. {
  117. var coeff = GetCoeff(totalOrigin);
  118. var payValue = originPay * coeff;
  119. var useValue = payValue - OffValue(payValue);
  120. totalOrigin = totalOrigin + payValue;
  121. totalUse = totalUse + useValue;
  122. }
  123. return new List<double>() {totalOrigin, totalUse};
  124. }
  125. private int i = 0;
  126. private void Button_Click(object sender, RoutedEventArgs e)
  127. {
  128. var originPay = OriginPayValue.Text.ToDouble();
  129. var payTimes = (int) PayTime.Text.ToDouble();
  130. var list=CalcPay(originPay, payTimes);
  131. OriginValue.Text = list[0].ToString();
  132. RealValue.Text = list[1].ToString();
  133. if (i / 2 == 0)
  134. {
  135. TestBinding.Click += (sen, ee) =>
  136. {
  137. MessageBox.Show(ee.ToString());
  138. };
  139. }
  140. else
  141. {
  142. //匿名方法不能取消
  143. TestBinding.Click -= (sen, ee) =>
  144. {
  145. MessageBox.Show(ee.ToString());
  146. };
  147. }
  148. }
  149. }
  150. }