예제 #1
0
        public static Cursor ResizeDirectionToCursor(ResizeDirection direction)
        {
            Cursor result;

            switch (direction)
            {
                case ResizeDirection.None:
                    result = Cursors.Arrow;
                    break;
                case ResizeDirection.HorizontalLeft:
                case ResizeDirection.HorizontalRight:
                    result = Cursors.SizeWE;
                    break;
                case ResizeDirection.VerticalTop:
                case ResizeDirection.VerticalBottom:
                    result = Cursors.SizeNS;
                    break;
                case ResizeDirection.AscendingTopRight:
                case ResizeDirection.AscendingBottomLeft:
                    result = Cursors.SizeNESW;
                    break;
                case ResizeDirection.DescendingTopLeft:
                case ResizeDirection.DescendingBottomRight:
                    result = Cursors.SizeNWSE;
                    break;
                default:
                    result = Cursors.SizeAll;
                    break;
            }

            return result;
        }
예제 #2
0
        protected override void Resize(ResizeDirection direction, Vector vector)
        {
            ElementBaseShape element = DesignerItem.Element as ElementBaseShape;
            if (element != null)
            {
                var rect = element.GetRectangle();
                var placeholder = new Rect(rect.TopLeft, rect.Size);
                if ((direction & ResizeDirection.Top) == ResizeDirection.Top)
                {
                    placeholder.Y += vector.Y;
                    placeholder.Height -= vector.Y;
                }
                else if ((direction & ResizeDirection.Bottom) == ResizeDirection.Bottom)
                    placeholder.Height += vector.Y;
                if ((direction & ResizeDirection.Left) == ResizeDirection.Left)
                {
                    placeholder.X += vector.X;
                    placeholder.Width -= vector.X;
                }
                else if ((direction & ResizeDirection.Right) == ResizeDirection.Right)
                    placeholder.Width += vector.X;
                double kx = rect.Width == 0 ? 0 : placeholder.Width / rect.Width;
                double ky = rect.Height == 0 ? 0 : placeholder.Height / rect.Height;

                PointCollection points = new PointCollection();
                foreach (var point in element.Points)
                    points.Add(new Point(placeholder.X + kx * (point.X - rect.X), placeholder.Y + ky * (point.Y - rect.Y)));
                element.Points = points;

                DesignerItem.Redraw();
                ServiceFactory.SaveService.PlansChanged = true;
            }
        }
예제 #3
0
		protected override void Resize(ResizeDirection direction, Vector vector)
		{
			ElementBaseRectangle element = DesignerItem.Element as ElementBaseRectangle;
			if (element != null)
			{
				if ((direction & ResizeDirection.Top) == ResizeDirection.Top)
				{
					element.Top += vector.Y;
					element.Height -= vector.Y;
				}
				else if ((direction & ResizeDirection.Bottom) == ResizeDirection.Bottom)
					element.Height += vector.Y;
				if ((direction & ResizeDirection.Left) == ResizeDirection.Left)
				{
					element.Left += vector.X;
					element.Width -= vector.X;
				}
				else if ((direction & ResizeDirection.Right) == ResizeDirection.Right)
					element.Width += vector.X;
				if (element.Height < 0)
					element.Height = 0;
				if (element.Width < 0)
					element.Width = 0;
				DesignerItem.RefreshPainter();
				DesignerCanvas.DesignerChanged();
			}
		}
        public DiagramMouseManager(Diagram diagram)
        {
            _diagram = diagram;

            _currentResizeDirection = ResizeDirection.None;

            _leftButtonAction = MouseAction.None;
            _rightButtonAction = MouseAction.None;

            _leftButtonDown = false;
            _rightButtonDown = false;
            _leftButtonDownMousePosition = null;

            _currentMousePosition = null;
            _leftButtonDownMousePosition = null;

            _itemUnderCursor = null;

            _baseXViewOffset = 0;
            _baseYViewOffset = 0;

            _offsetWorker = null;

            Selector = null;
        }
예제 #5
0
        public static void Resize(Window borderlessWindow, ResizeDirection direction)
        {
            if ((direction < ResizeDirection.Left) || (direction > ResizeDirection.BottomRight))
            {
                throw new ArgumentOutOfRangeException("direction", "Invalid direction: " + direction);
            }
            HwndSource source = (HwndSource)PresentationSource.FromVisual(borderlessWindow);

            if (source != null)
            {
                UnsafeNativeMethods.SendMessage(source.Handle, 0x112, (IntPtr)(0xf000 + direction), IntPtr.Zero);
            }
        }
예제 #6
0
 protected override void Resize(ResizeDirection direction, Vector vector)
 {
     ElementBasePoint element = DesignerItem.Element as ElementBasePoint;
     if (element != null)
     {
         if ((direction & ResizeDirection.Top) == ResizeDirection.Top || (direction & ResizeDirection.Bottom) == ResizeDirection.Bottom)
             element.Top += vector.Y;
         if ((direction & ResizeDirection.Left) == ResizeDirection.Left || (direction & ResizeDirection.Right) == ResizeDirection.Right)
             element.Left += vector.X;
         DesignerItem.SetLocation();
         ServiceFactory.SaveService.PlansChanged = true;
     }
 }
예제 #7
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (DesignMode)
            {
                return;
            }

            if (Sizable)
            {
                // True if the mouse is hovering over a child control
                bool isChildUnderMouse = GetChildAtPoint(e.Location) != null;

                if ((e.Location.X < _border.Thickness) && (e.Location.Y > Height - _border.Thickness) && !isChildUnderMouse && !_maximized)
                {
                    _resizeDir = ResizeDirection.BottomLeft;
                    Cursor     = Cursors.SizeNESW;
                }
                else if ((e.Location.X < _border.Thickness) && !isChildUnderMouse && !_maximized)
                {
                    _resizeDir = ResizeDirection.Left;
                    Cursor     = Cursors.SizeWE;
                }
                else if ((e.Location.X > Width - _border.Thickness) && (e.Location.Y > Height - _border.Thickness) && !isChildUnderMouse && !_maximized)
                {
                    _resizeDir = ResizeDirection.BottomRight;
                    Cursor     = Cursors.SizeNWSE;
                }
                else if ((e.Location.X > Width - _border.Thickness) && !isChildUnderMouse && !_maximized)
                {
                    _resizeDir = ResizeDirection.Right;
                    Cursor     = Cursors.SizeWE;
                }
                else if ((e.Location.Y > Height - _border.Thickness) && !isChildUnderMouse && !_maximized)
                {
                    _resizeDir = ResizeDirection.Bottom;
                    Cursor     = Cursors.SizeNS;
                }
                else
                {
                    _resizeDir = ResizeDirection.None;

                    // Only reset the cursor when needed, this prevents it from flickering when a child control changes the cursor to its own needs
                    if (((IList)_resizeCursors).Contains(Cursor))
                    {
                        Cursor = Cursors.Default;
                    }
                }
            }
        }
예제 #8
0
        void OnResize(Vector2 resizeDelta, ResizeDirection direction, bool moveWhileResizeHorizontal, bool moveWhileresizerVertical)
        {
            Vector2 normalizedResizeDelta = resizeDelta / 2f;

            Vector2 minSize = new Vector2(60f, 60f);

            if (!Mathf.Approximately(m_ResizeTarget.style.minWidth.value, 0f))
            {
                minSize.x = m_ResizeTarget.style.minWidth;
            }

            if (!Mathf.Approximately(m_ResizeTarget.style.minHeight.value, 0f))
            {
                minSize.y = m_ResizeTarget.style.minHeight.value;
            }

            if (direction == ResizeDirection.Vertical)
            {
                normalizedResizeDelta.x = 0f;
            }
            else if (direction == ResizeDirection.Horizontal)
            {
                normalizedResizeDelta.y = 0f;
            }

            Rect newLayout = m_ResizeTarget.layout;

            // Resize form bottom/right
            if (!moveWhileResizeHorizontal)
            {
                newLayout.width         = Mathf.Max(newLayout.width + normalizedResizeDelta.x, minSize.x);
                normalizedResizeDelta.x = 0f;
            }

            if (!moveWhileresizerVertical)
            {
                newLayout.height        = Mathf.Max(newLayout.height + normalizedResizeDelta.y, minSize.y);
                normalizedResizeDelta.y = 0f;
            }

            float previousFarX = m_ResizeTarget.layout.x + m_ResizeTarget.layout.width;
            float previousFarY = m_ResizeTarget.layout.y + m_ResizeTarget.layout.height;

            newLayout.width  = Mathf.Max(newLayout.width - normalizedResizeDelta.x, minSize.x);
            newLayout.height = Mathf.Max(newLayout.height - normalizedResizeDelta.y, minSize.y);

            newLayout.x = Mathf.Min(newLayout.x + normalizedResizeDelta.x, previousFarX - minSize.x);
            newLayout.y = Mathf.Min(newLayout.y + normalizedResizeDelta.y, previousFarY - minSize.y);

            m_ResizeTarget.layout = newLayout;
        }
