예제 #1
0
        private void SaveToolStripPanel(ToolStripPanel panel, string position,
                                        ToolStripSettingElementCollection newSettings)
        {
            int rowIndex = 0;

            foreach (ToolStripPanelRow row in panel.Rows)
            {
                this.SaveToolStripRow(row, newSettings, position, rowIndex);
                rowIndex++;
            }
        }
예제 #2
0
 public void SaveLayout()
 {
     if (!Settings.ToolbarsLocked)
     {
         ToolStripSettingElementCollection newSettings = new ToolStripSettingElementCollection();
         this.SaveToolStripPanel(this.TopToolStripPanel, "Top", newSettings);
         this.SaveToolStripPanel(this.LeftToolStripPanel, "Left", newSettings);
         this.SaveToolStripPanel(this.RightToolStripPanel, "Right", newSettings);
         this.SaveToolStripPanel(this.BottomToolStripPanel, "Bottom", newSettings);
         Settings.ToolbarSettings = newSettings;
     }
 }
예제 #3
0
        private void ReJoinAllPanels(ToolStripSettingElementCollection newSettings)
        {
            foreach (ToolStripSettingElement setting in newSettings)
            {
                ToolStrip         strip    = this.FindToolStripForSetting(setting);
                ToolStripMenuItem menuItem = this.FindMenuForSetting(setting);

                if (menuItem != null)
                {
                    menuItem.Checked = setting.Visible;
                }

                this.RestoreStripLayout(setting, strip);
            }
        }
예제 #4
0
        private void AplyAllPanelPositions(ToolStripSettingElementCollection newSettings)
        {
            foreach (ToolStripSettingElement setting in newSettings)
            {
                ToolStrip strip = this.FindToolStripForSetting(setting);

                if (strip == null)
                {
                    continue;
                }

                strip.GripStyle = ToolStripGripStyle.Visible;
                ApplyLastPosition(setting, strip);
            }
        }
예제 #5
0
 private void SaveToolStripRow(ToolStripPanelRow row, ToolStripSettingElementCollection newSettings,
                               string position, int rowIndex)
 {
     foreach (ToolStrip strip in row.Controls)
     {
         newSettings.Add(new ToolStripSettingElement
         {
             Dock    = position,
             Row     = rowIndex,
             Left    = strip.Left,
             Top     = strip.Top,
             Name    = strip.Name,
             Visible = strip.Visible
         });
     }
 }
예제 #6
0
        public void LoadToolStripsState()
        {
            ToolStripSettingElementCollection newSettings = Settings.ToolbarSettings;

            if (newSettings != null && newSettings.Count > 0)
            {
                this.SuspendLayout();
                this.ClearAllPanels();
                this.ReJoinAllPanels(newSettings);

                // paranoic, because the previous join can reset the position
                // dont assign if already there. Because it can reorder the toolbars
                // http://www.visualbasicask.com/visual-basic-language/toolstrips-controls-becoming-desorganized.shtml
                this.AplyAllPanelPositions(newSettings);
                this.ResumeLayout(true);

                this.ChangeLockState();
            }
        }