private void StopWatch_Click(object sender, RoutedEventArgs e) { watchitem t = listview2.SelectedItem as watchitem; if (t != null) { Thread temp = Systhread[t.Time]; temp.Abort(); watchitems.Remove(t); } else { ModernDialog.ShowMessage("没有选中任何项", "", MessageBoxButton.OK); } }
private void Watching_Click(object sender, RoutedEventArgs e) { myThread temp = new myThread(); if (string.IsNullOrWhiteSpace(buycode.Text) || string.IsNullOrWhiteSpace(buyprice.Text) || string.IsNullOrWhiteSpace(buyamount.Text)) { ModernDialog.ShowMessage("输入错误", "", MessageBoxButton.OK); } else { Auto con = new Auto(); temp.Code = buycode.Text; temp.Price = double.Parse(buyprice.Text); temp.Amount = int.Parse(buyamount.Text); temp.State = (SelectState)(this.SelectDealState.SelectedIndex); thishwnd = con.GetWindowHwnd("融资融券"); temp.mainhwnd = thishwnd; temp.treeview = tv; temp.window = this; int inputlength = buyprice.Text.Length - buyprice.Text.IndexOf(".") - 1; double pz = 0, pd = 0; Sina link = new Sina(); List <StockInfo> now = new List <StockInfo>(); now = link.GetCurrent(temp.Code); int length = now[0].YesterdayClose.ToString().Length - now[0].YesterdayClose.ToString().IndexOf(".") - 1; if (length == 2) { pz = (double)((int)((now[0].YesterdayClose * 1.1 + 0.005) * 100)) / 100; pd = (double)((int)((now[0].YesterdayClose * 0.9 + 0.005) * 100)) / 100; } else if (length == 3) { pz = (double)((int)((now[0].YesterdayClose * 1.1 + 0.0005) * 1000)) / 1000; pd = (double)((int)((now[0].YesterdayClose * 0.9 + 0.0005) * 1000)) / 1000; } if (temp.Amount % 100 != 0 || inputlength > 3) { ModernDialog.ShowMessage("输入错误", "", MessageBoxButton.OK); } else if (temp.Price > pz || temp.Price < pd) { ModernDialog.ShowMessage("输入价格超出当天涨跌停限制", "", MessageBoxButton.OK); } else { DateTime time = DateTime.Now; string st = time.ToLongTimeString(); watchitem tempw = new watchitem { Name = now[0].Name, Code = temp.Code, WatchPrice = temp.Price, Amount = temp.Amount, Time = st, State = temp.State }; temp.Select = tempw; Thread t = new Thread(new ThreadStart(temp.autobuy)); t.IsBackground = true; //t.Name = "监控" + ('0'+sysint); //sysint++; t.Start(); Systhread.Add(st, t); watchitems.Add(tempw); } } }
public static void remove(watchitem s) { watchitems.Remove(s); }