Exemplo n.º 1
0
        void ProcessChartMouseUp(MouseEventArgs e)
        {
            if (MouseState == ChartMouseState.Drag)
            {
                if (DragBox.Visible && !DragBox.Topics.IsNullOrEmpty())
                {
                    var htr = HitTest(e.X, e.Y);
                    if (!htr.IsEmpty && !htr.IsFoldingButton && TestDragDrop(DragBox.Topics, htr.Topic, CurrentDragMethod))
                    {
                        DargDropTo(DragBox.Topics, htr.Topic, CurrentDragMethod);
                    }
                }

                CancelDrag();
                return;
            }

            if (MouseState == ChartMouseState.Select)
            {
                Topic[] topics = GetTopicsInRect(LastSelectionBox);
                if (topics != null && topics.Length > 0)
                {
                    Select(topics, !Helper.TestModifierKeys(Keys.Control));
                }
                //SelectTopics(topics, !Helper.TestModifierKeys(Keys.Control));
                ExitSelectMode();
                //ClearSelectionBox();
                return;
            }

            if (MouseState == ChartMouseState.Scroll)
            {
                //Scroll(MouseDownPos.X - e.X, MouseDownPos.Y - e.Y);
                return;
            }

            if (!FormatPainter.Default.IsEmpty && !ReadOnly)
            {
                HitTestResult htr = HitTest(e.X, e.Y);
                if (!htr.IsEmpty && !htr.IsFoldingButton && e.Button == MouseButtons.Left)
                {
                    FormatPainter.Default.Assign(htr.Topic);
                }

                if (!FormatPainter.Default.HoldOn && !Helper.TestModifierKeys(Keys.Control))
                {
                    FormatPainter.Default.Clear();
                }
                return;
            }

            if (Helper.TestModifierKeys(Keys.Shift) &&
                e.Button == MouseButtons.Left &&
                (PressObject.Widget != null || PressObject.Topic != null))
            {
                // Open Url
                if (PressObject.Widget != null && !string.IsNullOrEmpty(PressObject.Widget.Hyperlink))
                {
                    Helper.OpenUrl(PressObject.Widget.Hyperlink);
                }
                else if (PressObject.Topic != null && !string.IsNullOrEmpty(PressObject.Topic.Hyperlink))
                {
                    Helper.OpenUrl(PressObject.Topic.Hyperlink);
                }
                return;
            }

            if (Helper.TestModifierKeys(Keys.Control) &&
                e.Button == System.Windows.Forms.MouseButtons.Left &&
                SelectedObjects.Length <= 1)
            {
                if (PressObject.Topic != null &&
                    !string.IsNullOrEmpty(PressObject.Topic.Hyperlink) &&
                    (SelectedObjects.IsEmpty() || SelectedObjects[0] == PressObject.Topic))
                {
                    Helper.OpenUrl(PressObject.Topic.Hyperlink);
                    return;
                }

                if (PressObject.Widget != null &&
                    !string.IsNullOrEmpty(PressObject.Widget.Hyperlink) &&
                    (SelectedObjects.IsEmpty() || SelectedObjects[0] == PressObject.Widget))
                {
                    Helper.OpenUrl(PressObject.Widget.Hyperlink);
                    return;
                }
            }

            // Normal Status
            if (HoverObject != null && HoverObject.Widget != null && HoverObject == PressObject)
            {
                HoverObject.Widget.OnMouseClick(new MouseEventArgs(e.Button, e.Clicks, e.X, e.Y, e.Delta));
            }

            if (e.Button == MouseButtons.Right && ChartContextMenuStrip != null)
            {
                ChartContextMenuStrip.Show(this.ChartBox, new Point(e.X, e.Y));
            }
        }