public ToggleMemoryButton()
        {
            InitializeComponent();

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Commands", DisplayExpression = "CommandDescription", FixedWidth = 230, TextAlignment = TextAlignment.Left, ToolTipBinding = "CommandDescription"
                }
            }, null, new string[] { }, "generateHeader", "false");

            _listView.PreviewMouseMove += new MouseEventHandler(_undoListView_PreviewMouseMove);
            _cbSubMenu.DropDownOpened  += new EventHandler(_cbSubMenu_DropDownOpened);
            _listView.SelectionChanged += new SelectionChangedEventHandler(_listView_SelectionChanged);
            _label.Content              = String.Format(DisplayFormat, CurrentIndex + 1);

            _button.MouseEnter += delegate {
                _buttonOpenSubMenuDrop.ShowMouseOver = true;
            };
            _buttonOpenSubMenuDrop.MouseEnter += delegate {
                _button.ShowMouseOver = true;
            };
            _button.MouseLeave += delegate {
                _buttonOpenSubMenuDrop.ShowMouseOver = false;
            };
            _buttonOpenSubMenuDrop.MouseLeave += delegate {
                _button.ShowMouseOver = false;
            };
        }
Beispiel #2
0
        public ViewIdPreviewDialog(SdeEditor editor, GDbTab tab) : base("View ID preview", "eye.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            _tab    = tab;
            _editor = editor;
            _editor._mainTabControl.SelectionChanged += _mainTabControl_SelectionChanged;

            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner       = WpfUtilities.TopWindow;
            WindowStyle = WindowStyle.ToolWindow;

            _helper = new PreviewHelper(_listView, _tab.DbComponent.To <int>(), _selector, _frameViewer, _gridSpriteMissing, _tbSpriteMissing);

            this.Loaded += delegate {
                Width    = 400;
                Height   = 300;
                IsOpened = true;
            };

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Job Name", DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap
                }
            }, null, new string[] { "Normal", "{DynamicResource TextForeground}" });

            _tupleUpdate();
        }
        public ExplorerDialog(string path, SdeEditor editor)
            : base("FTP explorer...", "find.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            _path   = path;
            _editor = editor;

            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listViewResults, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "Name", FixedWidth = 20, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Name", DisplayExpression = "Name", MinWidth = 100, ToolTipBinding = "Name", TextAlignment = TextAlignment.Left, IsFill = true
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Changed", DisplayExpression = "Changed", FixedWidth = 150, ToolTipBinding = "Changed", TextAlignment = TextAlignment.Left
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Rights", DisplayExpression = "Rights", FixedWidth = 100, ToolTipBinding = "Rights", TextAlignment = TextAlignment.Left
                }
            }, new DefaultListViewComparer <FtpEntry>(), new string[] { "Default", "{DynamicResource TextForeground}" });

            _validateFileManager();
            _setListing("/");

            _listViewResults.KeyDown += new KeyEventHandler(_listViewResults_KeyDown);

            _listViewResults.MouseDoubleClick += new MouseButtonEventHandler(_listViewResults_MouseDoubleClick);
            _listViewResults.SelectionChanged += new SelectionChangedEventHandler(_listViewResults_SelectionChanged);
        }
Beispiel #4
0
        private void _loadSettingsUI()
        {
            _changeRawViewButton();

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listViewResults, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "Error", FixedWidth = 20, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Error", DisplayExpression = "ErrorString", FixedWidth = 120, ToolTipBinding = "ErrorString", TextAlignment = TextAlignment.Left
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Id", DisplayExpression = "Id", FixedWidth = 50, ToolTipBinding = "Id", TextAlignment = TextAlignment.Right
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Db", DisplayExpression = "Db", FixedWidth = 100, ToolTipBinding = "Db", TextAlignment = TextAlignment.Left
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Message", DisplayExpression = "Message", MinWidth = 150, ToolTipBinding = "Message", TextAlignment = TextAlignment.Left, IsFill = true, TextWrapping = TextWrapping.Wrap
                },
            }, new DefaultListViewComparer <ValidationErrorView>(), new string[] { "Default", "Black" });

            _errors = new List <ValidationErrorView>();
            _listViewResults.ItemsSource = _errors;
        }
