/// <summary> /// Adds a customization drop down menu to the tool strip. Check if this drop down button /// is already present, in case the standard menus are setup twice (which happens in Legacy applications).</summary> private void AddCustomizationDropDown(ToolStrip toolStrip) { string customizeText = "Customize".Localize(); foreach (ToolStripItem item in toolStrip.Items) { if (item.Text == customizeText) { return; } } ToolStripDropDownButton button = new ToolStripDropDownButton(customizeText); button.Name = toolStrip.Name; button.Overflow = ToolStripItemOverflow.Always; button.DropDownOpening += button_DropDownOpening; toolStrip.Items.Add(button); }
private void tsddb_MouseHover(object sender, System.EventArgs e) { ToolStripDropDownButton tsddb = sender as ToolStripDropDownButton; foreach (ToolStripItem tsi in tsDest.Items) { if (tsi is ToolStripDropDownButton) { ToolStripDropDownButton tsddb2 = tsi as ToolStripDropDownButton; if (tsddb.Text != tsddb2.Text) { tsddb.DropDown.Close(); } } } tsddb.ShowDropDown(); tsddb.DropDown.AutoClose = false; }
/// <summary> /// Builds the drop down button. /// </summary> /// <param name = "name">The name.</param> /// <returns></returns> private static ToolStripDropDownButton BuildDropDownButton(string name) { ToolStripDropDownButton button = new ToolStripDropDownButton(name); string asyncText = CommonResources.TEXT_ASYNCHRONOUS; ToolStripItem async = new ToolStripMenuItem(asyncText); async.Tag = DropDownButtonClickedCommandFactory.GetCommand(name, asyncText); button.DropDownItems.Add(async); string syncText = CommonResources.TEXT_SYNCHRONOUS; ToolStripItem sync = new ToolStripMenuItem(syncText); sync.Tag = DropDownButtonClickedCommandFactory.GetCommand(name, syncText); button.DropDownItems.Add(sync); button.Name = name; return(button); }
internal static void RenameSession(Form1 form, String newName) { ToolStripButton sessionToolStripButton = form.sessionToolStripButton; ToolStripStatusLabel toolStripStatusLabel = form.toolStripStatusLabel; ToolStripDropDownButton sessionImageToolStripButton = form.sessionImageToolStripButton; try { if (!newName.EndsWith(".dps")) { newName += ".dps"; } String actualName = sessionImageToolStripButton.DropDownItems[0].Text; newName = Path.Combine(Path.GetDirectoryName(actualName), newName); //Rename session name XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(actualName); XmlNodeList nodeSession = xmldoc.GetElementsByTagName("session"); if (nodeSession.Count != 1) { throw new SessionException(String.Format(LanguageUtil.GetCurrentLanguageString("MoreSession", className), Path.GetFileNameWithoutExtension(actualName))); } XmlNode nodeFile = nodeSession[0]; nodeFile.Attributes["name"].Value = Path.GetFileNameWithoutExtension(newName); xmldoc.Save(actualName); //Rename file name File.Move(actualName, newName); //Rename form sessionToolStripButton.Text = Path.GetFileNameWithoutExtension(newName); sessionImageToolStripButton.DropDownItems[0].Text = newName; toolStripStatusLabel.Text = String.Format(LanguageUtil.GetCurrentLanguageString("Renamed", className), sessionToolStripButton.Text); } catch (Exception exception) { WindowManager.ShowErrorBox(form, exception.Message, exception); } }
private void GenerateToolStripCommands(ToolStripItemCollection items, bool onlyLabels = false) { foreach (object obj in items) { ToolStripDropDownButton subMenu = obj as ToolStripDropDownButton; if (subMenu != null && subMenu.HasDropDownItems) { GenerateToolStripCommands(subMenu.DropDownItems, onlyLabels); } else { var control = obj as ToolStripItem; if (!string.IsNullOrEmpty(control.Tag?.ToString())) { var command = CommandHandler.GetCommand(control.Tag.ToString()); if (command != null) { if (!onlyLabels) { control.Click += (sender, e) => { command.Execute?.Invoke(new CommandArgs { Editor = _editor, Window = this }); } } ; var hotkeyLabel = string.Join(", ", _editor.Configuration.UI_Hotkeys[control.Tag.ToString()]); var label = command.FriendlyName + (string.IsNullOrEmpty(hotkeyLabel) ? "" : " (" + hotkeyLabel + ")"); if (control is ToolStripMenuItem) { control.Text = label; } else { control.ToolTipText = label; } } } } } }
private void AddBtnsToMainMenu() { var statesBtn = new ToolStripDropDownButton("States", null, BuildDropDownItemsWithStates()) { Name = "States" }; var restartBtn = new ToolStripButton("Restart", null, (_, __) => RestartCurrentStateWithCurrentPathFinder()) { Name = "Restart" }; var speedUp = new ToolStripButton("+ Speed +", null, (_, __) => { timerInterval -= 100; }) { Name = "+ Speed +" }; var speedDown = new ToolStripButton("- Speed -", null, (_, __) => { timerInterval += 100; }) { Name = "- Speed -" }; pathFinderChangerBtn = new ToolStripButton("PathFinder", null, ChangePathFinderTypeAndRestart) { Name = "PathFinder" }; var prevBtn = new ToolStripButton("Previous state", null, SwitchToPreviousState) { Name = "Previous state" }; var nextBtn = new ToolStripButton("Next state", null, SwitchToNextState) { Name = "Next state" }; MainMenuStrip.Items.Add(statesBtn); MainMenuStrip.Items.Add(restartBtn); MainMenuStrip.Items.Add(speedUp); MainMenuStrip.Items.Add(speedDown); MainMenuStrip.Items.Add(pathFinderChangerBtn); MainMenuStrip.Items.Add(prevBtn); MainMenuStrip.Items.Add(nextBtn); }
public void toolStripCollectionTree_DropDownOpening(object sender, EventArgs e) { ToolStripItem menuItem = (ToolStripItem)sender; ToolStripDropDownButton parent = (ToolStripDropDownButton)sender; WorldObjectCollection collection = (WorldObjectCollection)menuItem.Tag; if (app.SelectedObject.Count >= 1 && app.SelectedObject.Count != 0) { foreach (WorldObjectCollection coll in collection.CollectionList) { if (app.SelectedObject[0] is WorldObjectCollection && ReferenceEquals(((IObjectChangeCollection)(app.SelectedObject[0])).Parent, coll) || ReferenceEquals(app.SelectedObject[0], coll)) { continue; } if (coll.CollectionList.Count != 0) { ToolStripDropDownButton but = new ToolStripDropDownButton(); but.Tag = coll; but.Text = coll.Name; but.DropDownOpening += new System.EventHandler(this.toolStripCollectionTree_DropDownOpening); but.MouseEnter += new System.EventHandler(this.toolStripButton_Enter); but.Click += new System.EventHandler(app.CollectionButton_clicked); but.DropDownClosed += new System.EventHandler(this.collectionDropDown_closed);; parent.DropDownItems.Add(but as ToolStripItem); } else { ToolStripButton but = new ToolStripButton(coll.Name); but.Tag = coll; but.Click += new System.EventHandler(app.CollectionButton_clicked); parent.DropDownItems.Add(but); } } } else { return; } }
public StatusReportView( Form appWindow, ToolStripItem toolStripStatusLabel, ToolStripDropDownButton cancelLongRunningProcessDropDownButton, ToolStripStatusLabel cancelLongRunningProcessLabel ) { this.appWindow = appWindow; this.toolStripStatusLabel = toolStripStatusLabel; this.cancelLongRunningProcessDropDownButton = cancelLongRunningProcessDropDownButton; this.cancelLongRunningProcessLabel = cancelLongRunningProcessLabel; this.cancelLongRunningProcessDropDownButton.Click += (s, e) => viewEvents.OnCancelLongRunningProcessButtonClicked(); this.infoPopup = new InfoPopupControl(); this.appWindow.Controls.Add(infoPopup); this.infoPopup.Location = new Point(appWindow.ClientSize.Width - infoPopup.Width, appWindow.ClientSize.Height - infoPopup.Height); this.infoPopup.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; this.infoPopup.BringToFront(); }
private void AddNodeButtonToCategoryMenu(MyNodeConfig nodeConfig) { ToolStripDropDownButton targetMenuButton = FindTargetMenuButton(CategorySortingHat.DetectCategoryName(nodeConfig)); // TODO: optimize with HashSet if (targetMenuButton == null) { return; } ToolStripItem newButton = new ToolStripMenuItem() { Text = MyProject.ShortenNodeTypeName(nodeConfig.NodeType), DisplayStyle = ToolStripItemDisplayStyle.ImageAndText }; ToolStripItemCollection targetItems = targetMenuButton.DropDownItems; InnerAddNodeButtonOrMenuItem(newButton, nodeConfig, targetItems, addSeparators: true); }
public static IEnumerable <object[]> ConnectedArea_Empty_TestData() { yield return(new object[] { null }); yield return(new object[] { new ToolStrip() }); yield return(new object[] { new ToolStripDropDown() }); yield return(new object[] { new ToolStripOverflow(new ToolStripButton()) }); yield return(new object[] { new ToolStripOverflow(new ToolStripDropDownButton()) }); var ownedDropDownItem = new ToolStripDropDownButton(); var owner = new ToolStrip(); owner.Items.Add(ownedDropDownItem); yield return(new object[] { new ToolStripOverflow(ownedDropDownItem) }); yield return(new object[] { new ToolStripOverflow(owner.OverflowButton) }); }
public FilterRevisionsHelper(ToolStripTextBox toolStripTextBoxFilter, ToolStripDropDownButton toolStripDropDownButton1, RevisionGrid RevisionGrid, ToolStripLabel toolStripLabel2, Form form) : this() { this._NO_TRANSLATE_toolStripDropDownButton1 = toolStripDropDownButton1; this._NO_TRANSLATE_toolStripTextBoxFilter = toolStripTextBoxFilter; this._NO_TRANSLATE_RevisionGrid = RevisionGrid; this._NO_TRANSLATE_toolStripLabel2 = toolStripLabel2; this._NO_TRANSLATE_form = form; this._NO_TRANSLATE_toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { this.commitToolStripMenuItem1, this.committerToolStripMenuItem, this.authorToolStripMenuItem, this.diffContainsToolStripMenuItem }); this._NO_TRANSLATE_toolStripLabel2.Click += this.ToolStripLabel2Click; this._NO_TRANSLATE_toolStripTextBoxFilter.Leave += this.ToolStripTextBoxFilterLeave; this._NO_TRANSLATE_toolStripTextBoxFilter.KeyPress += this.ToolStripTextBoxFilterKeyPress; }
public View() { InitializeComponent(); defaultForeColor = statusStrip1.ForeColor; foreach (ToolStripItem tsi in toolStrip1.Items) { if (tsi is ToolStripDropDownButton) { ToolStripDropDownButton tsd = (ToolStripDropDownButton)tsi; ((ToolStripDropDownMenu)tsd.DropDown).ShowImageMargin = false; ((ToolStripDropDownMenu)tsd.DropDown).ShowCheckMargin = false; } } EnableCancelBuild(false, false); toolStripStatusLabel1.Text = "Ready"; }
void ElementClickedEH(object sender, EventArgs e) { ContextMenuStrip popup = new ContextMenuStrip(); popup.AutoSize = true; ToolStripDropDownButton changeTo = new ToolStripDropDownButton("Change to..."); AdjustDropDownSize(popup, changeTo); changeTo.DropDown = new ToolStripDropDown(); changeTo.DropDown.Items.Add("Empty element", null, new EventHandler(ChangeToEmptyEH)); changeTo.DropDown.Items.Add("Letter", null, new EventHandler(ChangeToLetterEH)); popup.Items.Add(changeTo); popup.Items.Add("Assign definition", null, new EventHandler(AssignDefinitionEH)); AddPossibleWords(popup); popup.Opacity = 0.5; popup.PerformLayout(); popup.Show(_wControl, new Point(_wControl.Width, _wControl.Height)); popup.Update(); }
private void preberiDatoteko() { String vrstica; // Read the file as one string. if (File.Exists(System.Environment.CurrentDirectory + "\\kamere.txt")) { kamere = new List <String>(); StreamReader myFile = new StreamReader(System.Environment.CurrentDirectory + "\\kamere.txt"); while ((vrstica = myFile.ReadLine()) != null) { //zapis v list kamere.Add(vrstica); //doda v meni ToolStripDropDownButton btTemp = new ToolStripDropDownButton(vrstica, null, kameraOnClick, vrstica); kamereToolStripMenuItem.DropDownItems.Add(btTemp); } myFile.Close(); } }
private void ReadAllDrives(ToolStripDropDownButton btn) { btn.DropDownItems.Clear(); foreach (var driveInfo in DriveInfo.GetDrives()) { var newBtn = new ToolStripMenuItem(); if (driveInfo.IsReady) { newBtn.Text = driveInfo.Name + " [" + driveInfo.VolumeLabel + "]"; newBtn.ToolTipText = driveInfo.Name; newBtn.Image = Properties.Resources.Drive; newBtn.Tag = btn.Name == "tsddbtn1" ? 1 : 2; newBtn.Click += newBtn_Click; btn.DropDownItems.Add(newBtn); } } }
void SetupContextMenu() { closePanels = new ToolStripDropDownButton("Close"); thisContextMenu = new ContextMenuStrip(); thisContextMenu.Items.Add(closePanels); MyToolStripButton tempButton; int index = 0; foreach (MyPanel p in PanelsToDisplay) { tempButton = new MyToolStripButton(index++); tempButton.Text = p.Name; tempButton.ButtonClicked += tempButton_CustomCheckedChanged; closePanels.DropDownItems.Add(tempButton); } this.ContextMenuStrip = thisContextMenu; ContextMenuStrip.Width = 100; }
private void LoadActions() { ToolStripMenuItem menuRun = (ToolStripMenuItem)_grid.ContextMenuStrip.Items["EditRun"]; ToolStripDropDownButton tsbRun = (ToolStripDropDownButton)GetControl <ToolStrip>("Toolbar").Items["Run"]; List <ToolStripMenuItem> items = new List <ToolStripMenuItem>(); List <ToolStripMenuItem> buttons = new List <ToolStripMenuItem>(); JMXSchema schema = _grid.Schema; foreach (var att in schema.Attributes) { if (att.DataType == MdbType.@object) { JMXSchema rs = ClientGate.GetObjectSchema(att.ObjectName); if (rs.DbObjectType == DbObjectTypes.Action) { items.Add(new ToolStripMenuItem(att.Name, null, MenuRun_Click) { Name = att.AttribName, ToolTipText = att.Description }); buttons.Add(new ToolStripMenuItem(att.Name, null, MenuRun_Click) { Name = att.AttribName, ToolTipText = att.Description }); } } } if (items.Count > 0) { if (menuRun.DropDownItems.ContainsKey("Blank")) { menuRun.DropDownItems.Remove(menuRun.DropDownItems["Blank"]); } menuRun.DropDownItems.AddRange(items.ToArray()); menuRun.DropDownItems.Add(new ToolStripSeparator()); tsbRun.DropDown.Items.AddRange(buttons.ToArray()); } if ((menuRun.DropDownItems[menuRun.DropDownItems.Count - 1] is ToolStripSeparator)) { menuRun.DropDownItems.Remove(menuRun.DropDownItems[menuRun.DropDownItems.Count - 1]); } }
public menu_strip(Form frm) { ToolStripDropDownButton file = new ToolStripDropDownButton("Файл"); ToolStripMenuItem fileopen = new ToolStripMenuItem("Открыть файл"); fileopen.Click += Fileopen_Click; file.DropDownItems.Add(fileopen); ToolStripDropDownButton order = new ToolStripDropDownButton("Наряды"); ToolStripMenuItem accept_order = new ToolStripMenuItem("Принять наряды"); order.DropDownItems.Add(accept_order); accept_order.Click += Accept_order_Click; ToolStripDropDownButton stuff = new ToolStripDropDownButton("Сотрудники"); ToolStripMenuItem stuff_in = new ToolStripMenuItem("Принять сотрудника"); ToolStripMenuItem stuff_out = new ToolStripMenuItem("Уволить сотрудника"); stuff.DropDownItems.Add(stuff_in); stuff.DropDownItems.Add(stuff_out); stuff_in.Click += Stuff_in_Click; stuff_out.Click += Stuff_out_Click; ToolStripDropDownButton report = new ToolStripDropDownButton("Отчеты"); ToolStripMenuItem report_svod = new ToolStripMenuItem("Сводный отчет по площадке"); ToolStripMenuItem report_stuff = new ToolStripMenuItem("Сводный отчет по сотруднику"); report.DropDownItems.Add(report_svod); report.DropDownItems.Add(report_stuff); report_svod.Click += Report_svod_Click; report_stuff.Click += Report_stuff_Click; this.Items.Add(file); this.Items.Add(order); this.Items.Add(stuff); this.Items.Add(report); frm.Controls.Add(this); frm.FormClosing += Frm_FormClosing; }
void IMenuItemVisitor <MenuGeneratorContext> .Visit( IMenu menu, MenuGeneratorContext context) { ToolStripItem toolStripItem; if (context.MenuType == TargetMenuType.Menu || context.MenuType == TargetMenuType.ContextMenu) { toolStripItem = new ToolStripMenuItem( menu.Text, null, CreateStripItems(menu.Groups, TargetMenuType.Menu)); } else { toolStripItem = new ToolStripDropDownButton( menu.Text, null, CreateStripItems(menu.Groups, TargetMenuType.Menu)); } toolStripItem.Tag = menu; context.Result.Add(toolStripItem); }
void add_menu_strip_items() { ToolStripDropDownButton drop_down_bt = new ToolStripDropDownButton(); drop_down_bt.Text = "Menu"; ToolStripButton ts_to_main_menu = new ToolStripButton(); ts_to_main_menu.Text = "Exit main menu"; ts_to_main_menu.Click += new EventHandler(ms_to_main_menu_button_click); ToolStripButton ts_restart = new ToolStripButton(); ts_restart.Text = "Restart session"; ts_restart.Click += new EventHandler(ms_restart_button_click); drop_down_bt.DropDown.Items.AddRange(new ToolStripItem[] { ts_restart, ts_to_main_menu }); menu_strip.Items.Add(drop_down_bt); }
public static void UpdateMenuTextToShorterNameOfSelection(ToolStripDropDownButton toolStripButton, string itemText) { var idxChinese = itemText.IndexOf(" (Chinese"); if (idxChinese > 0) { toolStripButton.Text = itemText.Substring(0, idxChinese); } else { var idxCountry = itemText.IndexOf(" ("); if (idxCountry > 0) { toolStripButton.Text = itemText.Substring(0, idxCountry); } else { toolStripButton.Text = itemText; } } }
public static void InitCopyDropDown(this ListView lvwuse, ToolStripDropDownButton tsbutton, String ContentsName, String GroupColumnName, Action <String, DropDownItemListViewCopyData> ActionDelegate) { //set image and text of the dropdownbutton. tsbutton.Image = JobClockConfig.Imageman.GetLoadedImage("copy_s"); //set text... tsbutton.Text = "Copy"; //add a ghost item to the drop down, so it will fire the DropDownOpeningEvent. Actually come to think of it this might not be necessary. Best not to ask //too many questions, though. tsbutton.DropDownItems.Add("GHOST"); //hook the "DropDownOpening" event. tsbutton.DropDownOpening += new EventHandler(tsbutton_DropDownOpening); //set the button's tag to a new data object, which will be used in the DropDown and succeeding button Click Events. tsbutton.Tag = new DropDownListViewCopyData(lvwuse, tsbutton, ContentsName, GroupColumnName, ActionDelegate); //That's IT! }
public void ToolStripItemCollection_AddRange_ToolStripItemCollection_Success() { using var contextMenuStrip = new ContextMenuStrip(); using var toolStripDropDownButton = new ToolStripDropDownButton(); // Add 0 items. contextMenuStrip.Items.AddRange(toolStripDropDownButton.DropDownItems); Assert.Equal(0, contextMenuStrip.Items.Count); // Add 3 items. toolStripDropDownButton.DropDownItems.Add("a"); toolStripDropDownButton.DropDownItems.Add("b"); toolStripDropDownButton.DropDownItems.Add("c"); contextMenuStrip.Items.AddRange(toolStripDropDownButton.DropDownItems); Assert.Equal(3, contextMenuStrip.Items.Count); // Validate order. Assert.Equal("a", contextMenuStrip.Items[0].Text); Assert.Equal("b", contextMenuStrip.Items[1].Text); Assert.Equal("c", contextMenuStrip.Items[2].Text); }
protected override void InitialiseToolStrip() { base.InitialiseToolStrip(); selectFirstSession = new ToolStripDropDownButton("First Session"); selectSecondSession = new ToolStripDropDownButton("Second Session"); IndexedToolStripButton temp; foreach (var session in (Session[])Enum.GetValues(typeof(Session))) { temp = new IndexedToolStripButton((int)session); temp.Text = Convert.ToString(session); temp.ButtonClicked += FirstSessionButtonClicked; selectFirstSession.DropDownItems.Add(temp); temp = new IndexedToolStripButton((int)session); temp.Text = Convert.ToString(session); temp.ButtonClicked += SecondSessionButtonClicked; selectSecondSession.DropDownItems.Add(temp); } thisToolStripDropDown.DropDownItems.Add(selectFirstSession); thisToolStripDropDown.DropDownItems.Add(selectSecondSession); }
public RecentProjectsMenu() : base(TextHelper.GetString("Label.RecentProjects")) { ToolbarSelector = new ToolStripDropDownButton(); ToolbarSelector.Text = TextHelper.GetStringWithoutMnemonics("Label.RecentProjects"); ToolbarSelector.DisplayStyle = ToolStripItemDisplayStyle.Image; ToolbarSelector.Image = Icons.Project.Img; ToolbarSelector.Enabled = false; string cleanLabel = TextHelper.GetString("Label.CleanRecentProjects"); cleanItemMenu = new ToolStripMenuItem(cleanLabel); cleanItemMenu.Click += delegate { CleanAllItems(); }; cleanItemToolbar = new ToolStripMenuItem(cleanLabel); cleanItemToolbar.Click += delegate { CleanAllItems(); }; string clearLabel = TextHelper.GetString("Label.ClearRecentProjects"); clearItemMenu = new ToolStripMenuItem(clearLabel); clearItemMenu.Click += delegate { ClearAllItems(); }; clearItemToolbar = new ToolStripMenuItem(clearLabel); clearItemToolbar.Click += delegate { ClearAllItems(); }; RebuildList(); }
public void ToolStripDropDownButton_SelectChild() { ToolStripDropDownButton tsddb = new ToolStripDropDownButton(); tsddb.DropDownClosed += Helper.FireEvent1; tsddb.DropDownItemClicked += Helper.FireEvent2; tsddb.DropDownOpened += Helper.FireEvent1; tsddb.DropDownOpening += Helper.FireEvent1; tsddb.Click += Helper.FireEvent1; Helper item1 = new Helper(); Helper item2 = new Helper(); tsddb.DropDownItems.Add(item1); tsddb.DropDownItems.Add(item2); ToolStripDropDownButton_SelectChildVerify(item1); ToolStrip ts = new ToolStrip(); ts.Items.Add(tsddb); ToolStripDropDownButton_SelectChildVerify(item2); }
protected override void InitializeItem(ToolStripItem item) { base.InitializeItem(item); //Don't Affect ForeColor of TextBoxes and ComboBoxes if (!((item is ToolStripTextBox) || (item is ToolStripComboBox))) { item.ForeColor = ColorTable.Text; } item.Padding = new Padding(5); if (item is ToolStripSplitButton) { ToolStripSplitButton btn = item as ToolStripSplitButton; btn.DropDownButtonWidth = 18; foreach (ToolStripItem subitem in btn.DropDownItems) { if (subitem is ToolStripMenuItem) { InitializeToolStripMenuItem(subitem as ToolStripMenuItem); } } } if (item is ToolStripDropDownButton) { ToolStripDropDownButton btn = item as ToolStripDropDownButton; btn.ShowDropDownArrow = false; foreach (ToolStripItem subitem in btn.DropDownItems) { if (subitem is ToolStripMenuItem) { InitializeToolStripMenuItem(subitem as ToolStripMenuItem); } } } }
private void odpriToolStripMenuItem_Click(object sender, EventArgs e) { // Create an instance of the open file dialog box. OpenFileDialog openFileDialog1 = new OpenFileDialog(); // Set filter options and filter index. openFileDialog1.Filter = "Text Files (.txt)|*.txt"; openFileDialog1.FilterIndex = 1; //openFileDialog1.Multiselect = true; // Call the ShowDialog method to show the dialog box. DialogResult userClickedOK = openFileDialog1.ShowDialog(); //tbNaslovKamere.Text = userClickedOK.ToString(); // Process input if the user clicked OK. if (userClickedOK.ToString().Equals("OK")) { menuPobrisiKamere(); String vrstica; // Open the selected file to read. System.IO.Stream fileStream = openFileDialog1.OpenFile(); kamere = new List <String>(); StreamReader myFile = new StreamReader(fileStream); while ((vrstica = myFile.ReadLine()) != null) { //zapis v list kamere.Add(vrstica); //doda v meni ToolStripDropDownButton btTemp = new ToolStripDropDownButton(vrstica, null, kameraOnClick, vrstica); kamereToolStripMenuItem.DropDownItems.Add(btTemp); } myFile.Dispose(); myFile.Close(); fileStream.Dispose(); fileStream.Close(); myFile.Close(); fileStream.Close(); } }
private void menu_Closed(object sender, ToolStripDropDownClosedEventArgs e) { if (multiSelectHelpButton != null) { ((ContextMenuStrip)sender).Items.Remove(multiSelectHelpButton); multiSelectHelpButton = null; } if (multiSelectDeleteButton != null) { ((ContextMenuStrip)sender).Items.Remove(multiSelectDeleteButton); multiSelectDeleteButton = null; } if (multiSelectCopyClipbord != null) { ((ContextMenuStrip)sender).Items.Remove(multiSelectCopyClipbord); multiSelectCopyClipbord = null; } if (multiSelectChangeCollection != null) { ((ContextMenuStrip)sender).Items.Remove(multiSelectChangeCollection); multiSelectChangeCollection = null; } foreach (ToolStripItem item in ((ContextMenuStrip)sender).Items) { if (item != null && item is ToolStripButton) { ToolStripButton button = item as ToolStripButton; button.Visible = true; } else { if (item != null && item is ToolStripDropDownButton) { ToolStripDropDownButton button2 = item as ToolStripDropDownButton; button2.Visible = true; } } } ((ContextMenuStrip)sender).Closed -= new ToolStripDropDownClosedEventHandler(menu_Closed); }
public Form1() { InitializeComponent(); var panel = new Panel() { BackColor = Color.White, MinimumSize = new Size(150, 72), Size = MinimumSize, }; panel.Paint += (s, e) => { TextRenderer.DrawText(e.Graphics, "Pop-up Panel", SystemFonts.DefaultFont, panel.ClientRectangle, Color.Black, Color.Empty, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); }; var hostTool = new ToolStripControlHost(panel) { Padding = Padding.Empty, Margin = Padding.Empty }; var downButton = new ToolStripDropDownButton("Panel Menu") { Alignment = ToolStripItemAlignment.Right, DisplayStyle = ToolStripItemDisplayStyle.Text, DropDownDirection = ToolStripDropDownDirection.BelowLeft, }; ((ToolStripDropDownMenu)downButton.DropDown).ShowCheckMargin = false; ((ToolStripDropDownMenu)downButton.DropDown).ShowImageMargin = false; downButton.DropDown.AutoSize = false; downButton.DropDown.Size = new Size(panel.Width + 12, panel.Height + 4); downButton.DropDown.Items.Add(hostTool); //var tool = new ToolStrip(); toolStrip1.Items.Add(downButton); //this.Controls.Add(tool); }
private void InitializeComponent() { this.icontainer_0 = new Container(); this.toolStrip1 = new ToolStrip(); this.btnState = new ToolStripDropDownButton(); this.监听消息ToolStripMenuItem = new ToolStripMenuItem(); this.停止监听ToolStripMenuItem = new ToolStripMenuItem(); this.btnExport = new ToolStripDropDownButton(); this.btnExportText = new ToolStripMenuItem(); this.btnExportXml = new ToolStripMenuItem(); this.toolStripMenuItem1 = new ToolStripSeparator(); this.btnImportXml = new ToolStripMenuItem(); this.btnDelete = new ToolStripDropDownButton(); this.删除选定项ToolStripMenuItem = new ToolStripMenuItem(); this.删除全部ToolStripMenuItem = new ToolStripMenuItem(); this.toolStripSeparator2 = new ToolStripSeparator(); this.btnTopMost = new ToolStripButton(); this.toolStripSeparator1 = new ToolStripSeparator(); this.btnExit = new ToolStripButton(); this.txtExecuteInfo = new TextBox(); this.splitter1 = new Splitter(); this.listView1 = new ListView(); this.columnHeader_5 = new ColumnHeader(); this.columnHeader_0 = new ColumnHeader(); this.columnHeader_1 = new ColumnHeader(); this.columnHeader_2 = new ColumnHeader(); this.columnHeader_3 = new ColumnHeader(); this.columnHeader_4 = new ColumnHeader(); this.imageList_0 = new ImageList(this.icontainer_0); this.toolStrip1.SuspendLayout(); base.SuspendLayout(); this.toolStrip1.Items.AddRange(new ToolStripItem[] { this.btnState, this.btnExport, this.btnDelete, this.toolStripSeparator2, this.btnTopMost, this.toolStripSeparator1, this.btnExit }); this.toolStrip1.Location = new Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new Size(881, 25); this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; this.btnState.DropDownItems.AddRange(new ToolStripItem[] { this.监听消息ToolStripMenuItem, this.停止监听ToolStripMenuItem }); //this.btnState.Image = Resources.ball3; this.btnState.Name = "btnState"; this.btnState.Size = new Size(84, 22); this.btnState.Text = "监听消息"; //this.监听消息ToolStripMenuItem.Image = Resources.ball3; this.监听消息ToolStripMenuItem.Name = "监听消息ToolStripMenuItem"; this.监听消息ToolStripMenuItem.Size = new Size(122, 22); this.监听消息ToolStripMenuItem.Text = "监听消息"; this.监听消息ToolStripMenuItem.Click += new EventHandler(this.监听消息ToolStripMenuItem_Click); //this.停止监听ToolStripMenuItem.Image = Resources.ball2; this.停止监听ToolStripMenuItem.Name = "停止监听ToolStripMenuItem"; this.停止监听ToolStripMenuItem.Size = new Size(122, 22); this.停止监听ToolStripMenuItem.Text = "停止监听"; this.停止监听ToolStripMenuItem.Click += new EventHandler(this.停止监听ToolStripMenuItem_Click); this.btnExport.DropDownItems.AddRange(new ToolStripItem[] { this.btnExportText, this.btnExportXml, this.toolStripMenuItem1, this.btnImportXml }); //this.btnExport.Image = Resources.grid7; this.btnExport.Name = "btnExport"; this.btnExport.Size = new Size(108, 22); this.btnExport.Text = "消息导入导出"; this.btnExportText.Name = "btnExportText"; this.btnExportText.Size = new Size(182, 22); this.btnExportText.Text = "以普通文本格式导出"; this.btnExportText.Click += new EventHandler(this.btnExportText_Click); this.btnExportXml.Name = "btnExportXml"; this.btnExportXml.Size = new Size(182, 22); this.btnExportXml.Text = "以XML格式导出"; this.btnExportXml.Click += new EventHandler(this.btnExportXml_Click); this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Size = new Size(179, 6); this.btnImportXml.Name = "btnImportXml"; this.btnImportXml.Size = new Size(182, 22); this.btnImportXml.Text = "导入XML格式消息"; this.btnImportXml.Click += new EventHandler(this.btnImportXml_Click); this.btnDelete.DropDownItems.AddRange(new ToolStripItem[] { this.删除选定项ToolStripMenuItem, this.删除全部ToolStripMenuItem }); //this.btnDelete.Image = Resources.dele2; this.btnDelete.Name = "btnDelete"; this.btnDelete.Size = new Size(84, 22); this.btnDelete.Text = "删除消息"; this.删除选定项ToolStripMenuItem.Name = "删除选定项ToolStripMenuItem"; this.删除选定项ToolStripMenuItem.Size = new Size(158, 22); this.删除选定项ToolStripMenuItem.Text = "删除选定项"; this.删除选定项ToolStripMenuItem.Click += new EventHandler(this.删除选定项ToolStripMenuItem_Click); this.删除全部ToolStripMenuItem.Name = "删除全部ToolStripMenuItem"; this.删除全部ToolStripMenuItem.Size = new Size(158, 22); this.删除全部ToolStripMenuItem.Text = "删除全部列表项"; this.删除全部ToolStripMenuItem.Click += new EventHandler(this.删除全部ToolStripMenuItem_Click); this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Size = new Size(6, 25); this.btnTopMost.CheckOnClick = true; //this.btnTopMost.Image = Resources.unlockWnd; this.btnTopMost.Name = "btnTopMost"; this.btnTopMost.Size = new Size(75, 22); this.btnTopMost.Text = "窗口置顶"; this.btnTopMost.CheckStateChanged += new EventHandler(this.btnTopMost_CheckStateChanged); this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new Size(6, 25); //this.btnExit.Image = Resources.exit2; this.btnExit.Name = "btnExit"; this.btnExit.Size = new Size(75, 22); this.btnExit.Text = "退出程序"; this.btnExit.Click += new EventHandler(this.btnExit_Click); this.txtExecuteInfo.AcceptsReturn = true; this.txtExecuteInfo.Dock = DockStyle.Bottom; this.txtExecuteInfo.Font = new Font("Courier New", 9f, FontStyle.Regular, GraphicsUnit.Point, 0); this.txtExecuteInfo.Location = new Point(0, 303); this.txtExecuteInfo.Multiline = true; this.txtExecuteInfo.Name = "txtExecuteInfo"; this.txtExecuteInfo.ReadOnly = true; this.txtExecuteInfo.ScrollBars = ScrollBars.Both; this.txtExecuteInfo.Size = new Size(881, 201); this.txtExecuteInfo.TabIndex = 1; this.txtExecuteInfo.WordWrap = false; this.splitter1.Dock = DockStyle.Bottom; this.splitter1.Location = new Point(0, 296); this.splitter1.Name = "splitter1"; this.splitter1.Size = new Size(881, 7); this.splitter1.TabIndex = 2; this.splitter1.TabStop = false; this.listView1.Columns.AddRange(new ColumnHeader[] { this.columnHeader_5, this.columnHeader_0, this.columnHeader_1, this.columnHeader_2, this.columnHeader_3, this.columnHeader_4 }); this.listView1.Dock = DockStyle.Fill; this.listView1.FullRowSelect = true; this.listView1.HideSelection = false; this.listView1.Location = new Point(0, 25); this.listView1.Name = "listView1"; this.listView1.Size = new Size(881, 271); this.listView1.SmallImageList = this.imageList_0; this.listView1.TabIndex = 3; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.View = View.Details; this.listView1.SelectedIndexChanged += new EventHandler(this.listView1_SelectedIndexChanged); this.columnHeader_5.Text = "序号"; this.columnHeader_5.Width = 54; this.columnHeader_0.Text = "命令文本"; this.columnHeader_0.Width = 196; this.columnHeader_1.Text = "命令参数"; this.columnHeader_1.Width = 210; this.columnHeader_2.Text = "开始时间"; this.columnHeader_2.Width = 115; this.columnHeader_3.Text = "完成时间"; this.columnHeader_3.Width = 168; this.columnHeader_4.Text = "应用程序标识"; this.columnHeader_4.Width = 110; this.imageList_0.ColorDepth = ColorDepth.Depth8Bit; this.imageList_0.ImageSize = new Size(16, 16); this.imageList_0.TransparentColor = Color.Transparent; base.AutoScaleDimensions = new SizeF(6f, 12f); base.AutoScaleMode = AutoScaleMode.Font; base.ClientSize = new Size(881, 504); base.Controls.Add(this.listView1); base.Controls.Add(this.splitter1); base.Controls.Add(this.txtExecuteInfo); base.Controls.Add(this.toolStrip1); base.Name = "SQLProfilerForm"; this.Text = "FastDBEngineSQLProfiler"; base.Load += new EventHandler(this.SQLProfilerForm_Load); base.Shown += new EventHandler(this.SQLProfilerForm_Shown); base.FormClosing += new FormClosingEventHandler(this.SQLProfilerForm_FormClosing); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); base.ResumeLayout(false); base.PerformLayout(); }