예제 #9
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (e.Button == MouseButtons.None)
            {
                this.directionToResize = ResizeDirection.None;
                this.SetResizeDirection(e);
                return;
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (this.isWindowMoving)
            {
                Point location = this.PointToScreen(e.Location);

                int XDistance = location.X - this.initialMovingPoint.X;
                int YDistance = location.Y - this.initialMovingPoint.Y;

                this.Location = new Point(this.oldLocation.X + XDistance, this.oldLocation.Y + YDistance);
                //attempt to dock the floating form
                this.PerformDocking();
                return;
            }

            switch (this.directionToResize)
            {
            case ResizeDirection.Bottom:
                this.BottomResize(e);
                break;

            case ResizeDirection.Left:
                this.LeftResize(e);
                break;

            case ResizeDirection.Right:
                this.RightResize(e);
                break;

            case ResizeDirection.Top:
                this.TopResize(e);
                break;
            }

            this.Invalidate(true);
        }
예제 #10
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (DesignMode)
            {
                return;
            }

            //True if the mouse is hovering over a child control
            bool isChildUnderMouse = GetChildAtPoint(e.Location) != null;

            if (e.Location.X < BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse)
            {
                resizeDir = ResizeDirection.BottomLeft;
                Cursor    = Cursors.SizeNESW;
            }
            else if (e.Location.X < BORDER_WIDTH && !isChildUnderMouse)
            {
                resizeDir = ResizeDirection.Left;
                Cursor    = Cursors.SizeWE;
            }
            else if (e.Location.X > Width - BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse)
            {
                resizeDir = ResizeDirection.BottomRight;
                Cursor    = Cursors.SizeNWSE;
            }
            else if (e.Location.X > Width - BORDER_WIDTH && !isChildUnderMouse)
            {
                resizeDir = ResizeDirection.Right;
                Cursor    = Cursors.SizeWE;
            }
            else if (e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse)
            {
                resizeDir = ResizeDirection.Bottom;
                Cursor    = Cursors.SizeNS;
            }
            else
            {
                resizeDir = ResizeDirection.None;

                //Only reset the cursur when needed, this prevents it from flickering when a child control changes the cursor to its own needs
                if (resizeCursors.Contains(Cursor))
                {
                    Cursor = Cursors.Default;
                }
            }

            UpdateButtons(e);
        }
        private void ResizeForm(ResizeDirection direction)
        {
            if (DesignMode)
            {
                return;
            }
            int dir = -1;

            switch (direction)
            {
            case ResizeDirection.BottomLeft:
                dir = HTBOTTOMLEFT;
                break;

            case ResizeDirection.Left:
                dir = HTLEFT;
                break;

            case ResizeDirection.Right:
                dir = HTRIGHT;
                break;

            case ResizeDirection.BottomRight:
                dir = HTBOTTOMRIGHT;
                break;

            case ResizeDirection.Bottom:
                dir = HTBOTTOM;
                break;

            case ResizeDirection.Top:
                dir = HTTOP;
                break;

            case ResizeDirection.TopLeft:
                dir = HTTOPLEFT;
                break;

            case ResizeDirection.TopRight:
                dir = HTTOPRIGHT;
                break;
            }

            ReleaseCapture();
            if (dir != -1)
            {
                currently_sizing = true;
                SendMessage(Handle, WM_NCLBUTTONDOWN, dir, 0);
            }
        }
예제 #12
0
파일: MainForm.cs 프로젝트: Sarkie/ootd
        private void ResizeForm(ResizeDirection direction)
        {
            if (GlobalPreferences.LockPosition)
            {
                return;
            }

            int dir = -1;

            switch (direction)
            {
            case ResizeDirection.Left:
                dir = UnsafeNativeMethods.HTLEFT;
                break;

            case ResizeDirection.TopLeft:
                dir = UnsafeNativeMethods.HTTOPLEFT;
                break;

            case ResizeDirection.Top:
                dir = UnsafeNativeMethods.HTTOP;
                break;

            case ResizeDirection.TopRight:
                dir = UnsafeNativeMethods.HTTOPRIGHT;
                break;

            case ResizeDirection.Right:
                dir = UnsafeNativeMethods.HTRIGHT;
                break;

            case ResizeDirection.BottomRight:
                dir = UnsafeNativeMethods.HTBOTTOMRIGHT;
                break;

            case ResizeDirection.Bottom:
                dir = UnsafeNativeMethods.HTBOTTOM;
                break;

            case ResizeDirection.BottomLeft:
                dir = UnsafeNativeMethods.HTBOTTOMLEFT;
                break;
            }

            if (dir != -1)
            {
                UnsafeNativeMethods.ReleaseCapture();
                UnsafeNativeMethods.SendMessage(Handle, UnsafeNativeMethods.WM_NCLBUTTONDOWN, (IntPtr)dir, IntPtr.Zero);
            }
        }
예제 #13
0
        private void Rectangle_Resize(object sender, MouseEventArgs e)
        {
            FrameworkElement element = sender as FrameworkElement;

            ResizeDirection direction = (ResizeDirection)Enum.Parse(typeof(ResizeDirection), element.Name.Replace("RectangleSize", ""));

            this.Cursor = cursors[direction];
            //System.Drawing.Point pix;
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                Tools.SendMessage(_HwndSource.Handle, WM_SYSCOMMAND, (IntPtr)(61440 + direction), IntPtr.Zero);
            }
            e.Handled = true;
        }
예제 #14
0
        protected override Task OnInitializedAsync()
        {
            //Debug.WriteLine("Initialized");
            var state = GetInitialState();

            // Debug.WriteLine($"State dataToMeasure: {(state.DataToMeasure== null ? "null" : "not empty")}");
            _dataToMeasure    = state.DataToMeasure;
            _measureContainer = state.MeasureContainer;
            _renderedData     = state.RenderedData;
            //   Debug.WriteLine($"State renderedData: {(state.RenderedData==null ? "null" : "not empty")}");
            _resizeDirection = state.ResizeDirection;

            return(Task.CompletedTask);
        }
예제 #15
0
		protected override void Resize(ResizeDirection direction, Vector vector)
		{
			ElementBasePoint element = DesignerItem.Element as ElementBasePoint;
			if (element != null)
			{
				if ((direction & ResizeDirection.Top) == ResizeDirection.Top || (direction & ResizeDirection.Bottom) == ResizeDirection.Bottom)
					element.Top += vector.Y;
				if ((direction & ResizeDirection.Left) == ResizeDirection.Left || (direction & ResizeDirection.Right) == ResizeDirection.Right)
					element.Left += vector.X;
				//DesignerItem.Translate();
				DesignerItem.RefreshPainter();
				DesignerCanvas.DesignerChanged();
			}
		}