Beispiel #5
0
        public MapcacheDialog(string text)
            : base("Mapcache", "cache.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            ShowInTaskbar         = true;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            _cache = new Mapcache();
            _cache.Commands.ModifiedStateChanged += _commands_ModifiedStateChanged;
            _asyncOperation = new AsyncOperation(_progressBar);

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Name", DisplayExpression = "MapName", SearchGetAccessor = "MapName", ToolTipBinding = "MapName", TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center, FixedWidth = 140
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Width", DisplayExpression = "Xs", SearchGetAccessor = "Xs", ToolTipBinding = "Xs", TextAlignment = TextAlignment.Center, FixedWidth = 80
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Height", DisplayExpression = "Ys", SearchGetAccessor = "Ys", ToolTipBinding = "Ys", TextAlignment = TextAlignment.Center, FixedWidth = 80
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Size", DisplayExpression = "DisplaySize", SearchGetAccessor = "Len", ToolTipBinding = "DisplaySize", TextAlignment = TextAlignment.Center, FixedWidth = 150
                },
            }, new DefaultListViewComparer <MapInfo>(), new string[] { "Added", "{DynamicResource CellBrushAdded}" });

            _tmbUndo.SetUndo(_cache.Commands);
            _tmbRedo.SetRedo(_cache.Commands);
            _commands_ModifiedStateChanged(null, null);
            _listView.ItemsSource = _cache.ViewMaps;

            ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemSave_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _cache.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _cache.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _menuItemNew_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Open, () => _menuItemOpenFrom_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miDelete_Click(null, null), this);

            _recentFilesManager              = new WpfRecentFiles(Configuration.ConfigAsker, 6, _menuItemRecentFiles, "Mapcache");
            _recentFilesManager.FileClicked += _recentFilesManager_FileClicked;

            if (text != null)
            {
                _recentFilesManager.AddRecentFile(text);
                _load(text);
            }
            else
            {
                // Open the latest file
                if (_recentFilesManager.Files.Count > 0 && File.Exists(_recentFilesManager.Files[0]))
                {
                    _load(_recentFilesManager.Files[0]);
                }
            }
        }
        public MultiGrfExplorer(MultiGrfReader metaGrf, string explorerPath, string filter, string selected)
            : base("Meta GRF explorer", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            ShowInTaskbar = true;
            _explorerPath = explorerPath.ToLower();
            _metaGrf      = metaGrf;
            //metaGrf.Lock();

            if (filter != "")
            {
                _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry).Where(p => p.RelativePath.IndexOf(filter, StringComparison.OrdinalIgnoreCase) > -1));
            }
            else
            {
                _entries.AddRange(metaGrf.FilesInDirectory(_explorerPath).Select(metaGrf.GetEntry));
            }

            _entriesAll.AddRange(_entries);

            foreach (FileEntry entry in _entries)
            {
                entry.DataImage = entry.DisplayRelativePath;
            }

            _loadEncoding();

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_items, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "File name", DisplayExpression = "DataImage", ToolTipBinding = "RelativePath", IsFill = true, MinWidth = 60, TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Type", DisplayExpression = "FileType", FixedWidth = 40, TextAlignment = TextAlignment.Right, ToolTipBinding = "FileType"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Size", DisplayExpression = "DisplaySize", FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "DisplaySize"
                },
            }, new MetaGrfSorter(), new string[] { });

            _items.MouseDoubleClick += new MouseButtonEventHandler(_items_MouseDoubleClick);

            _items.ItemsSource = _entries;
            VirtualFileDataObject.SetDraggable(_imagePreview, _wrapper);

            ApplicationShortcut.Link(ApplicationShortcut.Copy, _copyItems, _items);
            ApplicationShortcut.Link(ApplicationShortcut.Confirm, () => _buttonSelect_Click(null, null), _items);

            this.Loaded += delegate {
                _items.SelectedItem = _entries.FirstOrDefault(p => String.CompareOrdinal(p.DisplayRelativePath, selected.ToDisplayEncoding(true) + ".bmp") == 0);
                _items.ScrollToCenterOfView(_items.SelectedItem);
            };

            this.Owner = WpfUtilities.TopWindow;
        }
