protected override void OnChartContextMenuStripOpening(CancelEventArgs e) { if (SelectedObjects != null && SelectedObjects.Length > 0) { int count = SelectedObjects.Length; Topic topic = mindMapView1.SelectedTopic; int topicCount = mindMapView1.SelectedTopics.Length; string urls = null; MenuOpenHyperlink.Enabled = HasAnyUrl(SelectedObjects, out urls); MenuOpenHyperlink.Available = MenuOpenHyperlink.Enabled; MenuOpenHyperlink.ToolTipText = urls; MenuAddTopic.Enabled = !ReadOnly && count == 1 && topicCount > 0 && !topic.IsRoot; MenuAddSubTopic.Enabled = !ReadOnly && count == 1 && topicCount > 0; MenuFolding.Available = topicCount > 0 && count == 1 && topic.HasChildren; MenuExpandFolding.Enabled = topicCount > 0 && count == 1 && topic.Folded && !topic.IsRoot; MenuCollapseFolding.Enabled = topicCount > 0 && count == 1 && !topic.Folded && !topic.IsRoot; MenuToggleFolding.Enabled = topicCount > 0 && count == 1 && !topic.IsRoot; MenuExpandAll.Enabled = topicCount > 0 && count == 1; MenuCollapseAll.Enabled = topicCount > 0 && count == 1; MenuAdd.Enabled = true; MenuAddIcon.Enabled = topicCount > 0; MenuAddProgressBar.Enabled = topicCount > 0; MenuAddRemark.Enabled = topicCount > 0; MenuNewChartFromHere.Available = topicCount == 1; bool hasLink = false; foreach (var mo in SelectedObjects) { if (mo is Link) { hasLink = true; break; } } MenuLink.Available = hasLink; } else { MenuOpenHyperlink.Enabled = false; MenuOpenHyperlink.ToolTipText = null; MenuAddTopic.Enabled = false; MenuAddSubTopic.Enabled = false; MenuFolding.Available = false; MenuAdd.Enabled = false; MenuLink.Available = false; MenuNewChartFromHere.Available = false; } MenuCut.Enabled = mindMapView1.CanCut; MenuCopy.Enabled = mindMapView1.CanCopy; MenuPaste.Enabled = mindMapView1.CanPaste; MenuDelete.Enabled = mindMapView1.CanDelete; MenuEdit.Enabled = mindMapView1.CanEdit; MenuAdvance.Available = MenuAdvance.HasAvailableItems(); ChartContextMenuStrip.SmartHideSeparators(); }
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)); } }