コード例 #1
0
        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);
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
 public override void AttachTo(INZazuWpfField field, INZazuWpfView view)
 {
     if (field == null)
     {
         throw new ArgumentNullException(nameof(field));
     }
 }
コード例 #4
0
 public static bool IsValid(this INZazuWpfField field)
 {
     if (field == null)
     {
         throw new ArgumentNullException(nameof(field));
     }
     return(field.Validate().IsValid);
 }
コード例 #5
0
 public FieldFocusChangedEventArgs(INZazuWpfField newFocusedElement, INZazuWpfField oldFocusedElement = null,
                                   INZazuWpfField parentElement = null)
 {
     //NewFocusedElement = newFocusedElement ?? throw new ArgumentNullException(nameof(newFocusedElement));
     NewFocusedElement = newFocusedElement;
     OldFocusedElement = oldFocusedElement;
     ParentElement     = parentElement;
 }
コード例 #6
0
        private void DataTableFieldOnTableFieldFocusChanged(object sender, FieldFocusChangedEventArgs e)
        {
            var oldFocusedElement = _lastFocusedElement;

            _lastFocusedElement = e.NewFocusedElement;

            OnFieldFocusChanged(new FieldFocusChangedEventArgs(_lastFocusedElement, oldFocusedElement,
                                                               e.ParentElement));
        }
コード例 #7
0
        private void AddField(INZazuWpfField field)
        {
            if (field is NZazuDataTableField dataTableField)
            {
                dataTableField.TableFieldFocusChanged += DataTableFieldOnTableFieldFocusChanged;
            }

            _fields.Add(field.Key, field);
        }
コード例 #8
0
        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]));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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));
                }
            }
        }
コード例 #11
0
        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();
        }
コード例 #12
0
 public abstract void AttachTo(INZazuWpfField field, INZazuWpfView view);
コード例 #13
0
 public void AttachTo(INZazuWpfField field, INZazuWpfView view)
 {
 }
コード例 #14
0
 public bool TryGetField(string key, out INZazuWpfField field)
 {
     return(_fields.TryGetValue(key, out field));
 }