Example #1
0
        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();
        }