/// <summary> /// 设置货架单元格状态 /// </summary> /// <param name="cell"></param> /// <param name="s"></param> public void SetCellCaptureStatus(HouseCell cell, CellMouseStatus s) { if (cell != null) { cell.CellMouse = s; //重绘 Rectangle redrawRect = new Rectangle(cell.ltCornerPos, cell.CellSize); redrawRect.Inflate(_CellColumnWidth, _CellRowHeight); rectScale(zoomScale / 100.0f, ref redrawRect); rectTranslate(this.panelWareCells.AutoScrollPosition.X, this.panelWareCells.AutoScrollPosition.Y, ref redrawRect); // redrawRect.Offset(this.panelWareCells.AutoScrollPosition.X, this.panelWareCells.AutoScrollPosition.Y); this.panelWareCells.Invalidate(redrawRect); switch (s) { case CellMouseStatus.MOUSE_ENTER: { //触发enter事件 if (CellMouseEnter != null) { CellMouseEventArgs cellE = new CellMouseEventArgs(cell.CellCoord); CellMouseEnter(cell, cellE); } break; } case CellMouseStatus.MOUSE_LEAVE: { //触发leave事件 if (CellMouseLeave != null) { CellMouseEventArgs cellE = new CellMouseEventArgs(cell.CellCoord); CellMouseLeave(cell, cellE); } break; } case CellMouseStatus.MOUSE_NONE: { break; } } } }
public void FillCells(Point OriPt,int L,int R) { _Location = OriPt; _RowIndex = R; _RowRect = new Rectangle(_Location, new Size(_ColumnCount * _CellColumnWidth, _CellRowHeight)); for (int C = 1; C <= _ColumnCount; C++) { Point ltCornerPt = new Point(); ltCornerPt.X = _Location.X+(C-1)*_CellColumnWidth; ltCornerPt.Y = _Location.Y; HouseCell cell = new HouseCell(new CellPos(L, R, C), ltCornerPt, new Size(_CellColumnWidth, _CellRowHeight), _BkgColor, _CellBorderColor); _CellsList.Add(cell); } }
/// <summary> /// 捕获货架单元格 /// </summary> /// <param name="cellCoord"></param> public void CaptureCell(CellPos cellCoord) { if (_LastCaptureCell != null) { SetCellCaptureStatus(_LastCaptureCell, CellMouseStatus.MOUSE_LEAVE); _LastCaptureCell = null; } HouseCell cell = _LayersList[cellCoord.L - 1].RowsList[cellCoord.R - 1].CellsList[cellCoord.C - 1]; if (cell != null) { SetCellCaptureStatus(cell, CellMouseStatus.MOUSE_ENTER); _LastCaptureCell = cell; } }
public void Add(HouseCell cell) { _CellsList.Add(cell); _RowSize.Width += cell.CellSize.Width; if (_RowSize.Height < cell.CellSize.Height) _RowSize.Height = cell.CellSize.Height; }