// Graphics methods
        //chuck's new code 2/20/04
        //this method indicates whether point is along outline of graphic
        //and if so, what type of cursor should show
        public virtual void BoundaryTest(System.Drawing.Point pt, SizeDirection dir)
        {
            System.Drawing.Drawing2D.GraphicsPath gp       = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.Matrix       myMatrix = new System.Drawing.Drawing2D.Matrix();
            System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 3);

            gp.AddRectangle(new System.Drawing.Rectangle(this.m_Position.X - 3, this.m_Position.Y - 3, this.m_Size.Width + 6, this.m_Size.Height + 6));
            if (this.m_Rotation != 0)
            {
                myMatrix.RotateAt((float)this.m_Rotation, new System.Drawing.PointF((float)this.X, (float)this.Y), System.Drawing.Drawing2D.MatrixOrder.Append);
            }

            gp.Transform(myMatrix);
            dir = SizeDirection.NA;
            if (gp.IsOutlineVisible(pt, pen))
            {
                //user has placed the mouse along the outline of the selected
                //object - change the mouse to allow for resizing
                System.Drawing.RectangleF rect = gp.GetBounds();
                if (Math.Abs((int)rect.Left - pt.X) <= 2)
                {
                    if (Math.Abs((int)rect.Top - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Northwest;
                    }
                    else if (Math.Abs((int)rect.Bottom - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Southwest;
                    }
                    else
                    {
                        dir = SizeDirection.West;
                    }
                }
                else if (Math.Abs((int)rect.Right - pt.X) <= 2)
                {
                    if (Math.Abs((int)rect.Top - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Northeast;
                    }
                    else if (Math.Abs((int)rect.Bottom - pt.Y) <= 2)
                    {
                        dir = SizeDirection.Southeast;
                    }
                    else
                    {
                        dir = SizeDirection.East;
                    }
                }
                else if (Math.Abs((int)rect.Top - pt.Y) <= 2)
                {
                    dir = SizeDirection.North;
                }
                else
                {
                    dir = SizeDirection.South;
                }
            }
        }
        private void MoleculeViewer_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_DrawingLine)
            {
                return;
            }
            m_DraggingSelectedObject = false;
            m_RotatingSelectedObject = false;
            m_RotatingSurface        = false;
            Point mousePT = gscTogoc(e.X, e.Y);

            if (m_SelectionDragging)
            {
                //'TODO: Rewrite to handle multiple selections
                //'really just need to change from this.SelectedObject to a collection
                //'add each found object in this loop, removing the Exit For
                System.Drawing.Rectangle zoomedSelection = DeZoomRectangle(m_SelectionRectangle);
                int numObj = m_DrawingObjects.Count;
                foreach (GraphicObject graphicObj in m_DrawingObjects)
                {
                    if (graphicObj.HitTest(zoomedSelection))
                    {
                        graphicObj.Selected = true;
                    }
                }
                m_SelectionDragging = false;
                if (SelectionChanged != null)
                {
                    if (numObj == 1)
                    {
                        SelectionChanged(this, new SelectionChangedEventArgs(SelectedObject));
                    }
                    else
                    {
                        SelectionChanged(this, new SelectionChangedEventArgs(SelectedObjects));
                    }
                }
            }
            else if (resizing)
            {
                resizing  = false;
                sz_direct = SizeDirection.NA;
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Arrow;
            }
            Invalidate();
        }
        public void AddCorner(Ellipse ellipse, SizeDirection sizeDirection)
        {
            switch (sizeDirection)
            {
            case SizeDirection.NorthWest:
                NorthWest = ellipse;
                break;

            case SizeDirection.SouthEast:
                SouthEast = ellipse;
                break;

            case SizeDirection.SouthWest:
                SouthWest = ellipse;
                break;

            case SizeDirection.NorthEast:
                NorthEast = ellipse;
                break;
            }
        }
Beispiel #4
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            IntPtr hwnd = this.Handle;

            if ((isSizing) && (this.Parent != null) && (this.Parent.IsHandleCreated))
            {
                hwnd = Parent.Handle;
            }
            int           nul  = 0;
            SizeDirection sdir = GetSizeDirection(e);

            switch (sdir)
            {
            case SizeDirection.sdSizeLeft:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_W, ref nul);
            } break;

            case SizeDirection.sdSizeRight:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_E, ref nul);
            } break;

            case SizeDirection.sdSizeDown:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_S, ref nul);
            } break;

            case SizeDirection.sdSizeUp:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_N, ref nul);
            } break;

            case SizeDirection.sdUpLeft:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_NW, ref nul);
            } break;

            case SizeDirection.sdUpRight:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_NE, ref nul);
            } break;

            case SizeDirection.sdDownLeft:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_SW, ref nul);
            } break;

            case SizeDirection.sdDownRight:
            {
                NativeCalls.ReleaseCapture(hwnd);
                NativeCalls.SendMessage(hwnd, NativeCalls.WM_SYSCOMMAND, NativeCalls.SC_DRAGSIZE_SE, ref nul);
            } break;
            }
        }