public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp)
        {
            _tab = tab;
            Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last();

            Label label = new Label();

            label.Content   = "Mob skills";
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);
            label.SetValue(Grid.ColumnProperty, 2);

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, _row);
            _lv.SetValue(Grid.ColumnProperty, 2);
            _lv.FocusVisualStyle = null;
            _lv.Margin           = new Thickness(3);
            _lv.BorderThickness  = new Thickness(1);
            WpfUtils.DisableContextMenuIfEmpty(_lv);

            Extensions.GenerateListViewTemplate(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Skill", DisplayExpression = "Name", SearchGetAccessor = "Name", ToolTipBinding = "SkillId", FixedWidth = 60, TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Condition", DisplayExpression = "Condition", SearchGetAccessor = "Condition", ToolTipBinding = "Condition", IsFill = true, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap
                }
            }, new DefaultListViewComparer <MobSkillView>(), new string[] { "Modified", "Green", "Added", "Blue", "Default", "Black" });

            _lv.ContextMenu       = new ContextMenu();
            _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick);

            MenuItem miSelectSkills = new MenuItem {
                Header = "Select skill", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miSelectMobSkills = new MenuItem {
                Header = "Select mob skill", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove mob skill", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("delete.png")
                }
            };

            _lv.ContextMenu.Items.Add(miSelectSkills);
            _lv.ContextMenu.Items.Add(miSelectMobSkills);
            _lv.ContextMenu.Items.Add(miRemoveDrop);

            miSelectSkills.Click    += new RoutedEventHandler(_miSelect_Click);
            miSelectMobSkills.Click += new RoutedEventHandler(_miSelect2_Click);
            miRemoveDrop.Click      += new RoutedEventHandler(_miRemoveDrop_Click);

            dp.AddUpdateAction(new Action <TValue>(_update));

            tab.GenericDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged;
            grid.Children.Add(label);
            grid.Children.Add(_lv);

            dp.AddResetField(_lv);
        }
        public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp)
        {
            _tab = tab;
            Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last();

            Label label = new Label();

            label.Content = "Mob skills";
            label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush);
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);
            label.SetValue(Grid.ColumnProperty, 2);

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, _row);
            _lv.SetValue(Grid.ColumnProperty, 2);
            _lv.FocusVisualStyle = null;
            _lv.Margin           = new Thickness(3);
            _lv.BorderThickness  = new Thickness(1);
            _lv.Background       = Application.Current.Resources["TabItemBackground"] as Brush;

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Skill", DisplayExpression = "Name", SearchGetAccessor = "Name", ToolTipBinding = "SkillId", FixedWidth = 60, TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Condition", DisplayExpression = "Condition", SearchGetAccessor = "Condition", ToolTipBinding = "Condition", IsFill = true, TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap
                }
            }, new DefaultListViewComparer <MobSkillView>(), new string[] { "Default", "{DynamicResource TextForeground}" });

            _lv.ContextMenu       = new ContextMenu();
            _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick);

            MenuItem miSelectSkills = new MenuItem {
                Header = "Select skill", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miSelectMobSkills = new MenuItem {
                Header = "Select mob skill", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove mob skill", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("delete.png")
                }, InputGestureText = "Del"
            };
            MenuItem miCopy = new MenuItem {
                Header = "Copy", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("copy.png")
                }, InputGestureText = "Ctrl-C"
            };
            MenuItem miPaste = new MenuItem {
                Header = "Paste", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("paste.png")
                }, InputGestureText = "Ctrl-V"
            };

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null), _lv);
            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPaste_Click(null, null), _lv);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click(null, null), _lv);

            _lv.ContextMenu.Items.Add(miSelectSkills);
            _lv.ContextMenu.Items.Add(miSelectMobSkills);
            _lv.ContextMenu.Items.Add(miRemoveDrop);
            _lv.ContextMenu.Items.Add(new Separator());
            _lv.ContextMenu.Items.Add(miCopy);
            _lv.ContextMenu.Items.Add(miPaste);

            miSelectSkills.Click    += new RoutedEventHandler(_miSelect_Click);
            miSelectMobSkills.Click += new RoutedEventHandler(_miSelect2_Click);
            miRemoveDrop.Click      += new RoutedEventHandler(_miRemoveDrop_Click);
            miCopy.Click            += new RoutedEventHandler(_miCopy_Click);
            miPaste.Click           += new RoutedEventHandler(_miPaste_Click);

            _lv.MouseRightButtonUp += (MouseButtonEventHandler)((sender, e) => {
                try {
                    bool hasItems = _lv.GetObjectAtPoint <ListViewItem>(e.GetPosition(_lv)) != null;
                    _lv.ContextMenu.Items.Cast <UIElement>().Take(5).ToList().ForEach(p => p.Visibility = hasItems ? Visibility.Visible : Visibility.Collapsed);
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            });

            _lv.PreviewMouseDown += delegate {
                Keyboard.Focus(_lv);
                //_lv.Focus();
            };

            dp.AddUpdateAction(new Action <TValue>(_update));

            tab.ProjectDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged;
            grid.Children.Add(label);
            grid.Children.Add(_lv);

            dp.AddResetField(_lv);
        }