예제 #16
0
        private void ResizeForm(ResizeDirection direction)
        {
            if (DesignMode)
            {
                return;
            }
            var dir = -1;

            switch (direction)
            {
            case ResizeDirection.BottomLeft:
                dir = Native.HTBOTTOMLEFT;
                break;

            case ResizeDirection.Left:
                dir = Native.HTLEFT;
                break;

            case ResizeDirection.Right:
                dir = Native.HTRIGHT;
                break;

            case ResizeDirection.BottomRight:
                dir = Native.HTBOTTOMRIGHT;
                break;

            case ResizeDirection.Bottom:
                dir = Native.HTBOTTOM;
                break;

            case ResizeDirection.Top:
                dir = Native.HTTOP;
                break;

            case ResizeDirection.TopLeft:
                dir = Native.HTTOPLEFT;
                break;

            case ResizeDirection.TopRight:
                dir = Native.HTTOPRIGHT;
                break;
            }

            Native.ReleaseCapture();
            if (dir != -1)
            {
                Native.SendMessage(Handle, Native.WM_NCLBUTTONDOWN, dir, 0);
            }
        }
예제 #17
0
        private void ResizePressed(object sender, MouseEventArgs e)
        {
            if (isMax)
            {
                return;
            }
            FrameworkElement element   = sender as FrameworkElement;
            ResizeDirection  direction = (ResizeDirection)Enum.Parse(typeof(ResizeDirection), element.Name.Replace("Resize", ""));

            this.Cursor = cursors[direction];
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                ResizeWindow(direction);
            }
        }
예제 #18
0
        private void ResizeForm(ResizeDirection direction)
        {
            int dir = -1;

            switch (direction)
            {
            case ResizeDirection.Left:
                dir = HTLEFT;
                break;

            case ResizeDirection.TopLeft:
                dir = HTTOPLEFT;
                break;

            case ResizeDirection.Top:
                dir = HTTOP;
                break;

            case ResizeDirection.TopRight:
                dir = HTTOPRIGHT;
                break;

            case ResizeDirection.Right:
                dir = HTRIGHT;
                break;

            case ResizeDirection.BottomRight:
                dir = HTBOTTOMRIGHT;
                break;

            case ResizeDirection.Bottom:
                dir = HTBOTTOM;
                break;

            case ResizeDirection.BottomLeft:
                dir = HTBOTTOMLEFT;
                break;

            case ResizeDirection.None:
                break;
            }

            if (dir != -1)
            {
                ReleaseCapture();
                SendMessage(ParentForm.Handle, WM_NCLBUTTONDOWN, dir, 0);
            }
        }
예제 #19
0
        private void SetResizeDirection(MouseEventArgs e)
        {
            if (!this.isWindowMoving)
            {
                if (e.Location.X >= 0 && e.Location.X <= this.ClientRectangle.Right)
                {
                    if (e.Location.Y >= 0 && e.Location.Y <= this.resizeConst)
                    {
                        this.directionToResize = ResizeDirection.Top;
                        Cursor.Current         = Cursors.SizeNS;
                    }
                }

                if (e.Location.X >= 0 && e.Location.X <= this.ClientRectangle.Right)
                {
                    if (e.Location.Y >= this.ClientRectangle.Bottom - this.resizeConst && e.Location.Y <= this.ClientRectangle.Bottom)
                    {
                        {
                            this.directionToResize = ResizeDirection.Bottom;
                            Cursor.Current         = Cursors.SizeNS;
                        }
                    }
                }


                if (e.Location.X >= 0 && e.Location.X <= this.resizeConst)
                {
                    if (e.Location.Y > this.resizeConst && e.Location.Y <= this.ClientRectangle.Bottom - this.resizeConst)
                    {
                        this.directionToResize = ResizeDirection.Left;
                        Cursor.Current         = Cursors.SizeWE;
                    }
                }

                if (e.Location.X >= this.ClientRectangle.Right - this.resizeConst && e.Location.X <= this.ClientRectangle.Right)
                {
                    if (e.Location.Y > this.resizeConst && e.Location.Y <= this.ClientRectangle.Bottom - this.resizeConst)
                    {
                        this.directionToResize = ResizeDirection.Right;
                        Cursor.Current         = Cursors.SizeWE;
                    }
                }

                this.offsetPoint     = Point.Empty;
                this.oldMousePos     = Point.Empty;
                this.lastResizePoint = e.Location;
            }
        }
예제 #20
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ResizeDirection resizeDirection = (ResizeDirection)value;

            switch (resizeDirection)
            {
            case ResizeDirection.NorthEast:
            case ResizeDirection.SouthWest:
                return(Cursors.SizeNESW);

            case ResizeDirection.NorthWest:
            case ResizeDirection.SouthEast:
                return(Cursors.SizeNWSE);
            }
            return(DependencyProperty.UnsetValue);
        }
예제 #21
0
        /// <summary>
        /// 点击RootGrid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnRootGridPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Point mousePosition = e.GetCurrentPoint(_panel).Position;

            if (GetResizeDirection(mousePosition) != ResizeDirection.None && _rootGrid.CapturePointer(e.Pointer))
            {
                _isHeadPressed = false;
                Point offset = TransformToVisual(_panel).TransformPoint(new Point(0.0, 0.0));
                _isResizing      = true;
                _resizeDirection = GetResizeDirection(mousePosition);
                _startPoint      = mousePosition;
                _initRect        = new Rect(offset.X, offset.Y, ActualWidth, ActualHeight);
                UpdateMouseCursor(_resizeDirection);
                e.Handled = true;
            }
        }
예제 #22
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="resizeForm">サイズ変更の対象となるフォーム</param>
        /// <param name="resizeDirection">サイズ変更が有効になる枠</param>
        /// <param name="resizeAreaWidth">サイズ変更が有効になる範囲の幅</param>
        public FormDragResizer(Form resizeForm, Panel panel, ResizeDirection resizeDirection, int resizeAreaWidth)
        {
            this.resizeForm      = resizeForm;
            this.panel           = panel;
            this.resizeDirection = resizeDirection;
            this.resizeAreaWidth = resizeAreaWidth;

            // 現時点でのカーソルを保存しておく
            defaultCursor = resizeForm.Cursor;

            // イベントハンドラを追加
            panel.MouseDown  += new MouseEventHandler(resizeForm_MouseDown);
            panel.MouseMove  += new MouseEventHandler(resizeForm_MouseMove);
            panel.MouseUp    += new MouseEventHandler(resizeForm_MouseUp);
            panel.MouseLeave += new EventHandler(resizeForm_MouseLeave);
        }
예제 #23
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ResizeDirection resizeDirection = (ResizeDirection)value;

            switch (resizeDirection)
            {
            case ResizeDirection.TopRight:
            case ResizeDirection.BottomLeft:
                return(Cursors.SizeNESW);

            case ResizeDirection.TopLeft:
            case ResizeDirection.BottomRight:
                return(Cursors.SizeNWSE);
            }

            return(DependencyProperty.UnsetValue);
        }
예제 #24
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ResizeDirection resizeDirection = (ResizeDirection)value;

            switch (resizeDirection)
            {
            case ResizeDirection.SouthWest:
                return(90);

            case ResizeDirection.NorthWest:
                return(180);

            case ResizeDirection.NorthEast:
                return(270);
            }
            return(0);
        }
예제 #25
0
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            if (DesignMode)
            {
                return;
            }
            _buttonState = ButtonState.None;
            _resizeDir   = ResizeDirection.None;
            //Only reset the cursor when needed
            if (_resizeCursors.Contains(Cursor))
            {
                Cursor = Cursors.Default;
            }

            Invalidate();
        }
예제 #26
0
        protected virtual void OnResizing(ResizeDirection direction, MouseEventArgs e)
        {
            if (Direction_Drag.ContainsKey(direction))
            {
                if (ResizeEnable)
                {
                    var v = Direction_Drag[direction];

                    NativeMethods.ReleaseCapture();
                    NativeMethods.SendMessage(this.Handle, (uint)NativeEnums.WM.SYSCOMMAND, new IntPtr((uint)v), IntPtr.Zero);
                }
            }
            else
            {
                DragMove(e);
            }
        }
예제 #27
0
        protected virtual void StartMove()
        {
            if (!this.Adapter.Capture)
            {
                this.Adapter.Capture = true;
            }

            this.MouseOrigin    = GetMousePosition();
            this.PreviousBounds = this.Adapter.Bounds;
            foreach (var snappingWindow in this.StickyWindows.Keys)
            {
                snappingWindow.MouseOrigin    = this.MouseOrigin;
                snappingWindow.PreviousBounds = snappingWindow.Adapter.Bounds;
            }
            this.ResizeDirection = ResizeDirection.None;
            this.SetHook(this.MoveHook);
        }
