コード例 #1
0
ファイル: Button.cs プロジェクト: noah1510/dotdevelop
        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));
                }
            }
        }
コード例 #2
0
ファイル: Button.cs プロジェクト: highattack30/monodevelop-1
        internal protected override void GenerateBuildCode(GeneratorContext ctx, CodeExpression var)
        {
            base.GenerateBuildCode(ctx, var);

            if (Type != ButtonType.TextAndIcon)
            {
                CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression(var, "Label");
                PropertyDescriptor prop = (PropertyDescriptor)this.ClassDescriptor ["Label"];
                bool           trans    = Type != ButtonType.StockItem && prop.IsTranslated(Wrapped);
                CodeExpression val      = ctx.GenerateValue(button.Label, typeof(string), trans);
                ctx.Statements.Add(new CodeAssignStatement(cprop, val));
            }
        }
コード例 #3
0
ファイル: Action.cs プロジェクト: orf53975/stetic
        internal protected override CodeExpression GenerateObjectCreation(GeneratorContext ctx)
        {
            CodeObjectCreateExpression exp = new CodeObjectCreateExpression();

            PropertyDescriptor prop = (PropertyDescriptor)ClassDescriptor ["Name"];

            exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType));

            prop = (PropertyDescriptor)ClassDescriptor ["Label"];
            string lab = (string)prop.GetValue(Wrapped);

            if (lab == "")
            {
                lab = null;
            }
            exp.Parameters.Add(ctx.GenerateValue(lab, prop.RuntimePropertyType, prop.Translatable));

            prop = (PropertyDescriptor)ClassDescriptor ["Tooltip"];
            exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType, prop.Translatable));

            prop = (PropertyDescriptor)ClassDescriptor ["StockId"];
            exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), prop.RuntimePropertyType, prop.Translatable));

            if (type == ActionType.Action)
            {
                exp.CreateType = new CodeTypeReference("Gtk.Action");
            }
            else if (type == ActionType.Toggle)
            {
                exp.CreateType = new CodeTypeReference("Gtk.ToggleAction");
            }
            else
            {
                exp.CreateType = new CodeTypeReference("Gtk.RadioAction");
                prop           = (PropertyDescriptor)ClassDescriptor ["Value"];
                exp.Parameters.Add(ctx.GenerateValue(prop.GetValue(Wrapped), typeof(int)));
            }
            return(exp);
        }
コード例 #4
0
        internal protected override void GenerateBuildCode(GeneratorContext ctx, CodeExpression var)
        {
            if (textCombo && Items != null && Items.Length > 0)
            {
                foreach (string str in Items)
                {
                    ctx.Statements.Add(new CodeMethodInvokeExpression(
                                           var,
                                           "AppendText",
                                           ctx.GenerateValue(str, typeof(string), true)
                                           ));
                }
            }

            base.GenerateBuildCode(ctx, var);
        }
コード例 #5
0
        protected CodeExpression GenerateUiManagerElement(GeneratorContext ctx, ActionTree tree)
        {
            Widget topLevel = GetTopLevel();
            string uiName   = topLevel.UIManagerName;

            if (uiName != null)
            {
                CodeFieldReferenceExpression uiManager = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), uiName);
                if (topLevel.includedActionGroups == null)
                {
                    topLevel.includedActionGroups = new ArrayList();
                }

                // Add to the uimanager all action groups required by the
                // actions of the tree

                foreach (ActionGroup grp in tree.GetRequiredGroups())
                {
                    if (!topLevel.includedActionGroups.Contains(grp))
                    {
                        // Insert the action group in the UIManager
                        CodeMethodInvokeExpression mi = new CodeMethodInvokeExpression(
                            uiManager,
                            "InsertActionGroup",
                            ctx.GenerateValue(grp, typeof(ActionGroup)),
                            new CodePrimitiveExpression(topLevel.includedActionGroups.Count)
                            );
                        ctx.Statements.Add(mi);
                        topLevel.includedActionGroups.Add(grp);
                    }
                }

                tree.GenerateBuildCode(ctx, uiManager);
                return(new CodeMethodInvokeExpression(
                           uiManager,
                           "GetWidget",
                           new CodePrimitiveExpression("/" + Wrapped.Name)
                           ));
            }
            return(null);
        }
コード例 #6
0
        internal protected override void GenerateBuildCode(GeneratorContext ctx, CodeExpression var)
        {
            if (Text.Length > 0)
            {
                PropertyDescriptor prop = (PropertyDescriptor)this.ClassDescriptor ["Text"];
                bool trans = prop.IsTranslated(Wrapped);

                ctx.Statements.Add(
                    new CodeAssignStatement(
                        new CodePropertyReferenceExpression(
                            new CodePropertyReferenceExpression(
                                var,
                                "Buffer"
                                ),
                            "Text"
                            ),
                        ctx.GenerateValue(Text, typeof(string), trans)
                        )
                    );
            }
            base.GenerateBuildCode(ctx, var);
        }