Exemple #3
0
        public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp)
        {
            _tab = tab;
            Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last();

            Label label = new Label();

            label.Content = "MVP drops";
            label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush);
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);
            label.SetValue(Grid.ColumnProperty, 1);

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, _row);
            _lv.SetValue(Grid.ColumnProperty, 1);
            _lv.FocusVisualStyle           = null;
            _lv.Margin                     = new Thickness(3);
            _lv.BorderThickness            = new Thickness(1);
            _lv.PreviewMouseRightButtonUp += _lv_PreviewMouseRightButtonUp;
            _lv.Background                 = Application.Current.Resources["TabItemBackground"] as Brush;

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = ServerItemAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 45, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID"
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = ServerItemAttributes.Name.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Drop %", DisplayExpression = "Drop", SearchGetAccessor = "DropOriginal", ToolTipBinding = "DropOriginal", FixedWidth = 60, TextAlignment = TextAlignment.Right
                },
            }, new DefaultListViewComparer <MobDropView>(), new string[] { "Default", "{DynamicResource TextForeground}", "IsMvp", "{DynamicResource CellBrushMvp}", "IsRandomGroup", "{DynamicResource CellBrushLzma}" });

            _lv.ContextMenu       = new ContextMenu();
            _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick);

            MenuItem miSelect = new MenuItem {
                Header = "Select", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miEditDrop = new MenuItem {
                Header = "Edit", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("properties.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("delete.png")
                }, InputGestureText = "Del"
            };
            MenuItem miCopy = new MenuItem {
                Header = "Copy", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("copy.png")
                }, InputGestureText = "Ctrl-C"
            };
            MenuItem miPaste = new MenuItem {
                Header = "Paste", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("paste.png")
                }, InputGestureText = "Ctrl-V"
            };
            MenuItem miAddDrop = new MenuItem {
                Header = "Add", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("add.png")
                }
            };

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null), _lv);
            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPaste_Click(null, null), _lv);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click(null, null), _lv);

            _lv.ContextMenu.Items.Add(miSelect);
            _lv.ContextMenu.Items.Add(miEditDrop);
            _lv.ContextMenu.Items.Add(miRemoveDrop);
            _lv.ContextMenu.Items.Add(new Separator());
            _lv.ContextMenu.Items.Add(miCopy);
            _lv.ContextMenu.Items.Add(miPaste);
            _lv.ContextMenu.Items.Add(miAddDrop);

            miSelect.Click     += _miSelect_Click;
            miEditDrop.Click   += _miEditDrop_Click;
            miRemoveDrop.Click += _miRemoveDrop_Click;
            miAddDrop.Click    += _miAddDrop_Click;
            miCopy.Click       += new RoutedEventHandler(_miCopy_Click);
            miPaste.Click      += new RoutedEventHandler(_miPaste_Click);

            _updateAction = new Action <TValue>(_update);

            _lv.PreviewMouseDown += delegate { Keyboard.Focus(_lv); };

            tab.ProjectDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged;
            dp.AddUpdateAction(_updateAction);
            dp.AddResetField(_lv);

            grid.Children.Add(label);
            grid.Children.Add(_lv);
        }
