예제 #1
0
        private static bool IsAutoHidden(DockPaneShim form)
        {
            DockState state = form.Content.DockState;

            return(state == DockState.DockLeftAutoHide ||
                   state == DockState.DockRightAutoHide ||
                   state == DockState.DockTopAutoHide ||
                   state == DockState.DockBottomAutoHide);
        }
예제 #2
0
        public void Hide(IDockPane pane)
        {
            Refresh();
            DockPaneShim form = _activePanes.Find(x => x.Pane == pane);

            if (form.Pane != null)
            {
                form.Content.Hide();
            }
        }
예제 #3
0
        public void Refresh()
        {
            DockPaneShim[] removedForms = _activePanes
                                          .Where(x => PluginManager.Get <IDockPane>(x.Name) == null)
                                          .ToArray();
            foreach (DockPaneShim form in removedForms)
            {
                form.Content.Dispose();
                _activePanes.Remove(form);
            }
            var newPanels = from name in PluginManager.GetNames <IDockPane>()
                            where _activePanes.All(form => form.Name != name)
                            select name;

            foreach (string name in newPanels)
            {
                IDockPane    plugin = PluginManager.Get <IDockPane>(name);
                DockPaneShim shim   = new DockPaneShim()
                {
                    Name = name, Pane = plugin
                };
                shim.Content = new DockContent()
                {
                    Name = name, TabText = name
                };
                shim.Content.Controls.Add(plugin.Control);
                shim.Content.Icon = plugin.DockIcon != null
                    ? Icon.FromHandle(plugin.DockIcon.GetHicon())
                    : null;

                shim.Content.HideOnClose = true;
                shim.Content.DockAreas   = DockAreas.Float
                                           | DockAreas.DockLeft | DockAreas.DockRight
                                           | DockAreas.DockTop | DockAreas.DockBottom;
                bool      autoHide = Core.Settings.AutoHidePanes.Contains(name);
                DockState state    = plugin.DockHint == DockHint.Float ? DockState.Float
                    : plugin.DockHint == DockHint.Left ? (autoHide ? DockState.DockLeftAutoHide : DockState.DockLeft)
                    : plugin.DockHint == DockHint.Right ? (autoHide ? DockState.DockRightAutoHide : DockState.DockRight)
                    : plugin.DockHint == DockHint.Top ? (autoHide ? DockState.DockTopAutoHide : DockState.DockTop)
                    : plugin.DockHint == DockHint.Bottom ? (autoHide ? DockState.DockBottomAutoHide : DockState.DockBottom)
                    : DockState.Float;  // stacked and nested ternary = awesome
                plugin.Control.Dock = DockStyle.Fill;
                shim.Content.Show(_mainPanel, state);
                if (!plugin.ShowInViewMenu || Core.Settings.HiddenPanes.Contains(name))
                {
                    shim.Content.Hide();
                }
                _activePanes.Add(shim);
            }
        }
예제 #4
0
        public void Toggle(IDockPane pane)
        {
            DockPaneShim form = _activePanes.Find(x => x.Pane == pane);

            if (form.Pane != null)
            {
                if (!IsVisible(form.Pane))
                {
                    Show(pane);
                }
                else
                {
                    Hide(pane);
                }
            }
        }
예제 #5
0
        public void Show(IDockPane pane)
        {
            Refresh();
            DockPaneShim shim = _activePanes.Find(x => x.Pane == pane);

            if (shim.Pane != null && !IsVisible(shim.Pane))
            {
                Control oldFocus = _mainPanel.Parent;
                while (oldFocus is ContainerControl)
                {
                    oldFocus = ((ContainerControl)oldFocus).ActiveControl;
                }
                shim.Content.Show();
                if (oldFocus != null)
                {
                    oldFocus.Focus();
                }
            }
        }
예제 #6
0
        public bool IsVisible(IDockPane pane)
        {
            DockPaneShim shim = _activePanes.Find(x => x.Pane == pane);

            return(shim.Pane != null && !shim.Content.IsHidden);
        }