SearchProperty() public method

Searches for a specific property of a given part
public SearchProperty ( string partIdentifier, string partProperty ) : System.Property
partIdentifier string
partProperty string
return System.Property
コード例 #1
0
ファイル: GtkRenderer.cs プロジェクト: jozilla/Uiml.net
		///<summary>
		/// Applies several properties to an individual concrete widget instance   
		/// relying on hard-coded knowledge about the widgets, after
        /// all the other properties have been set first.
		///</summary>
		///<param name="UiObject"></param>
		///<param name="part"></param>
		///<param name"s"></param>
		protected override System.Object LoadAdHocPropertiesAfter(ref System.Object uiObject, Part part, Style s)
		{
			if(part.Class == "Tree" || part.Class == "List")
			{
				Property p = s.SearchProperty(part.Identifier, "title");
                Gtk.TreeView tree = (Gtk.TreeView) uiObject;

				if (p == null)
                {
                    // add an empty column
                    Gtk.TreeViewColumn column = new Gtk.TreeViewColumn();
                    column.Title = (string) p.Value;
                    tree.AppendColumn(column);
                }

                for (int i = 0; i < tree.Columns.Length; i++)
                {
                    Gtk.TreeViewColumn col = tree.Columns[i];

                    Gtk.CellRendererText crt = new Gtk.CellRendererText();
                    col.PackStart(crt, true);
                    col.AddAttribute(crt, "text", i); 
                }

                tree.HeadersVisible = true;
			}
			
			return uiObject;
		}
コード例 #2
0
/* Moved to super class
		///<summary>
		/// Dissects the method information for a specific property
		///</summary>
		///<param name="baseT"></param>
		///<param name="newT"></param>
		///<param name="retType"></param>
		///<param name="nextValue"></param>
		private MemberInfo ResolveProperty(Type baseT, String newT, out Type retType, ref System.Object nextValue)
		{			
			MemberInfo m = baseT.GetProperty(newT);
			if(m == null)
			{
				m = baseT.GetMethod(newT, new Type[0]);
				retType = ((MethodInfo)m).ReturnType;
				nextValue = ((MethodInfo)m).Invoke(nextValue, null);
			}
			else
			{
				retType = ((PropertyInfo)m).PropertyType;
				nextValue = ((PropertyInfo)m).GetValue(nextValue, null);
			}
			return m;
		}
*/
		
		///<summary>
		/// Applies several properties to an individual concrete widget instance   
		/// relying on hard-coded knowledge about the widgets
		///</summary>
		///<todo>
		// Change to the .custom format, like used for the gtk# bindings
		///</todo>		
		protected override System.Object LoadAdHocProperties(ref System.Object uiObject, Part part, Style s)
		{
			// emulate the Items.AddRange() functionality
			Property prop = s.SearchProperty(part.Identifier, "content");			
			
			if(prop != null)
			{
				if(prop.Lazy)
					prop.Resolve(this);

				Param[] paramTypes = Voc.GetParams(prop.Name, part.Class);
				//convert the params to types
				Type[] tparamTypes = new Type[paramTypes.Length];
				for(int i = 0; i < paramTypes.Length; i++)
				{
					tparamTypes[i] = null;
					int k = 0;
					while(tparamTypes[i] == null)
						tparamTypes[i] = ((Assembly)ExternalLibraries.Instance.Assemblies[k++]).GetType(paramTypes[i].Type);
				}

				System.Object[] blaai = TypeDecoder.Instance.GetArgs(prop, tparamTypes);
				string[] content = (string[])blaai[0];

				switch(part.Class)
				{
					case "Combo":
						ComboBox cmb = (ComboBox) uiObject;						
						for(int i = 0; i < content.Length; i++)
						{
							cmb.Items.Add(content[i]);
						}
						return cmb;						
					case "ListBox":
						ListBox lb = (ListBox) uiObject;
						for(int i = 0; i < paramTypes.Length; i++)
						{
							lb.Items.Add(paramTypes[i].Value);
						}
						return lb;						
					case "List":
						ListView lv = (ListView) uiObject;
						for(int i = 0; i < paramTypes.Length; i++)
						{
							lv.Items.Add(new ListViewItem(paramTypes[i].Value));							
						}
						return lv;						
				}				
			}	
			return uiObject;
		}
コード例 #3
0
ファイル: GtkRenderer.cs プロジェクト: jozilla/Uiml.net
		/* moved to super class
		///<summary>
		/// Dissects the method information for a specific property
		///</summary>
		///<param name="baseT"></param>
		///<param name="newT"></param>
		///<param name="retType"></param>
		///<param name="nextValue"></param>
		private MemberInfo ResolveProperty(Type baseT, String newT, out Type retType, ref System.Object nextValue)
		{			
			MemberInfo m = baseT.GetProperty(newT);
			if(m == null)
			{
				m = baseT.GetMethod(newT, new Type[0]);
				retType = ((MethodInfo)m).ReturnType;
				nextValue = ((MethodInfo)m).Invoke(nextValue, null);
			}
			else
			{
				retType = ((PropertyInfo)m).PropertyType;
				nextValue = ((PropertyInfo)m).GetValue(nextValue, null);
			}
			return m;
		}
		*/

		///<summary>
		/// Applies several properties to an individual concrete widget instance   
		/// relying on hard-coded knowledge about the widgets
		///</summary>
		///<param name="UiObject"></param>
		///<param name="part"></param>
		///<param name"s"></param>
		///<todo>
		// Change to the .custom format, like used for the gtk# bindings
		///</todo>
		protected override System.Object LoadAdHocProperties(ref System.Object uiObject, Part part, Style s)
		{
			if(part.Class == "TabPage")
			{
				/* FIXME: this implementation does not work because the TabPage has not yet been added
				 * to the Tabs parent! 
				 */
				Property p = s.SearchProperty(part.Identifier, "label");
				string label;
				
				if(p != null)
					label = (string)p.Value;
				else
					label = "";
					
				if(!part.Top) // if we have a parent
				{
					Notebook n = (Notebook)part.Parent.UiObject;
					n.SetTabLabelText((Widget)part.UiObject, label);
				}
			}
			
			return uiObject;
		}