Exemple #4
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);
            }
        }
        public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp)
        {
            _tab = tab;
            Grid grid = tab.PropertiesGrid.Children.OfType <Grid>().Last();

            Label label = new Label();

            label.Content   = "MVP drops";
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);
            label.SetValue(Grid.ColumnProperty, 1);

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, _row);
            _lv.SetValue(Grid.ColumnProperty, 1);
            _lv.FocusVisualStyle           = null;
            _lv.Margin                     = new Thickness(3);
            _lv.BorderThickness            = new Thickness(1);
            _lv.PreviewMouseRightButtonUp += _lv_PreviewMouseRightButtonUp;

            Extensions.GenerateListViewTemplate(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = ServerItemAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 45, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID"
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = ServerItemAttributes.Name.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Drop %", DisplayExpression = "Drop", SearchGetAccessor = "DropOriginal", ToolTipBinding = "DropOriginal", FixedWidth = 60, TextAlignment = TextAlignment.Right
                },
            }, new DefaultListViewComparer <MobDropView>(), new string[] { "Modified", "Green", "Added", "Blue", "Default", "Black", "IsMvp", "#FFBA6200" });

            _lv.ContextMenu       = new ContextMenu();
            _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick);

            MenuItem miSelect = new MenuItem {
                Header = "Select", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miEditDrop = new MenuItem {
                Header = "Edit", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("properties.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("delete.png")
                }
            };
            MenuItem miAddDrop = new MenuItem {
                Header = "Add", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("add.png")
                }
            };

            _lv.ContextMenu.Items.Add(miSelect);
            _lv.ContextMenu.Items.Add(miEditDrop);
            _lv.ContextMenu.Items.Add(miRemoveDrop);
            _lv.ContextMenu.Items.Add(miAddDrop);

            miSelect.Click     += _miSelect_Click;
            miEditDrop.Click   += _miEditDrop_Click;
            miRemoveDrop.Click += _miRemoveDrop_Click;
            miAddDrop.Click    += _miAddDrop_Click;

            _updateAction = new Action <TValue>(_update);

            tab.GenericDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged;
            dp.AddUpdateAction(_updateAction);
            dp.AddResetField(_lv);

            grid.Children.Add(label);
            grid.Children.Add(_lv);
        }
Exemple #6
0
        public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp)
        {
            _tab = tab;
            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            _queryThread = new QueryThread <TKey, TValue>(btable, this);
            Grid grid = new Grid();

            WpfUtilities.SetGridPosition(grid, _row, _rSpan, _col, _cSpan);

            grid.Dispatcher.ShutdownStarted += delegate {
                _queryThread.Stop();
            };
            _queryThread.Start();

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

            Label label = new Label();

            label.Content   = "Dropped by";
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);
            label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush);

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, _row);
            _lv.FocusVisualStyle = null;
            _lv.Margin           = new Thickness(3);
            _lv.BorderThickness  = new Thickness(1);
            _lv.Background       = Application.Current.Resources["TabItemBackground"] as Brush;

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = ServerMobAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID"
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = ServerMobAttributes.KRoName.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Drop %", DisplayExpression = "Drop", SearchGetAccessor = "DropOriginal", ToolTipBinding = "DropOriginal", FixedWidth = 60, TextAlignment = TextAlignment.Right
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Type", DisplayExpression = "MVP", SearchGetAccessor = "MVP", FixedWidth = 45, TextAlignment = TextAlignment.Center
                },
            }, new DefaultListViewComparer <MobDropView>(), new string[] { "Default", "{DynamicResource TextForeground}", "IsMvp", "{DynamicResource CellBrushMvp}" });

            _lv.ContextMenu       = new ContextMenu();
            _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick);

            MenuItem miSelect = new MenuItem {
                Header = "Select", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miEditDrop = new MenuItem {
                Header = "Edit drop chance", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("properties.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("delete.png")
                }
            };
            MenuItem miAddDrop = new MenuItem {
                Header = "Add as normal drop", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("add.png")
                }
            };
            MenuItem miAddMvpDrop = new MenuItem {
                Header = "Add as MVP drop", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("add.png")
                }
            };

            _lv.ContextMenu.Items.Add(miSelect);
            _lv.ContextMenu.Items.Add(miEditDrop);
            _lv.ContextMenu.Items.Add(miRemoveDrop);
            _lv.ContextMenu.Items.Add(new Separator());
            _lv.ContextMenu.Items.Add(miAddDrop);
            _lv.ContextMenu.Items.Add(miAddMvpDrop);

            miSelect.Click     += new RoutedEventHandler(_miSelect_Click);
            miEditDrop.Click   += new RoutedEventHandler(_miEditDrop_Click);
            miRemoveDrop.Click += new RoutedEventHandler(_miRemoveDrop_Click);
            miAddDrop.Click    += (a, e) => _miAddDrop_Click(false);
            miAddMvpDrop.Click += (a, e) => _miAddDrop_Click(true);

            dp.AddUpdateAction(new Action <TValue>(_update));

            grid.Children.Add(label);
            grid.Children.Add(_lv);
            tab.ProjectDatabase.Commands.CommandIndexChanged += _commands_CommandIndexChanged;
            tab.PropertiesGrid.Children.Add(grid);
            dp.AddResetField(_lv);

            _lv.MouseRightButtonUp += (MouseButtonEventHandler)((sender, e) => {
                try {
                    bool hasItems = _lv.GetObjectAtPoint <ListViewItem>(e.GetPosition(_lv)) != null;
                    _lv.ContextMenu.Items.Cast <UIElement>().Take(4).ToList().ForEach(p => p.Visibility = hasItems ? Visibility.Visible : Visibility.Collapsed);
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            });
        }