Beispiel #7
0
 public override void OnInitListView()
 {
     ListViewDataTemplateHelper.GenerateListViewTemplateNew(_lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
         new ListViewDataTemplateHelper.GeneralColumnInfo {
             Header = ServerItemGroupSubAttributes.Id.DisplayName, DisplayExpression = "[" + ServerItemGroupSubAttributes.Id.Index + "]", SearchGetAccessor = ServerItemGroupSubAttributes.Id.AttributeName, FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + ServerItemGroupSubAttributes.Id.Index + "]"
         },
         new ListViewDataTemplateHelper.RangeColumnInfo {
             Header = ServerItemGroupSubAttributes.Name.DisplayName, DisplayExpression = "[" + ServerItemGroupSubAttributes.Name.Index + "]", SearchGetAccessor = ServerItemGroupSubAttributes.Name.AttributeName, IsFill = true, ToolTipBinding = "[" + ServerItemGroupSubAttributes.Name.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
         },
         new ListViewDataTemplateHelper.RangeColumnInfo {
             Header = "Freq", DisplayExpression = "[" + ServerItemGroupSubAttributes.Rate.Index + "]", SearchGetAccessor = ServerItemGroupSubAttributes.Rate.AttributeName, FixedWidth = 40, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + ServerItemGroupSubAttributes.Rate.Index + "]"
         },
         new ListViewDataTemplateHelper.RangeColumnInfo {
             Header = "Drop %", DisplayExpression = "[" + ServerItemGroupSubAttributes.DropPerc.Index + "]", SearchGetAccessor = ServerItemGroupSubAttributes.Rate.AttributeName, FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + ServerItemGroupSubAttributes.DropPerc.Index + "]"
         },
     }, new DatabaseItemSorter(_configuration.SubTableAttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" });
 }
Beispiel #8
0
        public ScriptEditDialog(string text) : base("Script edit", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            AvalonLoader.Load(_textEditor);
            AvalonLoader.SetSyntax(_textEditor, "Script");

            string script = DbIOFormatting.ScriptFormat(text, 0);

            _textEditor.Text = script;
            _textEditor.TextArea.TextEntered  += new TextCompositionEventHandler(_textArea_TextEntered);
            _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering);
            _textEditor.TextChanged           += (e, a) => OnValueChanged();
            //_textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy();

            _completionWindow            = new CompletionWindow(_textEditor.TextArea);
            _completionWindow.Background = Application.Current.Resources["TabItemBackground"] as Brush;
            _li = _completionWindow.CompletionList;
            ListView lv = _li.ListBox;

            lv.SelectionMode = SelectionMode.Single;
            lv.Background    = Application.Current.Resources["TabItemBackground"] as Brush;

            //Image
            ListViewDataTemplateHelper.GenerateListViewTemplateNew(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description"
                }
            }, null, new string[] { }, "generateHeader", "false");

            _completionWindow.Content = null;
            _completionWindow         = null;

            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            _textEditor.Loaded += delegate {
                _textEditor.Focus();
            };
        }
        private void _loadUi()
        {
            _rcm              = new WpfRecentFiles(SdeAppConfiguration.ConfigAsker, 6, _miLoadRecent, "Server database editor - IronPython recent files");
            _rcm.FileClicked += new RecentFilesManager.RFMFileClickedEventHandler(_rcm_FileClicked);

            Binder.Bind(_textEditor, () => SdeAppConfiguration.IronPythonScript);
            Binder.Bind(_miAutocomplete, () => SdeAppConfiguration.IronPythonAutocomplete);

            AvalonLoader.Load(_textEditor);
            AvalonLoader.SetSyntax(_textEditor, "Python");
            _textEditor.TextArea.TextEntered  += new TextCompositionEventHandler(_textArea_TextEntered);
            _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering);

            this.PreviewKeyDown += new KeyEventHandler(_ironPythonDialog_PreviewKeyDown);

            _completionWindow            = new CompletionWindow(_textEditor.TextArea);
            _completionWindow.Background = Application.Current.Resources["TabItemBackground"] as Brush;
            _li = _completionWindow.CompletionList;
            ListView lv = _li.ListBox;

            lv.SelectionMode = SelectionMode.Single;
            lv.Background    = Application.Current.Resources["TabItemBackground"] as Brush;

            //Image
            ListViewDataTemplateHelper.GenerateListViewTemplateNew(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description"
                }
            }, null, new string[] { }, "generateHeader", "false");

            _completionWindow.Content  = null;
            _completionWindow          = null;
            _rowConsole.Height         = new GridLength(0);
            _buttonCloseConsole.Margin = new Thickness(0, 5, SystemParameters.HorizontalScrollBarButtonWidth + 2, 0);
            _textEditor.Drop          += new DragEventHandler(_textEditor_Drop);
        }
