Example #1
0
        private void _addSelectAll(Grid grid, CheckBox selectAll)
        {
            List <CheckBox> boxes = DisplayablePropertyHelper.FindAll <CheckBox>(grid);

            boxes.ForEach(WpfUtils.AddMouseInOutEffectsBox);
            bool eventsActive = true;

            WpfUtils.AddMouseInOutEffectsBox(selectAll);

            foreach (var box in boxes)
            {
                box.Checked += delegate {
                    if (eventsActive)
                    {
                        _checkAllSelected(boxes, selectAll, true);
                    }
                };

                box.Unchecked += delegate {
                    if (eventsActive)
                    {
                        _checkAllSelected(boxes, selectAll, false);
                    }
                };
            }

            selectAll.Checked += delegate {
                eventsActive = false;

                foreach (var box in boxes)
                {
                    if (box.IsChecked == false)
                    {
                        box.IsChecked = true;
                    }
                }

                eventsActive = true;
            };

            selectAll.Unchecked += delegate {
                eventsActive = false;

                foreach (var box in boxes)
                {
                    if (box.IsChecked == true)
                    {
                        box.IsChecked = false;
                    }
                }

                eventsActive = true;
            };
        }
Example #2
0
        private void _loadAutocomplete()
        {
            Binder.Bind(_cbAcIdDn, () => ProjectConfiguration.AutocompleteIdDisplayName);
            Binder.Bind(_cbAcUnDn, () => ProjectConfiguration.AutocompleteUnDisplayName);
            Binder.Bind(_cbAcIdRn, () => ProjectConfiguration.AutocompleteIdResourceName);
            Binder.Bind(_cbAcUnRn, () => ProjectConfiguration.AutocompleteUnResourceName);
            Binder.Bind(_cbAcIdDesc, () => ProjectConfiguration.AutocompleteIdDescription);
            Binder.Bind(_cbAcUnDesc, () => ProjectConfiguration.AutocompleteUnDescription);
            Binder.Bind(_tbPropFormat, () => ProjectConfiguration.AutocompleteDescriptionFormat);
            Binder.Bind(_cbAcNumberOfSlot, () => ProjectConfiguration.AutocompleteNumberOfSlot);
            Binder.Bind(_cbAcEmptyFields, () => ProjectConfiguration.AutocompleteFillOnlyEmptyFields);
            Binder.Bind(_tbUnDesc, () => ProjectConfiguration.AutocompleteUnDescriptionFormat);
            Binder.Bind(_tbDescNotSet, () => ProjectConfiguration.AutocompleteDescNotSet);
            Binder.Bind(_cbWriteNeutralProperty, () => ProjectConfiguration.AutocompleteNeutralProperty);
            Binder.Bind(_cbAcViewId, () => ProjectConfiguration.AutocompleteViewId);

            int index = 0;

            List <TextBox> boxes = new List <TextBox>();

            foreach (ParameterHolderKeys property in ParameterHolderKeys.Keys)
            {
                ParameterHolderKeys key = property;
                Label label             = new Label {
                    Padding = new Thickness(0), Margin = new Thickness(3), Content = property.Key
                };
                TextBox box = new TextBox {
                    Text = SdeAppConfiguration.ConfigAsker["Autocompletion - " + key.Key, key.Key], Margin = new Thickness(3)
                };

                WpfUtilities.SetGridPosition(label, index, 1, 0, 1);
                WpfUtilities.SetGridPosition(box, index, 1, 2, 1);

                _gridDescProp.Children.Add(label);
                _gridDescProp.Children.Add(box);
                _gridDescProp.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(-1, GridUnitType.Auto)
                });

                SdeAppConfiguration.Bind(box, v => SdeAppConfiguration.ConfigAsker["Autocompletion - " + key.Key] = box.Text, p => p);

                index++;
            }

            index = 0;

            foreach (string property in ParameterHolder.Properties)
            {
                TextBox box = new TextBox {
                    Text = ProjectConfiguration.AutocompleteProperties[index], Margin = new Thickness(3)
                };
                TextBlock block = new TextBlock {
                    Text = property, Margin = new Thickness(3), VerticalAlignment = VerticalAlignment.Center
                };

                WpfUtilities.SetGridPosition(block, index / 2 + 4, 2 * (index % 2));
                WpfUtilities.SetGridPosition(box, index / 2 + 4, 2 * (index % 2) + 1);

                boxes.Add(box);
                _gridDescription.Children.Add(box);
                _gridDescription.Children.Add(block);

                SdeAppConfiguration.Bind(box, v => ProjectConfiguration.AutocompleteProperties = v, q => boxes.Select(p => p.Text).ToList());

                index++;
            }

            DisplayablePropertyHelper.FindAll <CheckBox>(_gridAutocomplete).ForEach(WpfUtils.AddMouseInOutEffectsBox);
        }
        public override void Init(GDbTabWrapper <int, ReadableTuple <int> > tab, DisplayableProperty <int, ReadableTuple <int> > dp)
        {
            _parent = _parent ?? tab.PropertiesGrid;

            _textBox              = new TextBox();
            _textBox.Margin       = new Thickness(3);
            _textBox.TextChanged += new TextChangedEventHandler(_textBox_TextChanged);
            _textBox.TabIndex     = dp.ZIndex++;

            _tab = tab;

            DisplayableProperty <int, ReadableTuple <int> > .RemoveUndoAndRedoEvents(_textBox, _tab);

            dp.AddResetField(_textBox);

            Grid grid = new Grid();

            grid.SetValue(Grid.RowProperty, _row);
            grid.SetValue(Grid.ColumnProperty, _column);
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            _textBox.SetValue(Grid.ColumnProperty, 0);

            _textPreview                   = new TextBlock();
            _textPreview.Margin            = new Thickness(7, 0, 0, 0);
            _textPreview.VerticalAlignment = VerticalAlignment.Center;
            _textPreview.TextAlignment     = TextAlignment.Left;
            _textPreview.Foreground        = Brushes.DarkGray;
            _textPreview.SetValue(Grid.ColumnProperty, 0);
            _textPreview.IsHitTestVisible = false;

            dp.Deployed += delegate {
                try {
                    if (_attribute.AttachedObject != null)
                    {
                        foreach (var attribute in (DbAttribute[])_attribute.AttachedObject)
                        {
                            var textBox = DisplayablePropertyHelper.Find <TextBox>(_parent, attribute).First();
                            textBox.TextChanged += (e, a) => OnUpdate();
                        }
                    }
                    else
                    {
                        var textBox = DisplayablePropertyHelper.Find <TextBox>(_parent, _attribute.AttachedAttribute as DbAttribute).First();
                        textBox.TextChanged += (e, a) => OnUpdate();
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            };

            grid.Children.Add(_textBox);
            grid.Children.Add(_textPreview);

            _parent.Children.Add(grid);

            dp.AddUpdateAction(new Action <ReadableTuple <int> >(item => _textBox.Dispatch(delegate {
                try {
                    string sval = item.GetValue <string>(_attribute);

                    if (sval == _textBox.Text)
                    {
                        return;
                    }

                    _textBox.Text      = sval;
                    _textBox.UndoLimit = 0;
                    _textBox.UndoLimit = int.MaxValue;
                }
                catch {
                }

                OnUpdate();
            })));

            _textBox.GotFocus += delegate { _textPreview.Visibility = Visibility.Collapsed; };

            _textBox.LostFocus += delegate { OnUpdate(); };
        }