Exemple #7
0
        public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp)
        {
            _tab = tab;
            Grid grid = new Grid();

            grid.SetValue(Grid.RowProperty, _row);
            grid.SetValue(Grid.RowSpanProperty, _rSpan);
            grid.SetValue(Grid.ColumnProperty, 0);
            grid.SetValue(Grid.ColumnSpanProperty, 5);

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

            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(3, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(6, GridUnitType.Star)
            });

            Label label = new Label();

            label.Content = "Evolutions";
            label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush);
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, _row);
            _lv.FocusVisualStyle           = null;
            _lv.Margin                     = new Thickness(3);
            _lv.BorderThickness            = new Thickness(1);
            _lv.PreviewMouseRightButtonUp += _lv_PreviewMouseRightButtonUp;

            _evolutionSorter = new DefaultListViewComparer <PetEvolutionView>(true);

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = ServerMobAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID"
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Name", DisplayExpression = "EvolutionName", SearchGetAccessor = "EvolutionName", IsFill = true, ToolTipBinding = "EvolutionName", TextWrapping = TextWrapping.Wrap, MinWidth = 40
                },
            }, _evolutionSorter, new string[] { "Default", "{DynamicResource TextForeground}" });

            _lv.ContextMenu       = new ContextMenu();
            _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick);

            MenuItem miSelect = new MenuItem {
                Header = "Select", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miEditDrop = new MenuItem {
                Header = "Edit", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("properties.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("delete.png")
                }, InputGestureText = "Del"
            };
            MenuItem miCopy = new MenuItem {
                Header = "Copy", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("copy.png")
                }, InputGestureText = "Ctrl-C"
            };
            MenuItem miPaste = new MenuItem {
                Header = "Paste", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("paste.png")
                }, InputGestureText = "Ctrl-V"
            };
            MenuItem miAddEvolution = new MenuItem {
                Header = "Add evolution", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("add.png")
                }
            };

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null, _lv), _lv);
            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPaste_Click(null, null), _lv);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click <PetEvolutionView>(null, null, _lv), _lv);

            _lv.ContextMenu.Items.Add(miSelect);
            _lv.ContextMenu.Items.Add(miEditDrop);
            _lv.ContextMenu.Items.Add(miRemoveDrop);
            _lv.ContextMenu.Items.Add(new Separator());
            _lv.ContextMenu.Items.Add(miCopy);
            _lv.ContextMenu.Items.Add(miPaste);
            _lv.ContextMenu.Items.Add(miAddEvolution);
            _lv.SelectionChanged += new SelectionChangedEventHandler(_lv_SelectionChanged);

            miSelect.Click       += (sender, e) => _miSelect_Click(sender, e, _lv, ServerDbs.Pet);
            miEditDrop.Click     += new RoutedEventHandler(_miEditDrop_Click);
            miRemoveDrop.Click   += (sender, e) => _miRemoveDrop_Click <PetEvolutionView>(sender, e, _lv);
            miAddEvolution.Click += new RoutedEventHandler(_miAddDrop_Click);
            miCopy.Click         += (sender, e) => _miCopy_Click(sender, e, _lv);
            miPaste.Click        += new RoutedEventHandler(_miPaste_Click);

            _updateAction = new Action <TValue>(_update);

            _lv.PreviewMouseDown += delegate { Keyboard.Focus(_lv); };

            dp.AddUpdateAction(_updateAction);
            dp.AddResetField(_lv);

            grid.Children.Add(label);
            grid.Children.Add(_lv);
            tab.PropertiesGrid.Children.Add(grid);

            _initRequirementGrid();
        }
