Ejemplo n.º 1
0
        public PropertyEditor(Type objectType, object objectInstance)
        {
            this.Build();
            buttonOk.Clicked += delegate
            {
                BindToObject();
                Destroy();
            };

            buttonCancel.Clicked += delegate
            {
                Destroy();
            };

            m_objectType = objectType;

            if (objectInstance == null || objectInstance.GetType() != objectType)
            {
                ObjectInstance = Activator.CreateInstance(objectType);
            }
            else
            {
                ObjectInstance = objectInstance;
            }

            m_widgetMap = new Dictionary <PropertyInfo, Widget>();
            BindToWidget();
            VBox.ResizeMode = ResizeMode.Immediate;
            VBox.CheckResize();

            ShowAll();
        }
Ejemplo n.º 2
0
    protected void OnTogglebuttonToggled(object sender, System.EventArgs e)
    {
        if (addNewOperation_togglebutton.Active)
        {
            Menu menu = new Menu();
            int  w, h;
            menu.GetSizeRequest(out w, out h);
            int menu_width = left_vbox.Allocation.Width;

            menu.SetSizeRequest(menu_width, h);

            Dictionary <MenuItem, Type> stage_operation_types = new Dictionary <MenuItem, Type>();

            for (int i = 0; i < mStageOperationTypes.Length; i++)
            {
                string name = StageOperationDescriptionAttribute.GetName(mStageOperationTypes[i]);
                if (name == null)
                {
                    name = mStageOperationTypes[i].Name;
                }
                string description = StageOperationDescriptionAttribute.GetDescription(mStageOperationTypes[i]);

                MenuItem item = new MenuItem();

                VBox item_vbox = new VBox();
                item_vbox.BorderWidth = 4;
                item_vbox.Show();


                Label lbl_name = new Label();
                lbl_name.Text    = name;
                lbl_name.Justify = Justification.Left;
                lbl_name.Xalign  = 0;

                // Setting the name font
                double name_size_k            = 1.1;
                Pango.FontDescription name_fd = FontHelpers.ScaleFontSize(lbl_name, name_size_k);
                name_fd.Weight = Pango.Weight.Bold;
                lbl_name.ModifyFont(name_fd);

                item_vbox.Add(lbl_name);
                lbl_name.Show();

                if (description != null && description != "")
                {
                    Label lbl_desc = new Label(description);
                    lbl_desc.LineWrapMode = Pango.WrapMode.Word;
                    lbl_desc.LineWrap     = true;
                    lbl_desc.Wrap         = true;

                    // Setting the description font
                    double desc_size_k            = 0.9;
                    Pango.FontDescription desc_fd = FontHelpers.ScaleFontSize(lbl_desc, desc_size_k);
                    lbl_desc.ModifyFont(desc_fd);

                    item_vbox.Add(lbl_desc);
                    lbl_desc.Show();
                    item_vbox.SizeAllocated += delegate(object o, SizeAllocatedArgs args) {
                        lbl_desc.WidthRequest = args.Allocation.Width - 10;
                    };
                }

                item.Child = item_vbox;
                stage_operation_types.Add(item, mStageOperationTypes[i]);

                item.Activated += delegate(object s, EventArgs ea) {
                    mStage.CreateAndAddNewItem(stage_operation_types[(MenuItem)s]).Active = true;
                    GtkScrolledWindow.HscrollbarPolicy  = PolicyType.Never;
                    GtkScrolledWindow.Vadjustment.Value = GtkScrolledWindow.Vadjustment.Upper;
                    ArrangeVBoxes();
                };

                menu.Append(item);
                item_vbox.CheckResize();
                //lbl_desc.WidthRequest = ww;
            }
            menu.Deactivated += delegate {
                addNewOperation_togglebutton.Active = false;
            };

            menu.ShowAll();
            menu.Popup(null, null, delegate(Menu m, out int x, out int y, out bool push_in) {
                int x1, y1, x0, y0;
                GdkWindow.GetOrigin(out x0, out y0);
                left_vbox.TranslateCoordinates(this, 0, 0, out x1, out y1);
                x       = x0 + x1;
                y       = y0 + y1;
                push_in = false;
            }, 0, 0);
        }
    }