//============================================================ // <T>开始绘制处理。</T> // // @param args 参数 //============================================================ public void Draw(SUiDrawArgs args) { FDxContext2d context = _context.Context; context.TransformIdentity(); // 计算坐标 _location.Assign(_control.CalculateDisplayPosition()); _size.Assign(_control.CalculateDisplaySize()); // 绘制选择区域 if (_designSelect) { // 绘制底版 context.FillRectangle(_selectBackColor.brush, _location.X, _location.Y, _size.Width, _size.Height); // 绘制边线 context.DrawRectangle(_selectForeColor.brush, _location.X, _location.Y, _size.Width, _size.Height); } // 绘制辅助点区域 if (_designFocus) { CalculatePoints(); foreach (SUiControlPoint point in _points) { DrawPoint(point); } } }
//============================================================ // <T>绘制辅助线。</T> //============================================================ public bool DrawAidLines() { // 检查状态 FUiControl focusControl = _selection.FocusControl; if (focusControl == null) { return(false); } FUiControl parent = focusControl.Parent as FUiControl; if (parent == null) { return(false); } // 获得环境 float scale = _context.Scale; FDxContext2d context = _context.Context; context.TransformIdentity(); // 绘制对齐线 SIntPoint2 location = focusControl.CalculateDisplayPosition(); SIntSize2 size = focusControl.CalculateDisplaySize(); foreach (FUiComponent component in parent.Components) { FUiControl control = component as FUiControl; // 检查变量 if (control == null) { continue; } if (control == focusControl) { continue; } // 计算坐标 SIntPoint2 findLocation = control.CalculateDisplayPosition(); SIntSize2 findSize = control.CalculateDisplaySize(); // 左辅助线 if (location.X == findLocation.X) { context.DrawLineLayer(location.X, 0, location.X, _size.Height, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle); } // 上辅助线 if (location.Y == findLocation.Y) { context.DrawLineLayer(0, location.Y, _size.Width, location.Y, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle); } // 右辅助线 int right = findLocation.X + findSize.Width; if (location.X + size.Width == right) { context.DrawLineLayer(right, 0, right, _size.Height, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle); } // 下辅助线 int bottom = findLocation.Y + findSize.Height; if (location.Y + size.Height == bottom) { context.DrawLineLayer(0, bottom, _size.Width, bottom, _lineBackBrush, _lineForeBrush, _lineWidth, _lineForeStrokeStyle); } } return(true); }