本文整理汇总了C#中Part.GetSubParts方法的典型用法代码示例。如果您正苦于以下问题:C# Part.GetSubParts方法的具体用法?C# Part.GetSubParts怎么用?C# Part.GetSubParts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.GetSubParts方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
///<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;
}
}
}
示例2: Render
///<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);
}
}
示例3: Render
///<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);
}
}