Пример #1
0
        private bool DragBounds(DragPointStyle hit)
        {
            MouseCapturer cap = new MouseCapturer(this.OwnerDocument.EditorControl);

            cap.Tag             = hit;
            cap.ReversibleShape = ReversibleShapeStyle.Custom;
            cap.Draw           += new CaptureMouseMoveEventHandler(cap_Draw);
            DomDocumentContentElement ce = this.DocumentContentElement;

            if (cap.CaptureMouseMove())
            {
                if (LastDragBounds.Width > 0 && LastDragBounds.Height > 0)
                {
                    if (LastDragBounds.Width != this.Width ||
                        LastDragBounds.Height != this.Height)
                    {
                        System.Drawing.SizeF OldSize = new System.Drawing.SizeF(
                            this.Width,
                            this.Height);
                        this.InvalidateView();
                        this.EditorSize = new SizeF(LastDragBounds.Width, LastDragBounds.Height);
                        this.InvalidateView();
                        ce.SetSelection(this.ViewIndex, 1);
                        if (this.OwnerDocument.BeginLogUndo())
                        {
                            this.OwnerDocument.UndoList.AddProperty(
                                XTextUndoStyles.EditorSize,
                                OldSize,
                                new System.Drawing.SizeF(this.Width, this.Height),
                                this);
                            this.OwnerDocument.EndLogUndo();
                        }
                        this.ContentElement.RefreshPrivateContent(
                            this.ContentElement.PrivateContent.IndexOf(this));
                        //ce.RefreshPrivateContent(ce.Content.IndexOf(this));
                        this.OwnerDocument.Modified = true;
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #2
0
        protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            myLastPoint = null;

            if (this.BehaviorStyle == XPictureBoxBehaviorStyle.DragScroll)
            {
                if (this.ImageBounds.Contains(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y))
                {
                    myDragPoint   = new myPointClass();
                    myDragPoint.X = e.X;
                    myDragPoint.Y = e.Y;
                }
            }
            else if (this.BehaviorStyle == XPictureBoxBehaviorStyle.DragSelect)
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    MouseCapturer cap = new MouseCapturer(this);
                    cap.ReversibleShape = ReversibleShapeStyle.Rectangle;
                    this.Cursor         = Cursors.Cross;
                    this.Capture        = true;
                    this.Refresh();
                    if (cap.CaptureMouseMove())
                    {
                        mySelectionBounds = GetBounds(cap.StartPosition, cap.EndPosition);
                        mySelectionBounds.Offset(-this.AutoScrollPosition.X, -this.AutoScrollPosition.Y);
                        Point p = this.ImageBounds.Location;
                        mySelectionBounds.Offset(-p.X, -p.Y);
                        myLastPoint = null;
                        this.Refresh();
                    }
                    this.Cursor  = Cursors.Default;
                    this.Capture = false;
                }
            }
            base.OnMouseDown(e);
        }