예제 #28
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (!base.DesignMode)
     {
         if (this.Sizable)
         {
             bool flag2 = base.GetChildAtPoint(e.Location) != null;
             if (!((((e.Location.X >= 7) || (e.Location.Y <= (base.Height - 7))) || flag2) || this.Maximized))
             {
                 this.resizeDir = ResizeDirection.BottomLeft;
                 this.Cursor    = Cursors.SizeNESW;
             }
             else if (!(((e.Location.X >= 7) || flag2) || this.Maximized))
             {
                 this.resizeDir = ResizeDirection.Left;
                 this.Cursor    = Cursors.SizeWE;
             }
             else if (!((((e.Location.X <= (base.Width - 7)) || (e.Location.Y <= (base.Height - 7))) || flag2) || this.Maximized))
             {
                 this.resizeDir = ResizeDirection.BottomRight;
                 this.Cursor    = Cursors.SizeNWSE;
             }
             else if (!(((e.Location.X <= (base.Width - 7)) || flag2) || this.Maximized))
             {
                 this.resizeDir = ResizeDirection.Right;
                 this.Cursor    = Cursors.SizeWE;
             }
             else if (!(((e.Location.Y <= (base.Height - 7)) || flag2) || this.Maximized))
             {
                 this.resizeDir = ResizeDirection.Bottom;
                 this.Cursor    = Cursors.SizeNS;
             }
             else
             {
                 this.resizeDir = ResizeDirection.None;
                 if (this.resizeCursors.Contains <Cursor>(this.Cursor))
                 {
                     this.Cursor = Cursors.Default;
                 }
             }
         }
         this.UpdateButtons(e, false);
     }
 }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (DesignMode)
            {
                return;
            }

            var isChildUnderMouse = GetChildAtPoint(e.Location) != null;

            if (e.Location.X < BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse)
            {
                _resizeDir = ResizeDirection.BottomLeft;
                Cursor     = Cursors.SizeNESW;
            }
            else if (e.Location.X < BORDER_WIDTH && !isChildUnderMouse)
            {
                _resizeDir = ResizeDirection.Left;
                Cursor     = Cursors.SizeWE;
            }
            else if (e.Location.X > Width - BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse)
            {
                _resizeDir = ResizeDirection.BottomRight;
                Cursor     = Cursors.SizeNWSE;
            }
            else if (e.Location.X > Width - BORDER_WIDTH && !isChildUnderMouse)
            {
                _resizeDir = ResizeDirection.Right;
                Cursor     = Cursors.SizeWE;
            }
            else if (e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse)
            {
                _resizeDir = ResizeDirection.Bottom;
                Cursor     = Cursors.SizeNS;
            }
            else
            {
                _resizeDir = ResizeDirection.None;
                if (_resizeCursors.Contains(Cursor))
                {
                    Cursor = Cursors.Default;
                }
            }
        }
예제 #30
0
        protected override void OnResizing(ResizeDirection direction, MouseEventArgs e)
        {
            if (direction == ResizeDirection.Center && e.Y > CaptionHeight)
            {
                return;
            }

            Box[] boxs = { mcBoxExit, mcBoxMinimize, mcBoxSetting };
            foreach (Box box in boxs)
            {
                if (IntersectWith(box.Bounds, new Point(e.X, e.Y)))
                {
                    return;
                }
            }

            base.OnResizing(direction, e);
        }
예제 #31
0
        private void SetSizer(ResizeDirection dir, int row, int column)
        {
            var sizer = new Border
            {
                Background = new SolidColorBrush(Colors.Black),
                Margin     = new Thickness(-1)
            };

            sizer.SetValue(Grid.RowProperty, row);
            sizer.SetValue(Grid.ColumnProperty, column);
            _grid.Children.Add(sizer);

            sizer.MouseEnter       += Sizer_MouseEnter;
            sizer.MouseLeave       += Sizer_MouseLeave;
            sizer.PreviewMouseDown += Sizer_PreviewMouseDown;

            _sizers.Add(sizer, dir);
        }
예제 #32
0
        private void ResizePressed(object sender, MouseEventArgs e)
        {
            FrameworkElement element   = sender as FrameworkElement;
            ResizeDirection  direction = (ResizeDirection)Enum.Parse(typeof(ResizeDirection), element.Name.Replace("Resize", ""));

            switch (direction)
            {
            case ResizeDirection.Left:
                Cursor = (Cursor)cursorDictionary["Cursor_horz"];
                break;

            case ResizeDirection.Right:
                Cursor = (Cursor)cursorDictionary["Cursor_horz"];
                break;

            case ResizeDirection.Top:
                Cursor = (Cursor)cursorDictionary["Cursor_vert"];
                break;

            case ResizeDirection.Bottom:
                Cursor = (Cursor)cursorDictionary["Cursor_vert"];
                break;

            case ResizeDirection.TopLeft:
                Cursor = (Cursor)cursorDictionary["Cursor_dgn1"];
                break;

            case ResizeDirection.BottomRight:
                Cursor = (Cursor)cursorDictionary["Cursor_dgn1"];
                break;

            case ResizeDirection.TopRight:
                Cursor = (Cursor)cursorDictionary["Cursor_dgn2"];
                break;

            case ResizeDirection.BottomLeft:
                Cursor = (Cursor)cursorDictionary["Cursor_dgn2"];
                break;
            }
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                ResizeWindow(direction);
            }
        }
예제 #33
0
파일: BaseFrame.cs 프로젝트: s4kr4/CHATTER
        //ドラッグでフォーム位置移動
        public void Frame_MouseDown(object sender, MouseEventArgs e)
        {
            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                // ドラッグ移動有効範囲
                Rectangle moveArea = new Rectangle(
                    margin, margin, this.Width - (margin * 2), this.Height - (margin * 2));

                formSize   = this.Size;
                mousePoint = e.Location;

                if (moveArea.Contains(e.Location))
                {
                    flag    = MoveOrSize.Move;
                    Capture = true;
                }
                else
                {
                    Capture    = true;
                    flag       = MoveOrSize.Size;
                    topRect    = new Rectangle(0, 0, this.Width, margin);
                    leftRect   = new Rectangle(0, 0, margin, this.Height);
                    rightRect  = new Rectangle(this.Width - margin, 0, margin, this.Height);
                    bottomRect = new Rectangle(0, this.Height - margin, this.Width, this.Height);

                    if (topRect.Contains(e.Location))
                    {
                        resizeStatus |= ResizeDirection.Top;
                    }
                    if (leftRect.Contains(e.Location))
                    {
                        resizeStatus |= ResizeDirection.Left;
                    }
                    if (rightRect.Contains(e.Location))
                    {
                        resizeStatus |= ResizeDirection.Right;
                    }
                    if (bottomRect.Contains(e.Location))
                    {
                        resizeStatus |= ResizeDirection.Bottom;
                    }
                }
            }
        }
예제 #34
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ResizeDirection resizeDirection = (ResizeDirection)value;

            switch (resizeDirection)
            {
            case ResizeDirection.BottomLeft:
                return(90);

            case ResizeDirection.TopLeft:
                return(180);

            case ResizeDirection.TopRight:
                return(270);

            default:
                return(0);
            }
        }
        private void CreateThumb(
            ref Thumb resizeThumb, Cursor customizedCursor, ResizeDirection direction)
        {
            if (resizeThumb != null)
            {
                return;
            }

            var thumb = new ResizeThumb {
                Direction  = direction,
                Cursor     = customizedCursor,
                Width      = 10,
                Height     = 10,
                Background = Brushes.Black
            };

            visualChildren.Add(thumb);
            resizeThumb = thumb;
        }
