public MenuSeparator(Codon codon, object caller, IEnumerable<ICondition> conditions) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; this.conditions = conditions; }
public ToolBarButton(UIElement inputBindingOwner, Codon codon, object caller, bool createCommand, IReadOnlyCollection<ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; if (createCommand) this.Command = CommandWrapper.CreateCommand(codon, conditions); else this.Command = CommandWrapper.CreateLazyCommand(codon, conditions); this.CommandParameter = caller; this.Content = ToolBarService.CreateToolBarItemContent(codon); this.conditions = conditions; if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); MenuCommand.AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName()); this.inputGestureText = MenuService.GetDisplayStringForShortcut(kg); } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ButtonStyleKey); }
public ToolBarSplitButton(Codon codon, object caller, ArrayList subItems, IEnumerable<ICondition> conditions) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; this.subItems = subItems; this.conditions = conditions; if (codon.Properties.Contains("label")){ Text = StringParser.Parse(codon.Properties["label"]); } if (imgButtonEnabled == null && codon.Properties.Contains("icon")) { imgButtonEnabled = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["icon"])); } if (imgButtonDisabled == null && codon.Properties.Contains("disabledIcon")) { imgButtonDisabled = WinFormsResourceService.GetBitmap(StringParser.Parse(codon.Properties["disabledIcon"])); } if (imgButtonDisabled == null) { imgButtonDisabled = imgButtonEnabled; } menuCommand = codon.AddIn.CreateObject(codon.Properties["class"]) as ICommand; menuCommand.Owner = this; UpdateStatus(); UpdateText(); }
public CommandWrapper(Codon codon, object caller, ICommand command) { this.codon = codon; this.caller = caller; this.addInCommand = command; commandCreated = true; }
public ToolBarCheckBox(Codon codon, object caller) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.Command = CommandWrapper.GetCommand(codon, caller, true); CommandWrapper wrapper = this.Command as CommandWrapper; if (wrapper != null) { ICheckableMenuCommand cmd = wrapper.GetAddInCommand() as ICheckableMenuCommand; if (cmd != null) { isCheckedBinding = SetBinding(IsCheckedProperty, new Binding("IsChecked") { Source = cmd, Mode = BindingMode.OneWay }); } } if (codon.Properties.Contains("icon")) { var image = PresentationResourceService.GetImage(StringParser.Parse(codon.Properties["icon"])); image.Height = 16; image.SetResourceReference(StyleProperty, ToolBarService.ImageStyleKey); this.Content = image; } else { this.Content = codon.Id; } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.CheckBoxStyleKey); }
public MenuCommand(string label) { this.RightToLeft = RightToLeft.Inherit; this.codon = null; this.caller = null; Text = StringParser.Parse(label); }
public MenuCheckBox(Codon codon, object caller) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; UpdateText(); }
public ToolBarCheckBox(Codon codon, object caller, IEnumerable<ICondition> conditions) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.conditions = conditions; this.Command = CommandWrapper.GetCommand(codon, caller, true, conditions); CommandWrapper wrapper = this.Command as CommandWrapper; if (wrapper != null) { ICheckableMenuCommand cmd = wrapper.GetAddInCommand() as ICheckableMenuCommand; if (cmd != null) { #if ModifiedForAltaxo isCheckedBinding = SetBinding(IsCheckedProperty, new Binding("IsChecked") { Source = cmd, Mode = BindingMode.TwoWay }); #else isCheckedBinding = SetBinding(IsCheckedProperty, new Binding("IsChecked") { Source = cmd, Mode = BindingMode.OneWay }); #endif } } this.Content = ToolBarService.CreateToolBarItemContent(codon); if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.CheckBoxStyleKey); }
public MenuCheckBox(Codon codon, object caller, IEnumerable<ICondition> conditions) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; this.conditions = conditions; UpdateText(); }
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { ServerStartup server = new ServerStartup(); server.Startup(); return server; }
public MenuCommand(string label) { this.RightToLeft = RightToLeft.Inherit; this.codon = null; this.caller = null; Text = StringParser.Parse(label); this.conditions = Enumerable.Empty<ICondition>(); }
public ConditionalSeparator(Codon codon, object caller, bool inToolbar) { this.codon = codon; this.caller = caller; if (inToolbar) { SetResourceReference(FrameworkElement.StyleProperty, ToolBar.SeparatorStyleKey); } }
public CommandWrapper(Codon codon, object caller, bool createCommand) { this.codon = codon; this.caller = caller; if (createCommand) { commandCreated = true; CreateCommand(); } }
public Menu(Codon codon, object caller, IList subItems) { if (subItems == null) subItems = new ArrayList(); // don't crash when item has no children this.codon = codon; this.caller = caller; this.subItems = subItems; this.RightToLeft = RightToLeft.Inherit; UpdateText(); }
public CommandWrapper(Codon codon, object caller, ICommand command, IEnumerable<ICondition> conditions) { if (conditions == null) throw new ArgumentNullException("conditions"); this.codon = codon; this.caller = caller; this.addInCommand = command; this.conditions = conditions; commandCreated = true; }
public MenuCommand(Codon codon, object caller, IReadOnlyCollection<ICondition> conditions) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; this.conditions = conditions; this.command = CommandWrapper.CreateLazyCommand(codon, conditions); UpdateText(); }
public ToolBarComboBox(Codon codon, object caller) { if (codon == null) throw new ArgumentNullException("codon"); this.IsEditable = false; menuCommand = (IComboBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]); menuCommand.ComboBox = this; menuCommand.Owner = caller; SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ComboBoxStyleKey); }
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { IMsgReceiver receiver = MsgMonitor.GetReceiver(codon.ID); if (receiver == null) { receiver = new GameConnecter(codon.ID); } return receiver; }
public CommandWrapper(Codon codon, object caller, bool createCommand, IEnumerable<ICondition> conditions) { if (conditions == null) throw new ArgumentNullException("conditions"); this.codon = codon; this.caller = caller; this.conditions = conditions; if (createCommand) { commandCreated = true; CreateCommand(); } }
public MenuCommand(UIElement inputBindingOwner, Codon codon, object caller, string activationMethod, IReadOnlyCollection<ICondition> conditions) : base(codon, caller, conditions) { this.ActivationMethod = activationMethod; this.Command = CommandWrapper.CreateLazyCommand(codon, conditions); this.CommandParameter = caller; if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); AddGestureToInputBindingOwner(inputBindingOwner, kg, this.Command, GetFeatureName()); this.InputGestureText = MenuService.GetDisplayStringForShortcut(kg); } }
internal static object CreateToolBarItemContent(Codon codon) { object result = null; Image image = null; Label label = null; bool isImage = false; bool isLabel = false; if (codon.Properties.Contains("icon")) { image = new Image(); image.Source = PresentationResourceService.GetBitmapSource(StringParser.Parse(codon.Properties["icon"])); image.Height = 16; image.SetResourceReference(FrameworkElement.StyleProperty, ToolBarService.ImageStyleKey); isImage = true; } if (codon.Properties.Contains("label")) { label = new Label(); label.Content = StringParser.Parse(codon.Properties["label"]); label.Padding = new Thickness(0); label.VerticalContentAlignment = VerticalAlignment.Center; isLabel = true; } if (isImage && isLabel) { StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; image.Margin = new Thickness(0, 0, 5, 0); panel.Children.Add(image); panel.Children.Add(label); result = panel; } else if (isImage) { result = image; } else if (isLabel) { result = label; } else { result = codon.Id; } return result; }
public CoreMenuItem(Codon codon, object caller) { this.codon = codon; this.caller = caller; if (codon.Properties.Contains("icon")) { try { var image = PresentationResourceService.GetImage(codon.Properties["icon"]); image.Height = 16; this.Icon = image; } catch (ResourceNotFoundException) {} } UpdateText(); }
public ToolBarDropDownButton(Codon codon, object caller, IList subMenu) { ToolTipService.SetShowOnDisabled(this, true); this.codon = codon; this.caller = caller; this.Content = ToolBarService.CreateToolBarItemContent(codon); if (codon.Properties.Contains("name")) { this.Name = codon.Properties["name"]; } this.DropDownMenu = MenuService.CreateContextMenu(subMenu); UpdateText(); }
public ToolBarLabel(Codon codon, object caller, IEnumerable<ICondition> conditions) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; this.conditions = conditions; if (codon.Properties.Contains("class")) { menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]); } UpdateText(); UpdateStatus(); }
public MenuCommand(Codon codon, object caller, bool createCommand) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; if (createCommand) { CreateCommand(); } UpdateText(); if (codon.Properties.Contains("shortcut")) { ShortcutKeys = ParseShortcut(codon.Properties["shortcut"]); } }
public ToolBarLabel(Codon codon, object caller) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; if (codon.Properties.Contains("class")) { menuCommand = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]); menuCommand.Owner = this; } UpdateText(); UpdateStatus(); }
public static System.Windows.Input.ICommand GetCommand(Codon codon, object caller, bool createCommand) { string commandName = codon.Properties["command"]; if (!string.IsNullOrEmpty(commandName)) { var wpfCommand = MenuService.GetRegisteredCommand(codon.AddIn, commandName); if (wpfCommand != null) { return wpfCommand; } else { MessageService.ShowError("Could not find WPF command '" + commandName + "'."); // return dummy command return new CommandWrapper(codon, caller, null); } } return new CommandWrapper(codon, caller, createCommand); }
public ToolBarTextBox(Codon codon, object caller) { this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; TextBox.KeyDown += new KeyEventHandler(TextBox_KeyDown); menuCommand = (ITextBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]); menuCommand.Owner = this; if (menuCommand == null) { throw new NullReferenceException("Can't create textbox toolbox command"); } UpdateText(); UpdateStatus(); }
public ToolBarComboBox(Codon codon, object caller, IEnumerable<ICondition> conditions) { if (codon == null) throw new ArgumentNullException("codon"); this.codon = codon; this.caller = caller; this.conditions = conditions; ToolTipService.SetShowOnDisabled(this, true); this.IsEditable = false; menuCommand = (IComboBoxCommand)codon.AddIn.CreateObject(codon.Properties["class"]); menuCommand.ComboBox = this; menuCommand.Owner = caller; UpdateText(); SetResourceReference(FrameworkElement.StyleProperty, ToolBar.ComboBoxStyleKey); }
public CoreMenuItem(Codon codon, object caller, IReadOnlyCollection<ICondition> conditions) { this.codon = codon; this.caller = caller; this.conditions = conditions; if (codon.Properties.Contains("icon")) { try { var image = new Image(); image.Source = PresentationResourceService.GetBitmapSource(codon.Properties["icon"]); image.Height = 16; this.Icon = image; } catch (ResourceNotFoundException) {} } UpdateText(); }
public FontFamilyChooser(Codon codon, object caller, IEnumerable <ICondition> conditions) : base(codon, caller, conditions) { }
public MenuSeparator(Codon codon, object caller) { //this.RightToLeft = RightToLeft.Inherit; this.caller = caller; this.codon = codon; }
public object BuildItem(object caller, Codon codon, ArrayList subItems) { return(Path.Combine(Path.GetDirectoryName(codon.AddIn.FileName), codon.Properties["path"])); }
public MenuCommand(Codon codon, object caller, IEnumerable <ICondition> conditions) : this(codon, caller, false, conditions) { }
public MenuTrackBarCommand(Codon codon, object caller) : this(codon, caller, false) { base.Edit = this.repositoryItemTrackBar; }
static object CreateMenuItemFromDescriptor(MenuItemDescriptor descriptor, string addinTreePath, ICommandRegister register) { Codon codon = descriptor.Codon; string cmdPath = addinTreePath + "/" + codon.Id; string builderid = string.Empty; if (codon.Properties.Contains("builderid")) { builderid = codon.Properties["builderid"]; } else if (codon.Properties.Contains("cmdId")) { string cmdId = codon.Properties["cmdId"]; return(register.GetBarItem(cmdId)); } else { throw new Exception(string.Format("BuiderID not found:codonid ={0},condonname = {1}", codon.Id, codon.Name)); } if (builderid == string.Empty) { throw new Exception(string.Format("BuiderID is empty:codonid ={0},condonname = {1}", codon.Id, codon.Name)); } IPartBuilder builder = RibbonBuilderManager.GetBuider(builderid); object obj = builder.Build(codon, descriptor.Caller, descriptor.Conditions);; try { if (obj is BarButtonItemEx) { BarItem cmdBar = obj as BarItem; string formats = "<MenuItem id ={0} checkForViewId =\"\" source =\"Ribbon\" cmdPath =\"{1}\"/>"; System.Diagnostics.Debug.WriteLine(string.Format(formats, codon.Id, cmdPath)); if (register != null) { //ICommand command = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]); //command.Owner = register.owner; ICommand command = cmdBar.Tag as ICommand; if (command != null) { if (string.IsNullOrEmpty(codon.Properties["groupName"])) { bool registerSuc = register.RegisterCommand(cmdBar, cmdPath, command, descriptor.Conditions); } else { string groupName = codon.Properties["groupName"]; bool registerSuc = register.RegisterCommand(cmdBar, codon.Id, cmdPath, command, groupName); } } //Debug.WriteLine("Register =" + registerSuc.ToString()); } } } catch (Exception ex) { throw ex; } return(obj); }
/// <summary> /// Creates an item with the specified sub items. And the current /// Condition status for this item. /// </summary> public object BuildItem(object caller, Codon codon, ArrayList subItems) { return(new FiletypeAssociation(codon.Id, StringParser.Parse(codon.Properties["icon"]), StringParser.Parse(codon.Properties["text"]))); }
public System.Collections.ICollection BuildItems(Codon codon, object owner) { return(BuildSubmenu(codon, owner).TranslateToWpf()); }
public LazyCodeCompletionBinding(Codon codon, string[] extensions) { this.codon = codon; this.extensions = extensions; }
private static List <SearchItem> HandleMenuCodon(SearchPathDescriptor descriptor, Codon codon, string path, List <string> pathChain) { List <SearchItem> result = new List <SearchItem>(); if (codon.Name != "MenuItem") { return(result); } List <string> nextPathChain = new List <string>(pathChain); string nextPath = string.Format("{0}/{1}", path, codon.Id); if (codon.Properties.Contains("type") && codon.Properties["type"] == "Menu") { nextPathChain.Add(AddNextPathChainString(codon)); if (AddInTree.ExistsTreeNode(nextPath)) { AddInTreeNode node = AddInTree.GetTreeNode(nextPath); foreach (Codon innerCodon in node.Codons) { result.AddRange(HandleMenuCodon(descriptor, innerCodon, nextPath, nextPathChain)); } } } if (!codon.Properties.Contains("type") || (codon.Properties.Contains("type") && (codon.Properties["type"] == "Item" || codon.Properties["type"] == "Command"))) { HandleItemMenuType(descriptor, codon, nextPath, nextPathChain, result); } if (codon.Properties.Contains("type") && codon.Properties["type"] == "Builder") { try { IMenuItemBuilder builder = codon.AddIn.CreateObject(codon.Properties["class"]) as IMenuItemBuilder; if (builder == null) { return(result); } ICollection collection = builder.BuildItems(codon, null); foreach (MenuItem menuItem in collection) { SearchItem item = GenerateSearchItem(descriptor, codon, nextPath, nextPathChain); item.Label = menuItem.Header.ToString(); item.Command = menuItem.Command; item.CommandParameter = menuItem.CommandParameter; item.Shortcut = menuItem.InputGestureText; if (String.IsNullOrWhiteSpace(item.CommandTypeString) && item.Command == null) { continue; } item.Id = path + "/" + item.Label; result.Add(item); } } catch (Exception ex) { LoggingService.Warn(String.Format("Could not load search item from builder at {0} - {1}", codon.Id, codon.AddIn.FileName), ex); } } return(result); }
private static SearchItem GenerateSearchItem(SearchPathDescriptor descriptor, Codon codon, string path, List <string> nextPathChain) { SearchItem item = new SearchItem(); item.Codon = codon; string commandName = codon.Properties["command"]; if (!string.IsNullOrEmpty(commandName)) { item.Command = MenuService.GetRegisteredCommand(codon.AddIn, commandName); } item.PathChain.AddRange(nextPathChain); item.Category = descriptor.Category; item.Id = path; return(item); }
public ToolStripItem[] BuildSubmenu(Codon codon, object owner) { MenuCommand cmd; IClass c; ClassNode classNode = owner as ClassNode; if (classNode != null) { c = classNode.Class; } else { ClassBookmark bookmark = (ClassBookmark)owner; c = bookmark.Class; } ParserService.ParseCurrentViewContent(); c = c.ProjectContent.GetClass(c.FullyQualifiedName, c.TypeParameters.Count); if (c == null) { return(new ToolStripMenuItem[0]); } LanguageProperties language = c.ProjectContent.Language; List <ToolStripItem> list = new List <ToolStripItem>(); if (!FindReferencesAndRenameHelper.IsReadOnly(c)) { if (c.DeclaringType == null && !c.BodyRegion.IsEmpty && !c.Name.Equals(Path.GetFileNameWithoutExtension(c.CompilationUnit.FileName), StringComparison.InvariantCultureIgnoreCase)) { // File name does not match class name string correctFileName = Path.Combine(Path.GetDirectoryName(c.CompilationUnit.FileName), c.Name + Path.GetExtension(c.CompilationUnit.FileName)); if (FileUtility.IsValidFileName(correctFileName) && Path.IsPathRooted(correctFileName) && !File.Exists(correctFileName)) { if (c.CompilationUnit.Classes.Count == 1) { // Rename file to ## cmd = new MenuCommand(StringParser.Parse("${res:SharpDevelop.Refactoring.RenameFileTo}", new string[, ] { { "FileName", Path.GetFileName(correctFileName) } }), delegate { FileService.RenameFile(c.CompilationUnit.FileName, correctFileName, false); if (c.ProjectContent.Project != null) { ((IProject)c.ProjectContent.Project).Save(); } }); list.Add(cmd); } else if (language.RefactoringProvider.SupportsCreateNewFileLikeExisting && language.RefactoringProvider.SupportsGetFullCodeRangeForType) { // Move class to file ## cmd = new MenuCommand(StringParser.Parse("${res:SharpDevelop.Refactoring.MoveClassToFile}", new string[, ] { { "FileName", Path.GetFileName(correctFileName) } }), delegate { MoveClassToFile(c, correctFileName); }); list.Add(cmd); } } } cmd = new MenuCommand("${res:SharpDevelop.Refactoring.RenameCommand}", Rename); cmd.Tag = c; list.Add(cmd); } if (c.BaseTypes.Count > 0) { cmd = new MenuCommand("${res:SharpDevelop.Refactoring.GoToBaseCommand}", GoToBase); cmd.Tag = c; list.Add(cmd); if (c.ClassType != ClassType.Interface && !FindReferencesAndRenameHelper.IsReadOnly(c)) { AddImplementInterfaceCommands(c, list); } } if (!c.IsSealed && !c.IsStatic) { cmd = new MenuCommand("${res:SharpDevelop.Refactoring.FindDerivedClassesCommand}", FindDerivedClasses); cmd.Tag = c; list.Add(cmd); } cmd = new MenuCommand("${res:SharpDevelop.Refactoring.FindReferencesCommand}", FindReferences); cmd.Tag = c; list.Add(cmd); return(list.ToArray()); }
/// <summary> /// Creates an item with the specified sub items. And the current /// Condition status for this item. /// </summary> public object BuildItem(object caller, Codon codon, ArrayList subItems) { return(new DisplayBindingDescriptor(codon)); }
public object BuildItem(object caller, Codon codon, ArrayList subItems) { return(new DebuggerDescriptor(codon)); }
public static void CreateTemplatedToolBarItem(Control control, Codon codon) { if (codon.Properties.Contains("template")) { ControlTemplate customTemplate = (ControlTemplate)Application .Current .TryFindResource(codon.Properties["template"]); if (customTemplate != null) { control.Template = customTemplate; control.ApplyTemplate(); } } else { if (codon.Properties.Contains("packIconKey")) { string[] packIconValues = codon.Properties["packIconKey"].Split(';'); string packIconType = packIconValues[0]; string packIconKind = packIconValues[1]; //PackIconBase icon = null; object Icon = null; switch (packIconType) { case "PackIconMaterial": var icon = new PackIconMaterial(); ((PackIconMaterial)icon).Kind = (PackIconMaterialKind)Enum .Parse(typeof(PackIconMaterialKind), packIconKind); Icon = icon; break; case "PackIconMaterialLight": var icon1 = new PackIconMaterialLight(); ((PackIconMaterialLight)icon1).Kind = (PackIconMaterialLightKind)Enum .Parse(typeof(PackIconMaterialLightKind), packIconKind); Icon = icon1; break; case "PackIconModern": var icon2 = new PackIconModern(); ((PackIconModern)icon2).Kind = (PackIconModernKind)Enum .Parse(typeof(PackIconModernKind), packIconKind); Icon = icon2; break; case "PackIconOcticons": var icon3 = new PackIconOcticons(); ((PackIconOcticons)icon3).Kind = (PackIconOcticonsKind)Enum .Parse(typeof(PackIconOcticonsKind), packIconKind); Icon = icon3; break; case "PackIconSimpleIcons": var icon4 = new PackIconSimpleIcons(); ((PackIconSimpleIcons)icon4).Kind = (PackIconSimpleIconsKind)Enum .Parse(typeof(PackIconSimpleIconsKind), packIconKind); Icon = icon4; break; case "PackIconEntypo": var icon5 = new PackIconEntypo(); ((PackIconEntypo)icon5).Kind = (PackIconEntypoKind)Enum .Parse(typeof(PackIconEntypoKind), packIconKind); Icon = icon5; break; case "PackIconFontAwesome": var icon6 = new PackIconFontAwesome(); ((PackIconFontAwesome)icon6).Kind = (PackIconFontAwesomeKind)Enum .Parse(typeof(PackIconFontAwesomeKind), packIconKind); Icon = icon6; break; } if (control is MenuItem) { (control as MenuItem).Header = Icon; } else if (control is MahApps.Metro.Controls.DropDownButton) { (control as MahApps.Metro.Controls.DropDownButton).Content = Icon; } else if (control is MahApps.Metro.Controls.SplitButton) { (control as MahApps.Metro.Controls.SplitButton).Icon = Icon; } else { (control as ContentControl).Content = Icon; } } if (codon.Properties.Contains("icon")) { Image image = new Image(); image.Source = PresentationResourceService.GetBitmapSource(StringParser.Parse(codon.Properties["icon"])); image.Height = 16; image.SetResourceReference(FrameworkElement.StyleProperty, ToolBarService.ImageStyleKey); if (control is MenuItem) { (control as MenuItem).Header = image; } else if (control is MahApps.Metro.Controls.DropDownButton) { (control as MahApps.Metro.Controls.DropDownButton).Content = image; } else if (control is MahApps.Metro.Controls.SplitButton) { (control as MahApps.Metro.Controls.SplitButton).Icon = image; } else { (control as ContentControl).Content = image; } } if (codon.Properties.Contains("label")) { Label label = new Label(); label.Content = StringParser.Parse(codon.Properties["label"]); label.Padding = new Thickness(0); label.VerticalContentAlignment = VerticalAlignment.Center; if (control is MenuItem) { (control as MenuItem).Header = label; } else if (control is MahApps.Metro.Controls.DropDownButton) { (control as MahApps.Metro.Controls.DropDownButton).Content = label; } else if (control is MahApps.Metro.Controls.SplitButton) { (control as MahApps.Metro.Controls.SplitButton).Icon = label; } else { (control as ContentControl).Content = label; } } } if (codon.Properties.Contains("style")) { Style customStyle = Application.Current.TryFindResource(codon.Properties["style"]) as Style; if (customStyle != null) { control.Style = customStyle; } } else { if (control is MenuItem) { Style menuStyle = Application.Current.TryFindResource("MaterialDesignMenuItem") as Style; if (menuStyle != null) { control.Style = menuStyle; } } else if (control is MahApps.Metro.Controls.DropDownButton) { Style btnStyle = new Style(); Setter fg = new Setter(); Setter bg = new Setter(); // Style btnStyle = Application.Current.TryFindResource("MaterialDesignToolForegroundButton") as Style; bg.Property = MahApps.Metro.Controls.DropDownButton.BackgroundProperty; bg.Value = (Brush)Application.Current.TryFindResource("MaterialDesignPaper"); fg.Property = MahApps.Metro.Controls.DropDownButton.ForegroundProperty; fg.Value = (Brush)Application.Current.TryFindResource("MaterialDesignBody"); btnStyle.Setters.Add(bg); btnStyle.Setters.Add(fg); if (btnStyle != null) { (control as MahApps.Metro.Controls.DropDownButton).ButtonStyle = btnStyle; } Style menuStyle = Application.Current.TryFindResource("MaterialDesignContextMenu") as Style; if (menuStyle != null) { (control as MahApps.Metro.Controls.DropDownButton).MenuStyle = menuStyle; } } else if (control is MahApps.Metro.Controls.SplitButton) { Style lbStyle = Application.Current.TryFindResource("MaterialDesignListBox") as Style; if (lbStyle != null) { (control as MahApps.Metro.Controls.SplitButton).ListBoxStyle = lbStyle; } } else { TryApplyMaterialStyle((control as ContentControl)); } } control.ApplyTemplate(); }
public MenuItemBuilderPlaceholder(IMenuItemBuilder builder, Codon codon, object caller) { this.builder = builder; this.codon = codon; this.caller = caller; }
public object BuildItem(object caller, Codon codon, ArrayList subItems) { return(new SchemeExtensionDescriptor(codon)); }
public TaskBoundLoggerFilterDescriptor(Codon codon) { classname = codon.Properties["class"]; taskname = codon.Properties["taskname"]; addIn = codon.AddIn; }
/// <summary> /// Creates an item with the specified sub items. And the current /// Condition status for this item. /// </summary> public object BuildItem(object caller, Codon codon, ArrayList subItems) { return(new ProjectContentRegistryDescriptor(codon)); }
public IEnumerable <object> BuildItems(Codon codon, object parameter) { StringCollection allowedChildElements = GetAllowedChildElements(parameter); return(CreateMenuItems(allowedChildElements)); }
public MenuCommand(Codon codon, object caller) : this(codon, caller, false) { }
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { return(codon.AddIn.CreateObject(codon.Properties["class"])); }
public ToolStripItem[] BuildSubmenu(Codon codon, object owner) { ToolStripMenuItem item; TextEditorControl textEditorControl = (TextEditorControl)owner; if (textEditorControl.FileName == null) { return(new ToolStripItem[0]); } List <ToolStripItem> resultItems = new List <ToolStripItem>(); TextArea textArea = textEditorControl.ActiveTextAreaControl.TextArea; IDocument doc = textArea.Document; int caretLine = textArea.Caret.Line; // list of dotnet names that have definition bookmarks in this line List <string> definitions = new List <string>(); // Include definitions (use the bookmarks which should already be present) // we need to use .ToArray() because the bookmarks might change during enumeration: // building member/class submenus can cause reparsing the current file, which might change // the available bookmarks foreach (Bookmark mark in doc.BookmarkManager.Marks.ToArray()) { if (mark != null && mark.LineNumber == caretLine) { ClassMemberBookmark cmb = mark as ClassMemberBookmark; ClassBookmark cb = mark as ClassBookmark; IClass type = null; if (cmb != null) { definitions.Add(cmb.Member.DotNetName); item = new ToolStripMenuItem(MemberNode.GetText(cmb.Member), ClassBrowserIconService.ImageList.Images[cmb.IconIndex]); MenuService.AddItemsToMenu(item.DropDown.Items, mark, ClassMemberBookmark.ContextMenuPath); resultItems.Add(item); type = cmb.Member.DeclaringType; } else if (cb != null) { type = cb.Class; } if (type != null) { definitions.Add(type.DotNetName); item = new ToolStripMenuItem(ClassNode.GetText(type), ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.GetIcon(type)]); MenuService.AddItemsToMenu(item.DropDown.Items, cb ?? new ClassBookmark(textArea.Document, type), ClassBookmark.ContextMenuPath); resultItems.Add(item); } } } // Include menu for member that has been clicked on IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(textEditorControl.FileName); ExpressionResult expressionResult; ResolveResult rr; int insertIndex = resultItems.Count; // Insert items at this position to get the outermost expression first, followed by the inner expressions (if any). expressionResult = FindFullExpressionAtCaret(textArea, expressionFinder); repeatResolve: rr = ResolveExpressionAtCaret(textArea, expressionResult); RefactoringMenuContext context = new RefactoringMenuContext { TextArea = textArea, ResolveResult = rr, ExpressionResult = expressionResult }; item = null; if (rr is MethodGroupResolveResult) { item = MakeItem(definitions, ((MethodGroupResolveResult)rr).GetMethodIfSingleOverload()); } else if (rr is MemberResolveResult) { MemberResolveResult mrr = (MemberResolveResult)rr; item = MakeItem(definitions, mrr.ResolvedMember); if (RefactoringService.FixIndexerExpression(expressionFinder, ref expressionResult, mrr)) { if (item != null) { resultItems.Insert(insertIndex, item); } // Include menu for the underlying expression of the // indexer expression as well. goto repeatResolve; } } else if (rr is TypeResolveResult) { item = MakeItem(definitions, ((TypeResolveResult)rr).ResolvedClass); } else if (rr is LocalResolveResult) { context.IsDefinition = caretLine + 1 == ((LocalResolveResult)rr).VariableDefinitionRegion.BeginLine; item = MakeItem((LocalResolveResult)rr, context); insertIndex = 0; // Insert local variable menu item at the topmost position. } else if (rr is UnknownIdentifierResolveResult) { item = MakeItemForResolveError((UnknownIdentifierResolveResult)rr, expressionResult.Context, textArea); insertIndex = 0; // Insert menu item at the topmost position. } else if (rr is UnknownConstructorCallResolveResult) { item = MakeItemForResolveError((UnknownConstructorCallResolveResult)rr, expressionResult.Context, textArea); insertIndex = 0; // Insert menu item at the topmost position. } if (item != null) { resultItems.Insert(insertIndex, item); } // Include menu for current class and method ICompilationUnit cu = null; IMember callingMember = null; if (rr != null && rr.CallingMember != null) { callingMember = rr.CallingMember; } else { ParseInformation parseInfo = ParserService.GetParseInformation(textEditorControl.FileName); if (parseInfo != null) { cu = parseInfo.MostRecentCompilationUnit; if (cu != null) { IClass callingClass = cu.GetInnermostClass(caretLine + 1, textArea.Caret.Column + 1); callingMember = GetCallingMember(callingClass, caretLine + 1, textArea.Caret.Column + 1); } } } if (callingMember != null) { item = MakeItem(definitions, callingMember); if (item != null) { item.Text = StringParser.Parse("${res:SharpDevelop.Refactoring.CurrentMethod}: ") + callingMember.Name; resultItems.Add(item); } } if (resultItems.Count == 0) { return(new ToolStripItem[0]); } else { resultItems.Add(new MenuSeparator()); return(resultItems.ToArray()); } }
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { return(new TaskBoundAdditionalLoggerDescriptor(codon)); }
public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { return(new DockPanelDescriptor(caller, codon)); }
public ParserDescriptor(Codon codon) { this.codon = codon; }
public MenuButtonCommand(string label) { this.codon = null; this.caller = null; this.Caption = StringParser.Parse(label); }
public DockPanelDescriptor(object caller, Codon codon) { Caller = caller; Codon = codon; }
/// <summary> /// Creates an item with the specified sub items. And the current /// Condition status for this item. /// </summary> public object BuildItem(object caller, Codon codon, ArrayList subItems) { return(new CustomToolDescriptor(codon.Id, codon.Properties["fileNamePattern"], codon.Properties["class"], codon.AddIn)); }
public DebuggerDescriptor(Codon codon) { this.codon = codon; }