123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- 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();
- }
- }
- /// <summary>
- /// WinCalc.xaml 的交互逻辑
- /// </summary>
- 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<int> list = new List<int>();
- //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<double> 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<double>() {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());
- };
- }
-
- }
- }
- }
|