/// <summary>
        /// 创建一个拖拽矩形对象
        /// </summary>
        /// <returns>新的拖拽矩形对象</returns>
        public virtual DragRectangle CreateDragRectangle()
        {
            DragRectangle.DragRectSize = DragBoxSize;
            DragRectangle rect = new DragRectangle(
                new System.Drawing.Rectangle(
                    (int)0,
                    (int)0,
                    (int)this.Width,
                    (int)this.Height),
                true);

            rect.CanMove       = true;
            rect.LineDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            rect.CanResize     = this.CanResize && this.OwnerDocument.DocumentControler.CanModify(
                this,
                DomAccessFlags.Normal);
            rect.Focus = true;             // myOwnerDocument.Content.CurrentElement == this && myOwnerDocument.Content.SelectionLength == 1 ;
            if (rect.CanResize)
            {
                if (this.OwnerDocument.Options.SecurityOptions.EnablePermission)
                {
                    // 进行权限判断用户能否改变元素大小
                    if (this.Style.DeleterIndex >= 0)
                    {
                        rect.CanResize = false;
                    }
                    else if (this.CreatorPermessionLevel > this.OwnerDocument.UserHistories.CurrentPermissionLevel)
                    {
                        rect.CanResize = false;
                    }
                }
            }
            return(rect);
        }
Exemple #2
0
 /// <summary>
 /// 重新绘制对象
 /// </summary>
 /// <param name="g">图形绘制对象</param>
 /// <param name="ClipRectangle">剪切矩形</param>
 public virtual void RefreshView(DomElement element, DocumentPaintEventArgs args)
 {
     if (element == null || element.OwnerLine == null)
     {
         return;
     }
     this.DrawBackground(element, args);
     this.DrawContent(element, args);
     if (args.RenderStyle == DocumentRenderStyle.Paint && args.ActiveMode)
     {
         if (element is DomObjectElement)
         {
             DomObjectElement oe = (DomObjectElement)element;
             if (oe.ShowDragRect)
             {
                 DragRectangle dr = oe.CreateDragRectangle();
                 dr.Bounds = new Rectangle(
                     (int)element.AbsLeft,
                     (int)element.AbsTop,
                     dr.Bounds.Width,
                     dr.Bounds.Height);
                 dr.RefreshView(args.Graphics);
             }
         }
     }
 }
Exemple #3
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && !DragRectangle.IsEmpty && !DragRectangle.Contains(e.Location))
            {
                deferredSelection = false;
            }

            base.OnMouseMove(e);
        }
 /// <summary>
 /// 处理文档用户界面事件
 /// </summary>
 /// <param name="args">事件参数</param>
 public override void HandleDocumentEvent(DocumentEventArgs args)
 {
     if (args.Style == DocumentEventStyles.MouseDown)
     {
         if (this.Enabled)
         {
             if (this.OwnerDocument.EditorControl != null)
             {
                 if (this.OwnerDocument.EditorControl.MouseDragScroll)
                 {
                     return;
                 }
             }
             DragPointStyle hit = this.GetDragHit(args.X, args.Y);
             if (this.ShowDragRect)
             {
                 if (hit >= 0)
                 {
                     DragBounds(hit);
                     args.CancelBubble = true;
                     if (this.OwnerDocument.EditorControl != null)
                     {
                         this.OwnerDocument.EditorControl.UpdateTextCaret();
                     }
                     return;
                 }
             }
             //if (this.AbsBounds.Contains(args.X, args.Y))
             {
                 this.OwnerDocument.CurrentContentElement.SetSelection(this.ViewIndex, 1);
                 args.CancelBubble = true;
             }
         }
     }
     else if (args.Style == DocumentEventStyles.MouseMove)
     {
         if (this.Enabled)
         {
             if (this.ShowDragRect)
             {
                 DragRectangle  dr  = this.CreateDragRectangle();
                 DragPointStyle hit = dr.DragHit(args.X, args.Y);
                 if (hit >= 0)
                 {
                     args.Cursor = DragRectangle.GetMouseCursor(hit);
                     base.HandleDocumentEvent(args);
                     return;
                 }
             }
             args.Cursor = System.Windows.Forms.Cursors.Arrow;
         }
     }
     else
     {
         base.HandleDocumentEvent(args);
     }
 }
        /// <summary>
        /// 进行控制点测试
        /// </summary>
        /// <param name="x">测试点X坐标</param>
        /// <param name="y">测试点Y坐标</param>
        /// <returns>测试点所在控制点编号</returns>
        protected virtual DragPointStyle GetDragHit(int x, int y)
        {
            DragRectangle dr = this.CreateDragRectangle();

            if (dr == null)
            {
                return(DragPointStyle.None);
            }
            else
            {
                return(dr.DragHit(x, y));
            }
        }
        //public override void RefreshView(DocumentPaintEventArgs  args)
        //{
        //    base.DrawBackground( args);
        //    this.DrawContent( args  );
        //    if( ShowDragRect )
        //    {
        //        DragRectangle dr = this.CreateDragRectangle();
        //        dr.RefreshView( args.Graphics );
        //    }
        //}

        /// <summary>
        /// 绘制对象
        /// </summary>
        /// <param name="args"></param>
        public override void Draw(DocumentPaintEventArgs args)
        {
            args.Render.DrawBackground(this, args);
            this.DrawContent(args);
            if (args.RenderStyle == DocumentRenderStyle.Paint && args.ActiveMode)
            {
                if (this.ShowDragRect && this.Enabled)
                {
                    DragRectangle dr = this.CreateDragRectangle();
                    dr.Bounds = new Rectangle(
                        (int)this.AbsLeft,
                        (int)this.AbsTop,
                        dr.Bounds.Width,
                        dr.Bounds.Height);
                    dr.RefreshView(args.Graphics);
                }
            }
            System.Drawing.RectangleF bounds = this.AbsBounds;
            bounds.Width  = bounds.Width - 1;
            bounds.Height = bounds.Height - 1;
            args.Render.RenderBorder(this, args, bounds);
        }
        private void cap_Draw(object sender, CaptureMouseMoveEventArgs e)
        {
            DragPointStyle hit = (DragPointStyle)e.Sender.Tag;

            System.Drawing.Rectangle rect  = Rectangle.Ceiling(this.AbsBounds);
            System.Drawing.Point     p1    = e.StartPosition;
            System.Drawing.Point     p2    = e.CurrentPosition;
            SimpleRectangleTransform trans = this.OwnerDocument.EditorControl.GetTransformItemByDescPoint(rect.Left, rect.Top);

            if (trans != null)
            {
                p1   = trans.TransformPoint(p1);
                p2   = trans.TransformPoint(p2);
                rect = DragRectangle.CalcuteDragRectangle(
                    (int)(p2.X - p1.X),
                    (int)(p2.Y - p1.Y),
                    hit,
                    Rectangle.Ceiling(this.AbsBounds));
                if (rect.Width > (int)this.OwnerDocument.Width)
                {
                    rect.Width = (int)this.OwnerDocument.Width;
                }
                if (this.WidthHeightRate > 0.1)
                {
                    rect.Height = (int)(rect.Width / this.WidthHeightRate);
                }
                LastDragBounds = rect;
                rect           = trans.UnTransformRectangle(rect);
                using (ReversibleDrawer drawer =
                           ReversibleDrawer.FromHwnd(this.OwnerDocument.EditorControl.Handle))
                {
                    drawer.PenStyle = PenStyle.PS_DOT;
                    drawer.PenColor = System.Drawing.Color.Red;
                    drawer.DrawRectangle(rect);
                }
            }
        }