Represents a node in the add in tree that can produce an item.
Beispiel #1
0
		public SchemeExtensionDescriptor(Codon codon)
		{
			this.codon = codon;
			schemeName = codon.Properties["scheme"];
			if (schemeName == null || schemeName.Length == 0)
				schemeName = codon.Id;
		}
		public DisplayBindingDescriptor(Codon codon)
		{
			isSecondary = codon.Properties["type"] == "Secondary";
			if (!isSecondary && codon.Properties["type"] != "" && codon.Properties["type"] != "Primary")
				MessageService.ShowWarning("Unknown display binding type: " + codon.Properties["type"]);
			this.codon = codon;
		}
Beispiel #3
0
		void DoSetUp(XmlReader reader, string endElement)
		{
			Stack<ICondition> conditionStack = new Stack<ICondition>();
			List<Codon> innerCodons = new List<Codon>();
			while (reader.Read()) {
				switch (reader.NodeType) {
					case XmlNodeType.EndElement:
						if (reader.LocalName == "Condition" || reader.LocalName == "ComplexCondition") {
							conditionStack.Pop();
						} else if (reader.LocalName == endElement) {
							if (innerCodons.Count > 0)
								this.codons.Add(innerCodons);
							return;
						}
						break;
					case XmlNodeType.Element:
						string elementName = reader.LocalName;
						if (elementName == "Condition") {
							conditionStack.Push(Condition.Read(reader));
						} else if (elementName == "ComplexCondition") {
							conditionStack.Push(Condition.ReadComplexCondition(reader));
						} else {
							Codon newCodon = new Codon(this.AddIn, elementName, Properties.ReadFromAttributes(reader), conditionStack.ToArray());
							innerCodons.Add(newCodon);
							if (!reader.IsEmptyElement) {
								ExtensionPath subPath = this.AddIn.GetExtensionPath(this.Name + "/" + newCodon.Id);
								subPath.DoSetUp(reader, elementName);
							}
						}
						break;
				}
			}
			if (innerCodons.Count > 0)
				this.codons.Add(innerCodons);
		}
		public ToolbarItemDescriptor(object caller, Codon codon, IList subItems, IEnumerable<ICondition> conditions)
		{
			this.Caller = caller;
			this.Codon = codon;
			this.SubItems = subItems;
			this.Conditions = conditions;
		}
Beispiel #5
0
 public MenuCommand(string label)
 {
     this.RightToLeft = RightToLeft.Inherit;
     this.codon  = null;
     this.caller = null;
     Text = StringParser.Parse(label);
 }
		/// <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)
		{
//			if (subItems == null || subItems.Count > 0) {
//				throw new ApplicationException("Tried to buil a command with sub commands, please check the XML definition.");
//			}
			return new DisplayBindingDescriptor(codon);
		}
		public object BuildItem(object caller, Codon codon, ArrayList subItems)
		{
			return new FileFilterDescriptor {
				Name = StringParser.Parse(codon.Properties["name"]),
				Extensions = codon.Properties["extensions"]
			};
		}
        public object BuildItem(object caller, Codon codon, ArrayList subItems)
        {
            string type = codon.Properties.Contains("type") ? codon.Properties["type"] : "Item";

            bool createCommand = codon.Properties["loadclasslazy"] == "false";

            switch (type) {
                case "Separator":
                    return new ToolBarSeparator(codon, caller);
                case "CheckBox":
                    return new ToolBarCheckBox(codon, caller);
                case "Item":
                    return new ToolBarCommand(codon, caller, createCommand);
                case "ComboBox":
                    return new ToolBarComboBox(codon, caller);
                case "TextBox":
                    return new ToolBarTextBox(codon, caller);
                case "Label":
                    return new ToolBarLabel(codon, caller);
                case "DropDownButton":
                    return new ToolBarDropDownButton(codon, caller, subItems);
                case "SplitButton":
                    return new ToolBarSplitButton(codon, caller, subItems);
                case "Builder":
                    return codon.AddIn.CreateObject(codon.Properties["class"]);
                default:
                    throw new System.NotSupportedException("unsupported menu item type : " + type);
            }
        }
 public MenuCheckBox(Codon codon, object caller)
 {
     this.RightToLeft = RightToLeft.Inherit;
     this.caller = caller;
     this.codon  = codon;
     UpdateText();
 }
Beispiel #10
0
		public ToolbarItemDescriptor(object parameter, Codon codon, IList subItems, IReadOnlyCollection<ICondition> conditions)
		{
			this.Parameter = parameter;
			this.Codon = codon;
			this.SubItems = subItems;
			this.Conditions = conditions;
		}
