private void ThreadImageGet(object data) { ThreadDate td = (ThreadDate)data; List <HistoryStockHoldEntity> HSHELNoSort; DBC.HistoryStockHoldReadByRange(td.date, td.days, out HSHELNoSort); Dictionary <string, int> hold = new Dictionary <string, int>(); List <HistoryStockHoldEntity> HSHEL = HSHELNoSort.OrderBy(g => g.date).ToList(); double pri = DBC.PrincipalRead(); double now = pri; foreach (HistoryStockHoldEntity HSHE in HSHEL) { if (!hold.ContainsKey(HSHE.id)) { hold.Add(HSHE.id, 0); } } Dictionary <string, Dictionary <DateTime, double> > moneydict = new Dictionary <string, Dictionary <DateTime, double> >(); foreach (string x in idl) { Dictionary <DateTime, double> money = new Dictionary <DateTime, double>(); NetDataController.HistoryMoney(x, td.date, td.days, out money); moneydict.Add(x, money); } List <DrawDataEntity> DDEL = new List <DrawDataEntity>(); DrawDataEntity DDE = new DrawDataEntity(); int index = 0; DateTime dt = td.date; if (dt.DayOfWeek == DayOfWeek.Saturday) { dt = dt.AddDays(2); } if (dt.DayOfWeek == DayOfWeek.Sunday) { dt = dt.AddDays(1); } for (int i = 0; i < td.days; i++) { dt = dt.AddDays(1); if (dt > DateTime.Now) { break; } if (!moneydict.First().Value.ContainsKey(dt)) { foreach (var x in moneydict) { x.Value.Add(dt, x.Value[dt.AddDays(-1)]); } } DDE.date = dt; while (index < HSHEL.Count - 1 && HSHEL[index].date <= dt) { hold[HSHEL[index].id] += HSHEL[index].change; now += -HSHEL[index].change * HSHEL[index].money; index++; } double money = 0; foreach (var x in hold) { if (x.Value != 0) { string id = idl.Where(s => s.Substring(1) == x.Key).First(); if (id == null) { continue; } double m = moneydict[id][dt]; money += x.Value * m; } } DDE.money = (money + now - pri) * 100 / pri; DDEL.Add(DDE); } DrawDataController DDC = new DrawDataController(td.Width, td.Height); DDC.DrawData(DDEL); Action <Image, System.Drawing.Bitmap> updateAction = new Action <Image, System.Drawing.Bitmap>(UpdateImage); yield.Dispatcher.BeginInvoke(updateAction, yield, DDC.GetImage()); }