public ActionGroupEditor() { changedEvent = new ObjectWrapperEventHandler(OnActionChanged); Gtk.Fixed fx = new Gtk.Fixed(); table = new Gtk.Table(0, 0, false); table.RowSpacing = 8; table.ColumnSpacing = 8; table.BorderWidth = 12; Gtk.EventBox ebox = new Gtk.EventBox(); ebox.ModifyBg(Gtk.StateType.Normal, this.Style.Backgrounds [0]); headerLabel = new EditableLabel(); headerLabel.MarkupTemplate = "<b>$TEXT</b>"; headerLabel.Changed += OnGroupNameChanged; Gtk.VBox vbox = new Gtk.VBox(); Gtk.Label grpLabel = new Gtk.Label(); grpLabel.Xalign = 0; grpLabel.Markup = string.Format("<small><i>{0}</i></small>", Catalog.GetString("Action Group")); // vbox.PackStart (grpLabel, false, false, 0); vbox.PackStart(headerLabel, false, false, 3); vbox.BorderWidth = 12; ebox.Add(vbox); Gtk.VBox box = new Gtk.VBox(); box.Spacing = 6; box.PackStart(ebox, false, false, 0); box.PackStart(table, false, false, 0); fx.Put(box, 0, 0); Add(fx); ShowAll(); }
public ActionGroupEditor() { changedEvent = new ObjectWrapperEventHandler (OnActionChanged); Gtk.Fixed fx = new Gtk.Fixed (); table = new Gtk.Table (0, 0, false); table.RowSpacing = 8; table.ColumnSpacing = 8; table.BorderWidth = 12; Gtk.EventBox ebox = new Gtk.EventBox (); ebox.ModifyBg (Gtk.StateType.Normal, this.Style.Backgrounds [0]); headerLabel = new EditableLabel (); headerLabel.MarkupTemplate = "<b>$TEXT</b>"; headerLabel.Changed += OnGroupNameChanged; Gtk.VBox vbox = new Gtk.VBox (); Gtk.Label grpLabel = new Gtk.Label (); grpLabel.Xalign = 0; grpLabel.Markup = "<small><i>Action Group</i></small>"; // vbox.PackStart (grpLabel, false, false, 0); vbox.PackStart (headerLabel, false, false, 3); vbox.BorderWidth = 12; ebox.Add (vbox); Gtk.VBox box = new Gtk.VBox (); box.Spacing = 6; box.PackStart (ebox, false, false, 0); box.PackStart (table, false, false, 0); fx.Put (box, 0, 0); Add (fx); ShowAll (); }
private void AddToTable(uint row, uint col, Gtk.Widget control, uint colSpan = 1) { var box = new Gtk.EventBox(); var al = new Gtk.Alignment(0, 0, control.GetType() == typeof(Gtk.Entry) ? 1 : 0, 1); al.SetPadding(0, 0, 5, 5); al.Add(control); box.Add(al); if (row % 2 == 1) { box.ModifyBg(Gtk.StateType.Normal, _altRowColor); } tblContainer.Attach(box, col, col + colSpan, row, row + 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0); }
void InitializeWidget() { _viewModel.Init(); // one row per option and one per group tblContainer.NRows = (uint)(_viewModel.GroupedOptions.Sum(x => x.Count()) + _viewModel.GroupedOptions.Count()) + 1; tblContainer.NColumns = 2; tblContainer.RowSpacing = 0; tblContainer.ColumnSpacing = 0; tblContainer.BorderWidth = 0; uint r = 0; var btn = new Gtk.Button(); btn.Label = "Reset to defaults"; btn.WidthRequest = 150; btn.Clicked += (sender, e) => { _viewModel.ResetToDefaults(); foreach (var item in tblContainer.Children) { item.Destroy(); } InitializeWidget(); }; tblContainer.Attach(btn, 0, 2, r, r + 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0); r++; foreach (var optionGroup in _viewModel.GroupedOptions) { // group label var grouplbl = new Gtk.Label(); grouplbl.SetAlignment(0f, 0.5f); grouplbl.HeightRequest = 40; grouplbl.Markup = $"<b> {optionGroup.Key}</b>"; var box = new Gtk.EventBox(); box.ModifyBg(Gtk.StateType.Normal, _groupHeaderColor); box.Add(grouplbl); tblContainer.Attach(box, 0, 2, r, r + 1, Gtk.AttachOptions.Fill, Gtk.AttachOptions.Fill, 0, 0); r++; foreach (var option in optionGroup) { // name label var lbl = new Gtk.Label(option.Name) { TooltipText = option.Description }; lbl.SetAlignment(0f, 0.5f); lbl.HeightRequest = 30; AddToTable(r, 0, lbl); var type = option.PropertyType; if (type == typeof(bool)) { var chk = new Gtk.CheckButton { Active = (bool)option.Property.GetValue(_viewModel.Options) }; chk.Clicked += (sender, e) => { option.Property.SetValue(_viewModel.Options, chk.Active); _viewModel.IsDirty = true; }; AddToTable(r, 1, chk); } else if (type == typeof(int)) { var val = (int)option.Property.GetValue(_viewModel.Options); var spin = new Gtk.SpinButton(0, 10, 1) { Value = val, WidthChars = 3 }; spin.ValueChanged += (sender, e) => { option.Property.SetValue(_viewModel.Options, (int)spin.Value); _viewModel.IsDirty = true; }; AddToTable(r, 1, spin); } else if (type == typeof(byte)) { var val = (byte)option.Property.GetValue(_viewModel.Options); var spin = new Gtk.SpinButton(0, 10, 1) { Value = val, WidthChars = 3 }; spin.ValueChanged += (sender, e) => { option.Property.SetValue(_viewModel.Options, (byte)spin.Value); _viewModel.IsDirty = true; }; AddToTable(r, 1, spin); } else if (type == typeof(string)) { var val = (string)option.Property.GetValue(_viewModel.Options); var txt = new Gtk.Entry(val); txt.Alignment = 0; txt.Changed += (sender, e) => { option.Property.SetValue(_viewModel.Options, txt.Text); _viewModel.IsDirty = true; }; AddToTable(r, 1, txt); } else if (type == typeof(string[])) { var vals = (string[])option.Property.GetValue(_viewModel.Options); var val = string.Join(Environment.NewLine, vals); var txt = new Gtk.TextView(new Gtk.TextBuffer(new Gtk.TextTagTable())); txt.LeftMargin = 5; txt.RightMargin = 5; txt.BorderWidth = 1; txt.SetSizeRequest(320, 150); txt.Buffer.Text = val; txt.Buffer.Changed += (sender, e) => { var newVals = txt.Buffer.Text.Split(Environment.NewLine.ToCharArray()); option.Property.SetValue(_viewModel.Options, newVals); _viewModel.IsDirty = true; }; var frame = new Gtk.Frame(); frame.Shadow = Gtk.ShadowType.In; frame.BorderWidth = 5; frame.Child = txt; AddToTable(r, 1, frame); } else if (type.IsEnum) { var val = option.Property.GetValue(_viewModel.Options); var values = Enum.GetNames(type); var cmb = new Gtk.ComboBox(values); cmb.Active = Array.IndexOf(values, val.ToString()); cmb.Changed += (sender, e) => { option.Property.SetValue(_viewModel.Options, Enum.Parse(type, cmb.ActiveText)); _viewModel.IsDirty = true; }; AddToTable(r, 1, cmb); } r++; } } alContainer.ShowAll(); }
private void Build() { global::Stetic.Gui.Initialize(this); // Widget Client.Forms.Notification this.Name = "notification"; this.Title = "Notification"; this.TypeHint = Gdk.WindowTypeHint.Normal; this.WindowPosition = ((global::Gtk.WindowPosition)(4)); // Container child Client.Forms.Notification.Gtk.Container+ContainerChild this.vbox1 = new global::Gtk.VBox(); this.vbox1.Name = "vbox1"; this.Icon = Gdk.Pixbuf.LoadFromResource("Client.Resources.pigeon_clip_art_hight.ico"); this.vbox1.Spacing = 6; // Container child vbox1.Gtk.Box+BoxChild this.label1 = new global::Gtk.Label(); this.label1.HeightRequest = 20; this.label1.Name = "label1"; this.label1.LabelProp = "Notification"; this.vbox1.Add(this.label1); global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.label1])); w1.Position = 0; w1.Expand = false; w1.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.hbox1 = new global::Gtk.HBox(); this.hbox1.Name = "hbox1"; this.hbox1.Spacing = 6; // Container child hbox1.Gtk.Box+BoxChild this.image1 = new global::Gtk.Image(); this.image1.Name = "image1"; this.image1.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("Client.Resources.icon.png"); this.hbox1.Add(this.image1); global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.image1])); w2.Position = 0; w2.Expand = false; w2.Fill = false; // Container child hbox1.Gtk.Box+BoxChild this.label2 = new global::Gtk.Label(); this.label2.Name = "label2"; this.label2.WidthRequest = 260; this.label2.Wrap = true; this.label2.LabelProp = "Description"; this.hbox1.Add(this.label2); global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label2])); w3.Position = 1; w3.Expand = false; w3.Fill = false; this.vbox1.Add(this.hbox1); global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.hbox1])); w4.Position = 1; w4.Expand = false; w4.Fill = false; root = new Gtk.EventBox(); root.ModifyBg(Gtk.StateType.Normal, Core.FromColor(System.Drawing.Color.Orange)); root.Add(this.vbox1); this.Decorated = false; this.Add(root); if ((this.Child != null)) { this.Child.ShowAll(); } this.DefaultWidth = 460; this.DefaultHeight = 220; }