private void EnsurePaneVisible()
        {
            TreeNode treeNode = preferencePaneTree.SelectedNode;

            if (treeNode != null)
            {
                bool found = false;
                foreach (PreferencePaneContainer preferencePaneContainer in preferencePaneSplitContainer.Panel2.Controls)
                {
                    if (preferencePaneContainer.Tag == treeNode)
                    {
                        preferencePaneContainer.Visible = true;
                        found = true;
                    }
                    else
                    {
                        preferencePaneContainer.Visible = false;
                    }
                }

                if (!found)
                {
                    PaneInfo paneInfo = (PaneInfo)treeNode.Tag;

                    PreferencePane preferencePane = paneInfo.Factory();
                    preferencePane.Dock         = DockStyle.Fill;
                    preferencePane.Margin       = new Padding(0, 0, 0, 0);
                    preferencePane.AutoSize     = true;
                    preferencePane.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                    preferencePane.PendingSettingsChangesChanged += preferencePane_PendingSettingsChangesChanged;
                    preferencePane.RequiresElevationChanged      += preferencePane_ElevationRequiredChanged;

                    PreferencePaneContainer preferencePaneContainer = new PreferencePaneContainer();
                    preferencePaneContainer.Dock           = DockStyle.Fill;
                    preferencePaneContainer.Margin         = new Padding(0, 0, 0, 0);
                    preferencePaneContainer.AutoSize       = true;
                    preferencePaneContainer.AutoSizeMode   = AutoSizeMode.GrowAndShrink;
                    preferencePaneContainer.Tag            = treeNode;
                    preferencePaneContainer.PreferencePane = preferencePane;
                    preferencePaneContainer.Title          = paneInfo.Title;

                    preferencePaneSplitContainer.Panel2.Controls.Add(preferencePaneContainer);

                    RefreshPendingSettingsChangesState();
                    RefreshElevationRequiredState();
                }
            }
        }
        private void EnsurePaneVisible()
        {
            TreeNode treeNode = preferencePaneTree.SelectedNode;
            if (treeNode != null)
            {
                bool found = false;
                foreach (PreferencePaneContainer preferencePaneContainer in preferencePaneSplitContainer.Panel2.Controls)
                {
                    if (preferencePaneContainer.Tag == treeNode)
                    {
                        preferencePaneContainer.Visible = true;
                        found = true;
                    }
                    else
                    {
                        preferencePaneContainer.Visible = false;
                    }
                }

                if (!found)
                {
                    PaneInfo paneInfo = (PaneInfo) treeNode.Tag;

                    PreferencePane preferencePane = paneInfo.Factory();
                    preferencePane.Dock = DockStyle.Fill;
                    preferencePane.Margin = new Padding(0, 0, 0, 0);
                    preferencePane.AutoSize = true;
                    preferencePane.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                    preferencePane.PendingSettingsChangesChanged += preferencePane_PendingSettingsChangesChanged;
                    preferencePane.RequiresElevationChanged += preferencePane_ElevationRequiredChanged;

                    PreferencePaneContainer preferencePaneContainer = new PreferencePaneContainer();
                    preferencePaneContainer.Dock = DockStyle.Fill;
                    preferencePaneContainer.Margin = new Padding(0, 0, 0, 0);
                    preferencePaneContainer.AutoSize = true;
                    preferencePaneContainer.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                    preferencePaneContainer.Tag = treeNode;
                    preferencePaneContainer.PreferencePane = preferencePane;
                    preferencePaneContainer.Title = paneInfo.Title;

                    preferencePaneSplitContainer.Panel2.Controls.Add(preferencePaneContainer);

                    RefreshPendingSettingsChangesState();
                    RefreshElevationRequiredState();
                }
            }
        }