public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
		{
			Debug.Assert(Class != null && Class.Length > 0);
			
			return (IViewType)AddIn.CreateObject(Class);
			
		}
Beispiel #2
0
		public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
		{
			if (subItems.Count > 0) {
				throw new ApplicationException("more than one level of icons don't make sense!");
			}
			
			return this;
		}
Beispiel #3
0
		public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
		{
			Debug.Assert(Class != null && Class.Length > 0);
			IPadContent pad = AddIn.CreateObject(Class) as IPadContent;
			pad.Shortcut = shortcut;
			
			return pad;
		}
		public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
		{
			if (subItems.Count > 0) {
				throw new ApplicationException("more than one level of file filters don't make sense!");
			}
			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));

			return stringParserService.Parse(filtername) + "|" + String.Join(";", extensions);
		}
		/// <summary>
		/// Creates an item with the specified sub items. And the current
		/// Condition status for this item.
		/// </summary>
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
        {
			Debug.Assert(Class != null && Class.Length > 0);
			IAlgorithm algorithm = (IAlgorithm)AddIn.CreateObject(Class);
			algorithm.CodeFiles = codeFiles;
			AssignValues();
			algorithm.LastLines = lastLines1;
			return algorithm;
		}
		/// <summary>
		/// Creates an item with the specified sub items. And the current
		/// Condition status for this item.
		/// </summary>
        public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
		{
			IDialogPanelDescriptor newItem = null;
			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
			
			if (subItems == null || subItems.Count == 0) {				
				if (Class != null) {
					newItem = new DefaultDialogPanelDescriptor(ID, stringParserService.Parse(Label), (IDialogPanel)AddIn.CreateObject(Class));
				} else {
					newItem = new DefaultDialogPanelDescriptor(ID, stringParserService.Parse(Label));
				}
			} else {
				newItem = new DefaultDialogPanelDescriptor(ID, stringParserService.Parse(Label), subItems);
			}
			return newItem;
		}
		/// <summary>
		///     <para>
		///       Initializes a new instance of <see cref="ConditionCollection"/> based on another <see cref="ConditionCollection"/>.
		///    </para>
		/// </summary>
		/// <param name="value">
		///       A <see cref="ConditionCollection"/> from which the contents are copied
		/// </param>
		public ConditionCollection(ConditionCollection value) {
			this.AddRange(value);
		}
		/// <summary>
		///     <para>
		///       Adds the contents of another <see cref="ConditionCollection"/> to the end of the collection.
		///    </para>
		/// </summary>
		/// <param name="value">
		///    A <see cref="ConditionCollection"/> containing the objects to add to the collection.
		/// </param>
		/// <returns>
		///   <para>None.</para>
		/// </returns>
		/// <seealso cref="ConditionCollection.Add"/>
		public void AddRange(ConditionCollection value) {
			for (int i = 0; (i < value.Count); i = (i + 1)) {
				this.Add(value[i]);
			}
		}
			/// <summary>
			/// Creates a new instance.
			/// </summary>
			public IConditionEnumerator(ConditionCollection mappings) {
				this.temp = ((IEnumerable)(mappings));
				this.baseEnumerator = temp.GetEnumerator();
			}
		/// <summary>
		/// Creates an item with the specified sub items and the current
		/// Conditions for this item.
		/// </summary>
		public abstract object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions);
 public NegatedCondition(ConditionCollection conditions)
 {
     this.conditions = conditions;
 }
 public OrCondition(ConditionCollection conditions)
 {
     this.conditions = conditions;
 }
		public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
		{
			this.subItems = subItems;
			return this;
		}
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 public IConditionEnumerator(ConditionCollection mappings)
 {
     this.temp           = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
		public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
		{
			SdMenuCommand newItem = null;	
			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
			
			object o = null;
			if (Class != null) 
			{
				o = AddIn.CreateObject(Class);//说明当前菜单项是没有子菜单项�?即它有自己的功能,其功能由Class类具体实�?这种菜单项也是最常见�?
			}
			if (o != null) 
			{
				if (o is ISubmenuBuilder) 
				{
					return ((ISubmenuBuilder)o).BuildSubmenu(owner);
				}
				
				if (o is IMenuCommand) 
				{
					newItem = new SdMenuCommand(stringParserService.Parse(Label), new EventHandler(new MenuEventHandler(owner, (IMenuCommand)o).Execute));
					if(beginGroup == "true")
					{
						newItem.BeginGroup = true;
					}
				}
			}
			
			if (newItem == null) 
			{//说明当前菜单项既不是Link类型�?也没有指出其Class属�?所以有可能是一个包含子菜单的菜单项.
				newItem = new SdMenuCommand(stringParserService.Parse(Label));
				if (subItems != null && subItems.Count > 0) 
				{//判断是否有子菜单�?
					foreach (object item in subItems) 
					{
						if (item is ButtonItem) 
						{//添加一个子菜单�?
							newItem.SubItems.Add((ButtonItem)item);
						} 
						else 
						{//添加一组子菜单�?
							newItem.SubItems.AddRange((ButtonItem[])item);
						}
					}
				}
			}
			
			Debug.Assert(newItem != null);//到这里为�?newItem即当前菜单项不应该为空了.
			
			if (Icon != null) 
			{//为菜单设置Icon.
				ResourceService ResourceService = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService));
				newItem.Image = ResourceService.GetBitmap(Icon);
			}
			newItem.Description = description;

			newItem.MouseEnter +=new EventHandler(newItem_MouseEnter);
			newItem.MouseLeave +=new EventHandler(newItem_MouseLeave);
			
			if (Shortcut != null) 
			{//为菜单设置Shortcut.
				try 
				{
					newItem.Shortcuts.Add((eShortcut)Enum.Parse(eShortcut.F1.GetType(),Shortcut));
				}
				catch (Exception) 
				{
				}
			}
			
			return newItem;//最后返回当前菜单项.

		}
 /// <summary>
 ///     <para>
 ///       Initializes a new instance of <see cref="ConditionCollection"/> based on another <see cref="ConditionCollection"/>.
 ///    </para>
 /// </summary>
 /// <param name="value">
 ///       A <see cref="ConditionCollection"/> from which the contents are copied
 /// </param>
 public ConditionCollection(ConditionCollection value)
 {
     this.AddRange(value);
 }
		public OrCondition(ConditionCollection conditions)
		{
			this.conditions = conditions;
		}
		public NegatedCondition(ConditionCollection conditions)
		{
			this.conditions = conditions;
		}