예제 #36
0
 /// <summary>
 /// Constructs a WindowX form instance
 /// </summary>
 public WindowX()
 {
     _buttonColor = startColor;
     _hoverColor = Color.FromArgb(80, 80, 80);
     _pushColor = Color.White;
     _aeroEnabled = false;
     _resizeDir = ResizeDirection.None;
     ClientSize = new Size(640, 480);
     MouseMove += new MouseEventHandler(OnMouseMove);
     MouseDown += new MouseEventHandler(OnMouseDown);
     Activated += new EventHandler(OnActivated);
     SetStyle(ControlStyles.ResizeRedraw, true);
     AutoScaleDimensions = new SizeF(6f, 13f);
     Font = new Font("Segoe UI", 8f, FontStyle.Regular, GraphicsUnit.Point);
     AutoScaleMode = AutoScaleMode.Font;
     BackColor = Color.White;
     StartPosition = FormStartPosition.CenterScreen;
     SetupButtons();
     DoubleBuffered = true;
 }
예제 #37
0
            public DragState(WorkspaceUI workspaceUI, Transform rayOrigin, bool resizing)
            {
                m_WorkspaceUI  = workspaceUI;
                m_Resizing     = resizing;
                this.rayOrigin = rayOrigin;

                if (resizing)
                {
                    var pointerPosition = m_WorkspaceUI.GetPointerPosition(rayOrigin);
                    m_DragStart       = pointerPosition;
                    m_PositionStart   = workspaceUI.transform.parent.position;
                    m_BoundsSizeStart = workspaceUI.bounds.size;
                    var localPosition = m_WorkspaceUI.transform.InverseTransformPoint(pointerPosition);
                    m_Direction = m_WorkspaceUI.GetResizeDirectionForLocalPosition(localPosition);
                }
                else
                {
                    MathUtilsExt.GetTransformOffset(rayOrigin, m_WorkspaceUI.transform.parent, out m_PositionOffset, out m_RotationOffset);
                }
            }
        public override void InitializeResize(System.Collections.Generic.IEnumerable<IDiagramItem> newSelectedItems, double adornerAngle, Rect adornerBounds, ResizeDirection resizingDirection, Point startPoint)
        {
            this.mainContainer = newSelectedItems.FirstOrDefault() as MainContainerShapeBase;
            if (this.mainContainer != null)
                this.mainContainer.UpdateMinBounds();

            base.InitializeResize(newSelectedItems, adornerAngle, adornerBounds, resizingDirection, startPoint);

            if (this.mainContainer != null)
            {
                var firstChild = this.mainContainer.OrderedChildren.FirstOrDefault();
                var lastChild = this.mainContainer.OrderedChildren.LastOrDefault();

                if (firstChild != null && lastChild != null)
                {
                    this.restrictResize = true;
                    this.startBounds = this.mainContainer.ContentBounds;

                    if (this.mainContainer.ChildrenPositioning == System.Windows.Controls.Orientation.Vertical)
                    {
                        this.isFirstChildResize = resizingDirection == ResizeDirection.NorthEastSouthWest || resizingDirection == ResizeDirection.NorthWestSouthEast;
                        this.min = firstChild.MinBoundsWithChildren != Rect.Empty ? firstChild.MinBoundsWithChildren.Top : firstChild.Bounds.Bottom - CustomResizingService.MinShapeHeight;
                        this.max = lastChild.MinBoundsWithChildren != Rect.Empty ? lastChild.MinBoundsWithChildren.Bottom : lastChild.Bounds.Top + CustomResizingService.MinShapeHeight;
                    }
                    else
                    {
                        this.isFirstChildResize = resizingDirection == ResizeDirection.SouthWestNorthEast || resizingDirection == ResizeDirection.NorthWestSouthEast;
                        this.min = firstChild.MinBoundsWithChildren != Rect.Empty ? firstChild.MinBoundsWithChildren.Left : firstChild.Bounds.Right - CustomResizingService.MinShapeWidth;
                        this.max = lastChild.MinBoundsWithChildren != Rect.Empty ? lastChild.MinBoundsWithChildren.Right : lastChild.Bounds.Left + CustomResizingService.MinShapeWidth;
                    }
                    this.CreateResizeCommand();
                }
                else
                {
                    this.restrictResize = false;
                }
            }

            //this.isFirstResize = true;
        }
예제 #39
0
		internal void setReziseDirection(Point p)
		{

			Rectangle r = new Rectangle(0, 0, 0, 0);
			Rectangle r1 = new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r1.Contains(p)) {
				resizeDirection = ResizeDirection.NW;
				return;
			}
			Rectangle r2 = new Rectangle(r.Location.X + r.Width, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r2.Contains(p)) {
				resizeDirection = ResizeDirection.NE;
				return;
			}          
			Rectangle r3 = new Rectangle(r.Location.X + (r.Width - CORNER_SQUARE_SIZE) / 2, r.Location.Y - CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r3.Contains(p)) {
				resizeDirection = ResizeDirection.N;
				return;
			} 
			Rectangle r4 = new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r4.Contains(p)) {
				resizeDirection = ResizeDirection.SW;
				return;
			} 
			Rectangle r5 = new Rectangle(r.Location.X - CORNER_SQUARE_SIZE, r.Location.Y + (r.Size.Height - CORNER_SQUARE_SIZE) / 2, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r5.Contains(p)) {
				resizeDirection = ResizeDirection.W;
				return;
			} 
			Rectangle r6 = new Rectangle(r.Location.X + r.Width, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r6.Contains(p)) {
				resizeDirection = ResizeDirection.SE;
				return;
			}
			Rectangle r7 = new Rectangle(r.Location.X + (r.Width - CORNER_SQUARE_SIZE) / 2, r.Location.Y + r.Size.Height, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r7.Contains(p)) {
				resizeDirection = ResizeDirection.S;
				return;
			}
			Rectangle r8 = new Rectangle(r.Location.X + r.Size.Width, r.Location.Y + (r.Size.Height - CORNER_SQUARE_SIZE) / 2, CORNER_SQUARE_SIZE, CORNER_SQUARE_SIZE);
			if (r8.Contains(p)) {
				resizeDirection = ResizeDirection.E;
				return;
			}

			resizeDirection = ResizeDirection.NONE;
		}
예제 #40
0
		/// <summary>
		/// Mouse up event handler.
		/// </summary>
		/// <param name="e">Event args</param>
		/// <returns>If this widget handled this event</returns>
		public bool OnMouseUp(System.Windows.Forms.MouseEventArgs e)
		{
			// if we aren't active do nothing.
			if ((!m_visible) || (!m_enabled))
				return false;

			int widgetTop = this.Top;
			int widgetBottom = this.Bottom;
			int widgetLeft = this.Left;
			int widgetRight = this.Right;

            // Check for close if header is rendered
			if(HeaderEnabled &&
                m_lastMouseDownPosition.X >= Location.X + m_size.Width - 18 &&
                m_lastMouseDownPosition.X <= AbsoluteLocation.X + m_size.Width &&
                m_lastMouseDownPosition.Y >= AbsoluteLocation.Y &&
                m_lastMouseDownPosition.Y <= AbsoluteLocation.Y + m_currHeaderHeight - 2)
			{
				Visible = false;
                m_isDragging = false;
                
                if (DestroyOnClose)
				{
					Enabled = false;

					WidgetCollection parentCollection = (WidgetCollection) m_parentWidget;
					if (parentCollection != null)
						parentCollection.Remove(this);

					this.Dispose();
				}
                m_lastMouseDownPosition = System.Drawing.Point.Empty;
                return true;
			}

			// reset scrolling flags (don't care what up button event it is)
			m_isVScrolling = false;
			m_isHScrolling = false;

			// if its the left mouse button then reset dragging and resizing
			if (((m_isDragging) || (m_resize != ResizeDirection.None)) && 
				(e.Button == System.Windows.Forms.MouseButtons.Left))
			{
				// reset dragging flags
				m_isDragging = false;
				m_resize = ResizeDirection.None;
                m_lastMouseDownPosition = System.Drawing.Point.Empty;
				return true;
			}

			// if we're in the client area handle let the children try 
			if(e.X >= widgetLeft &&
				e.X <= widgetRight &&
				e.Y >= widgetTop &&
				e.Y <= widgetBottom)
			{
                for(int i = m_ChildWidgets.Count - 1; i >= 0; i--)
				{
					if(m_ChildWidgets[i] is WorldWind.NewWidgets.IInteractive)
					{
						WorldWind.NewWidgets.IInteractive currentInteractive = m_ChildWidgets[i] as WorldWind.NewWidgets.IInteractive;
                        if (currentInteractive.OnMouseUp(e))
                        {
                            m_lastMouseDownPosition = System.Drawing.Point.Empty;
                            return true;
                        }
					}
				}
			}
            m_lastMouseDownPosition = System.Drawing.Point.Empty;
			return false;
		}