Beispiel #11
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return new Tool {
         ToolTipText = codon.Properties["tooltiptext"],
         Command = codon.AddIn.CreateObject(codon.Properties["class"]) as AbstractCommand
     };
 }
 private static string AddNextPathChainString(Codon codon)
 {
     if (codon.Properties.Contains("label"))
     return StringParser.Parse(codon.Properties["label"]).Replace("&", "");
       else
     return codon.Id;
 }
Beispiel #13
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return new Window {
         Title = codon.Properties["title"],
         DockPosition = codon.Properties["position"],
         ContainerControl = (codon.AddIn.CreateObject(codon.Properties["class"]) as ReturnableCommand).RunCommand() as Control
     };
 }
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
   string id = codon.Id;
   string resource = codon.Properties["resource"];
   ImageProxy proxy = ResourceImageProxy.FromResource(id,resource);
   TextureManager.BuiltinTextures.Add(proxy);
   return proxy;
 }
		public MenuItemDescriptor(object caller, Codon codon, IList subItems)
		{
			if (codon == null)
				throw new ArgumentNullException("codon");
			this.Caller = caller;
			this.Codon = codon;
			this.SubItems = subItems;
		}
Beispiel #16
0
 private CommandWrapper(Codon codon, IReadOnlyCollection<ICondition> conditions)
 {
     if (conditions == null)
         throw new ArgumentNullException("conditions");
     this.codon = codon;
     this.conditions = conditions;
     this.canExecuteChangedHandlersToRegisterOnCommand = new WeakCollection<EventHandler>();
 }
 public ParserDescriptor(Codon codon)
 {
     if (codon == null)
         throw new ArgumentNullException("codon");
     this.codon = codon;
     this.Language = codon.Id;
     this.SupportedFilenamePattern = new Regex(codon.Properties["supportedfilenamepattern"], RegexOptions.IgnoreCase);
 }
		public object BuildItem(object caller, Codon codon, ArrayList subItems)
		{
			string ext = codon.Properties["extensions"];
			if (ext != null && ext.Length > 0)
				return new LazyCodeCompletionBinding(codon, ext.Split(';'));
			else
				return codon.AddIn.CreateObject(codon.Properties["class"]);
		}
			public ContextActionOptionPanelDescriptor(Codon codon)
			{
				this.id = codon.Id;
				this.path = codon.Properties["path"];
				this.label = codon.Properties["label"];
				if (string.IsNullOrEmpty(label))
					label = "Context Actions"; // TODO: Translate
			}
		public ParserDescriptor(Codon codon)
		{
			if (codon == null)
				throw new ArgumentNullException("codon");
			this.codon = codon;
			this.Language = codon.Id;
			this.Supportedextensions = codon.Properties["supportedextensions"].Split(';');
		}
Beispiel #21
0
		/// <summary>
		/// Creates a non-lazy command.
		/// </summary>
		public static ICommand CreateCommand(Codon codon, IReadOnlyCollection<ICondition> conditions)
		{
			ICommand command = CreateCommand(codon);
			if (command != null && conditions.Count == 0)
				return command;
			else
				return new CommandWrapper(command, conditions);
		}
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     IDoozer doozer = (IDoozer)addIn.CreateObject(className);
     if (doozer == null) {
         return null;
     }
     AddInTree.Doozers[name] = doozer;
     return doozer.BuildItem(caller, codon, subItems);
 }
		/// <summary>
		/// Creates a new pad descriptor from the AddIn tree.
		/// </summary>
		public PadDescriptor(Codon codon)
		{
			addIn = codon.AddIn;
			shortcut = codon.Properties["shortcut"];
			category = codon.Properties["category"];
			icon = codon.Properties["icon"];
			title = codon.Properties["title"];
			@class = codon.Properties["class"];
		}
        public ConditionalSeparator(Codon codon, object caller, bool inToolbar, IEnumerable<ICondition> conditions)
        {
            this.codon = codon;
            this.caller = caller;
            this.conditions = conditions;

            if(inToolbar)
                SetResourceReference(FrameworkElement.StyleProperty, ToolBar.SeparatorStyleKey);
        }
		public ParserDescriptor(Codon codon)
		{
			if (codon == null)
				throw new ArgumentNullException("codon");
			_codon = codon;
			Language = codon.Id;
			SupportedExtensions = new List<string>(codon.Properties["supportedextensions"].Split(';'));
			SupportedProjects = new List<string>(codon.Properties["supportedprojects"].Split(';'));
		}
        public override object Build(ICSharpCode.Core.Codon codon, object caller, IEnumerable <ICSharpCode.Core.ICondition> conditions)
        {
            var label   = codon.Properties["label"] ?? codon.Id;
            var caption = StringParser.Parse(label);
            var group   = new NavBarGroup(caption);

            SetItemImage(group, codon);
            return(group);
        }
 public MenuItemDescriptor(object parameter, Codon codon, IList subItems, IReadOnlyCollection<ICondition> conditions)
 {
     if (codon == null)
         throw new ArgumentNullException("codon");
     this.Parameter = parameter;
     this.Codon = codon;
     this.SubItems = subItems;
     this.Conditions = conditions;
 }
		public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
		{
			ITextEditor editor = (ITextEditor)caller;
			string[] extensions = codon.Properties["extensions"].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
			if (CanAttach(extensions, editor.FileName)) {
				return codon.AddIn.CreateObject(codon.Properties["class"]);
			} else {
				return null;
			}
		}
		public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems)
		{
			CustomProperty cp = new CustomProperty(codon.Properties["name"]) {
				displayName = codon.Properties["displayName"],
				description = codon.Properties["description"]
			};
			if (!string.IsNullOrEmpty(codon.Properties["runCustomTool"]))
				cp.runCustomTool = bool.Parse(codon.Properties["runCustomTool"]);
			return cp;
		}
