Exemple #1
0
        private void MousePressDesign(int x, int y)
        {
            ThW.UI.Controls.Control c = FindDesignControl(x, y);

            SetControl(c, true);

            if (null != c)
            {
                int cx = 0;
                int cy = this.activeWindow.TopOffset;

                for (ThW.UI.Controls.Control pp = c.Parent; pp != null; pp = pp.Parent)
                {
                    ThW.UI.Utils.Rectangle r = pp.Bounds;

                    cx += r.X;
                    cy += r.Y;
                }

                if (this.activeWindow == this.activeControl)
                {
                    cy -= this.activeWindow.TopOffset;
                }

                if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomLeft, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeLeft;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopLeft, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeTop | ControlState.ControlResizeLeft;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopRight, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz | ControlState.ControlResizeTop;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomRight, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeHoriz;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleLeft, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeHoriz | ControlState.ControlResizeLeft;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleRight, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeHoriz;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopCenter, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert | ControlState.ControlResizeTop;
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomCenter, x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlResizing | ControlState.ControlResizeVert;
                }
                else if (true == c.Bounds.Contains(x - cx, y - cy))
                {
                    this.designMousePress.SetCoords(x, y);
                    this.designControlState = ControlState.ControlDragging;
                }
            }
        }
Exemple #2
0
        private void MouseMove1(int x, int y)
        {
            UpdateCursor(MousePointers.PointerStandard);

            if (null != this.activeControl)
            {
                int cx = 0;
                int cy = this.activeWindow.TopOffset;
                ThW.UI.Controls.Control c = this.activeControl;

                for (ThW.UI.Controls.Control pp = c.Parent; pp != null; pp = pp.Parent)
                {
                    ThW.UI.Utils.Rectangle r = pp.Bounds;

                    cx += r.X;
                    cy += r.Y;
                }

                if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomLeft, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize1);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopLeft, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize2);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopRight, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize1);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomRight, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerResize2);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleLeft, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerHResize);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.MiddleRight, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerHResize);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.TopCenter, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerVResize);
                }
                else if (true == c.IsOnBorder(ThW.UI.Controls.ContentAlignment.BottomCenter, x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerVResize);
                }
                else if (true == c.Bounds.IsInside(x - cx, y - cy))
                {
                    UpdateCursor(MousePointers.PointerMove);
                }

                if ((this.designControlState & ControlState.ControlDragging) > 0)
                {
                    int dx = x - this.designMousePress.X;
                    int dy = y - this.designMousePress.Y;

                    this.activeControl.X += dx;
                    this.activeControl.Y += dy;

                    this.designMousePress.SetCoords(x, y);
                }
                else if ((this.designControlState & ControlState.ControlResizing) > 0)
                {
                    int dx = x - this.designMousePress.X;
                    int dy = y - this.designMousePress.Y;

                    int nW = this.activeControl.Width + dx;
                    int nH = this.activeControl.Height + dy;
                    int nX = this.activeControl.X;
                    int nY = this.activeControl.Y;

                    this.designMousePress.SetCoords(x, y);

                    if ((this.designControlState & ControlState.ControlResizeHoriz) == 0)
                    {
                        nW -= dx;
                    }

                    if ((this.designControlState & ControlState.ControlResizeVert) == 0)
                    {
                        nH -= dy;
                    }

                    if ((this.designControlState & ControlState.ControlResizeLeft) > 0)
                    {
                        nX = this.activeControl.X + dx;
                        nW = this.activeControl.Width - dx;

                        if (nW < this.activeControl.MinSize.Width)
                        {
                            nX -= (this.activeControl.MinSize.Width - nW);
                            nW  = this.activeControl.MinSize.Width;
                            this.designMousePress.X -= dx;
                        }
                    }

                    if ((this.designControlState & ControlState.ControlResizeTop) > 0)
                    {
                        nY = this.activeControl.Y + dy;
                        nH = this.activeControl.Height - dy;

                        if (nH < this.activeControl.MinSize.Height)
                        {
                            nY -= (this.activeControl.MinSize.Height - nH);
                            nH  = this.activeControl.MinSize.Height;
                            this.designMousePress.Y -= dy;
                        }
                    }

                    if (nW < this.activeControl.MinSize.Width)
                    {
                        nW = this.activeControl.MinSize.Width;
                        this.designMousePress.X -= dx;
                    }

                    if (nH < this.activeControl.MinSize.Height)
                    {
                        nH = this.activeControl.MinSize.Height;
                        this.designMousePress.Y -= dy;
                    }

                    this.activeControl.Bounds = new Rectangle(nX, nY, nW, nH);
                }
            }
        }