Example #1
0
 public void Init(DbSearchPanel panel, ListView view, Func <List <TValue> > getItemsFunction)
 {
     // The initialization is delayed, it will start when loading the tab
     _searchDrop       = panel._gridSearchContent;
     _items            = view;
     _getItemsFunction = getItemsFunction;
     _tbSearchItems    = panel._searchTextBox;
     panel._buttonResetSearch.Click += (sender, args) => Reset();
     ApplicationShortcut.Link(ApplicationShortcut.Search, () => {
         panel._searchTextBox.SelectAll();
         Keyboard.Focus(panel._searchTextBox);
     }, view);
 }
Example #2
0
        public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp)
        {
            _tab           = tab;
            _configuration = (CustomTableInitializer)tab.Settings.AttributeList[1].AttachedObject;
            _configuration.AttributeTable       = tab.Settings.AttributeList[1];
            _tab.Settings.NewItemAddedFunction += item => item.SetRawValue(_configuration.AttributeTable, new Dictionary <int, ReadableTuple <int> >());

            SdeDatabase gdb = _tab.ProjectDatabase;

            _table.Commands.CommandUndo          += _commandChanged;
            _table.Commands.CommandRedo          += _commandChanged;
            _table.Commands.CommandExecuted      += _commandChanged;
            _table.Commands.ModifiedStateChanged += _visualUpdate;

            gdb.Commands.CommandUndo     += _commandChanged2;
            gdb.Commands.CommandRedo     += _commandChanged2;
            gdb.Commands.CommandExecuted += _commandChanged2;

            Grid grid = new Grid();

            grid.SetValue(Grid.RowProperty, _row);
            grid.SetValue(Grid.ColumnProperty, 0);
            grid.SetValue(Grid.ColumnSpanProperty, 1);

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(-1, GridUnitType.Auto)
            });
            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, 1);
            _lv.Width               = 334;
            _lv.FocusVisualStyle    = null;
            _lv.Margin              = new Thickness(3);
            _lv.BorderThickness     = new Thickness(1);
            _lv.HorizontalAlignment = HorizontalAlignment.Left;
            _lv.SelectionChanged   += _lv_SelectionChanged;
            SdeEditor.Instance.ProjectDatabase.Reloaded += _database_Reloaded;

            OnInitListView();

            _lv.PreviewMouseDown += delegate {
                _lv.Focus();
                Keyboard.Focus(_lv);
            };
            _lv.ContextMenu         = new ContextMenu();
            _configuration.ListView = _lv;
            dp.AddResetField(_lv);
            dp.AddUpdateAction(_updateTable);

            _dp                   = new DisplayableProperty <TKey, ReadableTuple <TKey> >();
            _dp.IsDico            = true;
            _dp.DicoConfiguration = _configuration;

            grid.Children.Add(_lv);
            OnDeplayTable();
            _tab.PropertiesGrid.Children.Add(grid);
            _dp.Deploy(_tab, null, true);

            DbSearchPanel dbSearchPanel = new DbSearchPanel();

            dbSearchPanel._border1.BorderThickness = new Thickness(1);
            dbSearchPanel.Margin = new Thickness(3, 0, 3, 0);
            grid.Children.Add(dbSearchPanel);

            Settings = new GTabSettings <TKey, ReadableTuple <TKey> >(ServerDbs.MobGroups, tab.DbComponent);

            var attributes = _configuration.SubTableAttributeList.Take(_configuration.MaxElementsToCopy).Where(p => !p.IsSkippable).ToList();

            if (!attributes.Any(p => p.IsDisplayAttribute))
            {
                var att = _configuration.SubTableAttributeList.Attributes.FirstOrDefault(p => p.IsDisplayAttribute);

                if (att != null)
                {
                    attributes.Insert(1, att);
                }
            }

            if (attributes.Count % 2 != 0)
            {
                attributes.Add(null);
            }

            Settings.AttributeList = _configuration.SubTableAttributeList;
            Settings.DbData        = _configuration.ServerDb;
            Settings.AttId         = attributes[0];
            Settings.AttDisplay    = attributes[1];

            SearchEngine = Settings.SearchEngine;
            SearchEngine.SetAttributes();
            SearchEngine.SetSettings(attributes[0], true);
            SearchEngine.SetSettings(attributes[1], true);
            SearchEngine.SetAttributes(attributes);

            SearchEngine.Init(dbSearchPanel, _lv, () => {
                var dico = _getSelectedGroups();

                if (dico == null)
                {
                    return(new List <ReadableTuple <TKey> >());
                }

                return(dico.Values.Cast <ReadableTuple <TKey> >().ToList());
            });

            ApplicationShortcut.Link(ApplicationShortcut.Cut, Cut, _lv);

            foreach (var update in _dp.Updates)
            {
                Tuple <DbAttribute, FrameworkElement> x = update;

                if (x.Item1.DataType == typeof(bool))
                {
                    CheckBox element = (CheckBox)x.Item2;
                    _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch(p => Debug.Ignore(() => p.IsChecked = item.GetValue <bool>(x.Item1)))));

                    element.Checked   += delegate { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, true); };
                    element.Unchecked += delegate { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, false); };
                }
                else if (
                    x.Item1.DataType == typeof(string) ||
                    x.Item1.DataType == typeof(int))
                {
                    // This will convert integers to strings, but the database engine
                    // is smart enough to auto-convert them to integers afterwards.
                    TextBox element = (TextBox)x.Item2;
                    _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch(
                                                                               delegate {
                        try {
                            string val = item.GetValue <string>(x.Item1);

                            if (val == element.Text)
                            {
                                return;
                            }

                            element.Text      = item.GetValue <string>(x.Item1);
                            element.UndoLimit = 0;
                            element.UndoLimit = int.MaxValue;
                        }
                        catch {
                        }
                    })));

                    element.TextChanged += delegate { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, element.Text); };
                }
            }

            foreach (var property in _dp.FormattedProperties)
            {
                //property.Initialize()
                property.Init(tab, _dp);
            }
        }
Example #3
0
 public void Init(DbSearchPanel panel, GDbTabWrapper <TKey, TValue> tab)
 {
     Init(panel, tab.List, tab.Table);
 }
Example #4
0
 public void Init(DbSearchPanel panel, ListView view, Table <TKey, TValue> table)
 {
     Init(panel, view, () => table.FastItems);
 }