Exemple #8
0
        private void _initRequirementGrid()
        {
            Grid grid = _tab.PropertiesGrid.Children.OfType <Grid>().Last();

            grid.Background = Application.Current.Resources["TabItemBackground"] as Brush;

            Label label = new Label();

            label.Content = "Requirements";
            label.SetValue(TextBlock.ForegroundProperty, Application.Current.Resources["TextForeground"] as Brush);
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);
            label.SetValue(Grid.ColumnProperty, 1);

            _lvRequirements = new RangeListView();
            _lvRequirements.SetValue(TextSearch.TextPathProperty, "ID");
            _lvRequirements.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lvRequirements.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lvRequirements.SetValue(Grid.RowProperty, _row);
            _lvRequirements.SetValue(Grid.ColumnProperty, 1);
            _lvRequirements.FocusVisualStyle           = null;
            _lvRequirements.Margin                     = new Thickness(3);
            _lvRequirements.BorderThickness            = new Thickness(1);
            _lvRequirements.PreviewMouseRightButtonUp += _lvRequirements_PreviewMouseRightButtonUp;

            _evolutionTargetSorter = new DefaultListViewComparer <PetEvolutionTargetView>(true);

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lvRequirements, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Item ID", DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID"
                },
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "ID", FixedWidth = 26, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Name", DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 40
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Amount", DisplayExpression = "Amount", SearchGetAccessor = "Amount", ToolTipBinding = "Amount", FixedWidth = 60, TextAlignment = TextAlignment.Right
                },
            }, _evolutionTargetSorter, new string[] { "Default", "{DynamicResource TextForeground}" });

            _lvRequirements.ContextMenu       = new ContextMenu();
            _lvRequirements.MouseDoubleClick += new MouseButtonEventHandler(_lvRequirements_MouseDoubleClick);

            MenuItem miSelect = new MenuItem {
                Header = "Select", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miEditDrop = new MenuItem {
                Header = "Edit", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("properties.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("delete.png")
                }, InputGestureText = "Del"
            };
            MenuItem miCopy = new MenuItem {
                Header = "Copy", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("copy.png")
                }, InputGestureText = "Ctrl-C"
            };
            MenuItem miPaste = new MenuItem {
                Header = "Paste", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("paste.png")
                }, InputGestureText = "Ctrl-V"
            };
            MenuItem miAddTarget = new MenuItem {
                Header = "Add requirement", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("add.png")
                }
            };

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => _miCopy_Click(null, null, _lvRequirements), _lvRequirements);
            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => _miPasteRequirement_Click(null, null), _lvRequirements);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miRemoveDrop_Click <PetEvolutionTargetView>(null, null, _lvRequirements), _lvRequirements);

            _lvRequirements.ContextMenu.Items.Add(miSelect);
            _lvRequirements.ContextMenu.Items.Add(miEditDrop);
            _lvRequirements.ContextMenu.Items.Add(miRemoveDrop);
            _lvRequirements.ContextMenu.Items.Add(new Separator());
            _lvRequirements.ContextMenu.Items.Add(miCopy);
            _lvRequirements.ContextMenu.Items.Add(miPaste);
            _lvRequirements.ContextMenu.Items.Add(miAddTarget);

            miSelect.Click     += (sender, e) => _miSelect_Click(sender, e, _lvRequirements, ServerDbs.Items);
            miEditDrop.Click   += new RoutedEventHandler(_miEditRequirement_Click);
            miRemoveDrop.Click += (sender, e) => _miRemoveDrop_Click <PetEvolutionTargetView>(sender, e, _lvRequirements);
            miAddTarget.Click  += new RoutedEventHandler(_miAddRequirement_Click);
            miCopy.Click       += (sender, e) => _miCopy_Click(sender, e, _lvRequirements);
            miPaste.Click      += new RoutedEventHandler(_miPasteRequirement_Click);

            _lvRequirements.PreviewMouseDown += delegate { Keyboard.Focus(_lvRequirements); };
            _lvRequirements.SelectionChanged += new SelectionChangedEventHandler(_lvRequirements_SelectionChanged);

            grid.Children.Add(label);
            grid.Children.Add(_lvRequirements);
        }