コード例 #7
0
ファイル: Action.cs プロジェクト: FreeBSD-DotNet/monodevelop
		internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
		{
			CodeObjectCreateExpression exp = new CodeObjectCreateExpression ();
			
			PropertyDescriptor prop = (PropertyDescriptor) ClassDescriptor ["Name"];
			exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType));
			
			prop = (PropertyDescriptor) ClassDescriptor ["Label"];
			string lab = (string) prop.GetValue (Wrapped);
			if (lab == "") lab = null;
			exp.Parameters.Add (ctx.GenerateValue (lab, prop.RuntimePropertyType, prop.Translatable));
			
			prop = (PropertyDescriptor) ClassDescriptor ["Tooltip"];
			exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable));
			
			prop = (PropertyDescriptor) ClassDescriptor ["StockId"];
			exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), prop.RuntimePropertyType, prop.Translatable));
			
			if (type == ActionType.Action)
				exp.CreateType = new CodeTypeReference ("Gtk.Action", CodeTypeReferenceOptions.GlobalReference);
			else if (type == ActionType.Toggle)
				exp.CreateType = new CodeTypeReference ("Gtk.ToggleAction", CodeTypeReferenceOptions.GlobalReference);
			else {
				exp.CreateType = new CodeTypeReference ("Gtk.RadioAction", CodeTypeReferenceOptions.GlobalReference);
				prop = (PropertyDescriptor) ClassDescriptor ["Value"];
				exp.Parameters.Add (ctx.GenerateValue (prop.GetValue (Wrapped), typeof(int)));
			}
			return exp;
		}
コード例 #8
0
ファイル: ComboBox.cs プロジェクト: Kalnor/monodevelop
		internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
		{
			if (textCombo && Items != null && Items.Length > 0) {
				foreach (string str in Items) {
					ctx.Statements.Add (new CodeMethodInvokeExpression (
						var,
						"AppendText",
						ctx.GenerateValue (str, typeof(string), true)
					));
				}
			}
			
			base.GenerateBuildCode (ctx, var);
		}
コード例 #9
0
		protected CodeExpression GenerateUiManagerElement (GeneratorContext ctx, ActionTree tree)
		{
			Widget topLevel = GetTopLevel ();
			string uiName = topLevel.UIManagerName;
			if (uiName != null) {
				CodeFieldReferenceExpression uiManager = new CodeFieldReferenceExpression (new CodeThisReferenceExpression (), uiName);
				if (topLevel.includedActionGroups == null)
					topLevel.includedActionGroups = new ArrayList ();
				
				// Add to the uimanager all action groups required by the 
				// actions of the tree
				
				foreach (ActionGroup grp in tree.GetRequiredGroups ()) {
					if (!topLevel.includedActionGroups.Contains (grp)) {
						// Insert the action group in the UIManager
						CodeMethodInvokeExpression mi = new CodeMethodInvokeExpression (
							uiManager,
							"InsertActionGroup",
							ctx.GenerateValue (grp, typeof(ActionGroup)),
							new CodePrimitiveExpression (topLevel.includedActionGroups.Count)
						);
						ctx.Statements.Add (mi);
						topLevel.includedActionGroups.Add (grp);
					}
				}
				
				tree.GenerateBuildCode (ctx, uiManager);
				return new CodeMethodInvokeExpression (
					uiManager,
					"GetWidget",
					new CodePrimitiveExpression ("/" + Wrapped.Name)
				);
			}
			return null;
		}
コード例 #10
0
ファイル: Button.cs プロジェクト: FreeBSD-DotNet/monodevelop
		internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
		{
			base.GenerateBuildCode (ctx, var);
			
			if (Type != ButtonType.TextAndIcon) {
				CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, "Label");
				PropertyDescriptor prop = (PropertyDescriptor) this.ClassDescriptor ["Label"];
				bool trans = Type != ButtonType.StockItem && prop.IsTranslated (Wrapped);
				CodeExpression val = ctx.GenerateValue (button.Label, typeof(string), trans);
				ctx.Statements.Add (new CodeAssignStatement (cprop, val));
			}
		}
コード例 #11
0
		protected virtual void GenerateChildPropertySet (GeneratorContext ctx, CodeVariableReferenceExpression var, ClassDescriptor containerChildClass, PropertyDescriptor prop, object child)
		{
			if (containerChildClass.InitializationProperties != null && Array.IndexOf (containerChildClass.InitializationProperties, prop) != -1)
				return;
			
			// Design time
			if (prop.Name == "AutoSize")
				return;
				
			object oval = prop.GetValue (child);
			if (oval == null || (prop.HasDefault && prop.IsDefaultValue (oval)))
				return;
				
			CodePropertyReferenceExpression cprop = new CodePropertyReferenceExpression (var, prop.Name);
			CodeExpression val = ctx.GenerateValue (oval, prop.RuntimePropertyType, prop.Translatable);
			ctx.Statements.Add (new CodeAssignStatement (cprop, val));
		}
コード例 #12
0
ファイル: Button.cs プロジェクト: Kalnor/monodevelop
		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));
				}
			}
		}