예제 #1
0
        //=========================================================================================
        // windows menu command
        //

        //---------------------------------------------------------------------------------
        private void windowToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            bool userMode = SystemConfig.IsInUserMode;

            editToolStripMenuItem.Visible       = !userMode;
            favoritesToolStripMenuItem.Visible  = !userMode;
            historyToolStripMenuItem.Visible    = !userMode;
            ascendantsToolStripMenuItem.Visible = !userMode;
            optionsToolStripMenuItem.Visible    = !userMode;

            debugInfoToolStripMenuItem.Visible = SystemConfig.IsInDebuggerMode;

            foreach (ToolStripItem item in windowToolStripMenuItem.DropDownItems)
            {
                if (!(item is ToolStripMenuItem))
                {
                    continue;
                }
                bool check = false;
                if (item != null && item.Tag != null && (item.Tag is Type))
                {
                    Type          type = item.Tag as Type;
                    ITaxonControl itc  = TaxonControlList.FindTaxonControl(item.Tag as Type);
                    check = itc != null;
                }
                (item as ToolStripMenuItem).Checked = check;
            }
        }
예제 #2
0
        //=========================================================================================
        // Taxon graph
        //

        //---------------------------------------------------------------------------------
        private void taxonGraph_AddOneIfNone()
        {
            TaxonGraphPanel graph = TaxonControlList.FindTaxonControl <TaxonGraphPanel>();

            // create main taxon graph
            if (graph == null)
            {
                AddGraph();
            }
        }
예제 #3
0
        //---------------------------------------------------------------------------------
        private void windowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            Type type = item.Tag as Type;

            if (type == null)
            {
                return;
            }

            ITaxonControl itc = TaxonControlList.FindTaxonControl(type);

            if (itc != null)
            {
                if (itc.OwnerContainer == null)
                {
                    return;
                }
                if (itc is TaxonControl)
                {
                    if ((itc as TaxonControl).CanBeClosed)
                    {
                        itc.OwnerContainer.Remove(itc as TaxonControl, true);
                        TaxonControlList.UnregisterTaxonControl(itc);
                    }
                    else // cannot close, just set focus then
                    {
                        itc.OwnerContainer.SetFocus(itc);
                    }
                }
            }
            else
            {
                object o = type.GetConstructor(new Type[] { }).Invoke(new object[] { });
                new FormContainer(o as TaxonControl).Show(this);
            }
        }
예제 #4
0
        //====================================================================================
        // Running mode changing
        //

        //---------------------------------------------------------------------------------
        private void SystemConfig_OnRunningModeChanged(object sender, EventArgs e)
        {
            bool userMode = SystemConfig.IsInUserMode;


            // file / load menu
            fileToolStripMenuItem.Visible         = !userMode;
            userModeLoadToolStripMenuItem.Visible = userMode;

            // database menu
            databaseToolStripMenuItem.Visible = false;

            // role menu
#if USER
            roleToolStripMenuItem.Visible = false;
#endif

            // tool menu
            List <ToolStripItem> toRemove = new List <ToolStripItem>();
            foreach (ToolStripItem item in menuMain.Items)
            {
                if (item is ToolStripMenuItem && item.Tag is string && item.Tag as string == "FromFactoryOfTool")
                {
                    toRemove.Add(item);
                }
            }
            foreach (ToolStripItem item in toRemove)
            {
                menuMain.Items.Remove(item);
            }

            ToolStripMenuItem menuToAdd = TreeOfLife.Tools.FactoryOfTool.BuildMenus(userMode);

            int index = menuMain.Items.IndexOf(aboutToolStripMenuItem);
            while (menuToAdd.DropDownItems.Count > 0)
            {
                menuToAdd.DropDownItems[0].Tag = "FromFactoryOfTool";
                if (index != -1)
                {
                    menuMain.Items.Insert(index, menuToAdd.DropDownItems[0]);
                }
                else
                {
                    menuMain.Items.Add(menuToAdd.DropDownItems[0]);
                }
            }

            // close unauthorized window
            List <TaxonControl> toClose = new List <TaxonControl>();

            if (userMode)
            {
                toClose.Add(TaxonControlList.FindTaxonControl <TaxonOptions>());
                toClose.Add(TaxonControlList.FindTaxonControl <TaxonFavorites>());
                toClose.Add(TaxonControlList.FindTaxonControl <TaxonEditInfo>());
                toClose.Add(TaxonControlList.FindTaxonControl <TaxonHistory>());
                toClose.Add(TaxonControlList.FindTaxonControl <TaxonAscendants>());
            }

            if (SystemConfig.RunningMode != SystemConfig.RunningModeEnum.Debugger)
            {
                toClose.Add(TaxonControlList.FindTaxonControl <TaxonDebugInfo>());
            }

            foreach (TaxonControl control in toClose)
            {
                if (control == null)
                {
                    continue;
                }
                control.OwnerContainer.Remove(control, true);
                TaxonControlList.UnregisterTaxonControl(control);
            }
        }