Exemple #9
0
        public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp)
        {
            _tab = tab;
            _initSettings(tab, dp);
            _tab.Settings.NewItemAddedFunction += item => item.SetRawValue(ServerItemGroupAttributes.Table, new Dictionary <int, ReadableTuple <int> >());

            GenericDatabase gdb = ((GenericDatabase)_tab.Database);

            _itemGroupsTable.Commands.PreviewCommandUndo     += _previewCommandChanged;
            _itemGroupsTable.Commands.PreviewCommandRedo     += _previewCommandChanged;
            _itemGroupsTable.Commands.PreviewCommandExecuted += _previewCommandChanged;
            _itemGroupsTable.Commands.CommandUndo            += _commandChanged;
            _itemGroupsTable.Commands.CommandRedo            += _commandChanged;
            _itemGroupsTable.Commands.CommandExecuted        += _commandChanged;

            gdb.Commands.PreviewCommandUndo     += _previewCommandChanged2;
            gdb.Commands.PreviewCommandRedo     += _previewCommandChanged2;
            gdb.Commands.PreviewCommandExecuted += _previewCommandChanged2;
            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());

            Label label = new Label();

            label.Content   = "Item IDs";
            label.FontStyle = FontStyles.Italic;
            label.Padding   = new Thickness(0);
            label.Margin    = new Thickness(3);

            _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.FocusVisualStyle    = null;
            _lv.Margin              = new Thickness(3);
            _lv.BorderThickness     = new Thickness(1);
            _lv.HorizontalAlignment = HorizontalAlignment.Left;
            _lv.SelectionChanged   += _lv_SelectionChanged;

            Extensions.GenerateListViewTemplate(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = ServerItemAttributes.Id.DisplayName, DisplayExpression = "ID", SearchGetAccessor = "ID", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "ID"
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = ServerItemAttributes.Name.DisplayName, DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap, MinWidth = 70
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Freq", DisplayExpression = "Drop", SearchGetAccessor = "Rate", ToolTipBinding = "Rate", FixedWidth = 40, TextAlignment = TextAlignment.Right
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Drop %", DisplayExpression = "Chance", SearchGetAccessor = "ChanceInt", ToolTipBinding = "Chance", FixedWidth = 60, TextAlignment = TextAlignment.Right
                }
            }, new DefaultListViewComparer <ItemView>(), new string[] { "Added", "Blue", "Modified", "Green", "Normal", "Black" });

            _lv.ContextMenu       = new ContextMenu();
            _lv.MouseDoubleClick += new MouseButtonEventHandler(_lv_MouseDoubleClick);

            MenuItem miSelect = new MenuItem {
                Header = "Select", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("arrowdown.png")
                }
            };
            MenuItem miEditDrop = new MenuItem {
                Header = "Edit", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("properties.png")
                }
            };
            MenuItem miRemoveDrop = new MenuItem {
                Header = "Remove", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("delete.png")
                }
            };
            MenuItem miAddDrop = new MenuItem {
                Header = "Add", Icon = new Image {
                    Source = (BitmapSource)ApplicationManager.PreloadResourceImage("add.png")
                }
            };

            _lv.ContextMenu.Items.Add(miSelect);
            _lv.ContextMenu.Items.Add(miEditDrop);
            _lv.ContextMenu.Items.Add(miRemoveDrop);
            _lv.ContextMenu.Items.Add(miAddDrop);

            dp.AddResetField(_lv);

            miSelect.Click     += new RoutedEventHandler(_miSelect_Click);
            miEditDrop.Click   += new RoutedEventHandler(_miEditDrop_Click);
            miRemoveDrop.Click += new RoutedEventHandler(_miRemoveDrop_Click);
            miAddDrop.Click    += new RoutedEventHandler(_miAddDrop_Click);

            dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(delegate(ReadableTuple <TKey> item) {
                Dictionary <int, ReadableTuple <int> > groups = (Dictionary <int, ReadableTuple <int> >)item.GetRawValue(1);

                if (groups == null)
                {
                    groups = new Dictionary <int, ReadableTuple <int> >();
                    item.SetRawValue(1, groups);
                }

                Table <int, ReadableTuple <int> > btable = ((GenericDatabase)tab.Database).GetMetaTable <int>(ServerDbs.Items);

                if (groups.Count == 0)
                {
                    _lv.ItemsSource = new RangeObservableCollection <ItemView>();
                    return;
                }

                List <ItemView> result = new List <ItemView>();

                try {
                    int chances = groups.Where(p => p.Key != 0).Sum(p => p.Value.GetValue <int>(ServerItemGroupSubAttributes.Rate));
                    result.AddRange(groups.Select(keypair => new ItemView(btable, groups, keypair.Key, chances)).OrderBy(p => p, Extensions.BindDefaultSearch <ItemView>(_lv, "ID")));
                }
                catch {
                }

                _lv.ItemsSource = new RangeObservableCollection <ItemView>(result);
            }));

            _dp = new DisplayableProperty <TKey, ReadableTuple <TKey> >();
            int  line    = 0;
            Grid subGrid = GTabsMaker.PrintGrid(ref line, 2, 1, 1, new SpecifiedIndexProvider(new int[] {
                //ServerItemGroupSubAttributes.Id.Index, -1,
                ServerItemGroupSubAttributes.Rate.Index, -1,
                ServerItemGroupSubAttributes.Amount.Index, -1,
                ServerItemGroupSubAttributes.Random.Index, -1,
                ServerItemGroupSubAttributes.IsAnnounced.Index, -1,
                ServerItemGroupSubAttributes.Duration.Index, -1,
                ServerItemGroupSubAttributes.IsNamed.Index, -1,
                ServerItemGroupSubAttributes.IsBound.Index, -1
            }), -1, 0, -1, -1, _dp, ServerItemGroupSubAttributes.AttributeList);

            subGrid.VerticalAlignment = VerticalAlignment.Top;

            grid.Children.Add(label);
            grid.Children.Add(_lv);
            tab.PropertiesGrid.RowDefinitions.Clear();
            tab.PropertiesGrid.RowDefinitions.Add(new RowDefinition());
            tab.PropertiesGrid.ColumnDefinitions.Clear();
            tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(340)
            });
            tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(10)
            });
            tab.PropertiesGrid.ColumnDefinitions.Add(new ColumnDefinition());
            tab.PropertiesGrid.Children.Add(grid);
            _dp.Deploy(_tab, null, true);

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

                if (x.Item1.DataType == typeof(int))
                {
                    TextBox element = (TextBox)x.Item2;
                    _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch(
                                                                               delegate {
                        Debug.Ignore(() => element.Text = item.GetValue <int>(x.Item1).ToString(CultureInfo.InvariantCulture));
                        element.UndoLimit = 0;
                        element.UndoLimit = int.MaxValue;
                    })));

                    element.TextChanged += delegate {
                        if (tab.ItemsEventsDisabled)
                        {
                            return;
                        }

                        try {
                            if (tab.List.SelectedItem != null && _lv.SelectedItem != null)
                            {
                                _setSelectedItem(x.Item1, element.Text);
                            }
                        }
                        catch (Exception err) {
                            ErrorHandler.HandleException(err);
                        }
                    };
                }
                else 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 {
                        if (tab.ItemsEventsDisabled)
                        {
                            return;
                        }

                        try {
                            if (tab.List.SelectedItem != null && _lv.SelectedItem != null)
                            {
                                _setSelectedItem(x.Item1, true);
                            }
                        }
                        catch (Exception err) {
                            ErrorHandler.HandleException(err);
                        }
                    };

                    element.Unchecked += delegate {
                        if (tab.ItemsEventsDisabled)
                        {
                            return;
                        }

                        try {
                            if (tab.List.SelectedItem != null && _lv.SelectedItem != null)
                            {
                                _setSelectedItem(x.Item1, false);
                            }
                        }
                        catch (Exception err) {
                            ErrorHandler.HandleException(err);
                        }
                    };
                }
                else if (x.Item1.DataType == typeof(string))
                {
                    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 {
                        if (tab.ItemsEventsDisabled)
                        {
                            return;
                        }

                        _validateUndo(tab, element.Text, x.Item1);
                        if (ReferenceEquals(x.Item1, ServerItemGroupSubAttributes.Rate))
                        {
                            ((RangeObservableCollection <ItemView>)_lv.ItemsSource).ToList().ForEach(p => p.VisualUpdate());
                        }
                    };
                }
            }
        }