예제 #1
0
        private int GetMinimumPanelsHeight([CanBeNull] ExpanderControl expandingPanel)
        {
            var minHeight = 0;

            foreach (ExpanderControl panel in _panels)
            {
                if (panel.Collapsed && panel != expandingPanel)
                {
                    minHeight = minHeight + panel.CollapsedHeight;
                }
                else
                {
                    // panel is expanded, or is about to be expanded
                    if (panel.Dock == DockStyle.Fill)
                    {
                        minHeight = minHeight + panel.CollapsedHeight +
                                    panel.Content.MinimumSize.Height;
                    }
                    else
                    {
                        minHeight = minHeight + panel.ExpandedHeight;
                    }
                }
            }

            return(minHeight);
        }
예제 #2
0
        private int GetMaximumPanelsHeight([CanBeNull] ExpanderControl expandingPanel)
        {
            var maxHeight = 0;

            foreach (ExpanderControl panel in _panels)
            {
                if (panel.Collapsed && panel != expandingPanel)
                {
                    maxHeight = maxHeight + panel.CollapsedHeight;
                }
                else
                {
                    // panel is expanded, or is a about to be expanded
                    if (panel.Dock == DockStyle.Fill)
                    {
                        maxHeight = 2000;
                        break;
                    }

                    maxHeight = maxHeight + panel.ExpandedHeight;
                }
            }

            return(maxHeight);
        }
예제 #3
0
        private void CollapsedPanel([NotNull] ExpanderControl collapsedPanel)
        {
            Assert.ArgumentNotNull(collapsedPanel, nameof(collapsedPanel));

            int heightReduction = collapsedPanel.ExpandedHeight -
                                  collapsedPanel.CollapsedHeight;

            int newHeight = Height - heightReduction;

            MinimumSize = new Size(MinimumSize.Width,
                                   GetMinimumPanelsHeight(null));

            MaximumSize = new Size(GetMaximumWidth(),
                                   GetMaximumPanelsHeight(null));

            Height = newHeight;
        }
예제 #4
0
        private void ExpandingPanel([NotNull] ExpanderControl expandingPanel)
        {
            Assert.ArgumentNotNull(expandingPanel, nameof(expandingPanel));

            int heightIncrease = expandingPanel.ExpandedHeight -
                                 expandingPanel.CollapsedHeight;

            int newHeight = Height + heightIncrease;

            MinimumSize = new Size(MinimumSize.Width,
                                   GetMinimumPanelsHeight(expandingPanel));

            MaximumSize = new Size(GetMaximumWidth(),
                                   GetMaximumPanelsHeight(expandingPanel));

            Height = newHeight;
        }
예제 #5
0
        public ExpanderControl AddPanel([NotNull] Control control, bool fill)
        {
            Assert.ArgumentNotNull(control, nameof(control));

            var panel = new ExpanderControl
            {
                PanelHeight = control.Height,
                Content     = control,
                Dock        = fill
                                                           ? DockStyle.Fill
                                                           : DockStyle.Bottom
            };

            _panels.Add(panel);

            SetMinimumSize();

            panel.CollapsedChanged  += panel_CollapsedChanged;
            panel.CollapsedChanging += panel_CollapsedChanging;

            return(panel);
        }