int activeIndex; //the index of the child that's "active": the entry or the clickable thingy. public TextEditableField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) { this.property = property; this.obj = (IDependable)obj; this.context = context; editable = attribute.EditAuthorized(obj); if (!context.compact) { activeIndex = 1; Label label = new Label((attribute.overrideLabel ?? UIFactory.ToReadable(property.Name)) + ": "); PackStart(label, false, false, 0); } if (attribute.tooltipText != "") { HasTooltip = true; TooltipMarkup = attribute.tooltipText; } rightclickMenu = new Menu(); MenuItem edit = new MenuItem("Edit"); edit.Activated += Open; rightclickMenu.Append(edit); Reload(); }
public ColorField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) { this.property = property; this.obj = (IGUIComplete)obj; this.context = context; Label label = new Label(UIFactory.ToReadable(property.Name) + ": "); PackStart(label, false, false, 0); colorButton = new ClickableEventBox { VisibleWindow = true, BorderWidth = 1 }; Graphics.SetAllBg(colorButton, (Gdk.Color)property.GetValue(obj)); PackStart(colorButton, false, false, 0); if (attribute.tooltipText != "") { HasTooltip = true; TooltipMarkup = attribute.tooltipText; } colorButton.SetSizeRequest(0, 0); SizeAllocated += InitializeDisplay; colorButton.DoubleClicked += OpenPicker; }
public Banner(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) { SetAlignment(0.5f, 0.5f); Justify = Justification.Center; UseMarkup = true; Markup = (string)property.GetValue(obj); }
public static Widget Fabricate(object obj, string propertyName, Context context) { PropertyInfo property = obj.GetType().GetProperty(propertyName); DisplayableAttribute attribute = (DisplayableAttribute)property.GetCustomAttribute(typeof(DisplayableAttribute)); return((Widget)attribute.widget.GetConstructor(constructorSignature) .Invoke(new object[] { property, obj, context, attribute })); }
public ActionField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(new Gtk.Alignment(0, 0, 1, 1)) { action = (GameAction)property.GetValue(obj); Gtk.Alignment alignment = (Gtk.Alignment)Child; alignment.Add(new Label(action.name)); if (attribute.arg != null) { alignment.BorderWidth = (uint)(int)attribute.arg; } TooltipText = action.description; Sensitive = action.condition(context); Clicked += (o, a) => action.action(context); }
public RatingsMultiviewField (PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) { this.context = context; BorderWidth = 5; // Nest containers VBox mainBox = new VBox(); HBox navigation = new HBox(); SquareContainer square = new SquareContainer(); notebook = new Notebook { ShowTabs = false, ShowBorder = false }; square.Add(notebook); mainBox.PackStart(navigation, false, false, 5); mainBox.PackStart(square, true, true, 0); Add(mainBox); // Navigation Label pageLabel = new Label("Table"); ClickableEventBox leftArrow = new ClickableEventBox(); leftArrow.Add(Graphics.GetIcon(IconTemplate.LeftArrow, new Gdk.Color(100, 100, 100), Graphics.textSize)); leftArrow.Clicked += delegate { if (notebook.CurrentPage > 0) { notebook.CurrentPage--; } else { notebook.CurrentPage = notebook.NPages - 1; } pageLabel.Text = labels[notebook.CurrentPage]; }; ClickableEventBox rightArrow = new ClickableEventBox(); rightArrow.Add(Graphics.GetIcon(IconTemplate.RightArrow, new Gdk.Color(100, 100, 100), Graphics.textSize)); rightArrow.Clicked += delegate { if (notebook.CurrentPage < notebook.NPages - 1) { notebook.CurrentPage++; } else { notebook.CurrentPage = 0; } pageLabel.Text = labels[notebook.CurrentPage]; }; navigation.PackStart(leftArrow, false, false, 5); navigation.PackStart(pageLabel, true, true, 0); navigation.PackStart(rightArrow, false, false, 5); // Fill notebook RatingsProfile profile = ((Func<Context, RatingsProfile>)property.GetValue(obj))(context); RatingsRadarChart radar = new RatingsRadarChart(context.butCompact, profile, null, null); RatingsTable table = new RatingsTable(context.butCompact, profile); notebook.AppendPage(radar, null); notebook.AppendPage(UIFactory.Align(table, 0.5f, 0.5f, 0, 0), null); }
public ReadonlyField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) { this.property = property; this.obj = obj; this.context = context; text = GetValueAsString(); if (context.compact) { Text = text; } else { Text = (attribute.overrideLabel ?? UIFactory.ToReadable(property.Name)) + ": " + text; } SetAlignment(0, 0.5f); }
public ObjectField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(0, 0, 1, 1) { this.property = property; this.obj = (IGUIComplete)property.GetValue(obj); this.context = context; title = attribute.overrideLabel ?? UIFactory.ToReadable(property.Name); if (this.obj != null) { DependencyManager.Connect(this.obj, this); Destroyed += (o, a) => DependencyManager.DisconnectAll(this); Reload(); } else { Label label = new Label(title + ": None"); label.SetAlignment(0, 0); Add(label); } }
public ExpressionField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(0, 0, 1, 1) { this.property = property; this.obj = obj; exp = (Expression)property.GetValue(obj); this.context = context; title = attribute.overrideLabel ?? UIFactory.ToReadable(property.Name); Label label = new Label(); label.UseMarkup = true; label.Justify = Justification.Right; label.SetAlignment(0, 0); //Multi-line expressions are put in an expander with the label text being the formattedResult of the expression. if (exp.text.Contains("\n")) { Expander expander = new Expander(title + ": " + exp.formattedResult); expander.Activated += (o, a) => ReloadLabel(); label.Markup = exp.ToString(); expander.Add(new Gtk.Alignment(0, 0, 1, 1) { Child = label, LeftPadding = 10, BottomPadding = 5 }); Add(expander); } else { label.Markup = title + ": " + exp; Add(label); } if (attribute.tooltipText != "") { HasTooltip = true; TooltipMarkup = attribute.tooltipText; } }
public DialogTextEditableField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(false, 2) { this.property = property; this.obj = (IDependable)obj; this.context = context; editable = attribute.EditAuthorized(obj); // Create the label if (!context.compact) { Label label = new Label(attribute.overrideLabel ?? UIFactory.ToReadable(property.Name) + ": "); label.SetAlignment(0, 1); if (attribute.tooltipText != null) { label.HasTooltip = true; label.TooltipMarkup = attribute.tooltipText; } PackStart(label, false, false, 0); } // Create the text body Label val = new Label((string)property.GetValue(obj)); if (val.Text == "") { val.Text = "-"; } val.SetAlignment(0, 0); if (!context.compact) { val.LineWrap = true; val.Justify = Justification.Fill; val.SetSizeRequest(0, -1); val.SizeAllocated += (o, a) => val.SetSizeRequest(a.Allocation.Width, -1); val.LineWrapMode = Pango.WrapMode.WordChar; } //Create the "clickable" functionality ClickableEventBox eventBox = new ClickableEventBox(); eventBox.DoubleClicked += OpenDialog; eventBox.RightClicked += delegate { rightclickMenu.Popup(); rightclickMenu.ShowAll(); }; if (context.compact) { Gtk.Alignment alignment = UIFactory.Align(val, 0, 0, 1, 1); alignment.BorderWidth = 5; if (editable) { eventBox.Add(alignment); PackStart(eventBox); } else { PackStart(alignment); } } else { Gtk.Alignment alignment = new Gtk.Alignment(0, 0, 1, 1); if (editable) { eventBox.Add(val); alignment.Add(eventBox); } else { alignment.Add(val); } alignment.LeftPadding = 10; PackStart(alignment, true, true, 0); } rightclickMenu = new Menu(); MenuItem edit = new MenuItem("Edit"); edit.Activated += OpenDialog; rightclickMenu.Append(edit); }
public PercentageField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(property, obj, context, attribute) { }
public TabularContainerField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(1, 1, false) { // arg ought to be a string[] containing the names of child properties. Here we turn it into a list and // use ConvertAll() to obtain the list of actual PropertyInfos. children = Array.ConvertAll((object[])attribute.arg, (str) => (string)str); this.context = context; ColumnSpacing = 5; RowSpacing = 2; Label label = new Label(UIFactory.ToReadable(property.Name) + ": "); if (attribute.tooltipText != "") { label.HasTooltip = true; label.TooltipMarkup = attribute.tooltipText; } Attach(label, 0, 1, 0, (uint)(2 * children.Length - 1), AttachOptions.Shrink, AttachOptions.Fill, 0, 0); Attach(new VSeparator(), 1, 2, 0, (uint)(2 * children.Length - 1), AttachOptions.Shrink, AttachOptions.Fill, 0, 0); for (int i = 0; i < children.Length; i++) { Widget childWidget = UIFactory.Fabricate(obj, children[i], context); Attach(childWidget, 2, 3, 2 * (uint)i, 2 * (uint)i + 1); if (i != children.Length - 1) { Attach(new HSeparator(), 2, 3, 2 * (uint)i + 1, 2 * (uint)i + 2); } } }
public IntVector2Field(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(property, obj, context, attribute) { }
public BasicReadonlyField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(property, obj, context, attribute) { }
public FractionsBar(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(1, 3, false) { fractions = (Fraction[])property.GetValue(obj); this.context = context; if ((bool)attribute.arg != false) { RowSpacing = 2; Label title = new Label("[ " + UIFactory.ToReadable(property.Name) + " ]"); Attach(title, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, 0, 2); } if (attribute.tooltipText != "") { HasTooltip = true; TooltipMarkup = attribute.tooltipText; } float leftspace = 0; for (int i = 0; i < fractions.Length; i++) { float spaceAlloc; if (fractions[i].val > 0.99) { spaceAlloc = 0; } else if (fractions[i].val < 0.01) { leftspace += fractions[i].val; continue; } else { spaceAlloc = leftspace / (1 - fractions[i].val); //xalign = % of free space allocated to the left = (free space to left)/(total free space). //Conditional eliminates division by zero issue } Frame frame = new Frame(); Graphics.SetAllBg(frame, fractions[i].color); Gtk.Alignment alignment = new Gtk.Alignment(spaceAlloc, 0, fractions[i].val, 1); alignment.Add(frame); frame.SetSizeRequest(0, -1); Attach(alignment, 0, 1, 1, 2); //A bunch of logic to try and make sure the label fits in the box. if (fractions[i].val > 0.1 || fractions.Length <= 2) { if (fractions[i].val <= 0.2) { frame.Child = new Label(fractions[i].val.ToString("P0")); } else { frame.Child = new Label(fractions[i].val.ToString("P1")); } frame.Child.SetSizeRequest(0, -1); Label label = new Label { UseMarkup = true, Markup = "<small>" + fractions[i].name + "</small>" }; label.SetAlignment(spaceAlloc, 0); label.SetSizeRequest(0, -1); Attach(label, 0, 1, 2, 3); } leftspace += fractions[i].val; } }
public DeploymentForceSelectionField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(false, 0) { deployment = (Deployment)obj; bool editable = attribute.EditAuthorized(obj); PackStart(new Label(UIFactory.ToReadable(property.Name) + ": "), false, false, 0); buttons = new RadioButton[4]; buttons[0] = new RadioButton("C"); buttons[1] = new RadioButton(buttons[0], "B"); buttons[2] = new RadioButton(buttons[0], "A"); buttons[3] = new RadioButton(buttons[0], "S"); buttons[(int)deployment.force_employed].Active = true; foreach (RadioButton button in buttons) { button.Toggled += OnThreatToggled; if (!editable || (deployment.affiliation != Game.player && !Game.omnipotent)) { button.State = StateType.Insensitive; } PackStart(button, false, false, 0); } }
public BasicHContainerField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(true, 10) { string[] children = Array.ConvertAll((object[])attribute.arg, (str) => (string)str); for (int i = 0; i < children.Length; i++) { Widget childWidget = UIFactory.Fabricate(obj, children[i], context.butCompact); PackStart(childWidget, true, true, 0); } BorderWidth = 10; }
public SlashDelimitedContainerField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) { string[] children = Array.ConvertAll((object[])attribute.arg, (str) => (string)str); Label label = new Label(UIFactory.ToReadable(property.Name) + ": "); if (attribute.tooltipText != "") { label.HasTooltip = true; label.TooltipMarkup = attribute.tooltipText; } PackStart(label, false, false, 0); for (int i = 0; i < children.Length; i++) { Widget childWidget = UIFactory.Fabricate(obj, children[i], context.butCompact); PackStart(childWidget, false, false, 0); if (i != children.Length - 1) { PackStart(new Label("/"), false, false, 0); } } }
public TabularListField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) //obj must be an IContainer. { VisibleWindow = false; parent = (IContainer)obj; this.context = context; editable = attribute.EditAuthorized(obj); // Local convenience variable List <T> list = (List <T>)property.GetValue(obj); // To align contents properly. Gtk.Alignment alignment = new Gtk.Alignment(0, 0, 1, 1) { TopPadding = 3, BottomPadding = 3 }; Add(alignment); if (editable) { // Creates rightclick menu for listwide management rightclickMenu = new Menu(); // "Clear" button MenuItem clearButton = new MenuItem("Clear"); //Clears list clearButton.Activated += delegate { ((IContainer)obj).RemoveRange(new List <T>(list)); DependencyManager.TriggerAllFlags(); }; rightclickMenu.Append(clearButton); // "Add existing" button, but only if it's a list of GameObjects which can be searched from SelectorDialog. if (typeof(T).IsSubclassOf(typeof(GameObject))) { MenuItem addExistingButton = new MenuItem("Add"); rightclickMenu.Append(addExistingButton); addExistingButton.Activated += (o, a) => new SelectorDialog( "Select new addition to " + UIFactory.ToReadable(property.Name) + " (shift to add multiple)", AddExistingFilter, delegate(GameObject returned) { ((IContainer)obj).Add(returned); DependencyManager.TriggerAllFlags(); }, true); } // "Add new" button if (Game.omnipotent) { MenuItem addNewButton = new MenuItem("Add New"); addNewButton.Activated += delegate { object newElement; ConstructorInfo constructor = typeof(T).GetConstructor(new Type[] { }); if (constructor != null) { newElement = constructor.Invoke(new object[0]); } else { MethodInfo method = typeof(T).GetMethod("Create"); if (method != null) { newElement = method.Invoke(null, new object[0]); if (newElement == null) { return; } } else { throw new NotImplementedException(); } } ((IContainer)obj).Add(newElement); if (newElement is GameObject) { Game.city.Add((GameObject)newElement); } DependencyManager.TriggerAllFlags(); }; rightclickMenu.Append(addNewButton); } } // Load tooltip (if exists) if (attribute.tooltipText != "") { HasTooltip = true; TooltipMarkup = attribute.tooltipText; } if (context.vertical) { int columns = (int)attribute.arg; if (columns < 0) { columns *= -1; } DynamicTable table = new DynamicTable(list.ConvertAll((element) => GetElementWidget(element)), (uint)columns); if (context.compact) { if (editable) { EventBox eventBox = new EventBox { Child = table, VisibleWindow = false }; alignment.Add(eventBox); eventBox.ButtonPressEvent += ListPressed; //Set up right-click menu MyDragDrop.DestSet(eventBox, typeof(T).Name); //Set up MyDragDrop.DestSetDropAction(eventBox, AttemptDrag); //drag support } else { alignment.Add(table); } } else { Expander expander = new Expander(attribute.overrideLabel ?? UIFactory.ToReadable(property.Name)); expander.Expanded = (int)attribute.arg > 0; expander.Add(table); alignment.Add(expander); if (editable) { expander.ButtonPressEvent += ListPressed; //Set up right-click menu MyDragDrop.DestSet(expander, typeof(T).Name); //Set up MyDragDrop.DestSetDropAction(expander, AttemptDrag); //drag support } } } else { HBox box = new HBox(false, 5); Label label = new Label(UIFactory.ToReadable(property.Name)) { Angle = 90 }; if (editable) { ClickableEventBox labelEventBox = new ClickableEventBox { Child = label }; labelEventBox.RightClicked += delegate { rightclickMenu.Popup(); rightclickMenu.ShowAll(); }; box.PackStart(labelEventBox, false, false, 2); //Set up drag support MyDragDrop.DestSet(this, typeof(T).Name); MyDragDrop.DestSetDropAction(this, AttemptDrag); } else { box.PackStart(label, false, false, 2); } for (int i = 0; i < list.Count; i++) { box.PackStart(GetElementWidget(list[i]), false, false, 0); } alignment.Add(box); } }
public RatingsListField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(0, 0, 1, 1) { RatingsProfile profile = ((Func <Context, RatingsProfile>)property.GetValue(obj))(context); float[,] values = profile.values; int[,] o_vals = profile.o_vals; Gtk.Alignment alignment = new Gtk.Alignment(0, 0, 1, 0); if (context.vertical && !context.compact) { Frame frame = new Frame(UIFactory.ToReadable(property.Name)); VBox box = new VBox(false, 4) { BorderWidth = 5 }; frame.Add(box); alignment.Add(frame); for (int i = 1; i <= 8; i++) { if (o_vals[0, i] != Ratings.O_NULL) { Label ratingLabel = new Label(Ratings.PrintSingle(i, values[0, i])); ratingLabel.SetAlignment(0, 0); box.PackStart(ratingLabel); } } for (int k = 1; k <= 3; k++) { if (o_vals[k, 0] != Ratings.O_NULL) { Label wrapperLabel = new Label(Ratings.PrintSingle(k + 8, values[k, 0])); wrapperLabel.SetAlignment(0, 0); VBox ratingBox = new VBox(false, 5) { BorderWidth = 5 }; Frame ratingFrame = new Frame { LabelWidget = wrapperLabel, Child = ratingBox }; for (int i = 1; i <= 8; i++) { if (o_vals[k, i] != Ratings.O_NULL) { Label ratingLabel = new Label(Ratings.PrintSingle(i, values[k, i])); ratingLabel.SetAlignment(0, 0); ratingBox.PackStart(ratingLabel, false, false, 0); } } box.PackStart(ratingFrame); } } } else { Box box; if (context.compact) { box = new VBox(false, 0) { BorderWidth = 5 }; } else { box = new HBox(false, 0) { BorderWidth = 5 }; } alignment.Add(box); for (int i = 1; i <= 8; i++) { if (o_vals[0, i] != Ratings.O_NULL) { bool comma = !context.compact && box.Children.Length > 0; Label ratingLabel = new Label((comma ? ", " : "") //Commas to delimit ratings + Ratings.PrintSingle(i, values[0, i])); ratingLabel.SetAlignment(0, 0); box.PackStart(ratingLabel, false, false, 0); } } for (int k = 1; k <= 3; k++) { if (o_vals[k, 0] != Ratings.O_NULL) { bool comma = !context.compact && box.Children.Length > 0; Label ratingLabel = new Label((comma ? ", " : "") //Commas to delimit ratings + Ratings.PrintSingle(k + 8, values[k, 0], true)); ratingLabel.SetAlignment(0, 0); List <String> subratings = new List <String>(); for (int i = 1; i <= 8; i++) { if (o_vals[k, i] != Ratings.O_NULL) { subratings.Add(Ratings.PrintSingle(i, values[k, i])); } } ratingLabel.TooltipText = String.Join("\n", subratings); box.PackStart(ratingLabel, false, false, 0); } } } if (attribute.EditAuthorized(obj)) { ClickableEventBox clickableEventBox = new ClickableEventBox { Child = alignment }; clickableEventBox.DoubleClicked += delegate { // The property this is attached to gets the *current ratings*, not the *base ratings*, which are // what we logically want to let the user manipulate. Hence, the optional arg supplied is the name // of the base profile. PropertyInfo baseProfileProperty = obj.GetType().GetProperty((string)attribute.arg); TextEditingDialog dialog = new TextEditingDialog( "Edit ratings", (Window)Toplevel, delegate { RatingsProfile baseProfile = (RatingsProfile)baseProfileProperty.GetValue(obj); return(Ratings.Print(baseProfile.values, baseProfile.o_vals)); }, delegate(string input) { if (Ratings.TryParse(input, out RatingsProfile? newRatings)) { baseProfileProperty.SetValue(obj, (RatingsProfile)newRatings); IDependable dependable = obj as IDependable; if (dependable != null) { DependencyManager.Flag(dependable); DependencyManager.TriggerAllFlags(); } return(true); } return(false); } ); }; Add(clickableEventBox); } else { Add(alignment); } }
public CellTabularListField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(property, obj, context, attribute) { }
public static VBox GenerateVertical(Context context, object obj) { context = context.butVertical; //Load up all properties List <PropertyInfo> properties = new List <PropertyInfo>(obj.GetType().GetProperties()); List <Tuple <PropertyInfo, DisplayableAttribute> > pairs = properties.ConvertAll( (property) => new Tuple <PropertyInfo, DisplayableAttribute>(property, (DisplayableAttribute)property.GetCustomAttribute(typeof(DisplayableAttribute)))); pairs.RemoveAll((pair) => pair.Item2 == null || !pair.Item2.generate || pair.Item2.horizontalOnly || !pair.Item2.ViewAuthorized(obj)); pairs.Sort((x, y) => x.Item2.order.CompareTo(y.Item2.order)); //Create boxes VBox mainBox = new VBox(false, 0) { BorderWidth = 5 }; VBox emphasisBox = null; //Draw each property foreach (Tuple <PropertyInfo, DisplayableAttribute> pair in pairs) { PropertyInfo property = pair.Item1; DisplayableAttribute attribute = pair.Item2; //Construct the widget ConstructorInfo constructor = attribute.widget.GetConstructor(constructorSignature); Widget newWidget = (Widget)constructor.Invoke(new object[] { pair.Item1, obj, attribute.forceHorizontal ? context.butHorizontal : context, attribute }); //Manage padding if (attribute.topPadding != 0 || attribute.bottomPadding != 0 || attribute.leftPadding != 0 || attribute.rightPadding != 0) { newWidget = new Gtk.Alignment(0, 0, 1, 1) { Child = newWidget, TopPadding = attribute.topPadding, BottomPadding = attribute.bottomPadding, LeftPadding = attribute.leftPadding, RightPadding = attribute.rightPadding }; } if (!attribute.fillSides) { newWidget = Align(newWidget, 0.5f, 0, 0, 1); } //Manage emphasis if (attribute.emphasized || attribute.emphasizedIfVertical) { if (emphasisBox == null) // If no emphasisBox at the moment, { emphasisBox = new VBox(false, 5); // make one. } emphasisBox.PackStart(new HSeparator(), false, false, 0); // Install a delimiter emphasisBox.PackStart(newWidget, attribute.expand, attribute.expand, 0); // Pack the widget into emphasisBox } else // and non-emphasis { if (emphasisBox != null) { emphasisBox.PackStart(new HSeparator(), false, false, 0); // Finish off the emphasis box mainBox.PackStart(emphasisBox, false, false, 6); // And pack emphasisBox into mainBox emphasisBox = null; // Null it so we know to create a new one next time } mainBox.PackStart(newWidget, attribute.expand, attribute.expand, 2); // Now actually pack the current widget } } //Pack the emphasisBox into mainBox if it's not already. if (emphasisBox != null) { emphasisBox.PackStart(new HSeparator(), false, false, 0); mainBox.PackStart(emphasisBox, true, true, 5); emphasisBox = null; } return(mainBox); }
public static VBox GenerateHorizontal(Context context, object obj) { context = context.butHorizontal; //Load up all properties List <PropertyInfo> properties = new List <PropertyInfo>(obj.GetType().GetProperties()); List <Tuple <PropertyInfo, DisplayableAttribute> > pairs = properties.ConvertAll( (property) => new Tuple <PropertyInfo, DisplayableAttribute>(property, (DisplayableAttribute)property.GetCustomAttribute(typeof(DisplayableAttribute)))); pairs.RemoveAll((pair) => pair.Item2 == null || !pair.Item2.generate || pair.Item2.verticalOnly || !pair.Item2.ViewAuthorized(obj)); pairs.Sort((x, y) => x.Item2.order.CompareTo(y.Item2.order)); //Initialize boxes VBox mainBox = new VBox(false, 10) { BorderWidth = 5 }; HBox regularBox = new HBox(false, 0); VBox emphasisBox = new VBox(false, 2); foreach (Tuple <PropertyInfo, DisplayableAttribute> pair in pairs) { PropertyInfo property = pair.Item1; DisplayableAttribute attribute = pair.Item2; //Obtain the correct constructor ConstructorInfo constructor = (attribute.altWidget ?? attribute.widget).GetConstructor(constructorSignature); //Construct the widget Widget newWidget = (Widget)constructor.Invoke(new object[] { property, obj, attribute.forceVertical?context.butVertical:context, attribute }); if (!attribute.fillSides) { newWidget = Align(newWidget, 0, 0.5f, 1, 0); } //Pack into the correcumentt box (emphasisBox/regularBox) if (attribute.emphasized || attribute.emphasizedIfHorizontal) { emphasisBox.PackStart(newWidget, attribute.expand, attribute.expand, 0); } else { if (regularBox.Children.Length > 0) { regularBox.PackStart(new VSeparator(), false, false, 5); } regularBox.PackStart(newWidget, attribute.expand, attribute.expand, 0); } } //Pack emphasisBox and regularBox into mainBox mainBox.PackStart(new Gtk.Alignment(0, 0, 1, 1) { Child = regularBox, RightPadding = 5 }, false, false, 0); mainBox.PackStart(emphasisBox, false, false, 0); return(mainBox); }