protected override void OnMdiChildActivate(EventArgs e) { base.OnMdiChildActivate(e); _activeMdiChildToolStripTextBox.Text = ActiveMdiChild != null ? ActiveMdiChild.Text : null; _saveButton.Enabled = ActiveMdiChild != null; if (ActiveMdiChild != null) { _toolStripPanel.ResumeLayout(false); if (_queryFormToolStrip != null) { _toolStripPanel.Controls.Remove(_queryFormToolStrip); } var queryForm = (QueryForm)ActiveMdiChild; var queryFormToolStrip = queryForm.ToolStrip; if (queryFormToolStrip != null) { queryFormToolStrip.Visible = true; var location = new Point(_toolStrip.Right, _toolStrip.Top); _toolStripPanel.Join(queryFormToolStrip, location); _toolStripPanel.PerformLayout(); _queryFormToolStrip = queryFormToolStrip; } CreateRecentFileListMenu(); } else { _mnuRecentFileList.DropDownItems.Clear(); } }
private void FixLayout(ToolStripPanel toolStripPanel) { toolStripPanel.SuspendLayout(); foreach (Control c in toolStripPanel.Controls) { ToolStrip ts = c as ToolStrip; if (ts != null) { ts.Location = new Point(0, 0); } } toolStripPanel.ResumeLayout(); }
private ToolStrip AddToolStrip(string groupName) { var strip = new ToolStrip { Name = groupName, }; _strips.Add(strip); var toAdd = new List <Control>(_tsPanel.Controls.Cast <Control>()) { strip }; _tsPanel.SuspendLayout(); _tsPanel.Controls.Clear(); _tsPanel.Controls.AddRange(toAdd.ToArray()); _tsPanel.ResumeLayout(); return(strip); }
//位置指定はフォームのOnLoad後にやらなくちゃいかんのか。めんどうだな public void RestoreLayout() { ICommandTarget target = (ICommandTarget)_parent.GetAdapter(typeof(ICommandTarget)); ToolStripPanel panel = this.TopToolStripPanel; panel.BeginInit(); panel.SuspendLayout(); bool location_available = _initialLocationInfo.Length > 0; //ToolStripPanelへの追加はかなり不可思議。 //BeginInitやSuspendLayoutを呼ぶかどうかでも相当様子が違う。 //なのでややいい加減だが、初回起動時など位置情報がないときはControls.AddRangeで一括登録で.NETに任せ、それ以降は位置指定という方針でいく if (!location_available) { panel.Controls.AddRange(_toolStrips.ToArray()); } foreach (ToolStrip t in _toolStrips) { if (location_available) { panel.Join(t, t.Location); } foreach (ToolStripItem c in t.Items) { ControlTagBase tag = c.Tag as ControlTagBase; if (tag != null) { RefreshElement(c, tag, target); } } } panel.ResumeLayout(); panel.EndInit(); }
public void Activate() { if (_isActivated) { return; } var headerControls = App.CompositionContainer.GetExportedValues <IHeaderControl>().ToList(); // Activate only if there are no other IHeaderControl implementations and // custom HeaderControl not yet set if (App.HeaderControl == null && headerControls.Count == 1 && headerControls[0].GetType() == GetType()) { _isActivated = true; var container = new ToolStripPanel { Dock = DockStyle.Top }; Shell.Controls.Add(container); var menuStrip = new MenuStrip { Name = DEFAULT_GROUP_NAME, Dock = DockStyle.Top }; Shell.Controls.Add(menuStrip); Initialize(container, menuStrip); // Add default buttons container.SuspendLayout(); menuStrip.SuspendLayout(); new DefaultMenuBars(App).Initialize(this); container.ResumeLayout(); menuStrip.ResumeLayout(); } }
private void InitializeComponent() { _dockedToolStrips = new Dictionary <String, DockedToolStrip>(); _mainMenuStrip = new MenuStrip(); _mainToolStripPanel = new ToolStripPanel(); _dockPanel = new DockPanel(); _mainStatusStrip = new StatusStrip(); _mainStatusStripMessage = new ToolStripStatusLabel(); _mainStatusStripTimer = new Timer(); _mainStatusStripTimer.Enabled = false; _mainStatusStripTimer.Tick += new EventHandler(MainStatusStripTimer_Tick); SuspendLayout(); _mainMenuStrip.SuspendLayout(); _mainToolStripPanel.SuspendLayout(); _dockPanel.SuspendLayout(); _mainStatusStrip.SuspendLayout(); #region Main Menu UI_FILE_MENU = new ToolStripMenuItem(); UI_FILE_MENU_NEW = new ToolStripMenuItem(); UI_FILE_MENU_OPEN = new ToolStripMenuItem(); UI_FILE_MENU_SAVE = new ToolStripMenuItem(); UI_FILE_MENU_SAVE_AS = new ToolStripMenuItem(); UI_FILE_MENU_SAVE_ALL = new ToolStripMenuItem(); UI_FILE_MENU_RECENT_FILES = new ToolStripMenuItem(); UI_FILE_MENU_EXIT = new ToolStripMenuItem(); UI_VIEW_MENU = new ToolStripMenuItem(); UI_VIEW_MENU_TOOLBAR = new ToolStripMenuItem(); UI_VIEW_MENU_STATUSBAR = new ToolStripMenuItem(); UI_VIEW_MENU_FULLSCREEN = new ToolStripMenuItem(); UI_TOOLS_MENU = new ToolStripMenuItem(); UI_TOOLS_MENU_OPTIONS = new ToolStripMenuItem(); UI_WINDOW_MENU = new ToolStripMenuItem(); UI_WINDOW_MENU_CLOSE = new ToolStripMenuItem(); UI_WINDOW_MENU_CLOSE_ALL = new ToolStripMenuItem(); UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE = new ToolStripMenuItem(); UI_HELP_MENU = new ToolStripMenuItem(); UI_HELP_MENU_ABOUT = new ToolStripMenuItem(); _mainMenuStrip.Location = new Point(0, 0); _mainMenuStrip.Name = "mainMenuStrip"; _mainMenuStrip.Size = new Size(692, 24); _mainMenuStrip.TabIndex = 0; _mainMenuStrip.Text = "menuStrip1"; _mainMenuStrip.Items.AddRange(new ToolStripItem[] { UI_FILE_MENU, UI_VIEW_MENU, UI_TOOLS_MENU, UI_WINDOW_MENU, UI_HELP_MENU }); // UI_FILE_MENU UI_FILE_MENU.DropDownItems.AddRange(new ToolStripItem[] { UI_FILE_MENU_NEW, UI_FILE_MENU_OPEN, UI_FILE_MENU_SAVE, UI_FILE_MENU_SAVE_AS, UI_FILE_MENU_SAVE_ALL }); if (_profile.MRUDocumentListMax > 0) { UI_FILE_MENU.DropDownItems.Add(UI_FILE_MENU_RECENT_FILES); } UI_FILE_MENU.DropDownItems.Add(UI_FILE_MENU_EXIT); UI_FILE_MENU.Name = Constants.UI_FILE_MENU; UI_FILE_MENU.Text = Resources.MainFileMenu; UI_FILE_MENU.DropDownOpening += new System.EventHandler(UI_FILE_MENU_DropDownOpening); // UI_FILE_MENU_NEW UI_FILE_MENU_NEW.Image = Resources.New; UI_FILE_MENU_NEW.ImageTransparentColor = Color.Fuchsia; UI_FILE_MENU_NEW.Name = Constants.UI_FILE_MENU_NEW; UI_FILE_MENU_NEW.ShortcutKeys = ((Keys)((Keys.Control | Keys.N))); UI_FILE_MENU_NEW.Text = Resources.MainFileMenuNew; UI_FILE_MENU_NEW.Click += new System.EventHandler(UI_FILE_MENU_NEW_Click); // UI_FILE_MENU_OPEN UI_FILE_MENU_OPEN.Image = Resources.Open; UI_FILE_MENU_OPEN.ImageTransparentColor = Color.Fuchsia; UI_FILE_MENU_OPEN.Name = Constants.UI_FILE_MENU_OPEN; UI_FILE_MENU_OPEN.ShortcutKeys = ((Keys)((Keys.Control | Keys.O))); UI_FILE_MENU_OPEN.Text = Resources.MainFileMenuOpen; UI_FILE_MENU_OPEN.Click += new System.EventHandler(UI_FILE_MENU_OPEN_Click); UI_FILE_MENU_OPEN.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_FILE_MENU_SAVE UI_FILE_MENU_SAVE.Image = Resources.Save; UI_FILE_MENU_SAVE.ImageTransparentColor = Color.Fuchsia; UI_FILE_MENU_SAVE.Name = Constants.UI_FILE_MENU_SAVE; UI_FILE_MENU_SAVE.ShortcutKeys = ((Keys)((Keys.Control | Keys.S))); UI_FILE_MENU_SAVE.Text = Resources.MainFileMenuSave; UI_FILE_MENU_SAVE.Click += new System.EventHandler(UI_FILE_MENU_SAVE_Click); // UI_FILE_MENU_SAVE_AS UI_FILE_MENU_SAVE_AS.Name = Constants.UI_FILE_MENU_SAVE_AS; UI_FILE_MENU_SAVE_AS.Text = Resources.MainFileMenuSaveAs; UI_FILE_MENU_SAVE_AS.Click += new System.EventHandler(UI_FILE_MENU_SAVE_AS_Click); // UI_FILE_MENU_SAVE_ALL UI_FILE_MENU_SAVE_ALL.Image = Resources.SaveAll; UI_FILE_MENU_SAVE_ALL.ImageTransparentColor = Color.Fuchsia; UI_FILE_MENU_SAVE_ALL.Name = Constants.UI_FILE_MENU_SAVE_ALL; UI_FILE_MENU_SAVE_ALL.ShortcutKeys = ((Keys)(((Keys.Control | Keys.Shift) | Keys.S))); UI_FILE_MENU_SAVE_ALL.Text = Resources.MainFileMenuSaveAll; UI_FILE_MENU_SAVE_ALL.Click += new System.EventHandler(UI_FILE_MENU_SAVE_ALL_Click); UI_FILE_MENU_SAVE_ALL.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_FILE_MENU_RECENT_FILES UI_FILE_MENU_RECENT_FILES.Name = Constants.UI_FILE_MENU_RECENT_FILES; UI_FILE_MENU_RECENT_FILES.Text = Resources.MainFileMenuRecentFiles; UI_FILE_MENU_RECENT_FILES.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_FILE_MENU_EXIT UI_FILE_MENU_EXIT.Name = Constants.UI_FILE_MENU_EXIT; UI_FILE_MENU_EXIT.Text = Resources.MainFileMenuExit; UI_FILE_MENU_EXIT.Click += new System.EventHandler(UI_FILE_MENU_EXIT_Click); UI_FILE_MENU_EXIT.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_VIEW_MENU UI_VIEW_MENU.DropDownItems.AddRange(new ToolStripItem[] { UI_VIEW_MENU_TOOLBAR, UI_VIEW_MENU_STATUSBAR, UI_VIEW_MENU_FULLSCREEN }); UI_VIEW_MENU.Name = Constants.UI_VIEW_MENU; UI_VIEW_MENU.Text = Resources.MainViewMenu; // UI_VIEW_MENU_TOOLBARS UI_VIEW_MENU_TOOLBAR.Name = Constants.UI_VIEW_MENU_TOOLBAR; // UI_VIEW_MENU_STATUSBAR UI_VIEW_MENU_STATUSBAR.Checked = true; UI_VIEW_MENU_STATUSBAR.CheckOnClick = true; UI_VIEW_MENU_STATUSBAR.CheckState = CheckState.Checked; UI_VIEW_MENU_STATUSBAR.Name = Constants.UI_VIEW_MENU_STATUSBAR; UI_VIEW_MENU_STATUSBAR.Text = Resources.MainViewMenuStatusBar; UI_VIEW_MENU_STATUSBAR.Click += new System.EventHandler(UI_VIEW_MENU_STATUSBAR_Click); UI_VIEW_MENU_STATUSBAR.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_VIEW_MENU_FULLSCREEN UI_VIEW_MENU_FULLSCREEN.Name = Constants.UI_VIEW_MENU_FULLSCREEN; UI_VIEW_MENU_FULLSCREEN.Text = Resources.MainViewMenuFullScreen; UI_VIEW_MENU_FULLSCREEN.Image = Resources.FullScreen; UI_VIEW_MENU_FULLSCREEN.ImageTransparentColor = Color.Fuchsia; UI_VIEW_MENU_FULLSCREEN.ShortcutKeys = Keys.F11; UI_VIEW_MENU_FULLSCREEN.Click += new System.EventHandler(UI_VIEW_MENU_FULLSCREEN_Click); UI_VIEW_MENU_FULLSCREEN.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_TOOLS_MENU UI_TOOLS_MENU.DropDownItems.AddRange(new ToolStripItem[] { UI_TOOLS_MENU_OPTIONS }); UI_TOOLS_MENU.Name = Constants.UI_TOOLS_MENU; UI_TOOLS_MENU.Text = Resources.MainToolsMenu; // UI_TOOLS_MENU_OPTIONS UI_TOOLS_MENU_OPTIONS.Name = Constants.UI_TOOLS_MENU_OPTIONS; UI_TOOLS_MENU_OPTIONS.Text = Resources.MainToolsMenuOptions; UI_TOOLS_MENU_OPTIONS.Click += new System.EventHandler(UI_TOOLS_MENU_OPTIONS_Click); UI_TOOLS_MENU_OPTIONS.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_WINDOW_MENU UI_WINDOW_MENU.DropDownItems.AddRange(new ToolStripItem[] { UI_WINDOW_MENU_CLOSE, UI_WINDOW_MENU_CLOSE_ALL, UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE }); UI_WINDOW_MENU.Name = Constants.UI_WINDOW_MENU; UI_WINDOW_MENU.Text = Resources.MainWindowMenu; UI_WINDOW_MENU.DropDownOpening += new System.EventHandler(UI_WINDOW_MENU_DropDownOpening); // UI_WINDOW_MENU_CLOSE UI_WINDOW_MENU_CLOSE.Name = Constants.UI_WINDOW_MENU_CLOSE; UI_WINDOW_MENU_CLOSE.Text = Resources.MainWindowMenuClose; UI_WINDOW_MENU_CLOSE.Click += new System.EventHandler(UI_WINDOW_MENU_CLOSE_Click); // UI_WINDOW_MENU_CLOSE_ALL UI_WINDOW_MENU_CLOSE_ALL.Name = Constants.UI_WINDOW_MENU_CLOSE_ALL; UI_WINDOW_MENU_CLOSE_ALL.Text = Resources.MainWindowMenuCloseAll; UI_WINDOW_MENU_CLOSE_ALL.Click += new System.EventHandler(UI_WINDOW_MENU_CLOSE_ALL_Click); // UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE.Name = Constants.UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE; UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE.Text = Resources.MainWindowMenuCloseAllButActive; UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE.Click += new System.EventHandler(UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE_Click); UI_WINDOW_MENU_CLOSE_ALL_BUT_ACTIVE.Tag = new ToolStripItemTag() { IncludeSeparator = true }; // UI_HELP_MENU UI_HELP_MENU.DropDownItems.AddRange(new ToolStripItem[] { UI_HELP_MENU_ABOUT }); UI_HELP_MENU.Name = Constants.UI_HELP_MENU; UI_HELP_MENU.Text = Resources.MainHelpMenu; // UI_HELP_MENU_ABOUT UI_HELP_MENU_ABOUT.Name = Constants.UI_HELP_MENU_ABOUT; UI_HELP_MENU_ABOUT.Text = Resources.MainHelpMenuAbout; UI_HELP_MENU_ABOUT.Click += new System.EventHandler(UI_HELP_MENU_ABOUT_Click); UI_HELP_MENU_ABOUT.Tag = new ToolStripItemTag() { IncludeSeparator = true }; #endregion #region ToolStrip Panel _mainToolStripPanel.Dock = DockStyle.Top; #endregion #region DockPanel DockPanelSkin dockPanelSkin1 = new DockPanelSkin(); AutoHideStripSkin autoHideStripSkin1 = new AutoHideStripSkin(); DockPanelGradient dockPanelGradient1 = new DockPanelGradient(); TabGradient tabGradient1 = new TabGradient(); DockPaneStripSkin dockPaneStripSkin1 = new DockPaneStripSkin(); DockPaneStripGradient dockPaneStripGradient1 = new DockPaneStripGradient(); TabGradient tabGradient2 = new TabGradient(); DockPanelGradient dockPanelGradient2 = new DockPanelGradient(); TabGradient tabGradient3 = new TabGradient(); DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient1 = new DockPaneStripToolWindowGradient(); TabGradient tabGradient4 = new TabGradient(); TabGradient tabGradient5 = new TabGradient(); DockPanelGradient dockPanelGradient3 = new DockPanelGradient(); TabGradient tabGradient6 = new TabGradient(); TabGradient tabGradient7 = new TabGradient(); _dockPanel.ActiveAutoHideContent = null; _dockPanel.AllowEndUserNestedDocking = true; _dockPanel.ActiveDocumentChanged += new System.EventHandler(MainForm_ActiveDocumentChanged); _dockPanel.Dock = DockStyle.Fill; _dockPanel.DockBackColor = SystemColors.AppWorkspace; _dockPanel.Location = new Point(0, 49); _dockPanel.Name = "dockPanel"; _dockPanel.Size = new Size(692, 395); dockPanelGradient1.EndColor = SystemColors.ControlLight; dockPanelGradient1.StartColor = SystemColors.ControlLight; autoHideStripSkin1.DockStripGradient = dockPanelGradient1; tabGradient1.EndColor = SystemColors.Control; tabGradient1.StartColor = SystemColors.Control; tabGradient1.TextColor = SystemColors.ControlDarkDark; autoHideStripSkin1.TabGradient = tabGradient1; dockPanelSkin1.AutoHideStripSkin = autoHideStripSkin1; tabGradient2.EndColor = SystemColors.ControlLightLight; tabGradient2.StartColor = SystemColors.ControlLightLight; tabGradient2.TextColor = SystemColors.ControlText; dockPaneStripGradient1.ActiveTabGradient = tabGradient2; dockPanelGradient2.EndColor = SystemColors.Control; dockPanelGradient2.StartColor = SystemColors.Control; dockPaneStripGradient1.DockStripGradient = dockPanelGradient2; tabGradient3.EndColor = SystemColors.ControlLight; tabGradient3.StartColor = SystemColors.ControlLight; tabGradient3.TextColor = SystemColors.ControlText; dockPaneStripGradient1.InactiveTabGradient = tabGradient3; dockPaneStripSkin1.DocumentGradient = dockPaneStripGradient1; tabGradient4.EndColor = SystemColors.ActiveCaption; tabGradient4.LinearGradientMode = LinearGradientMode.Vertical; tabGradient4.StartColor = SystemColors.GradientActiveCaption; tabGradient4.TextColor = SystemColors.ActiveCaptionText; dockPaneStripToolWindowGradient1.ActiveCaptionGradient = tabGradient4; tabGradient5.EndColor = SystemColors.Control; tabGradient5.StartColor = SystemColors.Control; tabGradient5.TextColor = SystemColors.ControlText; dockPaneStripToolWindowGradient1.ActiveTabGradient = tabGradient5; dockPanelGradient3.EndColor = SystemColors.ControlLight; dockPanelGradient3.StartColor = SystemColors.ControlLight; dockPaneStripToolWindowGradient1.DockStripGradient = dockPanelGradient3; tabGradient6.EndColor = SystemColors.GradientInactiveCaption; tabGradient6.LinearGradientMode = LinearGradientMode.Vertical; tabGradient6.StartColor = SystemColors.GradientInactiveCaption; tabGradient6.TextColor = SystemColors.ControlText; dockPaneStripToolWindowGradient1.InactiveCaptionGradient = tabGradient6; tabGradient7.EndColor = Color.Transparent; tabGradient7.StartColor = Color.Transparent; tabGradient7.TextColor = SystemColors.ControlDarkDark; dockPaneStripToolWindowGradient1.InactiveTabGradient = tabGradient7; dockPaneStripSkin1.ToolWindowGradient = dockPaneStripToolWindowGradient1; dockPanelSkin1.DockPaneStripSkin = dockPaneStripSkin1; _dockPanel.Skin = dockPanelSkin1; _dockPanel.TabIndex = 3; #endregion #region Status Bar _mainStatusStrip.Location = new Point(0, 444); _mainStatusStrip.Name = "mainStatusStrip"; _mainStatusStrip.Size = new Size(692, 22); _mainStatusStrip.TabIndex = 1; _mainStatusStrip.Text = "statusStrip1"; _mainStatusStrip.Items.AddRange(new ToolStripItem[] { _mainStatusStripMessage }); _mainStatusStripMessage.Name = "mainStatusBarMessage"; _mainStatusStripMessage.Size = new Size(0, 17); #endregion /* * MainForm */ AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(692, 466); IsMdiContainer = true; MainMenuStrip = _mainMenuStrip; Name = "MainForm"; Text = "MainForm"; FormClosing += new FormClosingEventHandler(MainForm_FormClosing); AllowDrop = true; if (!_applicationManager.ClientProfile.HaveFlag( ClientFlags.CoreDisableDragAndDropFileOpen)) { DragEnter += new DragEventHandler(MainForm_DragEnter); DragDrop += new DragEventHandler(MainForm_DragDrop); } // Order is important here Controls.Add(_dockPanel); Controls.Add(_mainStatusStrip); Controls.Add(_mainToolStripPanel); Controls.Add(_mainMenuStrip); _mainStatusStrip.ResumeLayout(false); _mainStatusStrip.PerformLayout(); _dockPanel.ResumeLayout(false); _dockPanel.PerformLayout(); _mainToolStripPanel.ResumeLayout(false); _mainToolStripPanel.PerformLayout(); _mainMenuStrip.ResumeLayout(false); _mainMenuStrip.PerformLayout(); ResumeLayout(false); PerformLayout(); }