Beispiel #30
0
		public Menu(Codon codon, object caller, ArrayList 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();
		}
Beispiel #31
0
        public override object Build(ICSharpCode.Core.Codon codon, object caller, IEnumerable <ICSharpCode.Core.ICondition> conditions)
        {
            var label      = codon.Properties["label"] ?? codon.Id;
            var caption    = StringParser.Parse(label);
            var page       = new RibbonPage(caption);
            int mergeOrder = codon.Properties.Get("mergeOrder", -1);

            page.MergeOrder = mergeOrder;
            page.Name       = codon.Id;
            return(page);
        }
 private void SetButtonStyle(ICSharpCode.Core.Codon codon)
 {
     if (string.IsNullOrEmpty(codon.Properties["ButtonStyle"]))
     {
         return;
     }
     if (codon.Properties["ButtonStyle"] == "Check")
     {
         ButtonStyle = BarButtonStyle.Check;
     }
 }
        public override object Build(ICSharpCode.Core.Codon codon, object caller, IEnumerable <ICSharpCode.Core.ICondition> conditions)
        {
            var             label      = codon.Properties["label"] ?? codon.Id;
            var             caption    = StringParser.Parse(label);
            RibbonPageGroup ribbonPage = new RibbonPageGroup(caption);

            ribbonPage.AllowTextClipping = false;
            ribbonPage.Name = codon.Id;
            ribbonPage.ItemLinks.CollectionChanged += ItemLinks_CollectionChanged;
            return(ribbonPage);
        }
		public override ICollection BuildItems(Codon codon, object owner)
		{
			List<MenuItem> items = new List<MenuItem>();
			
			items.Add(CreateItem("Border", delegate { new GroupIntoBorderWithoutChild().Run(); }));
			items.Add(CreateItem("Border With Root Grid", delegate { new GroupIntoBorderWithGrid().Run(); }));
			items.Add(CreateItem("Border With Root StackPanel - Vertical", delegate { new GroupIntoBorderWithStackPanelVertical().Run(); }));
			items.Add(CreateItem("Border With Root StackPanel - Horizontal", delegate { new GroupIntoBorderWithStackPanelHorizontal().Run(); }));
			
			return items.OrderBy(item => item.Header).ToList();
		}
 private void SetRibbonStyle(ICSharpCode.Core.Codon codon)
 {
     if (string.IsNullOrEmpty(codon.Properties["RibbonStyle"]))
     {
         return;
     }
     if (codon.Properties["RibbonStyle"].ToString() == "Small")
     {
         RibbonStyle = DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithText
                       | DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithoutText;
     }
 }
 private void SetBeginGroup(ICSharpCode.Core.Codon codon)
 {
     if (string.IsNullOrEmpty(codon.Properties["beginGroup"]))
     {
         return;
     }
     if (codon.Properties["beginGroup"].ToString() != "true")
     {
         return;
     }
     BeginGroup = true;
 }
        public override object Build(ICSharpCode.Core.Codon codon, object caller, IEnumerable <ICSharpCode.Core.ICondition> conditions)
        {
            var label   = codon.Properties["label"] ?? codon.Id;
            var command = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);

            command.Owner = caller;
            var caption = StringParser.Parse(label);
            var item    = new ModuleNavBarItem(caption, command);

            SetItemImage(item, codon);

            return(item);
        }
        private void SetItemImage(NavBarGroup group, ICSharpCode.Core.Codon codon)
        {
            if (string.IsNullOrEmpty(codon.Properties["icon"]))
            {
                return;
            }
            var icon = WinFormsResourceService.GetIcon(codon.Properties["icon"]);

            if (icon == null)
            {
                return;
            }
            group.LargeImage = icon.ToBitmap();
            group.SmallImage = icon.ToBitmap();
        }
        public BarButtonItemEx(ICSharpCode.Core.Codon codon, object caller, IEnumerable <ICSharpCode.Core.ICondition> conditions)
        {
            _conditions = conditions;
            _caller     = caller;

            var label = codon.Properties["label"] ?? codon.Id;

            Name = codon.Id;

            Caption = StringParser.Parse(label);
            SetRibbonStyle(codon);
            SetButtonStyle(codon);
            SetBeginGroup(codon);
            SetItemClick(codon);
            SetItemGlyph(codon);
            // EventAggregationManager.AddListener(this);
        }
        private void SetItemImage(NavBarItem barItem, ICSharpCode.Core.Codon codon)
        {
            string iconName = codon.Properties["icon"];

            if (string.IsNullOrEmpty(iconName))
            {
                return;
            }
            var icon = WinFormsResourceService.GetIcon(iconName.ToLower());

            if (icon == null)
            {
                return;
            }
            barItem.LargeImage = icon.ToBitmap();
            barItem.SmallImage = icon.ToBitmap();
        }
        private void SetItemClick(ICSharpCode.Core.Codon codon)
        {
            if (string.IsNullOrEmpty(codon.Properties["class"]))
            {
                return;
            }
            var command = (ICommand)codon.AddIn.CreateObject(codon.Properties["class"]);

            if (command == null)
            {
                return;
            }
            command.Owner     = _caller;
            command.Parameter = codon.Properties["Parameter"];
            this.Tag          = command;
            //ItemClick += (s, e) =>
            //{
            //    command.Run();
            //};
        }
        private void SetItemGlyph(ICSharpCode.Core.Codon codon)
        {
            string       imageName     = codon.Properties["imageName"];
            string       overlayName   = codon.Properties["overlay"];
            PropertyInfo objectNamePro = _caller.GetType().GetProperty("ObjectName");

            if (objectNamePro != null)
            {
                _objectName = objectNamePro.GetValue(_caller, null) as string;
            }
            if (string.IsNullOrEmpty(imageName))
            {
                imageName = _objectName;
            }

            if (string.IsNullOrEmpty(imageName))
            {
                return;
            }
            var icon = WinFormsResourceService.GetIcon(imageName.ToLower());

            if (icon == null)
            {
                return;
            }
            Image largeImage = icon.ToBitmap();


            if (!string.IsNullOrEmpty(overlayName))
            {
                var overlay = WinFormsResourceService.GetBitmap(overlayName.ToLower());
                if (overlay != null)
                {
                    DrawOverlay(largeImage, overlay);
                }
            }
            LargeGlyph = largeImage;
            Glyph      = new Bitmap(largeImage, new Size(16, 16));
        }
Beispiel #43
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(StringParser.Parse(codon.Properties["name"]) + "|" + codon.Properties["extensions"]);
 }
        public override object Build(ICSharpCode.Core.Codon codon, object caller, IEnumerable <ICSharpCode.Core.ICondition> conditions)
        {
            var item = new BarButtonItemEx(codon, caller, conditions);

            return(item);
        }
Beispiel #45
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(codon.AddIn.CreateObject(codon.Properties["class"]));
 }
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(new IconDescriptor(codon));
 }
Beispiel #47
0
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(StringParser.Parse(codon.Properties["text"]));
 }
Beispiel #48
0
        public object BuildItem(BuildItemArgs args)
        {
            Codon codon = args.Codon;

            return(codon.AddIn.CreateObject(codon.Properties["class"]));
        }
Beispiel #49
0
 public IconDescriptor(Codon codon)
 {
     this.codon = codon;
 }
 public object BuildItem(object caller, Codon codon, ArrayList subItems)
 {
     return(new MenuItemDescriptor(caller, codon, subItems));
 }
 public MenuItemDescriptor(object caller, Codon codon, IList subItems)
 {
     this.Caller   = caller;
     this.Codon    = codon;
     this.SubItems = subItems;
 }