예제 #41
0
		/// <summary>
		/// Mouse down event handler.
		/// </summary>
		/// <param name="e">Event args</param>
		/// <returns>If this widget handled this event</returns>
		public bool OnMouseDown(System.Windows.Forms.MouseEventArgs e)
		{
			// Whether or not the event was handled
			bool handled = false;

			// Whether or not we're in the form
			bool inClientArea = false;

			// if we aren't active do nothing.
			if ((!m_visible) || (!m_enabled))
				return false;

			int widgetTop = this.Top;
			int widgetBottom = this.Bottom;
			int widgetLeft = this.Left;
			int widgetRight = this.Right;

            m_lastMouseDownPosition = new Point(e.X, e.Y);

			// if we're in the client area bring to front
			if(e.X >= widgetLeft &&
				e.X <= widgetRight &&
				e.Y >= widgetTop &&
				e.Y <= widgetBottom)
			{
				if (m_parentWidget != null)
					m_parentWidget.ChildWidgets.BringToFront(this);

				inClientArea = true;
			}

			// if its the left mouse button check for UI actions (resize, drags, etc) 
			if(e.Button == System.Windows.Forms.MouseButtons.Left)
			{
				// Reset dragging and resizing
				m_isDragging = false;
				m_resize = ResizeDirection.None;

				// Reset scrolling
				m_isVScrolling = false;
				m_isHScrolling = false;

				#region resize and dragging

				// Check for resize (pointer is just outside the form)
				if(e.X > widgetLeft - resizeBuffer &&
					e.X < widgetLeft + resizeBuffer &&
					e.Y > widgetTop - resizeBuffer &&
					e.Y < widgetTop + resizeBuffer)
				{
					if ((HorizontalResizeEnabled) && (VerticalResizeEnabled))
						m_resize = ResizeDirection.UL;
					else if (HorizontalResizeEnabled)
						m_resize = ResizeDirection.Left;
					else if (VerticalResizeEnabled)
						m_resize = ResizeDirection.Up;
				}
				else if(e.X > widgetRight - resizeBuffer &&
					e.X < widgetRight + resizeBuffer &&
					e.Y > widgetTop - resizeBuffer &&
					e.Y < widgetTop + resizeBuffer)
				{
					if ((HorizontalResizeEnabled) && (VerticalResizeEnabled))
						m_resize = ResizeDirection.UR;
					else if (HorizontalResizeEnabled)
						m_resize = ResizeDirection.Right;
					else if (VerticalResizeEnabled)
						m_resize = ResizeDirection.Up;
				}
				else if(e.X > widgetLeft - resizeBuffer &&
					e.X < widgetLeft + resizeBuffer &&
					e.Y > widgetBottom - resizeBuffer &&
					e.Y < widgetBottom + resizeBuffer)
				{
					if ((HorizontalResizeEnabled) && (VerticalResizeEnabled))
						m_resize = ResizeDirection.DL;
					else if (HorizontalResizeEnabled)
						m_resize = ResizeDirection.Left;
					else if (VerticalResizeEnabled)
						m_resize = ResizeDirection.Down;
				}
				else if(e.X > widgetRight - resizeBuffer &&
					e.X < widgetRight + resizeBuffer &&
					e.Y > widgetBottom - resizeBuffer &&
					e.Y < widgetBottom + resizeBuffer )
				{
					if ((HorizontalResizeEnabled) && (VerticalResizeEnabled))
						m_resize = ResizeDirection.DR;
					else if (HorizontalResizeEnabled)
						m_resize = ResizeDirection.Right;
					else if (VerticalResizeEnabled)
						m_resize = ResizeDirection.Down;
				}
				else if(e.X > AbsoluteLocation.X - resizeBuffer &&
					e.X < AbsoluteLocation.X + resizeBuffer &&
					e.Y > AbsoluteLocation.Y - resizeBuffer &&
					e.Y < AbsoluteLocation.Y + resizeBuffer + m_size.Height &&
					HorizontalResizeEnabled)
				{
					m_resize = ResizeDirection.Left;
				}
				else if(e.X > AbsoluteLocation.X - resizeBuffer + m_size.Width &&
					e.X < AbsoluteLocation.X + resizeBuffer + m_size.Width &&
					e.Y > AbsoluteLocation.Y - resizeBuffer &&
					e.Y < AbsoluteLocation.Y + resizeBuffer + m_size.Height &&
					HorizontalResizeEnabled)
				{
					m_resize = ResizeDirection.Right;
				}
				else if(e.X > AbsoluteLocation.X - resizeBuffer &&
					e.X < AbsoluteLocation.X + resizeBuffer + m_size.Width &&
					e.Y > AbsoluteLocation.Y - resizeBuffer &&
					e.Y < AbsoluteLocation.Y + resizeBuffer &&
					VerticalResizeEnabled)
				{
					m_resize = ResizeDirection.Up;
				}
				else if(e.X > AbsoluteLocation.X - resizeBuffer &&
					e.X < AbsoluteLocation.X + resizeBuffer + m_size.Width &&
					e.Y > AbsoluteLocation.Y - resizeBuffer + m_size.Height &&
					e.Y < AbsoluteLocation.Y + resizeBuffer + m_size.Height &&
					VerticalResizeEnabled)
				{
					m_resize = ResizeDirection.Down;
				}
					
					// Check for header double click (if its shown)
				else if(HeaderEnabled &&
					e.X >= Location.X &&
					e.X <= AbsoluteLocation.X + m_size.Width &&
					e.Y >= AbsoluteLocation.Y &&
					e.Y <= AbsoluteLocation.Y + m_currHeaderHeight)
				{
					if (DateTime.Now > m_LastClickTime.AddSeconds(0.5))
					{
						m_isDragging = true;
						handled = true;
					}
					else
					{
						m_renderBody = !m_renderBody;
                        //if (AutoHideHeader && m_renderBody)
                        //{
                        //    HeaderEnabled = false;
                        //}
                        //else
                        //{
                        //    HeaderEnabled = true;
                        //}
					}
					m_LastClickTime = DateTime.Now;

				}

				#endregion

				#region scrolling

				if (inClientArea && m_renderBody)
				{
					// Check to see if we're in vertical scroll region
					if( m_showVScrollbar &&
						e.X > this.Right - m_scrollbarWidth &&
						(!m_showHScrollbar || e.Y < this.Bottom - m_scrollbarWidth) )
					{
						// set scroll position to e.Y offset from top of client area
						if (e.Y < this.BodyLocation.Y + m_vScrollbarPos)
						{
							m_vScrollbarPos -= m_clientSize.Height / 10;
						}
						else if (e.Y > this.BodyLocation.Y + m_vScrollbarPos + m_vScrollbarHeight)
						{
							m_vScrollbarPos += m_clientSize.Height / 10;
						}
						else
						{
							m_vScrollbarGrabPosition = e.Y - this.BodyLocation.Y;
							m_isVScrolling = true;
						}
						handled = true;
					}
					else if( m_showHScrollbar &&
						e.Y > this.Bottom - m_scrollbarWidth &&
						(!m_showVScrollbar || e.X < this.Right - m_scrollbarWidth) )
					{
						// set scroll position to e.Y offset from top of client area
						if (e.X < this.BodyLocation.X + m_hScrollbarPos)
						{
							m_hScrollbarPos -= m_clientSize.Width / 10;
						}
						else if (e.X > this.BodyLocation.X + m_hScrollbarPos + m_hScrollbarWidth)
						{
							m_hScrollbarPos += m_clientSize.Width / 10;
						}
						else
						{
							m_hScrollbarGrabPosition = e.X - this.BodyLocation.X;
							m_isHScrolling = true;
						}
						handled = true;
					}
				}

				#endregion
			}

			// Store the current position
			m_LastMousePosition = new System.Drawing.Point(e.X, e.Y);

			// If we aren't handling this then let the children try if they are rendered
			if(!handled && inClientArea && m_renderBody)
			{
                for (int i = m_ChildWidgets.Count - 1; i >= 0; i--)
				{
					if(!handled)
					{
						if(m_ChildWidgets[i] is WorldWind.NewWidgets.IInteractive)
						{
							WorldWind.NewWidgets.IInteractive currentInteractive = m_ChildWidgets[i] as WorldWind.NewWidgets.IInteractive;
							handled = currentInteractive.OnMouseDown(e);
						}
					}
				}
			}

			// If we resized or inside the form then consider it handled anyway.
			if(inClientArea || (m_resize != ResizeDirection.None))
			{
				handled = true;
			}

			return handled;			 
		}
