/// <summary> /// Specifies bounding box of region to which perform rendering. /// </summary> public void SetRegion(int x, int y, int w, int h) { this.clipViews.Add(this.clipView); int x1 = x; int y1 = y; int x2 = x + w; int y2 = y + h; if (null != this.clipView) { if (x1 < this.clipView.X) { x1 = this.clipView.X; } if (y1 < this.clipView.Y) { y1 = this.clipView.Y; } if (x2 > this.clipView.X2) { x2 = this.clipView.X2; } if (y2 > this.clipView.Y2) { y2 = this.clipView.Y2; } } this.clipView = new Rectangle(x1, y1, x2 - x1, y2 - y1); }
/// <summary> /// Clears the previous region. /// </summary> public void ClearRegion() { this.clipView = this.clipViews[clipViews.Count - 1]; this.clipViews.RemoveAt(this.clipViews.Count - 1); }
/// <summary> /// Handles mouse press event in design window. /// </summary> /// <param name="X">X mouse press coordinate.</param> /// <param name="Y">Y mouse press coordinate.</param> private void MousePressDesign(int x, int y) { Control control = FindDesignControl(x, y); SetControl(control, true); if (null != control) { int cx = this.Bounds.X; int cy = this.activeWindow.TopOffset + this.Bounds.Y; for (Control i = control.Parent; i != null; i = i.Parent) { cx += i.Bounds.X; cy += i.Bounds.Y; } if (this.activeWindow == this.activeControl) { cy -= this.activeWindow.TopOffset; } if (true == control.IsOnBorder(ContentAlignment.MiddleCenter, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlDragging; } else if (true == control.IsOnBorder(ContentAlignment.BottomLeft, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeLeft; } else if (true == control.IsOnBorder(ContentAlignment.TopLeft, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeTop | ControlState.ControlResizeLeft; } else if (true == control.IsOnBorder(ContentAlignment.TopRight, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeTop; } else if (true == control.IsOnBorder(ContentAlignment.BottomRight, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz; } else if (true == control.IsOnBorder(ContentAlignment.MiddleLeft, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeHoriz | ControlState.ControlResizeLeft; } else if (true == control.IsOnBorder(ContentAlignment.MiddleRight, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeHoriz; } else if (true == control.IsOnBorder(ContentAlignment.TopCenter, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeTop; } else if (true == control.IsOnBorder(ContentAlignment.BottomCenter, x - cx, y - cy)) { this.designMousePress.SetCoords(x, y); this.designControlBounds = control.Bounds.Clone(); this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert; } } }