private void dgvTick_SelectionChanged() { if (dgvTick.CurrentRow == null) { return; } nTickCurrentRowIndex = dgvTick.CurrentRow.Index; if (listTickView == null || nTickCurrentRowIndex >= listTickView.Count) { return; } PbTickView tick2 = listTickView[nTickCurrentRowIndex]; pgBar.SelectedObject = tick2.Bar; pgStatic.SelectedObject = tick2.Static; pgConfig.SelectedObject = tick2.Config; pgSplit.SelectedObject = tick2.Split; if (dgvDepth.CurrentCell == null) { dgvDepth.DataSource = tick2.DepthList; return; } int ColumnIndex = dgvDepth.CurrentCell.ColumnIndex; int RowIndex = dgvDepth.CurrentCell.RowIndex; bool Selected = dgvDepth.CurrentRow.Selected; int FirstDisplayedScrollingRowIndex = dgvDepth.FirstDisplayedScrollingRowIndex; int HorizontalScrollingOffset = dgvDepth.HorizontalScrollingOffset; dgvDepth.DataSource = tick2.DepthList; if (tick2.DepthList != null) { RowIndex = Math.Min(RowIndex, tick2.DepthList.Count - 1); } dgvDepth.CurrentCell = dgvDepth.Rows[RowIndex].Cells[ColumnIndex]; if (Selected) { dgvDepth.CurrentRow.Selected = Selected; } dgvDepth.FirstDisplayedScrollingRowIndex = FirstDisplayedScrollingRowIndex; dgvDepth.HorizontalScrollingOffset = HorizontalScrollingOffset; // 设置背景色 int pos = DepthListHelper.FindAsk1PositionDescending(tick2.DepthList, tick2.AskPrice1); for (int i = 0; i <= pos; ++i) { for (int j = 0; j < dgvDepth.Rows[i].Cells.Count; ++j) { dgvDepth.Rows[i].Cells[j].Style.BackColor = Color.Tomato; } } }
static void Main(string[] args) { List <DepthItem> oldPrevList = new List <DepthItem>(); List <DepthItem> oldCurrList = new List <DepthItem>(); List <DepthItem> newPrevList = new List <DepthItem>(); List <DepthItem> newCurrList = new List <DepthItem>(); DepthListHelper test = new DepthListHelper(); // 处理老的多一条 oldPrevList.Add(new DepthItem(1, 100, 0)); oldPrevList.Add(new DepthItem(7, 100, 0)); oldPrevList.Add(new DepthItem(12, 100, 0)); int j11 = DepthListHelper.FindAsk1Position(oldPrevList, 0); int j12 = DepthListHelper.FindAsk1Position(oldPrevList, 1); int j13 = DepthListHelper.FindAsk1Position(oldPrevList, 12); int j14 = DepthListHelper.FindAsk1Position(oldPrevList, 15); List <DepthItemView> oldPrevListV = new List <DepthItemView>(); oldPrevListV.Add(new DepthItemView() { Price = 10 }); oldPrevListV.Add(new DepthItemView() { Price = 5 }); oldPrevListV.Add(new DepthItemView() { Price = 1 }); int j21 = DepthListHelper.FindAsk1PositionDescending(oldPrevListV, 12); int j22 = DepthListHelper.FindAsk1PositionDescending(oldPrevListV, 10); int j23 = DepthListHelper.FindAsk1PositionDescending(oldPrevListV, 1); int j24 = DepthListHelper.FindAsk1PositionDescending(oldPrevListV, 0); //oldCurrList.Add(new DepthItem(5, 100, 0)); //oldCurrList.Add(new DepthItem(8, 100, 0)); //oldCurrList.Add(new DepthItem(13, 100, 0)); DepthListHelper.ExpandTwoListsToSameLength(oldPrevList, oldCurrList, 5, 13, newPrevList, newCurrList); List <DepthItem> newList = new List <DepthItem>(); DepthListHelper.SizeMinusInTwoLists(newPrevList, newCurrList, newList); List <DepthItem> newList2 = new List <DepthItem>(); DepthListHelper.SizeAddInTwoLists(newPrevList, newList, newList2); List <DepthItem> newList3 = new List <DepthItem>(); DepthListHelper.PriceMinusInOneList(newList2, newList3); List <DepthItem> newList4 = new List <DepthItem>(); DepthListHelper.PriceAddInOneList(newList3, newList4); DepthTick tick = new DepthTick(); DepthListHelper.SetDepthTick(tick, 4, 100); DepthListHelper.SetDepthTick(tick, 10, 200); DepthListHelper.SetDepthTick(tick, 15, 300); DepthListHelper.SetDepthTick(tick, 28, 400); DepthListHelper.SetDepthTick(tick, 30, 500); int i1 = DepthListHelper.GetDepthTick(tick, 4); int i2 = DepthListHelper.GetDepthTick(tick, 10); int i3 = DepthListHelper.GetDepthTick(tick, 15); int i4 = DepthListHelper.GetDepthTick(tick, 28); int i5 = DepthListHelper.GetDepthTick(tick, 30); int i6 = DepthListHelper.GetDepthTick(tick, 45); DepthTick tick2 = new DepthTick(); DepthListHelper.ListToStruct(newPrevList, 2, tick2); List <DepthItem> newList5 = new List <DepthItem>(); DepthListHelper.StructToList(tick2, 2, newList5); //int j1 = test.FindAsk1Position(oldCurrList, 5); //int j2 = test.FindAsk1Position(oldCurrList, 8); //int j3 = test.FindAsk1Position(oldCurrList, 12); //int j4 = test.FindAsk1Position(oldCurrList, 13); //int j5 = test.FindAsk1Position(oldCurrList, 14); //int j6 = test.FindAsk1Position(oldCurrList, 15); //int j7 = test.FindAsk1Position(oldCurrList, 4); //int j8 = test.FindAsk1Position(oldCurrList, 7); //oldPrevList = new List<DepthItem>(); //oldPrevList.Add(new DepthItem(3, 100, 0)); //oldPrevList.Add(new DepthItem(7, 100, 0)); //oldPrevList.Add(new DepthItem(12, 100, 0)); //int x1 = test.FindAsk1Position(oldPrevList, 3); //int x2 = test.FindAsk1Position(oldPrevList, 7); //int x3 = test.FindAsk1Position(oldPrevList, 12); //int x4 = test.FindAsk1Position(oldPrevList, 5); //int x5 = test.FindAsk1Position(oldPrevList, 13); //int x6 = test.FindAsk1Position(oldPrevList, 2); // 处理新的多一条 //oldPrevList.Add(new DepthItem(1, 100, 0)); //oldCurrList.Add(new DepthItem(1, 100, 0)); //oldCurrList.Add(new DepthItem(5, 100, 0)); //test.Do(oldPrevList, oldCurrList, newPrevList, newCurrList); //test. }