protected CommandBarMenu GetMenu(string groupId) { foreach (CommandBarItem item in m_menuBar.Items) { if (((ChoiceRelatedClass)item.Tag).Id == groupId) { return((CommandBarMenu)item); } else //look for submenus { CommandBarMenu menu = (CommandBarMenu)item; //need to simulate the user clicking on this in order to actually get populated. ((ChoiceGroup)menu.Tag).OnDisplay(null, null); //note that some of these may be set menus, others are just items; we don't bother checking foreach (CommandBarItem x in menu.Items) { if (x.Tag != null && //separators don't have tags ((ChoiceRelatedClass)x.Tag).Id == groupId) { return((CommandBarMenu)x); } } } } throw new ConfigurationException("could not find menu '" + groupId + "'."); }
protected override void OnSelect(EventArgs e) { // This is to support popup menus when using this class // in conjunction with a toolbar that behaves like a menu Menu parent = Parent; while (!(parent is CommandBarMenu) && !(parent == null)) { if (parent is MenuItemEx) { parent = (parent as MenuItemEx).Parent; } else if (parent is MenuItem) { parent = (parent as MenuItem).Parent; } else if (parent == Parent.GetMainMenu()) { parent = null; } else { parent = null; } } if (parent is CommandBarMenu) { CommandBarMenu cbm = (CommandBarMenu)parent; cbm.SelectedMenuItem = this; } base.OnSelect(e); }
public void CreateContextMenuUIForChoiceGroup(ChoiceGroup group) { CommandBarContextMenu menu = (CommandBarContextMenu)group.ReferenceWidget; foreach (CommandBarItem item in menu.Items) { item.Dispose(); } menu.Items.Clear(); foreach (ChoiceRelatedClass item in group) { if (item is ChoiceBase) { menu.Items.Add(CreateMenuItem((ChoiceBase)item)); } //if this is a submenu else if (item is ChoiceGroup) { // MakeMenu (menu, (ChoiceGroup)item); string label = item.Label.Replace("_", "&"); CommandBarMenu submenu = menu.Items.AddMenu(label); submenu.Tag = item; item.ReferenceWidget = submenu; submenu.DropDown += new System.EventHandler(((ChoiceGroup)item).OnDisplay); //Notice that we do not need to populate this menu now; it will be populated when its contents are displayed. } } }
public CommandBarMenu AddMenu(string text) { CommandBarMenu menu = new CommandBarMenu(text); this.Add(menu); //// clear hashes keyItems.Clear(); return menu; }
public void CreateUIForChoiceGroup(ChoiceGroup group) { if (group.ReferenceWidget is ContextMenu) { CreateContextMenuUIForChoiceGroup(group); return; } CommandBarMenu menu = (CommandBarMenu)group.ReferenceWidget; foreach (CommandBarItem item in menu.Items) { item.Dispose(); } menu.Items.Clear(); foreach (ChoiceRelatedClass item in group) { if (item is SeparatorChoice) { menu.Items.Add(new CommandBarSeparator()); } else if (item is ChoiceBase) { menu.Items.Add(CreateMenuItem((ChoiceBase)item)); } //if this is a submenu else if (item is ChoiceGroup) { // MakeMenu (menu, (ChoiceGroup)item); if (((ChoiceGroup)item).IsSubmenu) { string label = item.Label.Replace("_", "&"); CommandBarMenu submenu = menu.Items.AddMenu(label); submenu.Tag = item; item.ReferenceWidget = submenu; //submenu.IsEnabled= true; //the drop down the event seems to be ignored by the submenusof this package. //submenu.DropDown += new System.EventHandler(((ChoiceGroup)item).OnDisplay); //therefore, we need to populate the submenu right now and not wait ((ChoiceGroup)item).OnDisplay(this, null); //this was enough to make the menu enabled, but not enough to trigger the drop down event when chosen //submenu.Items.Add(new CommandBarSeparator()); } else if (((ChoiceGroup)item).IsInlineChoiceList) { ((ChoiceGroup)item).PopulateNow(); foreach (ChoiceRelatedClass inlineItem in ((ChoiceGroup)item)) { Debug.Assert(inlineItem is ChoiceBase, "It should not be possible for a in line choice list to contain anything other than simple items!"); menu.Items.Add(CreateMenuItem((ChoiceBase)inlineItem)); } } } } }
public Application() { this.applicationWindow = new ApplicationWindow(); this.applicationWindow.Load += new EventHandler(this.ApplicationWindow_Load); this.applicationWindow.Closing += new CancelEventHandler(this.ApplicationWindow_Closing); this.applicationWindow.ResourceBrowser.PropertyChanged += new PropertyChangedEventHandler(this.ResourceBrowser_PropertyChanged); this.applicationWindow.ResourceBrowser.SelectedIndexChanged += new EventHandler(this.ResourceBrowser_SelectedIndexChanged); this.cutItem = new CommandBarButton(CommandBarResource.Cut, "Cu&t", new EventHandler(this.Cut_Click), Keys.Control | Keys.X); this.copyItem = new CommandBarButton(CommandBarResource.Copy, "&Copy", new EventHandler(this.Copy_Click), Keys.Control | Keys.C); this.pasteItem = new CommandBarButton(CommandBarResource.Paste, "&Paste", new EventHandler(this.Paste_Click), Keys.Control | Keys.V); this.deleteItem = new CommandBarButton(CommandBarResource.Delete, "&Delete", new EventHandler(this.Delete_Click)); // MenuBar CommandBar menuBar = this.applicationWindow.MenuBar; CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File"); fileMenu.Items.AddButton(CommandBarResource.New, "&New", new EventHandler(this.New_Click), Keys.Control | Keys.N); fileMenu.Items.AddButton(CommandBarResource.Open, "&Open...", new EventHandler(this.Open_Click), Keys.Control | Keys.O); fileMenu.Items.AddButton(CommandBarResource.Save, "&Save", new EventHandler(this.Save_Click), Keys.Control | Keys.S); fileMenu.Items.AddButton("Save &As...", new EventHandler(this.SaveAs_Click)); fileMenu.Items.AddSeparator(); fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click)); CommandBarMenu editMenu = menuBar.Items.AddMenu("&Edit"); editMenu.Items.Add(this.cutItem); editMenu.Items.Add(this.copyItem); editMenu.Items.Add(this.pasteItem); editMenu.Items.Add(this.deleteItem); editMenu.Items.AddSeparator(); editMenu.Items.AddButton(CommandBarResource.Edit, "Insert &Text...", new EventHandler(this.InsertText_Click), Keys.Control | Keys.T); editMenu.Items.AddButton(CommandBarResource.Parent, "Insert &Files...", new EventHandler(this.InsertFiles_Click), Keys.Control | Keys.F); CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help"); helpMenu.Items.AddButton("&About .NET Resourcer...", new EventHandler(this.About_Click)); // ToolBar CommandBar toolBar = this.applicationWindow.ToolBar; toolBar.Items.AddButton(CommandBarResource.New, "New", new EventHandler(this.New_Click), Keys.Control | Keys.N); toolBar.Items.AddButton(CommandBarResource.Open, "Open...", new EventHandler(this.Open_Click), Keys.Control | Keys.O); toolBar.Items.AddButton(CommandBarResource.Save, "Save", new EventHandler(this.Save_Click), Keys.Control | Keys.S); toolBar.Items.AddSeparator(); toolBar.Items.Add(this.cutItem); toolBar.Items.Add(this.copyItem); toolBar.Items.Add(this.pasteItem); toolBar.Items.Add(this.deleteItem); toolBar.Items.AddSeparator(); toolBar.Items.AddButton(CommandBarResource.Edit, "Insert &Text...", new EventHandler(this.InsertText_Click), Keys.Control | Keys.T); toolBar.Items.AddButton(CommandBarResource.Parent, "Insert &Files...", new EventHandler(this.InsertFiles_Click), Keys.Control | Keys.F); System.Windows.Forms.Application.Idle += new EventHandler(this.Application_Idle); }
public bool HasItem(string groupId, string itemId) { CommandBarMenu menu = GetMenu(groupId); //need to simulate the user clicking on this in order to actually get populated. ((ChoiceGroup)menu.Tag).OnDisplay(null, null); CommandBarItem item = GetMenuItem(menu, itemId); return(item != null); }
public int GetItemCountOfGroup(string groupId) { CommandBarMenu menu = GetMenu(groupId); //need to simulate the user clicking on this in order to actually get populated. //could just as well have called our method CreateUIForChoiceGroup() instead of the groups OnDisplay() //method, but the latter is one step closer to reality. ((ChoiceGroup)menu.Tag).OnDisplay(null, null); return(menu.Items.Count); }
protected CommandBarItem MakeMenu(CommandBar parent, ChoiceGroup group) { string label = group.Label.Replace("_", "&"); CommandBarMenu menu = parent.Items.AddMenu(label); menu.Tag = group; group.ReferenceWidget = menu; menu.DropDown += new System.EventHandler(group.OnDisplay); #if DEBUG //needed for unit testing //menu.Click += new System.EventHandler(group.OnDisplay); #endif return(menu); }
protected CommandBarItem GetMenuItem(CommandBarMenu menu, string id) { //need to simulate the user clicking on this in order to actually get populated. ((ChoiceGroup)menu.Tag).OnDisplay(null, null); foreach (CommandBarItem item in menu.Items) { if (((ChoiceRelatedClass)item.Tag).Id == id) { return(item); } } //NO NO: this is not necessarily an error. remember, we are testing! // throw new ConfigurationException("could not find item '"+id +"'."); return(null); }
public void ClickItem(string groupId, string itemId) { CommandBarMenu menu = GetMenu(groupId); if (menu == null) { throw new ConfigurationException("Could not find the menu with an Id of '" + groupId + "'."); } CommandBarItem item = GetMenuItem(menu, itemId); if (item == null) { throw new ConfigurationException("Could not find the item with an Id of '" + itemId + "' in the menu '" + groupId + "'."); } OnClick(item, null); }
protected void ClickOnAllItems(CommandBarMenu menu) { //need to simulate the user clicking on this in order to actually get populated. ((ChoiceGroup)menu.Tag).OnDisplay(null, null); foreach (CommandBarItem item in menu.Items) { if (item.Tag is ChoiceGroup) //submenu { ClickOnAllItems((CommandBarMenu)item); } else { ((ChoiceBase)item.Tag).OnClick(null, null); } } }
/** * Initializes the plugin */ public void Initialize() { this.mainForm = this.pluginHost.MainForm; this.pluginUI = new PluginUI(this); System.Drawing.Image image = mainForm.GetSystemImage(22); /** * Create panel */ this.pluginUI.Tag = "Output"; this.pluginUI.Text = "Output"; this.pluginPanel = mainForm.CreateDockingPanel(this.pluginUI, this.pluginGuid, image, DockState.DockBottomAutoHide); /** * Create menu item */ CommandBarMenu ViewMenu = mainForm.GetCBMenu("ViewMenu"); ViewMenu.Items.AddButton(image, "&Output Panel", new EventHandler(this.OpenPanel)); }
public ProjectContextMenu(FDMenus menus) { this.menus = menus; AddNewClass = CreateButton("New &Class..", Icons.ActionScript.Img); AddNewXml = CreateButton("New &Xml File..", Icons.XmlFile.Img); AddNewFile = CreateButton("New &File..", Icons.AddFile.Img); AddNewFolder = CreateButton("New F&older", Icons.Folder.Img); AddLibraryAsset = CreateButton("Library &Asset..", Icons.ImageResource.Img); AddExistingFile = CreateButton("&Existing File..", Icons.HiddenFile.Img); Open = CreateButton("&Open", Icons.OpenFile.Img); Insert = CreateButton("&Insert Into Document", Icons.EditFile.Img); Execute = CreateButton("&Execute"); Cut = CreateButton("Cu&t", Icons.Cut.Img); Copy = CreateButton("Cop&y"); Paste = CreateButton("&Paste", Icons.Paste.Img); Delete = CreateButton("&Delete", Icons.Delete.Img); Rename = CreateButton("Rena&me"); AlwaysCompile = new CommandBarCheckBox("Always &Compile"); AddLibrary = new CommandBarCheckBox("Add to &Library"); LibraryOptions = CreateButton("&Options...", Icons.Options.Img); Hide = new CommandBarCheckBox("&Hide File"); ShowHidden = new CommandBarCheckBox(Icons.HiddenFile.Img, "&Show Hidden Items"); NothingToDo = new CommandBarButton("Not a valid group"); NothingToDo.IsEnabled = false; NoProjectOutput = new CommandBarButton("(Project output not built)"); NoProjectOutput.IsEnabled = false; AddMenu = new CommandBarMenu("&Add"); AddMenu.Items.Add(AddNewClass); AddMenu.Items.Add(AddNewXml); AddMenu.Items.Add(AddNewFile); AddMenu.Items.Add(AddNewFolder); AddMenu.Items.AddSeparator(); AddMenu.Items.Add(AddLibraryAsset); AddMenu.Items.Add(AddExistingFile); }
public FDMenus(IMainForm mainForm) { // modify the view menu CommandBarMenu viewMenu = mainForm.GetCBMenu("ViewMenu"); View = new CommandBarButton("&Project Explorer"); View.Image = Icons.Project.Img; viewMenu.Items.Add(View); // modify the tools menu - add a nice GUI classpath editor GlobalClasspaths = new CommandBarButton("&Global Classpaths..."); GlobalClasspaths.Shortcut = Keys.F9 | Keys.Control; mainForm.IgnoredKeys.Add(GlobalClasspaths.Shortcut); CommandBarMenu toolsMenu = mainForm.GetCBMenu("ToolsMenu"); toolsMenu.Items.AddSeparator(); toolsMenu.Items.Add(GlobalClasspaths); ProjectMenu = new ProjectMenu(); CommandBar mainMenu = mainForm.GetCBMainMenu(); mainMenu.Items.Insert(5, ProjectMenu); RecentComboBox = RecentComboBox.Create(); CommandBar toolBar = mainForm.GetCBToolbar(); if (toolBar != null) // you might have turned off the toolbar { toolBar.Items.AddSeparator(); toolBar.Items.Add(ProjectMenu.TestMovie); toolBar.Items.Add(RecentComboBox); } }
public HelloWorld() { this.Icon = SystemIcons.Application; this.Text = "Hello World"; this.Size = new Size(500, 500); this.Controls.Add(new StatusBar()); this.commandBarManager = new CommandBarManager(); this.menuBar = new CommandBar(this.commandBarManager, CommandBarStyle.Menu); this.toolBar = new CommandBar(this.commandBarManager, CommandBarStyle.ToolBar); // Menu and toolbar CommandBarButton newButton = new CommandBarButton(Images.New, "&New", null, Keys.Control | Keys.N); CommandBarButton openButton = new CommandBarButton(Images.Open, "&Open...", null, Keys.Control | Keys.O); CommandBarButton saveButton = new CommandBarButton(Images.Save, "&Save", null, Keys.Control | Keys.S); toolBar.Items.Add(newButton); toolBar.Items.Add(openButton); toolBar.Items.Add(saveButton); toolBar.Items.AddSeparator(); CommandBarButton cutButton = new CommandBarButton(Images.Cut, "Cu&t", null, Keys.Control | Keys.X); CommandBarItem copyButton = new CommandBarButton(Images.Copy, "&Copy", null, Keys.Control | Keys.C); CommandBarItem pasteButton = new CommandBarButton(Images.Paste, "&Paste", null, Keys.Control | Keys.V); CommandBarItem deleteButton = new CommandBarButton(Images.Delete, "&Delete", null, Keys.Delete); this.toolBar.Items.Add(cutButton); this.toolBar.Items.Add(copyButton); this.toolBar.Items.Add(pasteButton); this.toolBar.Items.Add(deleteButton); this.toolBar.Items.AddSeparator(); CommandBarButton undoButton = new CommandBarButton(Images.Undo, "&Undo", null, Keys.Control | Keys.Z); CommandBarButton redoButton = new CommandBarButton(Images.Redo, "&Redo", null, Keys.Control | Keys.Y); this.toolBar.Items.Add(undoButton); this.toolBar.Items.Add(redoButton); this.toolBar.Items.AddSeparator(); CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File"); fileMenu.Items.Add(newButton); fileMenu.Items.Add(openButton); fileMenu.Items.Add(saveButton); fileMenu.Items.AddButton("&Save As...", null); fileMenu.Items.AddSeparator(); fileMenu.Items.AddButton(Images.Preview, "Print Pre&view", null); fileMenu.Items.AddButton(Images.Print, "&Print", null, Keys.Control | Keys.P); fileMenu.Items.AddSeparator(); fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click)); CommandBarMenu editMenu = this.menuBar.Items.AddMenu("&Edit"); editMenu.Items.Add(undoButton); editMenu.Items.Add(redoButton); editMenu.Items.AddSeparator(); editMenu.Items.Add(cutButton); editMenu.Items.Add(copyButton); editMenu.Items.Add(pasteButton); editMenu.Items.Add(deleteButton); editMenu.Items.AddSeparator(); editMenu.Items.AddButton("Select &All", null, Keys.Control | Keys.A); CommandBarMenu viewMenu = this.menuBar.Items.AddMenu("&View"); CommandBarMenu goToMenu = viewMenu.Items.AddMenu("&Go To"); goToMenu.Items.AddButton(Images.Back, "&Back", null, Keys.Alt | Keys.Left); goToMenu.Items.AddButton(Images.Forward, "&Forward", null, Keys.Alt | Keys.Right); goToMenu.Items.AddSeparator(); goToMenu.Items.AddButton(Images.Home, "&Home", null); viewMenu.Items.AddButton(Images.Stop, "&Stop", null, Keys.Escape); viewMenu.Items.AddButton(Images.Refresh, "&Refresh", null, Keys.F5); this.enabledButton = new CommandBarButton(Images.Tiles, "&Enabled", null); this.enabledButton.Enabled = false; this.visibleButton = new CommandBarButton(Images.Icons, "&Visible", null); this.visibleButton.Visible = false; CommandBarCheckBox checkedPlainCheckBox = new CommandBarCheckBox("&Checked Plain"); checkedPlainCheckBox.IsChecked = true; CommandBarCheckBox checkedBitmapCheckBox = new CommandBarCheckBox(Images.List, "&Checked Bitmap"); checkedBitmapCheckBox.IsChecked = true; toolBar.Items.Add(enabledButton); toolBar.Items.Add(visibleButton); toolBar.Items.Add(checkedPlainCheckBox); toolBar.Items.Add(checkedBitmapCheckBox); toolBar.Items.AddSeparator(); ComboBox comboBox = new ComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Width = 100; toolBar.Items.AddComboBox("Combo Box", comboBox); toolBar.Items.AddSeparator(); CommandBarMenu testMenu = menuBar.Items.AddMenu("&Test"); testMenu.Items.AddButton("&Enabled On/Off", new EventHandler(ToggleEnabled_Click)); testMenu.Items.Add(this.enabledButton); testMenu.Items.AddSeparator(); testMenu.Items.AddButton("&Visible On/Off", new EventHandler(ToggleVisible_Click)); testMenu.Items.Add(this.visibleButton); testMenu.Items.AddSeparator(); testMenu.Items.Add(checkedPlainCheckBox); testMenu.Items.Add(checkedBitmapCheckBox); testMenu.Items.AddSeparator(); testMenu.Items.AddButton("Change Font", new EventHandler(this.ChangeFont_Click)); CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help"); helpMenu.Items.AddButton(Images.Mail, "&Your Feedback", null); helpMenu.Items.AddSeparator(); helpMenu.Items.AddButton("&About", null); this.commandBarManager.CommandBars.Add(this.menuBar); this.commandBarManager.CommandBars.Add(this.toolBar); this.Controls.Add(this.commandBarManager); // Context menu CommandBarContextMenu contextMenu = new CommandBarContextMenu(); contextMenu.Items.Add(undoButton); contextMenu.Items.Add(redoButton); contextMenu.Items.AddSeparator(); contextMenu.Items.Add(cutButton); contextMenu.Items.Add(copyButton); contextMenu.Items.Add(pasteButton); contextMenu.Items.Add(deleteButton); this.ContextMenu = contextMenu; }
private void SetupMRUList(CommandBarMenu fileMenu) { bool added = true; _mruList = new MRUList(); foreach (MRUList.MRUEntry entry in _mruList) { if (entry.Path != null) { CommandBarButton item = new CommandBarButton(entry.ToString(), new EventHandler(MRUEntry_Click)); item.Tag = entry; fileMenu.Items.Add(item); added = true; } } if (added) { fileMenu.Items.AddSeparator(); } }
public CommandBarMenu AddMenu(string text) { CommandBarMenu menu = new CommandBarMenu(text); this.Add(menu); return menu; }
public Application() { this.commandManager = new CommandManager(); this.configurationManager = new ConfigurationManager(); this.configurationManager.Load(this.GetType().Module.FullyQualifiedName); this.fileHistory = new FileHistory(); this.fileHistory.Configuration = this.configurationManager["FileHistory"]; this.ftpConfiguration = new FtpConfiguration(); this.ftpConfiguration.Configuration = this.configurationManager["FtpConfiguration"]; this.applicationWindow = new ApplicationWindow(); this.applicationWindow.Closed += new EventHandler(this.ApplicationWindow_Closed); this.applicationWindow.Closing += new CancelEventHandler(this.ApplicationWindow_Closing); this.applicationWindow.Activated += new EventHandler(this.ApplicationWindowActivated); // Toolbar CommandBar toolBar = this.applicationWindow.ToolBar; this.commandManager.Add("File.New", toolBar.Items.AddButton(CommandBarImageResource.New, "&New", null, Keys.Control | Keys.N)); this.commandManager.Add("File.Open", toolBar.Items.AddButton(CommandBarImageResource.Open, "&Open...", null, Keys.Control | Keys.O)); this.commandManager.Add("File.Save", toolBar.Items.AddButton(CommandBarImageResource.Save, "&Save", null, Keys.Control | Keys.S)); toolBar.Items.AddSeparator(); this.commandManager.Add("Edit.Cut", toolBar.Items.AddButton(CommandBarImageResource.Cut, "Cu&t", null, Keys.Control | Keys.X)); this.commandManager.Add("Edit.Copy", toolBar.Items.AddButton(CommandBarImageResource.Copy, "&Copy", null, Keys.Control | Keys.C)); this.commandManager.Add("Edit.Paste", toolBar.Items.AddButton(CommandBarImageResource.Paste, "&Paste", null, Keys.Control | Keys.V)); this.commandManager.Add("Edit.Delete", toolBar.Items.AddButton(CommandBarImageResource.Delete, "&Delete", null, Keys.Delete)); toolBar.Items.AddSeparator(); this.commandManager.Add("Edit.Undo", toolBar.Items.AddButton(CommandBarImageResource.Undo, "&Undo", null, Keys.Control | Keys.Z)); this.commandManager.Add("Edit.Redo", toolBar.Items.AddButton(CommandBarImageResource.Redo, "&Redo", null, Keys.Control | Keys.Y)); toolBar.Items.AddSeparator(); this.commandManager.Add("Format.Font", toolBar.Items.AddComboBox("Font", new FontComboBox())); this.commandManager.Add("Format.FontSize", toolBar.Items.AddComboBox("Font Size", new FontSizeComboBox())); toolBar.Items.AddSeparator(); this.commandManager.Add("Format.Bold", toolBar.Items.AddCheckBox(FormatResource.Bold, "&Bold", Keys.Control | Keys.B)); this.commandManager.Add("Format.Italic", toolBar.Items.AddCheckBox(FormatResource.Italic, "&Italic", Keys.Control | Keys.I)); this.commandManager.Add("Format.Underline", toolBar.Items.AddCheckBox(FormatResource.Underline, "U&nderline", Keys.Control | Keys.U)); toolBar.Items.AddSeparator(); this.commandManager.Add("Format.UnorderedList", toolBar.Items.AddCheckBox(FormatResource.UnorderedList, "&Bullets")); this.commandManager.Add("Format.OrderedList", toolBar.Items.AddCheckBox(FormatResource.OrderedList, "&Numbering")); this.commandManager.Add("Format.Unindent", toolBar.Items.AddButton(FormatResource.Unindent, "Unind&ent", null, Keys.Shift | Keys.Tab)); this.commandManager.Add("Format.Indent", toolBar.Items.AddButton(FormatResource.Indent, "In&dent", null, Keys.Tab)); toolBar.Items.AddSeparator(); CommandBarMenu foreColorMenu = toolBar.Items.AddMenu(FormatResource.ForeColor, "Foreground Color"); this.commandManager.Add("Format.ForeColor.Black", foreColorMenu.Items.AddButton(FormatResource.Black, "Blac&k", null)); this.commandManager.Add("Format.ForeColor.Yellow", foreColorMenu.Items.AddButton(FormatResource.Yellow, "&Yellow", null)); this.commandManager.Add("Format.ForeColor.Red", foreColorMenu.Items.AddButton(FormatResource.Red, "&Red", null)); this.commandManager.Add("Format.ForeColor.Green", foreColorMenu.Items.AddButton(FormatResource.Green, "&Green", null)); this.commandManager.Add("Format.ForeColor.Blue", foreColorMenu.Items.AddButton(FormatResource.Blue, "&Blue", null)); this.commandManager.Add("Format.ForeColor.White", foreColorMenu.Items.AddButton(FormatResource.White, "&White", null)); CommandBarMenu backColorMenu = toolBar.Items.AddMenu(FormatResource.BackColor, "Background Color"); this.commandManager.Add("Format.BackColor.Black", backColorMenu.Items.AddButton(FormatResource.Black, "Blac&k", null)); this.commandManager.Add("Format.BackColor.Yellow", backColorMenu.Items.AddButton(FormatResource.Yellow, "&Yellow", null)); this.commandManager.Add("Format.BackColor.Red", backColorMenu.Items.AddButton(FormatResource.Red, "&Red", null)); this.commandManager.Add("Format.BackColor.Green", backColorMenu.Items.AddButton(FormatResource.Green, "&Green", null)); this.commandManager.Add("Format.BackColor.Blue", backColorMenu.Items.AddButton(FormatResource.Blue, "&Blue", null)); this.commandManager.Add("Format.BackColor.White", backColorMenu.Items.AddButton(FormatResource.White, "&White", null)); // Menu CommandBar menuBar = this.applicationWindow.MenuBar; CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File"); this.commandManager.Add("File.New", fileMenu.Items.AddButton(CommandBarImageResource.New, "&New", null, Keys.Control | Keys.N)); this.commandManager.Add("File.Open", fileMenu.Items.AddButton(CommandBarImageResource.Open, "&Open...", null, Keys.Control | Keys.O)); this.commandManager.Add("File.Save", fileMenu.Items.AddButton(CommandBarImageResource.Save, "&Save", null, Keys.Control | Keys.S)); this.commandManager.Add("File.SaveAs", fileMenu.Items.AddButton("Save &As...", null)); CommandBarMenu publishToWebMenu = fileMenu.Items.AddMenu("Publish to &Web"); this.commandManager.Add("File.FtpSetting", publishToWebMenu.Items.AddButton("&Settings...", null)); this.commandManager.Add("File.Publish", publishToWebMenu.Items.AddButton("&Publish", null)); fileMenu.Items.AddSeparator(); this.commandManager.Add("File.PrintPreview", fileMenu.Items.AddButton(CommandBarImageResource.Preview, "Print Pre&view", null)); this.commandManager.Add("File.Print", fileMenu.Items.AddButton(CommandBarImageResource.Print, "&Print", null, Keys.Control | Keys.P)); fileMenu.Items.AddSeparator(); CommandBarMenu fileHistoryMenu = fileMenu.Items.AddMenu("Recent &Files"); this.commandManager.Add("File.History.0", fileHistoryMenu.Items.AddButton("&1", null)); this.commandManager.Add("File.History.1", fileHistoryMenu.Items.AddButton("&2", null)); this.commandManager.Add("File.History.2", fileHistoryMenu.Items.AddButton("&3", null)); this.commandManager.Add("File.History.3", fileHistoryMenu.Items.AddButton("&4", null)); fileMenu.Items.AddSeparator(); this.commandManager.Add("Application.Exit", fileMenu.Items.AddButton("E&xit", null)); CommandBarMenu editMenu = menuBar.Items.AddMenu("&Edit"); this.commandManager.Add("Edit.Undo", editMenu.Items.AddButton(CommandBarImageResource.Undo, "&Undo", null, Keys.Control | Keys.Z)); this.commandManager.Add("Edit.Redo", editMenu.Items.AddButton(CommandBarImageResource.Redo, "&Redo", null, Keys.Control | Keys.Y)); editMenu.Items.AddSeparator(); this.commandManager.Add("Edit.Cut", editMenu.Items.AddButton(CommandBarImageResource.Cut, "Cu&t", null, Keys.Control | Keys.X)); this.commandManager.Add("Edit.Copy", editMenu.Items.AddButton(CommandBarImageResource.Copy, "&Copy", null, Keys.Control | Keys.C)); this.commandManager.Add("Edit.Paste", editMenu.Items.AddButton(CommandBarImageResource.Paste, "&Paste", null, Keys.Control | Keys.V)); this.commandManager.Add("Edit.Delete", editMenu.Items.AddButton(CommandBarImageResource.Delete, "&Delete", null, Keys.Delete)); editMenu.Items.AddSeparator(); this.commandManager.Add("Edit.SelectAll", editMenu.Items.AddButton("Select &All", null, Keys.Control | Keys.A)); editMenu.Items.AddSeparator(); this.commandManager.Add("Edit.Find", editMenu.Items.AddButton(CommandBarImageResource.Search, "&Find...", null, Keys.Control | Keys.F)); this.commandManager.Add("Edit.FindNext", editMenu.Items.AddButton("Find &Next", null, Keys.F3)); this.commandManager.Add("Edit.Replace", editMenu.Items.AddButton("&Replace...", null, Keys.Control | Keys.H)); CommandBarMenu insertMenu = menuBar.Items.AddMenu("&Insert"); this.commandManager.Add("Edit.InsertHyperlink", insertMenu.Items.AddButton(FormatResource.Hyperlink, "Insert &Hyperlink", null, Keys.Control | Keys.K)); this.commandManager.Add("Edit.InsertPicture", insertMenu.Items.AddButton(FormatResource.Picture, "Insert &Picture...", null)); this.commandManager.Add("Edit.InsertDateTime", insertMenu.Items.AddButton("Insert &Date and Time...", null)); CommandBarMenu formatMenu = menuBar.Items.AddMenu("F&ormat"); this.commandManager.Add("Format.Bold", formatMenu.Items.AddCheckBox(FormatResource.Bold, "&Bold", Keys.Control | Keys.B)); this.commandManager.Add("Format.Italic", formatMenu.Items.AddCheckBox(FormatResource.Italic, "&Italic", Keys.Control | Keys.I)); this.commandManager.Add("Format.Underline", formatMenu.Items.AddCheckBox(FormatResource.Underline, "U&nderline", Keys.Control | Keys.U)); this.commandManager.Add("Format.Superscript", formatMenu.Items.AddCheckBox(FormatResource.Superscript, "&Superscript")); this.commandManager.Add("Format.Subscript", formatMenu.Items.AddCheckBox(FormatResource.Subscript, "Subscri&pt")); this.commandManager.Add("Format.Strikethrough", formatMenu.Items.AddCheckBox(FormatResource.Strikethrough, "Stri&ke")); formatMenu.Items.AddSeparator(); this.commandManager.Add("Format.ForeColor", formatMenu.Items.AddButton(FormatResource.ForeColor, "&Fore Color", null)); this.commandManager.Add("Format.BackColor", formatMenu.Items.AddButton(FormatResource.BackColor, "B&ack Color", null)); formatMenu.Items.AddSeparator(); this.commandManager.Add("Format.AlignLeft", formatMenu.Items.AddCheckBox(FormatResource.AlignLeft, "Align &Left")); this.commandManager.Add("Format.AlignCenter", formatMenu.Items.AddCheckBox(FormatResource.AlignCenter, "Align &Center")); this.commandManager.Add("Format.AlignRight", formatMenu.Items.AddCheckBox(FormatResource.AlignRight, "Align &Right")); formatMenu.Items.AddSeparator(); this.commandManager.Add("Format.OrderedList", formatMenu.Items.AddCheckBox(FormatResource.OrderedList, "&Numbering")); this.commandManager.Add("Format.UnorderedList", formatMenu.Items.AddCheckBox(FormatResource.UnorderedList, "B&ullets")); this.commandManager.Add("Format.Unindent", formatMenu.Items.AddButton(FormatResource.Unindent, "Unind&ent", null, Keys.Shift | Keys.Tab)); this.commandManager.Add("Format.Indent", formatMenu.Items.AddButton(FormatResource.Indent, "In&dent", null, Keys.Tab)); CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help"); this.commandManager.Add("Application.About", helpMenu.Items.AddButton("&About Writer...", null)); this.commandManager.AddTarget(this); this.FileNew(); CommandLine commandLine = new CommandLine(); string[] fileNames = commandLine.GetArguments(string.Empty); if ((fileNames != null) && (fileNames.Length > 0)) { this.LoadFile(fileNames[0]); } }
/// <summary> /// Loads the plugin menus. /// </summary> /// <param name="sender"> Sender object.</param> /// <param name="e"> LoadPluginMenuEventArgs arguments.</param> public void inspector_LoadPluginMenusEvent(object sender, LoadPluginMenuEventArgs e) { // Root Menus MenuRootHashtable ht = e.MenuRoot; SortedList root = new SortedList(ht,null); this.SuspendLayout(); //1: For each MenuRoot, add MenuItems foreach (DictionaryEntry de in root) { MenuRoot r = (MenuRoot)de.Value; // Create Menu Root CommandBarMenu menuRoot = new CommandBarMenu(r.Text); menuRoot.MenuShortcut = r.Shortcut; // add MenuRoot menubar.Items.Add(menuRoot); // if null then exit if ( r.MenuItems == null ) break; #region Create commands and commandlinks //2: Add Menu Children for (int i=0;i<r.MenuItems.Count;i++) { Ecyware.GreenBlue.Controls.MenuItem mn = (Ecyware.GreenBlue.Controls.MenuItem)r.MenuItems[r.MenuItems.GetKey(i)]; if ( mn is Ecyware.GreenBlue.Controls.ToolbarItem ) { #region Add Toolbar item // Create Command and add to CommandHolder Ecyware.GreenBlue.Controls.ToolbarItem tbItem = (Ecyware.GreenBlue.Controls.ToolbarItem)mn; // add any submenu toolbar if ( tbItem.IsDropDown ) { /* // for command with submenu if ( tbItem.ImageIndex > -1 ) { Image img = this.imgToolbar24.Images[tbItem.ImageIndex]; } CommandBarMenu m = toolbar.Items.AddMenu(img, tbItem.Text); m.DropDown += tbItem.DropDownDelegate; */ } else { if ( tbItem.Toggle ) { #region Single Command for toggle or checked type CommandBarCheckBox toolbarItem = new CommandBarCheckBox(tbItem.Text); toolbarItem.IsEnabled = tbItem.Enabled; toolbarItem.IsVisible = tbItem.Visible; toolbarItem.MenuShortcut = tbItem.Shortcut; if ( tbItem.ImageIndex > -1 ) toolbarItem.Image = this.imgToolbar24.Images[tbItem.ImageIndex]; toolbarItem.Click += tbItem.CheckedChangedDelegate; toolbar.Items.Add(toolbarItem); #endregion } else { #region Single Command not checked CommandBarButton toolbarItem = new CommandBarButton(tbItem.Text); toolbarItem.IsEnabled = tbItem.Enabled; toolbarItem.IsVisible = tbItem.Visible; toolbarItem.MenuShortcut = tbItem.Shortcut; if ( tbItem.ImageIndex > -1 ) toolbarItem.Image = this.imgToolbar24.Images[tbItem.ImageIndex]; toolbarItem.Click += tbItem.ClickDelegate; toolbar.Items.Add(toolbarItem); #endregion } // Add delimiter if ( mn.Delimiter ) { toolbar.Items.AddSeparator(); } } #endregion } else { if ( mn.Toggle ) { #region Add menu with checked CommandBarCheckBox menuItem = new CommandBarCheckBox(mn.Text); menuItem.IsVisible = mn.Visible; menuItem.IsEnabled = mn.Enabled; //if ( mn.ImageIndex > -1 ) // menuItem.Image = this.imgToolbar16.Images[mn.ImageIndex]; menuItem.MenuShortcut = mn.Shortcut; menuItem.Click += mn.CheckedChangedDelegate; #endregion // Add delimiter if ( mn.Delimiter ) { menuRoot.Items.AddSeparator(); } menuRoot.Items.Add(menuItem); } else { #region Add Menu CommandBarButton menuItem = new CommandBarButton(mn.Text); menuItem.IsVisible = mn.Visible; menuItem.IsEnabled = mn.Enabled; if ( mn.ImageIndex > -1 ) menuItem.Image = this.imgToolbar16.Images[mn.ImageIndex]; menuItem.MenuShortcut = mn.Shortcut; menuItem.Click += mn.ClickDelegate; #endregion // Add delimiter if ( mn.Delimiter ) { menuRoot.Items.AddSeparator(); } menuRoot.Items.Add(menuItem); } } } #endregion } this.ResumeLayout(false); }
protected void ClickOnAllItems (CommandBarMenu menu) { //need to simulate the user clicking on this in order to actually get populated. ((ChoiceGroup)menu.Tag).OnDisplay(null, null); foreach(CommandBarItem item in menu.Items) { if(item.Tag is ChoiceGroup) //submenu { ClickOnAllItems((CommandBarMenu)item); } else ((ChoiceBase)item.Tag).OnClick(null,null); } }
protected CommandBarItem GetMenuItem(CommandBarMenu menu, string id) { //need to simulate the user clicking on this in order to actually get populated. ((ChoiceGroup)menu.Tag).OnDisplay(null, null); foreach(CommandBarItem item in menu.Items) { if (((ChoiceRelatedClass)item.Tag).Id == id) return item; } //NO NO: this is not necessarily an error. remember, we are testing! // throw new ConfigurationException("could not find item '"+id +"'."); return null; }
private void SafeInit() { this.mainForm = this.pluginHost.MainForm; this.pluginUI = new PluginUI(); System.Drawing.Image image = this.mainForm.GetSystemImage(46); /** * Create panel */ this.pluginUI.Tag = "ActionScript"; this.pluginUI.Text = "ActionScript"; this.pluginPanel = mainForm.CreateDockingPanel(this.pluginUI, this.pluginGuid, image, DockState.DockRight); /** * Default shortcuts */ if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_CHECK)) { MainForm.MainSettings.AddValue(SETTING_SHORTCUT_CHECK, "F7"); } if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_BUILD)) { MainForm.MainSettings.AddValue(SETTING_SHORTCUT_BUILD, "CtrlF8"); } if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_GOTO)) { MainForm.MainSettings.AddValue(SETTING_SHORTCUT_GOTO, "F4"); } if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_BACK)) { MainForm.MainSettings.AddValue(SETTING_SHORTCUT_BACK, "ShiftF4"); } if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_CLEARCACHE)) { MainForm.MainSettings.AddValue(SETTING_SHORTCUT_CLEARCACHE, "CtrlF7"); } /** * Create menu items */ menuItems = new ArrayList(); CommandBarItem item; CommandBarMenu menu = mainForm.GetCBMenu("ViewMenu"); menu.Items.AddButton(image, "&ActionScript Panel", new EventHandler(this.OpenPanel)); Keys k; // tools items menu = this.mainForm.GetCBMenu("FlashToolsMenu"); if (menu != null) { menu.Items.AddSeparator(); // clear class cache k = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_CLEARCACHE); if (k != Keys.None) { this.mainForm.IgnoredKeys.Add(k); } else { ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_CLEARCACHE) + ")"); } menu.Items.AddButton("&Clear Class Cache", new EventHandler(this.ClearClassCache), k); // convert to intrinsic item = menu.Items.AddButton("Convert To &Intrinsic", new EventHandler(this.MakeIntrinsic)); menuItems.Add(item); // check actionscript image = this.pluginUI.treeIcons.Images[11]; k = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_CHECK); if (k != Keys.None) { this.mainForm.IgnoredKeys.Add(k); } else { ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_CHECK) + ")"); } item = menu.Items.AddButton(image, "Check &ActionScript", new EventHandler(this.CheckActionScript), k); menuItems.Add(item); // quick MTASC build image = this.pluginUI.treeIcons.Images[10]; k = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_BUILD); if (k != Keys.None) { this.mainForm.IgnoredKeys.Add(k); } else { ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_BUILD) + ")"); } item = menu.Items.AddButton(image, "&Quick Build", new EventHandler(this.QuickBuild), k); menuItems.Add(item); } else { ErrorHandler.ShowInfo("MainMenu Error: no 'FlashToolsMenu' group found"); } // toolbar items CommandBar toolbar = MainForm.GetCBToolbar(); if (toolbar != null) { toolbar.Items.AddSeparator(); // check image = this.pluginUI.treeIcons.Images[11]; item = toolbar.Items.AddButton(image, "Check ActionScript", new EventHandler(this.CheckActionScript)); menuItems.Add(item); // build image = this.pluginUI.treeIcons.Images[10]; item = toolbar.Items.AddButton(image, "Quick Build", new EventHandler(this.QuickBuild)); menuItems.Add(item); } // search items menu = this.mainForm.GetCBMenu("SearchMenu"); if (menu != null) { menu.Items.AddSeparator(); // goto back from declaration image = this.mainForm.GetSystemImage(18); k = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_BACK); if (k != Keys.None) { this.mainForm.IgnoredKeys.Add(k); } else { ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_BACK) + ")"); } item = menu.Items.AddButton(image, "&Back From Declaration", new EventHandler(this.BackDeclaration), k); menuItems.Add(item); // goto declaration image = this.mainForm.GetSystemImage(17); k = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_GOTO); if (k != Keys.None) { this.mainForm.IgnoredKeys.Add(k); } else { ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_GOTO) + ")"); } item = menu.Items.AddButton(image, "Goto &Declaration", new EventHandler(this.GotoDeclaration), k); menuItems.Add(item); } else { ErrorHandler.ShowInfo("MainMenu Error: no 'SearchMenu' group found"); } /** * Initialize completion context */ sciReferences = new ArrayList(); ASContext.Init(this); UITools.OnCharAdded += new UITools.CharAddedHandler(OnChar); InfoTip.OnMouseHover += new InfoTip.MouseHoverHandler(OnMouseHover); UITools.OnTextChanged += new UITools.TextChangedHandler(ASContext.OnTextChanged); InfoTip.OnUpdateCallTip += new InfoTip.UpdateCallTipHandler(OnUpdateCallTip); this.mainForm.IgnoredKeys.Add(Keys.Control | Keys.Enter); this.mainForm.IgnoredKeys.Add(Keys.F1); /** * Path to the Flash IDE */ if (!MainForm.MainSettings.HasKey(SETTING_MACROMEDIA_FLASHIDE)) { string found = ""; foreach (string flashexe in MACROMEDIA_FLASHIDE_PATH) { if (System.IO.File.Exists(flashexe)) { found = flashexe; break; } } MainForm.MainSettings.AddValue(SETTING_MACROMEDIA_FLASHIDE, found); } }
private void Initialize( Image image, string text, EventHandler clickHandler, Keys shortCut, string toolTip, int imageListIndex ) { m_imgIcon = image; m_strText = text; if( clickHandler != null ) { this.Click += clickHandler; } m_sCut = shortCut; m_strToolTip = toolTip; m_arrItems = new MenuItemExCollection(); m_mnuSubMenu = new CommandBarMenu( m_arrItems, true ); m_iImageIndex = imageListIndex; }