Example #1
0
		///<summary>
		/// This is the ``core'' rendering method. It will recursively descend into the Part hierarchy
		/// and using the .net reflection mechanisms to create the appropriate widgets
		///</summary>
		public Control Render(Part uiPart, Style uiStyle) //throws WrongNestingException, MappingNotFoundException
		{
			string className = Voc.MapsOnCls(uiPart.Class);				
			Type classType = GuiAssembly.GetType(className);
			Type containerType = GuiAssembly.GetType(CONTAINER);

			object swfObject = (Activator.CreateInstance(classType));
			  			  
			//attach it to the Part for later manipulation
			uiPart.UiObject = swfObject;

			if(uiPart.HasSubParts())
			{	
				if(classType.IsSubclassOf(containerType))
				{
					IEnumerator enumParts = uiPart.GetSubParts();
					while(enumParts.MoveNext())
					{
						Part subPart = (Part)enumParts.Current;
						Control b = Render(subPart, uiStyle);						

						// add b to swfObject
						PropertyInfo p = classType.GetProperty(m_addProperty);						
						Control.ControlCollection controls = (Control.ControlCollection)p.GetValue(swfObject, null);
						MethodInfo m = controls.GetType().GetMethod(m_addMethod, new Type[] { b.GetType() } );
						m.Invoke(controls, new System.Object[] { b });						
					}
					return (Control)ApplyProperties((Control)swfObject, uiPart, uiStyle);
					
				}
				else
				{
					throw new WrongNestingException(className, CONTAINER);
				}
			}
			else
			{
				try
				{						
					return (Control) ApplyProperties((Control)swfObject, uiPart, uiStyle);
				}
				catch(Exception e)
					{
						Console.WriteLine("Waaaaahhhgggrrr!:{0}",e);
						Console.WriteLine(swfObject.GetType().ToString());
						return null;
					}
			}
		}
Example #2
0
		///<summary>
		/// This is the ``core'' rendering method. It will recursively descend into the Part hierarchy
		/// and using the .net reflection mechanisms to create the appropriate widgets
		///</summary>
		private Window Render(Part uiPart, Style uiStyle, Window parent) //throws WrongNestingException, MappingNotFoundException
		{
		     string className = Voc.MapsOnCls(uiPart.Class);
			  Type classType = GuiAssembly.GetType(className);
			  Type containerType = GuiAssembly.GetType(CONTAINER);

			  System.Object wxObject;
			  
//			  try{ 			  
//				  Console.WriteLine("Try to create instance for {0}", classType);
//				  wxObject = Activator.CreateInstance(classType); 			  
//				  Console.WriteLine("Created object {0}", wxObject);
//			  }
//				  catch(MissingMethodException mme)
				  {
					  	if(classType.Equals(containerType))
							wxObject = CreateLayoutWithParams(classType, uiPart, uiStyle); 
						else
							wxObject = CreateWithParams(classType, uiPart, uiStyle, parent); 
				  }
			  
			  //attach it to the Part for later manipulation
			  uiPart.UiObject = wxObject;


				if(uiPart.HasSubParts())
				{
					if(classType.Equals(containerType))
					{
						m_adder = ADD;
						IEnumerator enumParts = uiPart.GetSubParts();
						Window wxContainer = new Panel(parent);
						while(enumParts.MoveNext())
						{
							Part subPart = (Part)enumParts.Current;
							Window b = Render(subPart, uiStyle, wxContainer);
							MethodInfo m = classType.GetMethod(m_adder, new Type[] { b.GetType() } );
							m.Invoke(wxObject, new System.Object[] { b });
						}
						PropertyInfo addLayout = typeof(Window).GetProperty(APPLY_LAYOUT /*, new Type[] { classType }*/ );
						addLayout.SetValue(wxContainer, wxObject, null );
						wxContainer.Fit();
						return (Window)ApplyProperties((Window)wxContainer, uiPart, uiStyle);
					}
					else
					{
						throw new WrongNestingException(className, CONTAINER);
					}
				}
				else
				{
					//wxObject = AttachEvents((Widget)wxObject, uiBehavior);
					return (Window)ApplyProperties((Window)wxObject, uiPart, uiStyle);
				}
		}
Example #3
0
		///<summary>
		/// This is the ``core'' rendering method. It will recursively descend into the Part hierarchy
		/// and using the .net reflection mechanisms to create the appropriate widgets
		///</summary>
		private Widget Render(Part uiPart, Style uiStyle) //throws WrongNestingException, MappingNotFoundException
		{
		     string className = Voc.MapsOnCls(uiPart.Class);
			  Type classType = GuiAssembly.GetType(className);
			  Type containerType = GuiAssembly.GetType(CONTAINER);

			  bool layoutWidget = DoesLayout(classType);			  
			  System.Object gtkObject;
			  
			  try
			  {
				  if(layoutWidget)
					  gtkObject = Activator.CreateInstance(classType, new System.Object[] { HOMOGENEOUS, SPACING} );
				  else
					  gtkObject = Activator.CreateInstance(classType);				  
			  }
			  catch(MissingMethodException mme)
			  {
				  gtkObject = CreateWithParams(classType, uiPart, uiStyle);
			  }
			  
			  //attach it to the Part for later manipulation
			  uiPart.UiObject = gtkObject;


				if(uiPart.HasSubParts())
				{	
					if(classType.IsSubclassOf(containerType))
					{
						//if(layoutWidget)//this is layout code
						//	m_adder = PACKSTART;
						//else
							m_adder = ADD;
							
						IEnumerator enumParts = uiPart.GetSubParts();
						while(enumParts.MoveNext())
						{
							Part subPart = (Part)enumParts.Current;
                            if (subPart.Identifier == "textfield2")
                            {
                                int zz = 0;
                            }
							Widget b = Render(subPart, uiStyle);
							//((Container)gtkObject).Add(b); replaced by:
							MethodInfo m = classType.GetMethod(m_adder, new Type[] { b.GetType() } );
							m.Invoke(gtkObject, new System.Object[] { b });
						}
						return (Container)ApplyProperties((Container)gtkObject, uiPart, uiStyle);
						
					}
					else
					{
						throw new WrongNestingException(className, CONTAINER);
					}
				}
				else
				{
					//gtkObject = AttachEvents((Widget)gtkObject, uiBehavior);
					return (Widget)ApplyProperties((Widget)gtkObject, uiPart, uiStyle);
				}
		}