Пример #1
0
        public OptionsPanel SwitchPanel(string optionCategory)
        {
            try
            {
                OptionsPanelPath.Text = "";

                if (_panels.Count > 0)
                {
                    OptionsPanel pn = null;

                    for (int i = 0; i < _panels.Count; i++)
                    {
                        if (_panels[i].CategoryPath == optionCategory)
                        {
                            pn = _panels[i];
                            break;
                        }
                    }

                    if (pn != null)
                    {
                        var displayName = pn.DisplayName;

                        var lpaths = GetPaths(optionCategory);
                        var paths  = lpaths[0];

                        if (paths.Length > 1)
                        {
                            var search = CatTree.Nodes.Find(paths[0], false);

                            if (search.Length > 0)
                            {
                                OptionsPanelPath.Text += search[0].Text + @" >";

                                int i   = 1;
                                int sub = paths.Length - 1;
                                for (; i < sub; i++)
                                {
                                    search = search[0].Nodes.Find(paths[i], false);

                                    if (search.Length > 0)
                                    {
                                        OptionsPanelPath.Text += search[0].Text + @" >";
                                    }
                                }
                            }
                        }

                        OptionsPanelPath.Text += displayName;

                        if (this.OptionPanelContainer.Controls.Count == 0 || !OptionPanelContainer.Controls[0].Equals(pn))
                        {
                            this.OptionPanelContainer.Controls.Clear();
                            this.OptionPanelContainer.Controls.Add(pn);

                            pn.Visible = true;
                        }

                        return(pn);
                    }
                }

                return(null);
            }
            catch
            {
                return(null);
            }
        }
Пример #2
0
 public OptionsPanelEventArgs(OptionsPanel panel)
 {
     _Panel = panel;
 }
Пример #3
0
        private void AddPanel(OptionsPanel panel)
        {
            string optionCategory = panel.CategoryPath;
            string displayName    = panel.DisplayName;

            string[][] lpaths = GetPaths(optionCategory);
            string[]   paths  = lpaths[0];
            string[]   labs   = lpaths[1];

            TreeNode pnode = null;
            TreeNode nnode = null;

            if (paths.Length > 1)
            {
                TreeNode[] search = CatTree.Nodes.Find(paths[0], false);

                if (search != null && search.Length > 0)
                {
                    pnode = search[0];
                }
                else
                {
                    CatTree.Nodes.Add(paths[0], labs[0], paths[0], paths[0]);
                    pnode = CatTree.Nodes[CatTree.Nodes.Count - 1];
                }

                int i   = 1;
                int sub = paths.Length - 1;
                for (; i < sub; i++)
                {
                    search = pnode.Nodes.Find(paths[i], false);

                    if (search != null && search.Length > 0)
                    {
                        pnode = search[0];
                    }
                    else
                    {
                        pnode.Nodes.Add(paths[i], labs[i], string.Join(@"\", paths, 0, i + 1), string.Join(@"\", paths, 0, i + 1));
                        pnode = pnode.Nodes[pnode.Nodes.Count - 1];
                    }
                }

                if (i < sub)
                {
                    pnode = null;
                }
            }

            if (pnode != null)
            {
                nnode                  = new TreeNode(displayName);
                nnode.Name             = optionCategory;
                nnode.ImageKey         = string.Join(@"\", paths);
                nnode.SelectedImageKey = string.Join(@"\", paths);
                pnode.Nodes.Add(nnode);

                panel.OptionsChanged += new EventHandler(panel_OptionsChanged);
                panel.Dock            = DockStyle.Fill;
                panel.PanelAdded(this);

                EnableDescrControl(panel);
            }
            else if (paths.Length == 1)
            {
                nnode      = new TreeNode(displayName);
                nnode.Name = optionCategory;
                CatTree.Nodes.Add(nnode);

                panel.OptionsChanged += new EventHandler(panel_OptionsChanged);
                panel.Dock            = DockStyle.Fill;
                panel.PanelAdded(this);

                EnableDescrControl(panel);
            }
        }