예제 #42
0
 private void ResizeWindow(ResizeDirection direction)
 {
     NativeMethods.SendMessage(this.hwndSource.Handle, WM_SYSCOMMAND, (IntPtr)(61440 + direction), IntPtr.Zero);
 }
예제 #43
0
 private void ResizeWindow(ResizeDirection direction)
 {
     Console.WriteLine("direction:" + direction.ToString());
     SendMessage(_hwndSource.Handle, 0x112, (IntPtr)(61440 + direction), IntPtr.Zero);
 }
예제 #44
0
 /// <summary>
 /// Resizes the window in a given direction.
 /// </summary>
 /// <param name="direction">
 /// The direction.
 /// </param>
 private void ResizeWindow(ResizeDirection direction)
 {
     SendMessage(new WindowInteropHelper(this).Handle, WmSyscommand, (IntPtr)(61440 + direction), IntPtr.Zero);
 }
예제 #45
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="element"></param>
 /// <param name="value"></param>
 public static void SetResizeMode(DependencyObject element, ResizeDirection value)
 {
     element.SetValue(ResizeModeProperty, value);
 }
예제 #46
0
 private Vector CalculateSize(ResizeDirection direction, double horizontalChange, double verticalChange)
 {
     double dragDeltaHorizontal = horizontalChange;
     double dragDeltaVertical = verticalChange;
     foreach (DesignerItem designerItem in DesignerCanvas.SelectedItems)
     {
         Rect rect = new Rect(Canvas.GetLeft(designerItem), Canvas.GetTop(designerItem), designerItem.ActualWidth, designerItem.ActualHeight);
         if ((direction & ResizeDirection.Top) == ResizeDirection.Top)
         {
             if (rect.Height - dragDeltaVertical < DesignerItem.MinHeight)
                 dragDeltaVertical = rect.Height - DesignerItem.MinHeight;
             if (rect.Top + dragDeltaVertical < 0)
                 dragDeltaVertical = -rect.Top;
         }
         else if ((direction & ResizeDirection.Bottom) == ResizeDirection.Bottom)
         {
             if (rect.Height + dragDeltaVertical < DesignerItem.MinHeight)
                 dragDeltaVertical = DesignerItem.MinHeight - rect.Height;
             if (rect.Bottom + dragDeltaVertical > DesignerCanvas.Height)
                 dragDeltaVertical = DesignerCanvas.Height - rect.Bottom;
         }
         if ((direction & ResizeDirection.Left) == ResizeDirection.Left)
         {
             if (rect.Width - dragDeltaHorizontal < DesignerItem.MinWidth)
                 dragDeltaHorizontal = rect.Width - DesignerItem.MinWidth;
             if (rect.Left + dragDeltaHorizontal < 0)
                 dragDeltaHorizontal = -rect.Left;
         }
         else if ((direction & ResizeDirection.Right) == ResizeDirection.Right)
         {
             if (rect.Width + dragDeltaHorizontal < DesignerItem.MinWidth)
                 dragDeltaHorizontal = DesignerItem.MinWidth - rect.Width;
             if (rect.Right + dragDeltaHorizontal > DesignerCanvas.Width)
                 dragDeltaHorizontal = DesignerCanvas.Width - rect.Right;
         }
     }
     return new Vector(dragDeltaHorizontal, dragDeltaVertical);
 }
예제 #47
0
		private void UpdateResizeDirection(Point point)
		{
			_resizeDirection = ResizeDirection.None;
			if (_canResize)
			{
				var rect = GetBounds();
				if (IsInsideThumb(rect.TopLeft, point))
					_resizeDirection = ResizeDirection.TopLeft;
				else if (IsInsideThumb(rect.TopRight, point))
					_resizeDirection = ResizeDirection.TopRight;
				else if (IsInsideThumb(rect.BottomRight, point))
					_resizeDirection = ResizeDirection.BottomRight;
				else if (IsInsideThumb(rect.BottomLeft, point))
					_resizeDirection = ResizeDirection.BottomLeft;
				else if (IsInsideRect(new Rect(rect.Left, rect.Top - ResizeThumbSize, rect.Width, 2 * ResizeThumbSize), point))
					_resizeDirection = ResizeDirection.Top;
				else if (IsInsideRect(new Rect(rect.Left, rect.Bottom - ResizeThumbSize, rect.Width, 2 * ResizeThumbSize), point))
					_resizeDirection = ResizeDirection.Bottom;
				else if (IsInsideRect(new Rect(rect.Left - ResizeThumbSize, rect.Top, 2 * ResizeThumbSize, rect.Height), point))
					_resizeDirection = ResizeDirection.Left;
				else if (IsInsideRect(new Rect(rect.Right - ResizeThumbSize, rect.Top, 2 * ResizeThumbSize, rect.Height), point))
					_resizeDirection = ResizeDirection.Right;
			}
		}
예제 #48
0
		private Vector CalculateSize(ResizeDirection direction, Vector change)
		{
			double dragDeltaHorizontal = change.X;
			double dragDeltaVertical = change.Y;
			foreach (DesignerItem designerItem in DesignerCanvas.SelectedItems)
			{
				Rect rect = designerItem.GetRectangle();
				if ((direction & ResizeDirection.Top) == ResizeDirection.Top)
				{
					if (rect.Height - dragDeltaVertical < DesignerItem.MinHeight)
						dragDeltaVertical = rect.Height - DesignerItem.MinHeight;
					if (rect.Top + dragDeltaVertical < 0)
						dragDeltaVertical = -rect.Top;
				}
				else if ((direction & ResizeDirection.Bottom) == ResizeDirection.Bottom)
				{
					if (rect.Height + dragDeltaVertical < DesignerItem.MinHeight)
						dragDeltaVertical = DesignerItem.MinHeight - rect.Height;
					if (rect.Bottom + dragDeltaVertical > DesignerCanvas.CanvasHeight)
						dragDeltaVertical = DesignerCanvas.CanvasHeight - rect.Bottom;
				}
				if ((direction & ResizeDirection.Left) == ResizeDirection.Left)
				{
					if (rect.Width - dragDeltaHorizontal < DesignerItem.MinWidth)
						dragDeltaHorizontal = rect.Width - DesignerItem.MinWidth;
					if (rect.Left + dragDeltaHorizontal < 0)
						dragDeltaHorizontal = -rect.Left;
				}
				else if ((direction & ResizeDirection.Right) == ResizeDirection.Right)
				{
					if (rect.Width + dragDeltaHorizontal < DesignerItem.MinWidth)
						dragDeltaHorizontal = DesignerItem.MinWidth - rect.Width;
					if (rect.Right + dragDeltaHorizontal > DesignerCanvas.CanvasWidth)
						dragDeltaHorizontal = DesignerCanvas.CanvasWidth - rect.Right;
				}
			}
			return new Vector(dragDeltaHorizontal, dragDeltaVertical);
		}
예제 #49
0
		void IVisualItem.DragCompleted(Point point)
		{
			_resizeDirection = ResizeDirection.None;
			if (IsMoved)
				DesignerCanvas.EndChange();
			IsMoved = false;
			DesignerCanvas.Cursor = GetCursor(point);
		}