Beispiel #10
0
        public BackupDialog() : base("Backups manager", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();
            Extensions.SetMinimalSize(this);

            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Date", DisplayExpression = "Date", SearchGetAccessor = "DateInt", ToolTipBinding = "Date", TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center, FixedWidth = 140
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Database path", DisplayExpression = "DbPath", SearchGetAccessor = "DbPath", IsFill = true, ToolTipBinding = "DbPath", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                }
            }, null, new string[] { "Normal", "{DynamicResource TextForeground}" });

            _items = new RangeObservableCollection <BackupView>();
            _listView.ItemsSource = _items;
            _load();
            Loaded += delegate {
                _listView.Dispatch(p => p.ScrollToCenterOfView(_items.Last()));
            };
            WpfUtils.DisableContextMenuIfEmpty(_listView);
        }
Beispiel #11
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);
                }
            });
        }
Beispiel #12
0
        public void Initialize(GTabSettings <TKey, TValue> settings)
        {
            Settings = settings;

            _displayGrid = new Grid();
            _displayGrid.SetValue(Grid.ColumnProperty, 2);
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition());
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(10)
            });
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            _displayGrid.ColumnDefinitions.Add(new ColumnDefinition());

            if (Settings.DbData == ServerDbs.ClientItems ||
                Settings.DbData == ServerDbs.Pet ||
                Settings.DbData == ServerDbs.Pet2 ||
                Settings.DbData == ServerDbs.Mobs ||
                Settings.DbData == ServerDbs.Mobs2 ||
                Settings.DbData == ServerDbs.MobGroups ||
                Settings.DbData == ServerDbs.Items ||
                Settings.DbData == ServerDbs.Items2)
            {
                _viewGrid.Children.Add(_displayGrid);
            }
            else
            {
                ScrollViewer sv = new ScrollViewer();
                sv.SetValue(Grid.ColumnProperty, 2);
                sv.SetValue(ScrollViewer.VerticalScrollBarVisibilityProperty, ScrollBarVisibility.Auto);
                sv.Focusable = false;
                sv.Content   = _displayGrid;
                _viewGrid.Children.Add(sv);
            }

            ProjectDatabase = settings.ClientDatabase;
            DbComponent     = ProjectDatabase.GetDb <TKey>(settings.DbData);
            Table           = Settings.Table;
            Header          = Settings.TabName;
            Style           = TryFindResource(settings.Style) as Style ?? Style;
            SearchEngine    = settings.SearchEngine;
            SearchEngine.Init(_dbSearchPanel, this);
            Table.TableUpdated += new Table <TKey, TValue> .UpdateTableEventHandler(_table_TableUpdated);

            if (Settings.SearchEngine.SetupImageDataGetter != null)
            {
                ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                    new ListViewDataTemplateHelper.GeneralColumnInfo {
                        Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]"
                    },
                    new ListViewDataTemplateHelper.ImageColumnInfo {
                        Header = "", DisplayExpression = "DataImage", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = 26, MaxHeight = 24
                    },
                    new ListViewDataTemplateHelper.RangeColumnInfo {
                        Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                    }
                }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" });
            }
            else
            {
                ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                    new ListViewDataTemplateHelper.GeneralColumnInfo {
                        Header = Settings.AttId.DisplayName, DisplayExpression = "[" + Settings.AttId.Index + "]", SearchGetAccessor = Settings.AttId.AttributeName, FixedWidth = Settings.AttIdWidth, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + Settings.AttId.Index + "]"
                    },
                    new ListViewDataTemplateHelper.RangeColumnInfo {
                        Header = Settings.AttDisplay.DisplayName, DisplayExpression = "[" + Settings.AttDisplay.Index + "]", SearchGetAccessor = Settings.AttDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + Settings.AttDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                    }
                }, new DatabaseItemSorter(Settings.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" });
            }

            if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable))
            {
                _deployTabControls();
            }

            _initTableEvents();

            if (Settings.ContextMenu != null)
            {
                if (Header is Control)
                {
                    ((Control)Header).ContextMenu = Settings.ContextMenu;
                }
            }

            if (Settings.Loaded != null)
            {
                Settings.Loaded((GDbTabWrapper <TKey, ReadableTuple <TKey> >)(object) this, (GTabSettings <TKey, ReadableTuple <TKey> >)(object) Settings, ProjectDatabase.GetDb <TKey>(Settings.DbData));
            }

            if (Settings.DisplayablePropertyMaker.OnTabVisible != null)
            {
                Settings.DisplayablePropertyMaker.OnTabVisible(this);
            }

            Loaded += delegate {
                TabControl parent = WpfUtilities.FindParentControl <TabControl>(this);

                if (parent != null)
                {
                    parent.SelectionChanged += new SelectionChangedEventHandler(_parent_SelectionChanged);
                }
            };

            _listView.PreviewMouseDown += delegate { _listView.Focus(); };

            _listView.Loaded += delegate {
                try {
                    if (IsVisible)
                    {
                        Keyboard.Focus(_listView);
                    }
                }
                catch {
                }
            };

            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView);
            ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste, () => ImportFromFile("clipboard", true), this);
            ApplicationShortcut.Link(ApplicationShortcut.AdvancedPaste2, () => ImportFromFile("clipboard", true), this);
            ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("F3", "Search next empty ID"), () => {
                if (_listView.SelectedItems.Count > 0)
                {
                    ReadableTuple <int> item = (_listView.SelectedItems[_listView.SelectedItems.Count - 1]) as ReadableTuple <int>;
                    var original             = item;

                    if (item != null)
                    {
                        int id = item.Key;

                        while (true)
                        {
                            id++;
                            var idGeneric = (TKey)(object)id;

                            var tuple = (ReadableTuple <int>)(object) Table.TryGetTuple(idGeneric);

                            if (tuple == null && item != original && item != null)
                            {
                                TabNavigation.SelectList(DbComponent.DbSource, new TKey[] { item.GetKey <TKey>() });
                                break;
                            }

                            item = tuple;
                        }
                    }
                }
            }, _listView);
        }
