public static bool IsReadOnly(this INZazuWpfField field) { if (field == null) { throw new ArgumentNullException(nameof(field)); } if (!field.IsEditable) { return(true); } if (field is INZazuWpfFieldContainer) { return(true); } var control = field.ValueControl; if (control == null) { return(true); } var textBox = control as TextBoxBase; return(textBox != null ? textBox.IsReadOnly : !control.IsEnabled); }
public static void SetReadOnly(this INZazuWpfField field, bool isReadOnly) { if (field == null) { throw new ArgumentNullException(nameof(field)); } if (!field.IsEditable) { return; } if (field is INZazuWpfFieldContainer) { return; } var control = field.ValueControl; if (control == null) { return; } var textBox = control as TextBoxBase; if (textBox != null) { textBox.IsReadOnly = isReadOnly; } else { control.IsEnabled = !isReadOnly; } }
public override void AttachTo(INZazuWpfField field, INZazuWpfView view) { if (field == null) { throw new ArgumentNullException(nameof(field)); } }
public static bool IsValid(this INZazuWpfField field) { if (field == null) { throw new ArgumentNullException(nameof(field)); } return(field.Validate().IsValid); }
public FieldFocusChangedEventArgs(INZazuWpfField newFocusedElement, INZazuWpfField oldFocusedElement = null, INZazuWpfField parentElement = null) { //NewFocusedElement = newFocusedElement ?? throw new ArgumentNullException(nameof(newFocusedElement)); NewFocusedElement = newFocusedElement; OldFocusedElement = oldFocusedElement; ParentElement = parentElement; }
private void DataTableFieldOnTableFieldFocusChanged(object sender, FieldFocusChangedEventArgs e) { var oldFocusedElement = _lastFocusedElement; _lastFocusedElement = e.NewFocusedElement; OnFieldFocusChanged(new FieldFocusChangedEventArgs(_lastFocusedElement, oldFocusedElement, e.ParentElement)); }
private void AddField(INZazuWpfField field) { if (field is NZazuDataTableField dataTableField) { dataTableField.TableFieldFocusChanged += DataTableFieldOnTableFieldFocusChanged; } _fields.Add(field.Key, field); }
public void AttachTo(INZazuWpfField field, INZazuWpfView view) { if (field == null) { throw new ArgumentNullException(nameof(field)); } var valueControl = field.ValueControl; Control = valueControl; Control.BorderThickness = new Thickness(Thickness); var rgb = ForegroundColor.Split(',').Select(byte.Parse).ToArray(); Control.BorderBrush = new SolidColorBrush(Color.FromRgb(rgb[0], rgb[1], rgb[2])); }
protected void ProcessGroupField( IResolveLayout resolveLayout, Control control, INZazuWpfField field) { var contentControl = control as ContentControl; if (!(field is INZazuWpfFieldContainer groupField) || contentControl == null) { return; } var layout = SafeResolve(resolveLayout, groupField.Layout); layout.DoLayout(contentControl, groupField.Fields, resolveLayout); }
private void ValueControlOnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { if (sender is Control control) { if (_fields.ContainsKey(control.Name)) { var oldFocusedElement = _lastFocusedElement; // remember ctrl with focus for state var newFocusedElement = _fields[control.Name]; _lastFocusedElement = newFocusedElement; OnTableFieldFocusChanged(new FieldFocusChangedEventArgs(newFocusedElement, oldFocusedElement, this)); } } }
private void InitializeComponent() { // cf.: http://compiledexperience.com/blog/posts/using-caliburn-micro-as-a-data-template-selector/ // we make this tab selectable so we can jump directly into the last selected field Layout.Focusable = true; Layout.IsTabStop = true; Layout.VerticalContentAlignment = VerticalAlignment.Stretch; Layout.HorizontalContentAlignment = HorizontalAlignment.Stretch; SetHorizontalScrollBarVisibility(Layout, ScrollBarVisibility.Visible); SetVerticalScrollBarVisibility(Layout, ScrollBarVisibility.Visible); Layout.LostFocus += (s, e) => ApplyChanges(); Layout.GotKeyboardFocus += (s, e) => { var oldFocusedElement = _lastFocusedElement; // remember ctrl with focus for state var newFocusedElement = GetFocusedControl(e.NewFocus as FrameworkElement); // now if I focus on the control, I focus on the last field if (Equals(e.NewFocus, Layout)) { TrySetFocusOn(); } if (newFocusedElement is NZazuDataTableField) { return; } _lastFocusedElement = newFocusedElement; OnFieldFocusChanged(new FieldFocusChangedEventArgs(newFocusedElement, oldFocusedElement)); }; FieldFactory = new NZazuFieldFactory(); }
public abstract void AttachTo(INZazuWpfField field, INZazuWpfView view);
public void AttachTo(INZazuWpfField field, INZazuWpfView view) { }
public bool TryGetField(string key, out INZazuWpfField field) { return(_fields.TryGetValue(key, out field)); }