本文整理汇总了C#中GeneratorContext.GenerateNewInstanceCode方法的典型用法代码示例。如果您正苦于以下问题:C# GeneratorContext.GenerateNewInstanceCode方法的具体用法?C# GeneratorContext.GenerateNewInstanceCode怎么用?C# GeneratorContext.GenerateNewInstanceCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneratorContext
的用法示例。
在下文中一共展示了GeneratorContext.GenerateNewInstanceCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateChildBuildCode
protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
{
if (wrapper.Wrapped == expander.LabelWidget) {
CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
CodeAssignStatement assign = new CodeAssignStatement (
new CodePropertyReferenceExpression (
parentVar,
"LabelWidget"
),
var
);
ctx.Statements.Add (assign);
} else
base.GenerateChildBuildCode (ctx, parentVar, wrapper);
}
示例2: GenerateChildBuildCode
protected virtual void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
{
ObjectWrapper childwrapper = ChildWrapper (wrapper);
if (childwrapper != null) {
ctx.Statements.Add (new CodeCommentStatement ("Container child " + Wrapped.Name + "." + childwrapper.Wrapped.GetType ()));
CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
parentVar,
"Add",
var
);
ctx.Statements.Add (invoke);
GenerateSetPacking (ctx, parentVar, var, childwrapper);
}
}
示例3: GenerateChildBuildCode
protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentExp, Widget wrapper)
{
Gtk.Widget child = (Gtk.Widget) wrapper.Wrapped;
if (notebook.PageNum (child) == -1) {
// It's a tab
ctx.Statements.Add (new CodeCommentStatement ("Notebook tab"));
Gtk.Widget page = null;
CodeExpression pageVar;
// Look for the page widget contained in this tab
for (int n=0; n < notebook.NPages; n++) {
if (notebook.GetTabLabel (notebook.GetNthPage (n)) == child) {
page = notebook.GetNthPage (n);
break;
}
}
// If the page contains a placeholder, generate a dummy page
if (page is Stetic.Placeholder) {
CodeVariableDeclarationStatement dvar = new CodeVariableDeclarationStatement (
"Gtk.Label".ToGlobalTypeRef (),
ctx.NewId (),
new CodeObjectCreateExpression ("Gtk.Label".ToGlobalTypeRef ())
);
ctx.Statements.Add (dvar);
ctx.Statements.Add (
new CodeAssignStatement (
new CodePropertyReferenceExpression (
new CodeVariableReferenceExpression (dvar.Name),
"Visible"
),
new CodePrimitiveExpression (true)
)
);
ctx.Statements.Add (
new CodeMethodInvokeExpression (
parentExp,
"Add",
new CodeVariableReferenceExpression (dvar.Name)
)
);
pageVar = new CodeVariableReferenceExpression (dvar.Name);
} else
pageVar = ctx.WidgetMap.GetWidgetExp (page);
// Generate code for the tab
CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
// Assign the tab to the page
CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
parentExp,
"SetTabLabel",
pageVar,
var
);
ctx.Statements.Add (invoke);
// Workaround for GTK bug. ShowAll is not propagated to tab labels.
invoke = new CodeMethodInvokeExpression (
var,
"ShowAll"
);
ctx.Statements.Add (invoke);
} else
base.GenerateChildBuildCode (ctx, parentExp, wrapper);
}
示例4: GenerateChildBuildCode
protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
{
if (actionDialog != null && wrapper is Button) {
// If this is the action area of a dialog, buttons must be added using AddActionWidget,
// so they are properly registered.
ObjectWrapper childwrapper = ChildWrapper (wrapper);
Button button = wrapper as Button;
if (childwrapper != null) {
CodeExpression dialogVar = ctx.WidgetMap.GetWidgetExp (actionDialog);
ctx.Statements.Add (new CodeCommentStatement ("Container child " + Wrapped.Name + "." + childwrapper.Wrapped.GetType ()));
CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
if (button.ResponseId != (int) Gtk.ResponseType.None) {
CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
dialogVar,
"AddActionWidget",
var,
new CodePrimitiveExpression (button.ResponseId)
);
ctx.Statements.Add (invoke);
}
else {
CodeMethodInvokeExpression invoke = new CodeMethodInvokeExpression (
parentVar,
"Add",
var
);
ctx.Statements.Add (invoke);
}
GenerateSetPacking (ctx, parentVar, var, childwrapper);
}
} else
base.GenerateChildBuildCode (ctx, parentVar, wrapper);
}
示例5: GenerateBuildCode
internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
{
base.GenerateBuildCode (ctx, var);
string text = button.Label;
if (!string.IsNullOrEmpty (text)) {
CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, "Label");
PropertyDescriptor prop = (PropertyDescriptor)this.ClassDescriptor ["Label"];
bool trans = Type != ButtonType.StockItem && prop.IsTranslated (Wrapped);
CodeExpression val = ctx.GenerateValue (text, typeof(string), trans);
ctx.Statements.Add (new CodeAssignStatement (cprop, val));
}
if (Type == ButtonType.TextAndIcon) {
var imageWidget = (Gtk.Image) button.Image;
if (imageWidget != null) {
Image imageWrapper = (Image)Widget.Lookup (imageWidget);
var imgVar = ctx.GenerateNewInstanceCode (imageWrapper);
var imgProp = new CodePropertyReferenceExpression (var, "Image");
ctx.Statements.Add (new CodeAssignStatement (imgProp, imgVar));
}
}
}