Beispiel #13
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 = "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);
        }
Beispiel #14
0
        public SdeEditor() : base("Server database editor", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            _parseCommandLineArguments(true);

            SplashDialog loading = new SplashDialog();

            loading.Show();
            Loaded += delegate {
                loading.Terminate();
            };

            try {
                ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);
            }
            catch (Exception err) {
                SdeAppConfiguration.Remapper.Clear();
                ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);
                ErrorHandler.HandleException("Failed to load the custom key bindings. The bindings will be reset to their default values.", err);
            }

            string configFile = _parseCommandLineArguments();

            GrfPath.Delete(ProjectConfiguration.DefaultFileName);

            if (SdeAppConfiguration.ThemeIndex == 1)
            {
                UIElement.IsEnabledProperty.OverrideMetadata(typeof(RangeListView), new UIPropertyMetadata(true, List_IsEnabledChanged, CoerceIsEnabled));
                UIElement.IsEnabledProperty.OverrideMetadata(typeof(ListView), new UIPropertyMetadata(true, List_IsEnabledChanged, CoerceIsEnabled));
            }

            InitializeComponent();
            Instance      = this;
            ShowInTaskbar = true;

            _asyncOperation = new AsyncOperation(_progressBar);
            _clientDatabase = new SdeDatabase(_metaGrf);
            _loadMenu();

            if (configFile == null)
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(ProjectConfiguration.DefaultFileName);

                if (SdeAppConfiguration.AlwaysReopenLatestProject)
                {
                    if (_recentFilesManager.Files.Count > 0 && File.Exists(_recentFilesManager.Files[0]))
                    {
                        ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile = _recentFilesManager.Files[0]);
                    }
                }
            }
            else if (File.Exists(configFile))
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile);
            }

            _loadSettingsTab();
            if (configFile != null)
            {
                ReloadSettings(configFile);
            }
            _loadGenericTab();

            _clientDatabase.Commands.ModifiedStateChanged += new AbstractCommand <IGenericDbCommand> .AbstractCommandsEventHandler(_commands_ModifiedStateChanged);

            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.UndoGlobal, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.RedoGlobal, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Search, () => _execute(v => v.Search()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _execute(v => v.DeleteItems()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Rename, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward, () => _tabEngine.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward2, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationForward, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Change, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Restrict, () => _execute(v => v.ShowSelectedOnly()), this);
            ApplicationShortcut.Link(ApplicationShortcut.CopyTo, () => _execute(v => v.CopyItemTo()), this);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _execute(v => v.AddNewItem()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemDatabaseSave_Click(this, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Replace, () => { if (_menuItemReplaceAll.IsEnabled)
                                                                          {
                                                                              _menuItemReplaceAll_Click(this, null);
                                                                          }
                                     }, this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Enter", "Select next entry"), () => _execute(v => v.SelectNext()), this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Shift-Enter", "Select previous entry"), () => _execute(v => v.SelectPrevious()), this);
            Configuration.EnableDebuggerTrace = false;

            _tnbUndo.SetUndo(_tabEngine);
            _tnbRedo.SetRedo(_tabEngine);

            _tmbUndo.SetUndo(_clientDatabase.Commands);
            _tmbRedo.SetRedo(_clientDatabase.Commands);

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_debugList, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "#", DisplayExpression = "ErrorNumber", SearchGetAccessor = "ErrorNumber", FixedWidth = 35, ToolTipBinding = "ErrorNumber", TextAlignment = TextAlignment.Right
                },
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "Exception", FixedWidth = 20, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Exception", DisplayExpression = "Exception", SearchGetAccessor = "Exception", IsFill = true, TextAlignment = TextAlignment.Left, ToolTipBinding = "OriginalException", TextWrapping = TextWrapping.Wrap, MinWidth = 120
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Id", DisplayExpression = "Id", SearchGetAccessor = "Id", FixedWidth = 90, TextAlignment = TextAlignment.Left, ToolTipBinding = "Id", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "File", DisplayExpression = "FileName", SearchGetAccessor = "FilePath", FixedWidth = 145, TextAlignment = TextAlignment.Left, ToolTipBinding = "FilePath", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Line", DisplayExpression = "Line", SearchGetAccessor = "Line", FixedWidth = 40, TextAlignment = TextAlignment.Left, ToolTipBinding = "Line"
                },
            }, null, new string[] { "Default", "{DynamicResource TextForeground}" });

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => WpfUtils.CopyContent(_debugList), _debugList);

            _debugItems            = new ObservableCollection <DebugItemView>();
            _debugList.ItemsSource = _debugItems;

            DbIOErrorHandler.ClearListeners();
            DbIOErrorHandler.AddListener(this);

            _clientDatabase.PreviewReloaded += delegate {
                this.BeginDispatch(delegate {
                    foreach (TabItem tabItem in _mainTabControl.Items)
                    {
                        tabItem.IsEnabled = true;

                        var tabItemHeader = tabItem.Header as DisplayLabel;

                        if (tabItemHeader != null)
                        {
                            tabItemHeader.ResetEnabled();
                        }
                    }
                });
            };

            _clientDatabase.Reloaded += delegate {
                _mainTabControl.Dispatch(p => p.RaiseEvent(new SelectionChangedEventArgs(Selector.SelectionChangedEvent, new List <object>(), _mainTabControl.SelectedItem == null ? new List <object>() : new List <object> {
                    _mainTabControl.SelectedItem
                })));
                ServerType serverType = DbPathLocator.GetServerType();
                bool       renewal    = DbPathLocator.GetIsRenewal();
                string     header     = String.Format("Current ({0} - {1})", serverType == ServerType.RAthena ? "rA" : "Herc", renewal ? "Renewal" : "Pre-Renewal");

                this.BeginDispatch(delegate {
                    _menuItemExportDbCurrent.IsEnabled = true;
                    _menuItemExportDbCurrent.Header    = header;

                    _menuItemExportSqlCurrent.IsEnabled = true;
                    _menuItemExportSqlCurrent.Header    = header;
                });
            };

            SelectionChanged += _sdeEditor_SelectionChanged;
        }
