Exemplo n.º 1
0
 public bool isPanelVisible()
 {
     if (ContainerPanel != null)
     {
         if (ContainerPanel.GetType() == typeof(SplitterPanel))
         {
             SplitContainer parent = (SplitContainer)ContainerPanel.Parent;
             if (parent.Panel1 == ContainerPanel)
             {
                 if (ArrowOrientation == Orientation.Horizontal)
                 {
                     return(parent.SplitterDistance != this.Width);
                 }
                 else
                 {
                     return(parent.SplitterDistance != this.Height);
                 }
             }
             else
             {
                 if (ArrowOrientation == Orientation.Horizontal)
                 {
                     return(parent.SplitterDistance != (parent.Width - this.Width));
                 }
                 else
                 {
                     return(parent.SplitterDistance != (parent.Height - this.Height));
                 }
             }
         }
         else
         {
             if (ArrowOrientation == Orientation.Horizontal)
             {
                 return(ContainerPanel.Width != this.Width);
             }
             else
             {
                 return(ContainerPanel.Height != this.Height);
             }
         }
     }
     else if (TogglePanel.GetType() == typeof(SplitterPanel))
     {
         SplitContainer parent = (SplitContainer)TogglePanel.Parent;
         if (parent.Panel1 == TogglePanel)
         {
             return(!parent.Panel1Collapsed);
         }
         else
         {
             return(!parent.Panel2Collapsed);
         }
     }
     else
     {
         return(TogglePanel.Visible);
     }
 }
Exemplo n.º 2
0
 public void setContainerPanelOriginalSize()
 {
     if (ContainerPanel.GetType() == typeof(SplitterPanel))
     {
         SplitContainer parent = (SplitContainer)ContainerPanel.Parent;
         if (parent.Panel1 == ContainerPanel)
         {
             ContainerPanelOriginalSize = new Size(parent.SplitterDistance, parent.SplitterDistance);
         }
         else
         {
             ContainerPanelOriginalSize = new Size(parent.Width - parent.SplitterDistance, parent.Height - parent.SplitterDistance);
         }
     }
     else
     {
         ContainerPanelOriginalSize = ContainerPanel.Size;
     }
 }
Exemplo n.º 3
0
        public void toggle()
        {
            if (ContainerPanel != null)
            {
                if (ContainerPanelOriginalSize.Width == 0 || ContainerPanelOriginalSize.Height == 0)
                {
                    setContainerPanelOriginalSize();
                }

                if (ContainerPanel.GetType() == typeof(SplitterPanel))
                {
                    SplitContainer parent = (SplitContainer)ContainerPanel.Parent;
                    if (parent.Panel1 == ContainerPanel)
                    {
                        if (ArrowOrientation == Orientation.Horizontal)
                        {
                            if (isPanelOpen)
                            {
                                parent.SplitterDistance = this.Width;
                            }
                            else
                            {
                                parent.SplitterDistance = ContainerPanelOriginalSize.Width;
                            }
                        }
                        else
                        {
                            if (isPanelOpen)
                            {
                                parent.SplitterDistance = this.Height;
                            }
                            else
                            {
                                parent.SplitterDistance = ContainerPanelOriginalSize.Height;
                            }
                        }
                    }
                    else
                    {
                        if (ArrowOrientation == Orientation.Horizontal)
                        {
                            if (isPanelOpen)
                            {
                                parent.SplitterDistance = parent.Width - this.Width;
                            }
                            else
                            {
                                int splitterDistance = parent.Width - ContainerPanelOriginalSize.Width;
                                if (splitterDistance < 0)
                                {
                                    splitterDistance = MinimumSplitterDistance;
                                }
                                parent.SplitterDistance = splitterDistance;
                            }
                        }
                        else
                        {
                            if (isPanelOpen)
                            {
                                parent.SplitterDistance = parent.Height - this.Height;
                            }
                            else
                            {
                                int splitterDistance = parent.Height - ContainerPanelOriginalSize.Height;
                                if (splitterDistance < 0)
                                {
                                    splitterDistance = MinimumSplitterDistance;
                                }
                                parent.SplitterDistance = splitterDistance;
                            }
                        }
                    }
                }
                else
                {
                    if (ArrowOrientation == Orientation.Horizontal)
                    {
                        if (isPanelOpen)
                        {
                            ContainerPanel.Width = this.Width;
                        }
                        else
                        {
                            ContainerPanel.Width = ContainerPanelOriginalSize.Width;
                        }
                    }
                    else
                    {
                        if (isPanelOpen)
                        {
                            ContainerPanel.Height = this.Height;
                        }
                        else
                        {
                            ContainerPanel.Height = ContainerPanelOriginalSize.Height;
                        }
                    }
                }
            }
            else if (TogglePanel.GetType() == typeof(SplitterPanel))
            {
                SplitContainer parent = (SplitContainer)TogglePanel.Parent;
                if (parent.Panel1 == TogglePanel)
                {
                    parent.Panel1Collapsed = !parent.Panel1Collapsed;
                    setNewLocationBasedOnOrientation(parent.Panel1);
                }
                else
                {
                    parent.Panel2Collapsed = !parent.Panel2Collapsed;
                    setNewLocationBasedOnOrientation(parent.Panel2);
                }
            }
            else
            {
                TogglePanel.Visible = !TogglePanel.Visible;
                setNewLocationBasedOnOrientation(TogglePanel);
            }

            isPanelOpen = !isPanelOpen;

            //set arrow image
            if (pictureBox.BackgroundImage == _ArrowLeft)
            {
                setDirection(ArrowDirection.Right);
            }
            else if (pictureBox.BackgroundImage == _ArrowRight)
            {
                setDirection(ArrowDirection.Left);
            }
            else if (pictureBox.BackgroundImage == _ArrowUp)
            {
                setDirection(ArrowDirection.Down);
            }
            else
            {
                setDirection(ArrowDirection.Up);
            }
        }