Exemple #1
0
        void ShowDragBox(Topic[] topics, int x, int y, bool canDrag, DragTopicsMethod dragMethod)
        {
            return; // datnq block drag drop feature

            if (DragBox.Visible && !DragBox.Bounds.IsEmpty)
            {
                InvalidateChart(DragBox.Bounds, true);
            }

            if (topics.IsNullOrEmpty())
            {
                DragBox.ClearTopics();
                DragBox.Visible = false;
            }
            else
            {
                DragBox.Refresh(x, y, canDrag, dragMethod, ClientSize);
                DragBox.Visible = true;

                if (!DragBox.Bounds.IsEmpty)
                {
                    InvalidateChart(DragBox.Bounds, true);
                }
            }
        }
Exemple #2
0
 public DragDropCommand(Document document, IEnumerable <ChartObject> objects, Topic target, DragTopicsMethod method)
 {
     Document = document;
     if (objects != null)
     {
         this.DragObjects = objects.ToArray();
     }
     this.Target         = target;
     this.DragDropMethod = method;
 }
Exemple #3
0
        void DargDropTo(IEnumerable <ChartObject> chartObjects, Topic target, DragTopicsMethod dragMethod)
        {
            if (chartObjects.IsNullOrEmpty() || target == null || dragMethod == DragTopicsMethod.None)
            {
                return;
            }

            var comd = new DragDropCommand(Map.Document, chartObjects, target, dragMethod);

            this.ExecuteCommand(comd);
        }
Exemple #4
0
        //bool TestDrop(Topic topic, Topic target)
        //{
        //    if (ReadOnly || topic == null || target == null || topic == target || topic.ParentTopic == target)
        //        return false;

        //    if (topic.IsDescent(target))
        //        return false;

        //    return true;
        //}

        bool TestDragDrop(Topic[] topics, Topic target, DragTopicsMethod dragMethod)
        {
            if (ReadOnly || topics.IsNullOrEmpty() || target == null)
            {
                return(false);
            }

            if (topics.Exists(t => t == target || t.ParentTopic == target || t.IsDescent(target)))
            {
                return(false);
            }

            return(true);
        }
Exemple #5
0
        public void Refresh(int x, int y, bool canDragDrop, DragTopicsMethod dragMethod, Size clientSize)
        {
            if (Topics.IsNullOrEmpty())
            {
                ClearTopics();
            }
            else
            {
                var location = new Point(ObjectsOriginalBounds.X + (x - StartMousePosition.X), ObjectsOriginalBounds.Y + (y - StartMousePosition.Y));
                location.X = Math.Max(0, Math.Min(clientSize.Width - Bounds.Width, location.X));
                location.Y = Math.Max(0, Math.Min(clientSize.Height - Bounds.Height, location.Y));

                Bounds      = new Rectangle(location, ObjectsOriginalBounds.Size);
                CanDragDrop = canDragDrop;

                DraggingMethod = dragMethod;
                switch (dragMethod)
                {
                case DragTopicsMethod.Move:
                    SubTitle     = Lang.GetTextWithEllipsis("Moving");
                    SubTitleIcon = Properties.Resources.cut;
                    break;

                case DragTopicsMethod.Copy:
                    SubTitle     = Lang.GetTextWithEllipsis("Copying");
                    SubTitleIcon = Properties.Resources.copy;
                    break;

                default:
                    SubTitle     = null;
                    SubTitleIcon = null;
                    break;
                }
                if (!string.IsNullOrEmpty(SubTitle))
                {
                    SubTitleSize = TextRenderer.MeasureText(SubTitle, SystemFonts.MenuFont);
                    SubTitleSize = new Size(SubTitleSize.Width + 2, SubTitleSize.Height + 6);
                    Bounds.Size  = new Size(Math.Max(Bounds.Width, SubTitleSize.Width + 18), Bounds.Height + SubTitleSize.Height);
                }
                else
                {
                    SubTitleSize = Size.Empty;
                }

                //this.Invalidate();
            }
        }
Exemple #6
0
        protected override void OnChartMouseMove(MouseEventArgs e)
        {
            base.OnChartMouseMove(e);

            // if the Shift is press, maybe is hover hyperlink, or reverse MouseMethod
            ChartMouseMethod mouseMethod = MouseMethod;

            if (Helper.TestModifierKeys(Keys.Shift))
            {
                if (mouseMethod == ChartMouseMethod.Select)
                {
                    mouseMethod = ChartMouseMethod.Scroll;
                }
            }

            if (MouseState == ChartMouseState.Drag)
            {
                CurrentDragMethod = Helper.TestModifierKeys(Keys.Control) ? DragTopicsMethod.Copy : DragTopicsMethod.Move;
                //bool canDrop = TestDrop(PressObject.Topic, HitTest(e.X, e.Y).Topic);
                //ShowDragBox(PressObject.Topic, e.X, e.Y, canDrop);
                bool canDrag = TestDragDrop(DragBox.Topics, HitTest(e.X, e.Y).Topic, CurrentDragMethod);
                ShowDragBox(DragBox.Topics, e.X, e.Y, canDrag, CurrentDragMethod);
            }
            else if (mouseMethod == ChartMouseMethod.Scroll)
            {
                if (MouseMethod == mouseMethod)
                {
                    MouseState = ChartMouseState.Scroll;
                }

                if (e.Button == MouseButtons.Left)
                {
                    Scroll(LastMousePos.X - e.X, LastMousePos.Y - e.Y);
                    LastMousePos.X = e.X;
                    LastMousePos.Y = e.Y;
                }
            }
            else if (IsMouseDown)
            {
                if (PressObject.IsEmpty) // select
                {
                    if (e.Button == MouseButtons.Left)
                    {
                        MouseState = ChartMouseState.Select;
                    }
                }
                else if (MouseState != ChartMouseState.Drag)
                {
                    // test drag
                    if (Math.Abs(MouseDownPos.X - e.X) > SystemInformation.DragSize.Width ||
                        Math.Abs(MouseDownPos.Y - e.Y) > SystemInformation.DragSize.Height)
                    {
                        DragBox.Start(MouseDownPos, SelectedTopics);
                        MouseState = ChartMouseState.Drag;
                    }
                }
            }

            if (!EditMode && MouseState == ChartMouseState.Normal)
            {
                HoverObject = HitTest(e.X, e.Y);
            }

            _ResetCursor();
        }
Exemple #7
0
 public void ClearTopics()
 {
     Topics         = new Topic[0];
     DraggingMethod = DragTopicsMethod.None;
     Bounds         = Rectangle.Empty;
 }