Beispiel #19
0
		void AddCodonsToExtension(Extension e, XmlElement el, ConditionCollection conditions)
		{
			foreach (object o in el.ChildNodes) {
				if (!(o is XmlElement)) {
					continue;
				}
				XmlElement curEl = (XmlElement)o;
				
				switch (curEl.Name) {
					case "And": // these nodes are silently ignored.
					case "Or":
					case "Not":
					case "Condition":
						break;
					case "Conditional":
						ICondition condition = null;
						
						// 若当前条件结点的属性个数为零或者(个数为1并且包含action属性),
						//则说明当前条件结点为一个复合逻辑条件(即该条件由一些and,or等条件组成)
						if (curEl.Attributes.Count == 0 || (curEl.Attributes.Count == 1 && curEl.Attributes["FailedAction"] != null)) 
						{
							condition = BuildComplexCondition(curEl);
							
							// set condition action manually
							if (curEl.Attributes["FailedAction"] != null) 
							{
								condition.FailedAction = (ConditionFailedAction)Enum.Parse(typeof(ConditionFailedAction), curEl.Attributes["FailedAction"].InnerText);
							}
							
							if (condition == null) 
							{
								throw new AddInTreeFormatException("empty conditional, but no condition definition found.");
							}
						} 
						else 
						{   //当前条件结点为一个简单条件结点,该条件结点不会包含<Or>,<And>等子结点
							condition = AddInTreeSingleton.AddInTree.ConditionFactory.CreateCondition(this, curEl);
							AutoInitializeAttributes(condition, curEl);
						}
						
						// put the condition at the end of the condition 'stack'
						conditions.Add(condition);
						
						// traverse the subtree
						AddCodonsToExtension(e, curEl, conditions);
						
						// now we are back to the old level, remove the condition
						// that was applied to the subtree.
						conditions.RemoveAt(conditions.Count - 1);
						break;
					default:
						ICodon codon = AddInTreeSingleton.AddInTree.CodonFactory.CreateCodon(this, curEl);
						
						AutoInitializeAttributes(codon, curEl);
						
						// Ensure that the codon is inserted after the codon which is defined
						// before in the add-in definition.
						// The codons get topologically sorted and if I don't set the InsertAfter they may
						// change it's sorting order.
						e.Conditions[codon.ID] = new ConditionCollection(conditions);
						if (codon.InsertAfter == null && codon.InsertBefore == null && e.CodonCollection.Count > 0) {
							codon.InsertAfter = new string[] { ((ICodon)e.CodonCollection[e.CodonCollection.Count - 1]).ID };
						}
						
						e.CodonCollection.Add(codon);
						if (curEl.ChildNodes.Count > 0) {
							Extension newExtension = new Extension(e.Path + '/' + codon.ID);
							AddCodonsToExtension(newExtension, curEl, conditions);
							extensions.Add(newExtension);
						}
						break;
				}
			}
		}
Beispiel #20
0
		ICondition GetCondition(XmlElement el)
		{//这个函数为递归函数
			ConditionCollection conditions = new ConditionCollection();
			
			foreach (XmlElement child in el.ChildNodes) {
				conditions.Add(GetCondition(child));
			}
			
			switch (el.Name) {
				case "Condition":
					if (conditions.Count > 0) {//说明<Condition>结点不可以有子结点
						throw new AddInTreeFormatException("Condition node childs found. (doesn't make sense)");
					}
					ICondition c = AddInTreeSingleton.AddInTree.ConditionFactory.CreateCondition(this, el);
					AutoInitializeAttributes(c, el);
					return c;
				case "And":
					if (conditions.Count <= 1) {
						throw new AddInTreeFormatException("And node with none or only one child found.");
					}
					return new AndCondition(conditions);
				case "Or":
					if (conditions.Count <= 1) {
						throw new AddInTreeFormatException("Or node with none or only one child found.");
					}
					return new OrCondition(conditions);
				case "Not":
					if (conditions.Count > 1) {
						throw new AddInTreeFormatException("Not node with more than one child found");
					}
					if (conditions.Count == 0) {
						throw new AddInTreeFormatException("Not node without child found.");
					}
					return new NegatedCondition(conditions);
			}
			
			throw new AddInTreeFormatException("node " + el.Name + " not valid in expression.");
		}