private void LoadSingleToolStrip() { /* * Update the toolbar menu for single-item operation. */ UI_VIEW_MENU.DropDownOpening += new EventHandler(UI_VIEW_MENU_DropDownOpeningSingle); UI_VIEW_MENU_TOOLBAR.Text = Resources.MainViewMenuToolbarSingle; UI_VIEW_MENU_TOOLBAR.Click += new EventHandler(UI_VIEW_MENU_TOOLBAR_ITEM_Click); UI_VIEW_MENU_TOOLBAR.Tag = Constants.MAIN_TOOLBAR_NAME; /* * Add the main toolbar to the panel. */ DockedToolStrip dockedToolStrip = _dockedToolStrips[Constants.MAIN_TOOLBAR_NAME]; // Make it full width. dockedToolStrip.ToolStrip.Stretch = true; _mainToolStripPanel.Join(dockedToolStrip.ToolStrip); }
public void AddToolStrip() { // add debug toolbar right to the main toolbar ToolStripPanel tsp = PluginBase.MainForm.ToolStripPanel; if (tsp.Rows.Length > 1) { int idx = tsp.Rows.Length - 1; Control[] row = tsp.Rows[idx].Controls; foreach (Control c in row) { tsp.Controls.Remove(c); } tsp.Join(m_DebuggerToolStrip, idx); for (int i = row.Length - 1; i >= 0; i--) { tsp.Join(row[0] as ToolStrip, idx); } } else { tsp.Join(m_DebuggerToolStrip); } }
/// <summary> /// Loads the toolstrips in the order, that was saved on the last exit. /// </summary> public void LoadToolstrips() { _toolstripsLoaded = false; _tsPanel.Controls.Clear(); foreach (var i in _stripPosList.OrderBy(tsp => tsp.Row).ThenByDescending(tsp => tsp.Column)) { // add toolstrips after saved order var ts = _strips.Find(_ => _.Name == i.Name); if (ts != null) { _tsPanel.Join(ts, i.Row); } } _toolstripsLoaded = true; // all toolstrips in _StripPosList are added, any missing strips can now be added var index = Math.Max(1, _tsPanel.Rows.Length - 1); // add toolstrips that were added after saving (e.g. Plugins dropped into Plugin-folder) foreach (var strip in Enumerable.Reverse(_strips)) { // Reverse order because join adds at the beginning of the ToolStripPanelRow if (!_stripPosList.Exists(_ => _.Name == strip.Name)) { _tsPanel.Join(strip, index); } } }
/// <summary> /// This prevents odd positioning issues due to toolbar load order. /// Since all toolbars start in this temp panel, no toolbar load /// can be blocked by pre-existing toolbars. /// </summary> private void ResetAllToolbarLocations() { var tempToolStrip = new ToolStripPanel(); tempToolStrip.Join(_mainMenu); tempToolStrip.Join(_quickConnectToolStrip); tempToolStrip.Join(_externalToolsToolStrip); tempToolStrip.Join(_multiSshToolStrip); }
private void InitializeBottomToolStripPanel() { bottomToolStrip = new ToolStripPanel() { Parent = this, Dock = DockStyle.Bottom, }; statusStrip = new StatusStrip() { Parent = bottomToolStrip, Dock = DockStyle.Bottom, SizingGrip = true, GripStyle = ToolStripGripStyle.Visible, }; bottomToolStrip.Join(statusStrip); statusLabel = new ToolStripStatusLabel() { Text = "Ready", Spring = true, TextAlign = ContentAlignment.MiddleLeft, }; statusStrip.Items.Add(statusLabel); }
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(); } }
/// <summary> /// 创建所有工具栏(这儿不创建每一项,每一项在MenuStripManager中创建) /// </summary> static void CreateAllToolbar() { XmlDocument doc = new XmlDocument(); doc.Load(PathService.CL_ToolbarList); //由于显示的顺序是后添加的显示在上面,所以用一个Stack存储起来再添加 Stack <string> tempStack = new Stack <string>(); foreach (XmlNode node in doc.DocumentElement.ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } MyToolStrip tempToolStrip = new MyToolStrip(node.Attributes["text"].Value, (WorkspaceType)Enum.Parse(typeof(WorkspaceType), node.Attributes["defaultWorkspace"].Value)); tempToolStrip.ImageList = ResourceService.MainImageList; tempToolStrip.ImageScalingSize = new System.Drawing.Size(16, 16); _toolStripList.Add(node.Name, tempToolStrip); tempStack.Push(node.Name); } //添加进Panel中去 foreach (string name in tempStack) { _toolStripPanel.Join(_toolStripList[name]); } }
public void RegisterToolbar(string toolBarName, ToolStrip toolBar) { if (_toolBars.ContainsKey(toolBarName)) { throw new ArgumentException("Toolbar is already registered"); } if (OnToolbarRegistered != null) { OnToolbarRegistered(this, new ToolbarEventArgs(toolBarName)); } _toolBars.Add(toolBarName, toolBar); _panel.Join(toolBar, 1); bool showToolbar; try { showToolbar = ((bool)Settings.Default[toolBarName.Replace(" ", string.Empty)]); } catch (Exception) { showToolbar = false; } if (showToolbar) { ShowToolBar(toolBarName); } else { HideToolBar(toolBarName); } }
private void OnToolStripSettingsPropertyChanged(object sender, PropertyChangedEventArgs e) { ToolStripSettings settings = ToolStripSettings.Default; if (e.PropertyName == "WrapLongToolstrips" || e.PropertyName == "ToolStripDock") { // handle both wrapping and docking together because both affect flow direction bool verticalOrientation = ReferenceEquals(_toolbar.Parent, _toolStripContainer.LeftToolStripPanel) || ReferenceEquals(_toolbar.Parent, _toolStripContainer.RightToolStripPanel); _toolbar.SuspendLayout(); _toolbar.LayoutStyle = settings.WrapLongToolstrips ? ToolStripLayoutStyle.Flow : ToolStripLayoutStyle.StackWithOverflow; if (settings.WrapLongToolstrips) { ((FlowLayoutSettings)_toolbar.LayoutSettings).FlowDirection = verticalOrientation ? FlowDirection.TopDown : FlowDirection.LeftToRight; } _toolbar.ResumeLayout(true); ToolStripPanel targetParent = ConvertToToolStripPanel(_toolStripContainer, settings.ToolStripDock); if (targetParent != null && !ReferenceEquals(targetParent, _toolbar.Parent)) { _toolStripContainer.SuspendLayout(); targetParent.Join(_toolbar); _toolStripContainer.ResumeLayout(true); } } else if (e.PropertyName == "IconSize") { ToolStripBuilder.ChangeIconSize(_toolbar, settings.IconSize); } }
void SetupToolbars() { MenuItem mmitem = m_menuItems.GetItem("New"); mmitem.Text = "&New"; mmitem.Image = MenuImages16x16.Image(MenuImages16x16.eIndexes.NewDocument); mmitem.Click += new EventHandler(OnFileNew); mmitem.ToolTipText = "New document"; mmitem = m_menuItems.GetItem("Open"); mmitem.Text = "&Open"; mmitem.Image = MenuImages16x16.Image(MenuImages16x16.eIndexes.OpenDocument); mmitem.Click += new EventHandler(OnFileOpen); mmitem.ToolTipText = "Open document"; mmitem = m_menuItems.GetItem("Save"); mmitem.Text = "&Save"; mmitem.Image = MenuImages16x16.Image(MenuImages16x16.eIndexes.SaveDocument); mmitem.Click += new EventHandler(OnFileSave); mmitem.ToolTipText = "Save document"; mmitem = m_menuItems.GetItem("SaveAs"); mmitem.Text = "Save &As"; mmitem.Click += new EventHandler(OnFileSaveAs); mmitem = m_menuItems.GetItem("Exit"); mmitem.Text = "E&xit"; mmitem.Click += new EventHandler(OnFileExit); ToolStrip strip = m_menuItems.GetStrip("file"); strip.Items.Add(m_menuItems.GetItem("New").CreateButton()); strip.Items.Add(m_menuItems.GetItem("Open").CreateButton()); strip.Items.Add(m_menuItems.GetItem("Save").CreateButton()); ToolStripMenuItem menuitem = m_menuItems.GetMenuStrip("file"); menuitem.Text = "&File"; menuitem.DropDownItems.Add(m_menuItems.GetItem("New").CreateMenuItem()); menuitem.DropDownItems.Add(m_menuItems.GetItem("Open").CreateMenuItem()); menuitem.DropDownItems.Add(m_menuItems.GetItem("Save").CreateMenuItem()); menuitem.DropDownItems.Add(m_menuItems.GetItem("SaveAs").CreateMenuItem()); menuitem.DropDownItems.Add(new ToolStripSeparator()); menuitem.DropDownItems.Add(m_menuItems.GetItem("Exit").CreateMenuItem()); m_mainMenu.Items.Insert(0, menuitem); ToolStripPanel panel = m_menuItems.GetStripPanel(DockStyle.Top); panel.Join(m_menuItems.GetStrip("layer")); panel.Join(m_menuItems.GetStrip("draw")); panel.Join(m_menuItems.GetStrip("edit")); panel.Join(m_menuItems.GetStrip("file")); panel.Join(m_mainMenu); panel = m_menuItems.GetStripPanel(DockStyle.Left); panel.Join(m_menuItems.GetStrip("modify")); panel = m_menuItems.GetStripPanel(DockStyle.Bottom); panel.Join(m_menuItems.GetStatusStrip("status")); }
private void AppendToolStrips(int row, IList <ToolStrip> toolStrips) { ToolStripPanel panel = toolStripContainer1.TopToolStripPanel; for (int i = toolStrips.Count; --i >= 0;) { panel.Join(toolStrips[i], row); } }
// Append toolstrips to the ToolStrip Panel private void AppendToolStrips(int row, IList <ToolStrip> toolStrips) { ToolStripPanel topToolStripPanel = toolStripContainer.TopToolStripPanel; int num = toolStrips.Count; while (--num >= 0) { topToolStripPanel.Join(toolStrips[num], row); } }
public void RegisterMenu(string menuName, MenuStrip menu) { if (_menus.ContainsKey(menuName)) { throw new ArgumentException("Menu is already registered"); } _menus.Add(menuName, menu); _panel.Join(menu, 0); }
void UpdateToolStripLayout(ToolStrip toolStrip, bool visible) { ToolStripPanel panel = (ToolStripPanel)toolStrip.Parent; if (!visible && panel != null) { // Hide toolStrip.Parent.Controls.Remove(toolStrip); } else { if (visible && panel == null) { panel = toolStripContainer1.TopToolStripPanel; // Show bool done = false; int width = toolStrip.Width; for (int i = 0; i < toolStripContainer1.TopToolStripPanel.Rows.Length; i++) { ToolStripPanelRow row = toolStripContainer1.TopToolStripPanel.Rows[i]; int leftPos = 0; foreach (Control c in row.Controls) { leftPos = Math.Max(leftPos, c.Right + 1); } if (row.Bounds.Width >= leftPos + width) { panel.Join(toolStrip, leftPos, row.Bounds.Top); System.Diagnostics.Debug.WriteLine(toolStrip.Name + " Join " + leftPos.ToString() + "," + row.Bounds.Top.ToString()); done = true; } } if (!done) { panel.Join(toolStrip, panel.Rows.Length); toolStrip.Left = 0; } } } }
/// <summary> /// 设置菜单、工具条、状态条 /// </summary> private void SetupToolStripUI() { // 主菜单 MenuStrip menuMain = SetupMainMenu(); this.MainMenuStrip = menuMain; // 工具条 List <ToolStrip> toolStripList = SetupToolbar(); // Top Panel ToolStripPanel topPanel = _toolStripMgr.GetToolStripPanle(DockStyle.Top, true); this.Controls.Add(topPanel); // 将主菜单和工具条添加到 Top Panel for (int i = toolStripList.Count - 1; i >= 0; --i) { topPanel.Join(toolStripList[i]); } topPanel.Join(menuMain); }
private void toolBars_InsertedItem(object sender, CollectionChangedEventArgs e) { var toolstrip = e.TargetObject as ToolStrip; var lastRow = ToolStripPanel.Rows[ToolStripPanel.Rows.Length - 1]; Point nextControlLocation = lastRow.DisplayRectangle.Location; foreach (var toolbar in lastRow.Controls) { nextControlLocation.Offset(toolbar.Margin.Horizontal + toolbar.Padding.Horizontal + toolbar.Width, toolbar.Margin.Top); } ToolStripPanel.Join(toolstrip, nextControlLocation); }
private void JoinPanelOnLastPosition(ToolStrip strip, ToolStripSetting setting) { ToolStripPanel toolStripPanel = GetToolStripPanelToJoin(setting); if (!toolStripPanel.Controls.Contains(strip)) { Point lastPosition = new Point(setting.Left, setting.Top); toolStripPanel.Join(strip, lastPosition); } else // set position only when comming from fullscreen { ApplyLastPosition(setting, strip); } }
private void Frm_Main_Load(object sender, EventArgs e) { ToolStripPanel tsp_Top = new ToolStripPanel(); //创建ToolStripPanel对象 ToolStripPanel tsp_Bottom = new ToolStripPanel(); //创建ToolStripPanel对象 ToolStripPanel tsp_Left = new ToolStripPanel(); //创建ToolStripPanel对象 ToolStripPanel tsp_right = new ToolStripPanel(); //创建ToolStripPanel对象 tsp_Top.Dock = DockStyle.Top; //设置停靠方式 tsp_Bottom.Dock = DockStyle.Bottom; //设置停靠方式 tsp_Left.Dock = DockStyle.Left; //设置停靠方式 tsp_right.Dock = DockStyle.Right; //设置停靠方式 Controls.Add(tsp_Top); //添加到控件集合 Controls.Add(tsp_Bottom); //添加到控件集合 Controls.Add(tsp_Left); //添加到控件集合 Controls.Add(tsp_right); //添加到控件集合 tsp_Bottom.Join(toolStrip1); //将指定的工具栏添加到面板 }
private void Frm_Main_Load(object sender, EventArgs e) { ToolStripPanel tsp_Top = new ToolStripPanel(); //建立ToolStripPanel物件 ToolStripPanel tsp_Bottom = new ToolStripPanel(); //建立ToolStripPanel物件 ToolStripPanel tsp_Left = new ToolStripPanel(); //建立ToolStripPanel物件 ToolStripPanel tsp_right = new ToolStripPanel(); //建立ToolStripPanel物件 tsp_Top.Dock = DockStyle.Top; //設定停靠方式 tsp_Bottom.Dock = DockStyle.Bottom; //設定停靠方式 tsp_Left.Dock = DockStyle.Left; //設定停靠方式 tsp_right.Dock = DockStyle.Right; //設定停靠方式 Controls.Add(tsp_Top); //新增到控制元件集合 Controls.Add(tsp_Bottom); //新增到控制元件集合 Controls.Add(tsp_Left); //新增到控制元件集合 Controls.Add(tsp_right); //新增到控制元件集合 tsp_Bottom.Join(toolStrip1); //將指定的工具欄新增到面板 }
private static void ReadPanel(XmlNode panelNode, ToolStripPanel toolStripPanel, ICollection <ToolStrip> toolStrips) { if (toolStripPanel == null) { return; } var stripNodes = panelNode.SelectNodes("Strip"); if (stripNodes == null) { return; } foreach (XmlNode node in stripNodes) { ToolStrip item = null; foreach (var strip2 in toolStrips) { strip2.ImageScalingSize = new Size(IconSize, IconSize); ResizeChildren(strip2.Items); if (node.Attributes == null || strip2.Name != node.Attributes["name"].Value) { continue; } item = strip2; break; } if (item == null) { continue; } toolStrips.Remove(item); var strArray = node.Attributes["location"].Value.Split(','); toolStripPanel.Join(item, int.Parse(strArray[0]), int.Parse(strArray[1])); item.Visible = bool.Parse(node.Attributes["visible"].Value); item.GripStyle = Locked ? ToolStripGripStyle.Hidden : ToolStripGripStyle.Visible; } }
void SortItems(ToolStripPanel panel) { if (panel == null) { throw new ArgumentNullException("panel"); } ArrayList list = new ArrayList(); foreach (object o in panel.Controls) { list.Add(o); } list.Sort(new ToolStripBarCustomIComparer()); panel.Controls.Clear(); foreach (object o in list) { panel.Join(o as System.Windows.Forms.ToolStrip); } }
//位置指定はフォームの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(); }
private void CreateToolbars(WidgetConfiguration pageConfiguration) { foreach (ToolbarAreaConfiguration areaConfiguration in pageConfiguration.ToolbarAreas.Values) { ToolStripPanel area = GetToolStripPanel(areaConfiguration.Name); for (int row = 0; row < areaConfiguration.RowConfigurations.Length; row++) { for (int position = areaConfiguration.RowConfigurations[row].ToolbarConfigurations.Length - 1; position >= 0; position--) { ToolStrip strip = GetToolbarWidget(areaConfiguration .RowConfigurations[row] .ToolbarConfigurations[position] .ToolbarTypeId); //@todo Not implemented in Mono (find alternative?). They are just added. area.Join(strip, row); if (area.Orientation == Orientation.Horizontal) { strip.Left = areaConfiguration .RowConfigurations[row] .ToolbarConfigurations[position] .Offset; } else { strip.Top = areaConfiguration .RowConfigurations[row] .ToolbarConfigurations[position] .Offset; } area.PerformLayout(); } } } }
/// <summary> /// 安装工具栏(上/左/下) /// </summary> void SetupToolbars() { #region "文件"下拉菜单项通过MenuItemManager初始化 MenuItem mmitem = m_menuItems.GetItem("New"); //mmitem.Text = "&New"; mmitem.Text = "&新建"; mmitem.Image = MenuImages16x16.Image(MenuImages16x16.eIndexes.NewDocument); mmitem.Click += new EventHandler(OnFileNew); mmitem.ToolTipText = "New document"; mmitem = m_menuItems.GetItem("Open"); //mmitem.Text = "&Open"; mmitem.Text = "&打开"; mmitem.Image = MenuImages16x16.Image(MenuImages16x16.eIndexes.OpenDocument); mmitem.Click += new EventHandler(OnFileOpen); mmitem.ToolTipText = "Open document"; mmitem = m_menuItems.GetItem("Save"); //mmitem.Text = "&Save"; mmitem.Text = "&保存"; mmitem.Image = MenuImages16x16.Image(MenuImages16x16.eIndexes.SaveDocument); mmitem.Click += new EventHandler(OnFileSave); mmitem.ToolTipText = "Save document"; mmitem = m_menuItems.GetItem("SaveAs"); //mmitem.Text = "Save &As"; mmitem.Text = "另存为"; mmitem.Click += new EventHandler(OnFileSaveAs); mmitem = m_menuItems.GetItem("Exit"); //mmitem.Text = "E&xit"; mmitem.Text = "退出"; mmitem.Click += new EventHandler(OnFileExit); #endregion #region "文件"图片列工具栏构造 ToolStrip strip = m_menuItems.GetStrip("file"); strip.Items.Add(m_menuItems.GetItem("New").CreateButton()); strip.Items.Add(m_menuItems.GetItem("Open").CreateButton()); strip.Items.Add(m_menuItems.GetItem("Save").CreateButton()); #endregion #region "文件"下拉菜单栏添加控件 ToolStripMenuItem menuitem = m_menuItems.GetMenuStrip("file"); menuitem.Text = "&File"; menuitem.Text = "文件"; menuitem.DropDownItems.Add(m_menuItems.GetItem("New").CreateMenuItem()); menuitem.DropDownItems.Add(m_menuItems.GetItem("Open").CreateMenuItem()); menuitem.DropDownItems.Add(m_menuItems.GetItem("Save").CreateMenuItem()); menuitem.DropDownItems.Add(m_menuItems.GetItem("SaveAs").CreateMenuItem()); menuitem.DropDownItems.Add(new ToolStripSeparator()); menuitem.DropDownItems.Add(m_menuItems.GetItem("Exit").CreateMenuItem()); m_mainMenu.Items.Insert(0, menuitem); #endregion #region 左下菜单栏/状态栏设置控件 ToolStripPanel panel = m_menuItems.GetStripPanel(DockStyle.Top); panel.Join(m_menuItems.GetStrip("layer")); panel.Join(m_menuItems.GetStrip("draw")); panel.Join(m_menuItems.GetStrip("edit")); panel.Join(m_menuItems.GetStrip("file")); panel.Join(m_mainMenu); //主菜单加入面板 panel = m_menuItems.GetStripPanel(DockStyle.Left); panel.Join(m_menuItems.GetStrip("modify")); //左侧修改栏 panel = m_menuItems.GetStripPanel(DockStyle.Bottom); panel.Join(m_menuItems.GetStatusStrip("status")); //底部状态栏 #endregion }
public Form1() { // Make the Form an MDI parent. this.IsMdiContainer = true; // <snippet11> // Create ToolStripPanel controls. ToolStripPanel tspTop = new ToolStripPanel(); ToolStripPanel tspBottom = new ToolStripPanel(); ToolStripPanel tspLeft = new ToolStripPanel(); ToolStripPanel tspRight = new ToolStripPanel(); // Dock the ToolStripPanel controls to the edges of the form. tspTop.Dock = DockStyle.Top; tspBottom.Dock = DockStyle.Bottom; tspLeft.Dock = DockStyle.Left; tspRight.Dock = DockStyle.Right; // Create ToolStrip controls to move among the // ToolStripPanel controls. // Create the "Top" ToolStrip control and add // to the corresponding ToolStripPanel. ToolStrip tsTop = new ToolStrip(); tsTop.Items.Add("Top"); tspTop.Join(tsTop); // Create the "Bottom" ToolStrip control and add // to the corresponding ToolStripPanel. ToolStrip tsBottom = new ToolStrip(); tsBottom.Items.Add("Bottom"); tspBottom.Join(tsBottom); // Create the "Right" ToolStrip control and add // to the corresponding ToolStripPanel. ToolStrip tsRight = new ToolStrip(); tsRight.Items.Add("Right"); tspRight.Join(tsRight); // Create the "Left" ToolStrip control and add // to the corresponding ToolStripPanel. ToolStrip tsLeft = new ToolStrip(); tsLeft.Items.Add("Left"); tspLeft.Join(tsLeft); // </snippet11> // <snippet12> // Create a MenuStrip control with a new window. MenuStrip ms = new MenuStrip(); ToolStripMenuItem windowMenu = new ToolStripMenuItem("Window"); ToolStripMenuItem windowNewMenu = new ToolStripMenuItem("New", null, new EventHandler(windowNewMenu_Click)); windowMenu.DropDownItems.Add(windowNewMenu); ((ToolStripDropDownMenu)(windowMenu.DropDown)).ShowImageMargin = false; ((ToolStripDropDownMenu)(windowMenu.DropDown)).ShowCheckMargin = true; // Assign the ToolStripMenuItem that displays // the list of child forms. ms.MdiWindowListItem = windowMenu; // Add the window ToolStripMenuItem to the MenuStrip. ms.Items.Add(windowMenu); // Dock the MenuStrip to the top of the form. ms.Dock = DockStyle.Top; // The Form.MainMenuStrip property determines the merge target. this.MainMenuStrip = ms; // </snippet12> // Add the ToolStripPanels to the form in reverse order. this.Controls.Add(tspRight); this.Controls.Add(tspLeft); this.Controls.Add(tspBottom); this.Controls.Add(tspTop); // Add the MenuStrip last. // This is important for correct placement in the z-order. this.Controls.Add(ms); }
public MainForm() { // // _rightPanel // _rightPanel = new ToolStripPanel (); _rightPanel.Dock = DockStyle.Right; Controls.Add (_rightPanel); // // _leftPanel // _leftPanel = new ToolStripPanel (); _leftPanel.Dock = DockStyle.Left; Controls.Add (_leftPanel); // // _bottomPanel // _bottomPanel = new ToolStripPanel (); _bottomPanel.Dock = DockStyle.Bottom; Controls.Add (_bottomPanel); // // _topPanel // _topPanel = new ToolStripPanel (); _topPanel.Dock = DockStyle.Top; Controls.Add (_topPanel); // // _topStrip // _topStrip = new ToolStrip (); _topStrip.Items.Add ("Top"); _topPanel.Join (_topStrip); // // _bottomStrip // _bottomStrip = new ToolStrip (); _bottomStrip.Items.Add ("Bottom"); _bottomPanel.Join (_bottomStrip); // // _leftStrip // _leftStrip = new ToolStrip (); _leftStrip.Items.Add ("Left"); _leftPanel.Join (_leftStrip); // // _leftStrip // _rightStrip = new ToolStrip(); _rightStrip.Items.Add ("Right"); _rightPanel.Join (_rightStrip); // // _menuStrip // _menuStrip = new MenuStrip (); _menuStrip.Dock = DockStyle.Top; Controls.Add (_menuStrip); // // _windowMenu // _windowMenu = new ToolStripMenuItem ("Window"); _menuStrip.MdiWindowListItem = _windowMenu; ((ToolStripDropDownMenu) (_windowMenu.DropDown)).ShowImageMargin = false; ((ToolStripDropDownMenu) (_windowMenu.DropDown)).ShowCheckMargin = true; _menuStrip.Items.Add (_windowMenu); // // _newWindowMenu // _newWindowMenu = new ToolStripMenuItem ("New", null, new EventHandler (NewWindowMenu_Click)); _windowMenu.DropDownItems.Add (_newWindowMenu); // // MainForm // ClientSize = new Size (300, 300); IsMdiContainer = true; Location = new Point (250, 100); MainMenuStrip = _menuStrip; StartPosition = FormStartPosition.Manual; Text = "bug #341998"; Load += new EventHandler (MainForm_Load); }
void Initialize() { ClientSize = new Size(800, 600); Text = AppName; AllowDrop = true; IsMdiContainer = true; DockArea = new DockPanel { Dock = DockStyle.Fill, Theme = new VS2010Theme(), DockLeftPortion = 0.35, DockBottomPortion = 0.3, DocumentStyle = DocumentStyle.DockingMdi, ShowDocumentIcon = true, AllowEndUserDocking = false, AllowEndUserNestedDocking = false }; Controls.Add(DockArea); Languages = new LanguageManager(); Analyzer = new Analyzer(this); Modules = new ModuleManager(this); Modules.SelectionChanged += OnNodeSelected; Modules.History.Navigated += (sender, e) => UpdateHistoryButtons(); Modules.Show(DockArea, DockState.Document); // Reduce flickering when first show document later Modules.Show(DockArea, DockState.DockLeft); toolStripPanel = new ToolStripPanel { Dock = DockStyle.Top }; Controls.Add(toolStripPanel); mainStrip = new ToolStrip(); toolStripPanel.Join(mainStrip); backBtn = new ToolStripButton(Resources.GetResource <Image>("Icons.back.png")) { ToolTipText = "Go Back", Enabled = false }; backBtn.Click += (sender, e) => Modules.History.GoBack(); mainStrip.Items.Add(backBtn); forwardBtn = new ToolStripButton(Resources.GetResource <Image>("Icons.forward.png")) { ToolTipText = "Go Forward", Enabled = false }; forwardBtn.Click += (sender, e) => Modules.History.GoForward(); mainStrip.Items.Add(forwardBtn); mainStrip.Items.Add(new ToolStripSeparator()); var langCombo = new ToolStripComboBox(); mainStrip.Items.Add(langCombo); langCombo.ComboBox.DataSource = Languages.Languages; Languages.PropertyChanged += (sender, e) => langCombo.ComboBox.SelectedItem = Languages.ActiveLanguage; Shown += (sender, e) => { langCombo.ComboBox.SelectedItem = Languages.ActiveLanguage; langCombo.ComboBox.SelectedValueChanged += (s, ee) => Languages.ActiveLanguage = (ILanguage)langCombo.ComboBox.SelectedItem; }; langCombo.ComboBox.DisplayMember = "Name"; langCombo.ComboBox.DropDownStyle = ComboBoxStyle.DropDownList; PerformLayout(); }
private void InitializeTopToolStripPanel() { topToolStrip = new ToolStripPanel() { Parent = this, Dock = DockStyle.Top, }; mainMenu = new MenuStrip() { Parent = topToolStrip, Dock = DockStyle.Top, }; topToolStrip.Join(mainMenu); MainMenuStrip = mainMenu; fileMenuItem = new ToolStripMenuItem() { Name = "File", Text = "&File", }; fileMenuItem.DropDownOpening += FileMenuItem_DropDownOpening; mainMenu.Items.Add(fileMenuItem); openKubeConfigMenuItem = new ToolStripMenuItem() { Name = "OpenKubeConfig", Text = "&Open KubeConfig File...", }; openKubeConfigMenuItem.Click += OpenKubeConfigMenuItem_Click; fileMenuItem.DropDownItems.Add(openKubeConfigMenuItem); closeKubeConfigMenuItem = new ToolStripMenuItem() { Name = "CloseCurrentKubeConfig", Text = "&Close Current KubeConfig", }; closeKubeConfigMenuItem.Click += CloseKubeConfigMenuItem_Click; fileMenuItem.DropDownItems.Add(closeKubeConfigMenuItem); fileMenuItem.DropDownItems.Add(new ToolStripSeparator()); exitAppMenuItem = new ToolStripMenuItem() { Name = "ExitApp", Text = "E&xit App", }; exitAppMenuItem.Click += ExitAppMenuItem_Click; fileMenuItem.DropDownItems.Add(exitAppMenuItem); windowMenuItem = new ToolStripMenuItem() { Name = "Window", Text = "&Window", }; mainMenu.Items.Add(windowMenuItem); mainMenu.MdiWindowListItem = windowMenuItem; helpMenuItem = new ToolStripMenuItem() { Name = "Help", Text = "&Help", }; mainMenu.Items.Add(helpMenuItem); aboutMenuItem = new ToolStripMenuItem() { Name = "About", Text = "&About...", }; aboutMenuItem.Click += AboutMenuItem_Click; helpMenuItem.DropDownItems.Add(aboutMenuItem); kubeConfigOpenFileDialog = new OpenFileDialog() { DefaultExt = ".kubeconfig", Title = "Open KubeConfig File", Filter = "All Supported File Types|*.kubeconfig;*.yaml;*.yml|KubeConfig Files (*.kubeconfig)|*.kubeconfig|YAML File (*.yaml;*.yml)|*.yaml;*.yml|All Files|*.*", DereferenceLinks = true, Multiselect = true, AutoUpgradeEnabled = true, CheckFileExists = true, CheckPathExists = true, ReadOnlyChecked = true, SupportMultiDottedExtensions = true, ValidateNames = true, RestoreDirectory = true, }; kubeConfigOpenFileDialog.CustomPlaces.Add(new FileDialogCustomPlace( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".k8s"))); container.Add(kubeConfigOpenFileDialog); }
public Form1() { InitializeComponent(); panel.Parent = this; panel.AutoSize = true; panel.Dock = DockStyle.Fill; //MENUSTRIP MenuStrip menu = new MenuStrip(); menu.Parent = this; //TOOLSTRIPCONTROLHOST MyLabel label = new MyLabel("Ги-ги "); menu.Items.Add(new ToolStripControlHost(label)); //IMAGELIST ImageList list = new ImageList(); list.Images.Add("open", Image.FromFile("picture.bmp")); menu.ImageList = list; //TOOLSTRIPMENUITEM ToolStripMenuItem item = new ToolStripMenuItem("Image"); item.ImageKey = "open"; menu.Items.Add(item); //CONTEXTMENUSTRIP ContextMenuStrip conMenu = new ContextMenuStrip(); conMenu.Items.Add(new ToolStripMenuItem("Hello")); label.ContextMenuStrip = conMenu; //TOOLSTRIP ToolStrip tool = new ToolStrip(); tool.Items.Add(new ToolStripButton("Save")); tool.Items.Add(new ToolStripComboBox()); tool.Items.Add(new ToolStripSplitButton()); //TOOLSTRIPPANEL ToolStripPanel strPanel = new ToolStripPanel(); strPanel.Dock = DockStyle.Left; strPanel.Parent = panel; strPanel.Join(tool); //TOOLSTRIPCONTAINER //ToolStripContainer container = new ToolStripContainer(); //container.LeftToolStripPanel.Controls.Add(tool); //container.Parent = panel; //STATUSSTRIP StatusStrip status = new StatusStrip(); ToolStripStatusLabel lab = new ToolStripStatusLabel("Стоп"); status.Items.Add(lab); status.Items.Add(new ToolStripButton("Оновити")); status.Parent = this; }
/// <summary> /// 設定ファイルを読み込み、指定したコンテナの状態を復元します。 /// </summary> /// <param name="parentCtrl">Containerを子に持つ最上位の親コントロール、またはメインフォーム。</param> /// <param name="Container">状態を復元するコンテナ</param> /// <param name="fileName">設定ファイルの保存先ファイルパス</param> public static void Load(Control parentCtrl, ToolStripContainer Container, string fileName) { ToolStripdockContainerSetting dockContainerSetting = new ToolStripdockContainerSetting(fileName); dockContainerSetting.Load(); if (!dockContainerSetting.IsDeserialized) { return; } Dictionary <string, ToolStripPanel> allPanels = GetToolStripPanelDictionary(Container); Dictionary <string, ToolStrip> tsDic = new Dictionary <string, ToolStrip>(); Dictionary <ToolStrip, ToolStripPanel> remainds = new Dictionary <ToolStrip, ToolStripPanel>(); // 全パネル内のToolStripコントロールをすべて tsDic に入れ、一度コントロールコレクションをクリアする foreach (ToolStripPanel panel in allPanels.Values) { foreach (Control c in panel.Controls) { if (c is ToolStrip) { tsDic.Add(c.Name, (ToolStrip)c); remainds.Add((ToolStrip)c, panel); } } panel.Controls.Clear(); } // 保存されている順に再度パネルにToolStripを追加していく foreach (ToolStripPanelSetting panelSetting in dockContainerSetting.Panels) { if (!allPanels.ContainsKey(panelSetting.Alignment)) { continue; } ToolStripPanel panel = allPanels[panelSetting.Alignment]; foreach (ToolStripSetting setting in panelSetting.Rows) { ToolStrip item = null; if (tsDic.ContainsKey(setting.Name)) { item = tsDic[setting.Name]; } else if (parentCtrl != null) { // 現在のToolStripContainer内にコントロールが見つからない場合は親のコントロール内から探す foreach (Control c in parentCtrl.Controls.Find(setting.Name, true)) { if (c is ToolStrip) { item = (ToolStrip)c; break; } } } if (item != null) { panel.Join(item, setting.Location); remainds.Remove(item); } } } // どこにも追加されずに残ったToolStripをもともとあったパネルに追加する foreach (KeyValuePair <ToolStrip, ToolStripPanel> pair in remainds) { pair.Value.Join(pair.Key, Point.Empty); } }
public static void Load(IPluginHost host, ToolStripPanel panel, ToolStripMenuItem pluginMenu) { PluginHost = host; Program.LoadedPlugins.Clear( ); var asm = typeof(PluginLoader).Assembly; var plugins = Settings.Instance.PluginSettings.GetPlugins(host); var rows = panel.Rows.Length; foreach (IPlugin plugin in plugins) { var pluginInfo = Settings.Instance.PluginSettings.GetPluginInfo(plugin); if (pluginInfo.Enabled) { pluginInfo.LogDebug("Loading: {0}", pluginInfo.Name); Program.LoadedPlugins.Add(plugin); plugin.Initialize(host); if (!plugin.CreateToolButton) { continue; } var tsb = plugin.CreateToolStripButton( ); var tsm = plugin.CreateToolStripMenuItem( ); var group = plugin.Group.Or("[DEFAULT]"); var added = false; foreach (var c in panel.Controls) { if (c.Is <ToolStrip> ( ) && string.Compare(((ToolStrip)c).Name, group, true) == 0) { ((ToolStrip)c).Items.Add(tsb); added = true; break; } } if (!added) { // need to create the toolstrip and add the item var strip = new ToolStrip(tsb) { Name = group, }; panel.Join(strip, rows); } // menu items var parentMenu = default(ToolStripMenuItem); foreach (ToolStripMenuItem mi in pluginMenu.DropDownItems) { if (mi.Text == group) { parentMenu = (ToolStripMenuItem)mi; } } if (parentMenu == null) { parentMenu = new ToolStripMenuItem(group); pluginMenu.DropDownItems.Add(parentMenu); } parentMenu.DropDownItems.Add(tsm); if (pluginInfo.ExecuteOnLoad && pluginInfo.Enabled) { plugin.Execute(host); } } } }