Ejemplo n.º 1
0
		public MenuSeparator(Codon codon, object caller, IEnumerable<ICondition> conditions)
		{
			this.RightToLeft = RightToLeft.Inherit;
			this.caller      = caller;
			this.codon       = codon;
			this.conditions  = conditions;
		}
Ejemplo n.º 2
0
		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);
		}
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
		public CommandWrapper(Codon codon, object caller, ICommand command)
		{
			this.codon = codon;
			this.caller = caller;
			this.addInCommand = command;
			commandCreated = true;
		}
Ejemplo n.º 5
0
		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);
 }
Ejemplo n.º 7
0
		public MenuCheckBox(Codon codon, object caller)
		{
			this.RightToLeft = RightToLeft.Inherit;
			this.caller = caller;
			this.codon  = codon;
			UpdateText();
		}
Ejemplo n.º 8
0
		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);
		}
Ejemplo n.º 9
0
		public MenuCheckBox(Codon codon, object caller, IEnumerable<ICondition> conditions)
		{
			this.RightToLeft = RightToLeft.Inherit;
			this.caller = caller;
			this.codon  = codon;
			this.conditions = conditions;
			UpdateText();
		}
Ejemplo n.º 10
0
        public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
        {
            ServerStartup server = new ServerStartup();

            server.Startup();

            return server;
        }
Ejemplo n.º 11
0
 public MenuCommand(string label)
 {
     this.RightToLeft = RightToLeft.Inherit;
     this.codon  = null;
     this.caller = null;
     Text = StringParser.Parse(label);
     this.conditions = Enumerable.Empty<ICondition>();
 }
Ejemplo n.º 12
0
		public ConditionalSeparator(Codon codon, object caller, bool inToolbar)
		{
			this.codon = codon;
			this.caller = caller;
			
			if (inToolbar) {
				SetResourceReference(FrameworkElement.StyleProperty, ToolBar.SeparatorStyleKey);
			}
		}
Ejemplo n.º 13
0
		public CommandWrapper(Codon codon, object caller, bool createCommand)
		{
			this.codon = codon;
			this.caller = caller;
			if (createCommand) {
				commandCreated = true;
				CreateCommand();
			}
		}
Ejemplo n.º 14
0
        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();
        }
Ejemplo n.º 15
0
		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;
		}
Ejemplo n.º 16
0
        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();
        }
Ejemplo n.º 17
0
		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);
		}
Ejemplo n.º 18
0
        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;
        }
Ejemplo n.º 19
0
		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();
			}
		}
Ejemplo n.º 20
0
		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);
			}
		}
Ejemplo n.º 21
0
        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;
        }
Ejemplo n.º 22
0
		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();
		}
Ejemplo n.º 23
0
		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();
		}
Ejemplo n.º 24
0
		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();
        }
Ejemplo n.º 27
0
		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();
        }
Ejemplo n.º 29
0
		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);
		}
Ejemplo n.º 30
0
        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();
        }
Ejemplo n.º 31
0
 public FontFamilyChooser(Codon codon, object caller, IEnumerable <ICondition> conditions) : base(codon, caller, conditions)
 {
 }
Ejemplo n.º 32
0
 public MenuSeparator(Codon codon, object caller)
 {
     //this.RightToLeft = RightToLeft.Inherit;
     this.caller = caller;
     this.codon  = codon;
 }
Ejemplo n.º 33
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(Path.Combine(Path.GetDirectoryName(codon.AddIn.FileName), codon.Properties["path"]));
 }
Ejemplo n.º 34
0
 public MenuCommand(Codon codon, object caller, IEnumerable <ICondition> conditions)
     : this(codon, caller, false, conditions)
 {
 }
Ejemplo n.º 35
0
 public MenuTrackBarCommand(Codon codon, object caller)
     : this(codon, caller, false)
 {
     base.Edit = this.repositoryItemTrackBar;
 }
Ejemplo n.º 36
0
        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"])));
 }
Ejemplo n.º 38
0
 public System.Collections.ICollection BuildItems(Codon codon, object owner)
 {
     return(BuildSubmenu(codon, owner).TranslateToWpf());
 }
Ejemplo n.º 39
0
 public LazyCodeCompletionBinding(Codon codon, string[] extensions)
 {
     this.codon      = codon;
     this.extensions = extensions;
 }
Ejemplo n.º 40
0
        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);
        }
Ejemplo n.º 41
0
        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);
        }
Ejemplo n.º 42
0
        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));
 }
Ejemplo n.º 44
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(new DebuggerDescriptor(codon));
 }
Ejemplo n.º 45
0
        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();
        }
Ejemplo n.º 46
0
 public MenuItemBuilderPlaceholder(IMenuItemBuilder builder, Codon codon, object caller)
 {
     this.builder = builder;
     this.codon   = codon;
     this.caller  = caller;
 }
Ejemplo n.º 47
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(new SchemeExtensionDescriptor(codon));
 }
Ejemplo n.º 48
0
 public TaskBoundLoggerFilterDescriptor(Codon codon)
 {
     classname = codon.Properties["class"];
     taskname  = codon.Properties["taskname"];
     addIn     = codon.AddIn;
 }
Ejemplo n.º 49
0
 /// <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));
        }
Ejemplo n.º 51
0
 public MenuCommand(Codon codon, object caller) : this(codon, caller, false)
 {
 }
Ejemplo n.º 52
0
 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());
            }
        }
Ejemplo n.º 54
0
 public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
 {
     return(new TaskBoundAdditionalLoggerDescriptor(codon));
 }
Ejemplo n.º 55
0
 public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
 {
     return(new DockPanelDescriptor(caller, codon));
 }
Ejemplo n.º 56
0
 public ParserDescriptor(Codon codon)
 {
     this.codon = codon;
 }
Ejemplo n.º 57
0
 public MenuButtonCommand(string label)
 {
     this.codon   = null;
     this.caller  = null;
     this.Caption = StringParser.Parse(label);
 }
Ejemplo n.º 58
0
 public DockPanelDescriptor(object caller, Codon codon)
 {
     Caller = caller;
     Codon  = codon;
 }
Ejemplo n.º 59
0
 /// <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));
 }
Ejemplo n.º 60
0
 public DebuggerDescriptor(Codon codon)
 {
     this.codon = codon;
 }