Beispiel #15
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);
        }
Beispiel #16
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);
        }
Beispiel #17
0
        public SelectFromDialog(Table <int, ReadableTuple <int> > table, ServerDbs db, string text) : base("Select item in [" + db.Filename + "]", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();
            Extensions.SetMinimalSize(this);

            DbAttribute attId      = table.AttributeList.PrimaryAttribute;
            DbAttribute attDisplay = table.AttributeList.Attributes.FirstOrDefault(p => p.IsDisplayAttribute) ?? table.AttributeList.Attributes[1];

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = attId.DisplayName, DisplayExpression = "[" + attId.Index + "]", SearchGetAccessor = attId.AttributeName, FixedWidth = 60, TextAlignment = TextAlignment.Right, ToolTipBinding = "[" + attId.Index + "]"
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = attDisplay.DisplayName, DisplayExpression = "[" + attDisplay.Index + "]", SearchGetAccessor = attDisplay.AttributeName, IsFill = true, ToolTipBinding = "[" + attDisplay.Index + "]", MinWidth = 100, TextWrapping = TextWrapping.Wrap
                }
            }, new DatabaseItemSorter(table.AttributeList), new string[] { "Deleted", "{DynamicResource CellBrushRemoved}", "Modified", "{DynamicResource CellBrushModified}", "Added", "{DynamicResource CellBrushAdded}", "Normal", "{DynamicResource TextForeground}" });

            //_listView.ItemsSource = new ObservableCollection<ReadableTuple<int>>(table.FastItems);

            GTabSettings <int, ReadableTuple <int> > gTabSettings = new GTabSettings <int, ReadableTuple <int> >(db, null);

            gTabSettings.AttributeList = table.AttributeList;
            gTabSettings.AttId         = attId;
            gTabSettings.AttDisplay    = attDisplay;

            GSearchEngine <int, ReadableTuple <int> > gSearchEngine = new GSearchEngine <int, ReadableTuple <int> >(db, gTabSettings);

            var attributes = new DbAttribute[] { attId, attDisplay }.Concat(table.AttributeList.Attributes.Skip(2).Where(p => p.IsSearchable != null)).ToList();

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

            gSearchEngine.SetAttributes(attributes);
            gSearchEngine.SetSettings(attId, true);
            gSearchEngine.SetSettings(attDisplay, true);
            gSearchEngine.Init(_dbSearchPanel, _listView, table);

            _listView.MouseDoubleClick += new MouseButtonEventHandler(_listView_MouseDoubleClick);

            Loaded += delegate {
                gSearchEngine.Filter(this);
            };

            bool first = true;

            gSearchEngine.FilterFinished += delegate {
                if (!first)
                {
                    return;
                }

                try {
                    int ival;

                    if (Int32.TryParse(text, out ival))
                    {
                        _listView.Dispatch(delegate {
                            _listView.SelectedItem = table.TryGetTuple(ival);
                            TokeiLibrary.WPF.Extensions.ScrollToCenterOfView(_listView, _listView.SelectedItem);
                        });
                    }
                }
                finally {
                    first = false;
                }
            };

            Loaded += delegate {
                _dbSearchPanel._searchTextBox.Focus();
                _dbSearchPanel._searchTextBox.SelectAll();
            };
        }
Beispiel #18
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();
        }
Beispiel #19
0
 public static void GenerateListViewTemplate(ListView list, ListViewDataTemplateHelper.GeneralColumnInfo[] columnInfos, ListViewCustomComparer sorter, IList <string> triggers, params string[] extraCommands)
 {
     Gen1(list);
     ListViewDataTemplateHelper.GenerateListViewTemplateNew(list, columnInfos, sorter, triggers, extraCommands);
 }