예제 #50
0
 private void TransparencySlider_MouseHover(object sender, EventArgs e)
 {
     ResizeDir = ResizeDirection.None;
     Cursor = Cursors.Default;
 }
예제 #51
0
 private void ResizeWindow(ResizeDirection direction)
 {
     SendMessage(_hwndSource.Handle, 0x112, (IntPtr)(61440 + direction), IntPtr.Zero);
 }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (DesignMode) return;

	        if (Sizable)
	        {
				//True if the mouse is hovering over a child control
				bool isChildUnderMouse = GetChildAtPoint(e.Location) != null;
                if (!Resize_Enabled)
                {
                    resizeDir = ResizeDirection.None;

                    //Only reset the cursur when needed, this prevents it from flickering when a child control changes the cursor to its own needs
                    if (resizeCursors.Contains(Cursor))
                    {
                        Cursor = Cursors.Default;
                    }
                }
                else
                {
                    if (e.Location.X < BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.BottomLeft;
                        Cursor = Cursors.SizeNESW;
                    }
                    else if (e.Location.Y < BORDER_WIDTH && e.Location.X < BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.TopLeft;
                        Cursor = Cursors.SizeNWSE;
                    }
                    else if (e.Location.Y < BORDER_WIDTH && e.Location.X > Width - BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.TopRight;
                        Cursor = Cursors.SizeNESW;
                    }
                    else if (e.Location.X < BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.Left;
                        Cursor = Cursors.SizeWE;
                    }
                    else if (e.Location.X > Width - BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.BottomRight;
                        Cursor = Cursors.SizeNWSE;
                    }
                    else if (e.Location.X > Width - BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.Right;
                        Cursor = Cursors.SizeWE;
                    }
                    else if (e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.Bottom;
                        Cursor = Cursors.SizeNS;
                    }
                    else if (e.Location.Y < BORDER_WIDTH && !isChildUnderMouse && !Maximized)
                    {
                        resizeDir = ResizeDirection.Top;
                        Cursor = Cursors.SizeNS;
                    }
                    else
                    {
                        resizeDir = ResizeDirection.None;

                        //Only reset the cursur when needed, this prevents it from flickering when a child control changes the cursor to its own needs
                        if (resizeCursors.Contains(Cursor))
                        {
                            Cursor = Cursors.Default;
                        }
                    }
                }
	        }

            UpdateButtons(e);
        }
예제 #53
0
 private void HeaderPanel_MouseMove(object sender, MouseEventArgs e)
 {
     ResizeDir = ResizeDirection.None;
     Cursor = Cursors.SizeAll;
 }
예제 #54
0
 private void ResizeWindow(ResizeDirection direction)
 {
     m_hwndSource = (HwndSource)PresentationSource.FromVisual(this);
     NativeMethods.SendMessage(m_hwndSource.Handle, WM_SYSCOMMAND,
         (IntPtr)(61440 + direction), IntPtr.Zero);
 }
예제 #55
0
 protected abstract void Resize(ResizeDirection direction, Vector vector);
예제 #56
0
        private void MainForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (GlobalPreferences.LockPosition)
                return;

            if (e.Location.X < ResizeBorderWidth && e.Location.Y < ResizeBorderWidth)
                ResizeDir = ResizeDirection.TopLeft;

            else if (e.Location.X < ResizeBorderWidth && e.Location.Y > Height - ResizeBorderWidth)
                ResizeDir = ResizeDirection.BottomLeft;

            else if (e.Location.X > Width - ResizeBorderWidth && e.Location.Y > Height - ResizeBorderWidth)
                ResizeDir = ResizeDirection.BottomRight;

            else if (e.Location.X > Width - ResizeBorderWidth && e.Location.Y < ResizeBorderWidth)
                ResizeDir = ResizeDirection.TopRight;

            else if (e.Location.X < ResizeBorderWidth)
                ResizeDir = ResizeDirection.Left;

            else if (e.Location.X > Width - ResizeBorderWidth)
                ResizeDir = ResizeDirection.Right;

            else if (e.Location.Y < ResizeBorderWidth)
                ResizeDir = ResizeDirection.Top;

            else if (e.Location.Y > Height - ResizeBorderWidth)
                ResizeDir = ResizeDirection.Bottom;

            else
                ResizeDir = ResizeDirection.None;
        }
예제 #57
0
        private void ResizeForm(ResizeDirection direction)
        {
            int dir = -1;
            switch (direction)
            {
                case ResizeDirection.Left:
                    dir = HTLEFT;
                    break;
                case ResizeDirection.TopLeft:
                    dir = HTTOPLEFT;
                    break;
                case ResizeDirection.Top:
                    dir = HTTOP;
                    break;
                case ResizeDirection.TopRight:
                    dir = HTTOPRIGHT;
                    break;
                case ResizeDirection.Right:
                    dir = HTRIGHT;
                    break;
                case ResizeDirection.BottomRight:
                    dir = HTBOTTOMRIGHT;
                    break;
                case ResizeDirection.Bottom:
                    dir = HTBOTTOM;
                    break;
                case ResizeDirection.BottomLeft:
                    dir = HTBOTTOMLEFT;
                    break;
            }

            if (dir != -1)
            {
                ReleaseCapture();
                SendMessage(this.Handle, WM_NCLBUTTONDOWN, dir, 0);
            }
        }
예제 #58
0
 private void MonthButton_MouseHover(object sender, EventArgs e)
 {
     ResizeDir = ResizeDirection.None;
     Cursor = Cursors.Default;
 }
        private void ResizeForm(ResizeDirection direction)
        {
            if (DesignMode) return;
            int dir = -1;
            switch (direction)
            {
                case ResizeDirection.BottomLeft:
                    dir = HTBOTTOMLEFT;
                    break;
                case ResizeDirection.Left:
                    dir = HTLEFT;
                    break;
                case ResizeDirection.Right:
                    dir = HTRIGHT;
                    break;
                case ResizeDirection.BottomRight:
                    dir = HTBOTTOMRIGHT;
                    break;
                case ResizeDirection.Bottom:
                    dir = HTBOTTOM;
                    break;
                case ResizeDirection.Top:
                    dir = HTTOP;
                    break;
                case ResizeDirection.TopLeft:
                    dir = HTTOPLEFT;
                    break;
                case ResizeDirection.TopRight:
                    dir = HTTOPRIGHT;
                    break;
                
            }

            ReleaseCapture();
            if (dir != -1)
            {
                currently_sizing = true;
                SendMessage(Handle, WM_NCLBUTTONDOWN, dir, 0);
            }
        }
예제 #60
0
        private void ResizeForm(ResizeDirection direction)
        {
            if (GlobalPreferences.LockPosition) return;

            int dir = -1;
            switch (direction)
            {
                case ResizeDirection.Left:
                    dir = UnsafeNativeMethods.HTLEFT;
                    break;
                case ResizeDirection.TopLeft:
                    dir = UnsafeNativeMethods.HTTOPLEFT;
                    break;
                case ResizeDirection.Top:
                    dir = UnsafeNativeMethods.HTTOP;
                    break;
                case ResizeDirection.TopRight:
                    dir = UnsafeNativeMethods.HTTOPRIGHT;
                    break;
                case ResizeDirection.Right:
                    dir = UnsafeNativeMethods.HTRIGHT;
                    break;
                case ResizeDirection.BottomRight:
                    dir = UnsafeNativeMethods.HTBOTTOMRIGHT;
                    break;
                case ResizeDirection.Bottom:
                    dir = UnsafeNativeMethods.HTBOTTOM;
                    break;
                case ResizeDirection.BottomLeft:
                    dir = UnsafeNativeMethods.HTBOTTOMLEFT;
                    break;
            }

            if (dir != -1)
            {
                UnsafeNativeMethods.ReleaseCapture();
                UnsafeNativeMethods.SendMessage(Handle, UnsafeNativeMethods.WM_NCLBUTTONDOWN, (IntPtr)dir, IntPtr.Zero);
            }
        }