private static List<Control> AddActionProperty(IViewProperty viewProperty) { var property = ((ActionViewProperty) viewProperty); var actionControl = new Button() { Text = property.Title, }; int preferedWidth = actionControl.PreferredSize.Width; actionControl.Width = preferedWidth < DefaultActionControlWidth ? DefaultActionControlWidth : preferedWidth; actionControl.Dock = property.FixedSize? DockStyle.None : DockStyle.Fill; actionControl.Click += (s, e) => property.Perform(); var controls = new List<Control>(); for (int i = 0; i < property.ShiftColumnsCount; i++) controls.Add(null); controls.Add(actionControl); return controls; }
private static Label GetLabel(IViewProperty viewProperty) { var label = new Label { Location = new Point(0, 0), TextAlign = ContentAlignment.MiddleRight, Text = viewProperty.Title, Dock = DockStyle.Right }; label.Size = label.PreferredSize; viewProperty.TitleChanged += (s, e) => { label.Text = viewProperty.Title; label.Size = label.PreferredSize; }; return label; }
private static List<Control> AddTextProperty(IViewProperty viewProperty) { var property = ((TextViewProperty) viewProperty); var valueControl = new TextBox { Text = property.Value, Dock = DockStyle.Fill, Width = DefaultTextPropertyWidth, ReadOnly = property.ReadOnly }; valueControl.TextChanged += (s, e) => property.Value = valueControl.Text; return new List<Control> { GetLabel(viewProperty), valueControl }; }
private static List<Control> AddNumericProperty(IViewProperty viewProperty) { var hostControl = new UserControl {Width = DefaultNumberPropertyWidth}; var property = ((NumberViewProperty) viewProperty); var valueControl = new NumericUpDown { Value = property.Value, Margin = new Padding(0, 0, 0, 0), Dock = DockStyle.Fill, DecimalPlaces = property.Attributes.DecimalPlaces, }; hostControl.Controls.Add(valueControl); var textControl = new TextBox { Text = GetTextValue(property), Dock = DockStyle.Fill, Margin = new Padding(0,0,0,0), ReadOnly = true }; hostControl.Controls.Add(textControl); valueControl.ValueChanged += delegate { property.Value = valueControl.Value; textControl.Text = GetTextValue(property); }; ApplyReadOnlyStateToCompositeControl(property.ReadOnly, valueControl, textControl); property.ReadOnlyChanged += (s, e) => ApplyReadOnlyStateToCompositeControl(e.Value, valueControl, textControl); return new List<Control> {GetLabel(viewProperty), valueControl}; }
public bool Equals(IViewProperty other) { return(EqualityComparer <string> .Default.Equals(Name, other?.Name)); }