예제 #1
0
        private void _miEditDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.SelectedItems.Count <= 0)
            {
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                var            selectedItem = (MobDropView)_lv.SelectedItem;
                DropEditDialog dialog       = new DropEditDialog(selectedItem.ID.ToString(CultureInfo.InvariantCulture), selectedItem.DropOriginal.ToString(CultureInfo.InvariantCulture), ServerDbs.Items, _tab.ProjectDatabase);
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    if (id <= 0)
                    {
                        return;
                    }

                    try {
                        btable.Commands.Begin();

                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex, id);
                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex + 1, value);
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    selectedItem.Update();
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
예제 #2
0
        public BackupDialog() : base("Backups manager", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();
            Extensions.SetMinimalSize(this);

            WindowStartupLocation = WindowStartupLocation.CenterOwner;

            Extensions.GenerateListViewTemplate(_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", "Black" });

            _items = new RangeObservableCollection <BackupView>();
            _listView.ItemsSource = _items;
            _load();
            WpfUtils.DisableContextMenuIfEmpty(_listView);
        }
예제 #3
0
        private void _addedItem(ReadableTuple <int> tuple, DbAttribute attribute, int dkey, ReadableTuple <int> dvalue, int newdkey, bool executed)
        {
            RangeObservableCollection <ItemView> result = (RangeObservableCollection <ItemView>)_lv.ItemsSource;

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

            if (executed)
            {
                Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)tuple.GetRawValue(1);
                var itemView = new ItemView(((GenericDatabase)_tab.Database).GetMetaTable <int>(ServerDbs.Items), dico, dkey);
                Extensions.InsertIntoList(_lv, itemView, result);
                _lv.SelectedItem = itemView;
                _lv.ScrollToCenterOfView(itemView);
            }
            else
            {
                result.Remove(result.FirstOrDefault(p => p.ID == dkey));
            }
        }
예제 #4
0
        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);
            _li = _completionWindow.CompletionList;
            ListView lv = _li.ListBox;

            lv.SelectionMode = SelectionMode.Single;

            //Image
            Extensions.GenerateListViewTemplate(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);
        }
        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);
        }
예제 #6
0
        private void _miEditDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.SelectedItems.Count <= 0)
            {
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                var            selectedItem = (MobDropView)_lv.SelectedItem;
                DropEditDialog dialog       = new DropEditDialog(selectedItem.ID.ToString(CultureInfo.InvariantCulture), selectedItem.DropOriginal.ToString(CultureInfo.InvariantCulture), ServerDbs.Items, _tab.ProjectDatabase, false, DbPathLocator.IsYamlMob() ? 3 : 0);

                if (DbPathLocator.IsYamlMob())
                {
                    dialog._tbRandGroup.Text           = selectedItem.RandomOptionGroup;
                    dialog._tbStealProtected.IsChecked = selectedItem.StealProtected;
                }

                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid            = dialog.Id;
                    string svalue         = dialog.DropChance;
                    string randGroup      = "";
                    bool   stealProtected = false;
                    int    value;
                    int    id;

                    if (DbPathLocator.IsYamlMob())
                    {
                        randGroup      = dialog.RandGroup;
                        stealProtected = dialog.StealProtected;
                    }

                    Int32.TryParse(sid, out id);

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    if (id <= 0)
                    {
                        return;
                    }

                    try {
                        btable.Commands.Begin();

                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex, id);
                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex + 1, value);

                        if (DbPathLocator.IsYamlMob())
                        {
                            int b             = (selectedItem.AttributeIndex - ServerMobAttributes.Drop1ID.Index) / 2;
                            int distRandGroup = ServerMobAttributes.Drop1RandomOptionGroup.Index + b;
                            int distSteal     = ServerMobAttributes.Drop1Flags.Index + b;

                            btable.Commands.Set(selectedItem.Tuple, distRandGroup, randGroup);
                            btable.Commands.Set(selectedItem.Tuple, distSteal, stealProtected.ToString());
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    selectedItem.Update();
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
예제 #7
0
 public void Update(List <MobDropView> result)
 {
     _tab.BeginDispatch(delegate {
         _lv.ItemsSource = new RangeObservableCollection <MobDropView>(result.OrderBy(p => p, Extensions.BindDefaultSearch <MobDropView>(_lv, "ID")));
     });
 }
예제 #8
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.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);

            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 = 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);
        }
예제 #9
0
        public SdeEditor() : base("Server database editor", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            SplashDialog loading = new SplashDialog();

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

            string configFile = _parseCommandLineArguments();

            GrfPath.Delete(ProjectConfiguration.DefaultFileName);

            if (configFile == null)
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(ProjectConfiguration.DefaultFileName);
            }
            else if (File.Exists(configFile))
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile);
            }

            InitializeComponent();
            ShowInTaskbar = true;

            _asyncOperation = new AsyncOperation(_progressBar);
            _clientDatabase = new GenericDatabase(_metaGrf);

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

            _clientDatabase.Modified += new BaseGenericDatabase.ClientDatabaseEventHandler(_clientDatabase_Modified);

            _cbAssociate.Checked  -= new RoutedEventHandler(_cbAssociate_Checked);
            _cbAssociate.IsChecked = (SdeAppConfiguration.FileShellAssociated & FileAssociation.Sde) == FileAssociation.Sde;
            _cbAssociate.Checked  += new RoutedEventHandler(_cbAssociate_Checked);

            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.SaveAll, () => _menuItemDatabaseSaveAll_Click(this, null), this);

            SdeAppConfiguration.Bind(_cbStackTrace, () => Configuration.EnableDebuggerTrace, v => {
                Configuration.EnableDebuggerTrace = v;
                SdeErrorHandler.ShowStackTraceViewer();
            });

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

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

            Extensions.GenerateListViewTemplate(_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 = 130, 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[] { "Added", "Blue", "Default", "Black" });

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

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

            DbLoaderErrorHandler.ClearListeners();
            DbLoaderErrorHandler.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 = AllLoaders.GetServerType();
                bool       renewal    = AllLoaders.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;
                });
            };
        }
예제 #10
0
        private void _update(TValue item)
        {
            List <MobDropView> result = new List <MobDropView>();
            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

            try {
                int startIndex = ServerMobAttributes.Mvp1ID.Index;

                for (int j = 0; j < 6; j += 2)
                {
                    string value = (string)item.GetRawValue(startIndex + j);

                    if (string.IsNullOrEmpty(value) || value == "0")
                    {
                        continue;
                    }

                    ReadableTuple <int> tuple = (ReadableTuple <int>)(object) item;
                    result.Add(new MobDropView(tuple, startIndex + j, btable));
                }
            }
            catch {
            }

            _lv.ItemsSource = new RangeObservableCollection <MobDropView>(result.OrderBy(p => p, Extensions.BindDefaultSearch <MobDropView>(_lv, "ID")));
        }
예제 #11
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());
                        }
                    };
                }
            }
        }
예제 #12
0
        private void _update(TValue item)
        {
            if (_item != item)
            {
                _lastSelectedIndex1 = -1;
                _lastSelectedIndex2 = -1;
            }

            _item = item;
            List <PetEvolutionView>           result = new List <PetEvolutionView>();
            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                _evolution = new Evolution((string)item.GetRawValue(ServerPetAttributes.Evolution.Index));
                result.AddRange(_evolution.Targets.Select(t => new PetEvolutionView((ReadableTuple <int>)(object) item, t, btable)));
            }
            catch {
            }

            _lv.ItemsSource = new RangeObservableCollection <PetEvolutionView>(result.OrderBy(p => p, Extensions.BindDefaultSearch <PetEvolutionView>(_lv, "ID", true)));

            if (_lv.Items.Count > 0)
            {
                if (_lastSelectedIndex1 == -1)
                {
                    _lv.SelectedIndex = 0;
                }
                else
                {
                    //if (_lastSelectedIndex1 >= _lv.Items.Count) {
                    //	_lastSelectedIndex1 = 0;
                    //}

                    int index2 = _lastSelectedIndex2;

                    _lv.SelectedIndex = _lastSelectedIndex1;

                    if (index2 >= _lvRequirements.Items.Count)
                    {
                        _lastSelectedIndex2 = -1;
                    }
                    else
                    {
                        _lastSelectedIndex2 = index2;
                    }

                    _lvRequirements.SelectedIndex = _lastSelectedIndex2;
                }
            }
        }
예제 #13
0
        private void _miEditRequirement_Click(object sender, RoutedEventArgs e)
        {
            if (_lvRequirements.SelectedItems.Count <= 0 || _tab.List.SelectedItem == null)
            {
                return;
            }

            TValue item   = (TValue)_tab.List.SelectedItem;
            var    btable = _tab.Table;

            try {
                var            selectedItem = (PetEvolutionTargetView)_lvRequirements.SelectedItem;
                DropEditDialog dialog       = new DropEditDialog(selectedItem.ID.ToString(CultureInfo.InvariantCulture), selectedItem.Amount.ToString(CultureInfo.InvariantCulture), ServerDbs.Items, _tab.ProjectDatabase);
                dialog.Owner    = WpfUtilities.TopWindow;
                dialog.Element2 = "Amount";

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    if (id <= 0)
                    {
                        return;
                    }

                    try {
                        btable.Commands.Begin();

                        _evolution = new Evolution();

                        foreach (var targetEv in _lv.Items.OfType <PetEvolutionView>())
                        {
                            if (targetEv == _lv.SelectedItem)
                            {
                                List <Utilities.Extension.Tuple <object, int> > requirements = new List <Utilities.Extension.Tuple <object, int> >();

                                foreach (var requirement in _lvRequirements.Items.OfType <PetEvolutionTargetView>())
                                {
                                    if (requirement == _lvRequirements.SelectedItem)
                                    {
                                        requirements.Add(new Utilities.Extension.Tuple <object, int>(dialog.Id, value));
                                    }
                                    else
                                    {
                                        requirements.Add(requirement.Requirement);
                                    }
                                }

                                targetEv.EvolutionTarget.ItemRequirements = requirements;
                            }

                            _evolution.Targets.Add(targetEv.EvolutionTarget);
                        }

                        btable.Commands.Set(item, ServerPetAttributes.Evolution, _evolution.ToString());
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    _update(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
예제 #14
0
        private void _updateRequirements(PetEvolutionView evolution)
        {
            List <PetEvolutionTargetView>     result = new List <PetEvolutionTargetView>();
            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);
            Table <int, ReadableTuple <int> > ctable = _tab.ProjectDatabase.GetTable <int>(ServerDbs.CItems);

            try {
                result.AddRange(evolution.EvolutionTarget.ItemRequirements.Select(t => new PetEvolutionTargetView(t, btable, ctable)));
            }
            catch {
            }

            _lvRequirements.ItemsSource = new RangeObservableCollection <PetEvolutionTargetView>(result.OrderBy(p => p, Extensions.BindDefaultSearch <PetEvolutionTargetView>(_lvRequirements, "ID", true)));
        }
예제 #15
0
        public void Init(GDbTabWrapper <TKey, TValue> tab, DisplayableProperty <TKey, TValue> dp)
        {
            _tab = tab;
            Grid grid = new Grid();

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

            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);

            _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);

            Extensions.GenerateListViewTemplate(_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[] { "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 = 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);
                }
            });
        }
예제 #16
0
        private void _update(TValue item)
        {
            Table <int, ReadableTuple <int> > btable = _tab.GetMetaTable <int>(ServerDbs.Mobs);
            string id = item.GetKey <int>().ToString(CultureInfo.InvariantCulture);

            if (item.GetKey <int>() == 0)
            {
                _lv.ItemsSource = null;
                return;
            }

            List <ReadableTuple <int> > tuples = btable.FastItems;
            List <MobDropView>          result = new List <MobDropView>();

            try {
                int  startIndex;
                bool found;

                for (int i = 0; i < tuples.Count; i++)
                {
                    var p = tuples[i];

                    found      = false;
                    startIndex = ServerMobAttributes.Mvp1ID.Index;

                    for (int j = 0; j < 6; j += 2)
                    {
                        if ((string)p.GetRawValue(startIndex + j) == id)
                        {
                            result.Add(new MobDropView(p, startIndex + j));
                            found = true;
                            break;
                        }
                    }

                    if (found)
                    {
                        continue;
                    }

                    startIndex = ServerMobAttributes.Drop1ID.Index;

                    for (int j = 0; j < 20; j += 2)
                    {
                        if ((string)p.GetRawValue(startIndex + j) == id)
                        {
                            result.Add(new MobDropView(p, startIndex + j));
                            break;
                        }
                    }
                }
            }
            catch {
            }

            _lv.ItemsSource = new RangeObservableCollection <MobDropView>(result.OrderBy(p => p, Extensions.BindDefaultSearch <MobDropView>(_lv, "ID")));
        }
예제 #17
0
        private void _miAddDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.Items.Count >= 10)
            {
                ErrorHandler.HandleException("You cannot add more than 10 drops. Delete an item and then add a new one.");
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                DropEditDialog dialog = new DropEditDialog("", "", ServerDbs.Items, _tab.ProjectDatabase, true);
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (id <= 0)
                    {
                        return;
                    }

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    TValue item = (TValue)_tab.List.SelectedItem;

                    try {
                        btable.Commands.Begin();

                        int startIndex = ServerMobAttributes.Drop1ID.Index;

                        for (int i = 0; i < 18; i += 2)
                        {
                            if (item.GetValue <int>(startIndex + i) == 0)
                            {
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id);
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value);
                                break;
                            }
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    //_lv.Items.OfType<MobDropView>().ToList().ForEach(p => p.RemoveEvents());
                    _lv.ItemsSource = null;
                    _updateAction(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #18
0
        public DebuggerDialog(bool isMain = true)
        {
            InitializeComponent();

            string icon = "cde.ico";
            Stream bitmapStream;

            try {
                bitmapStream = new MemoryStream(ApplicationManager.GetResource(icon));
            }
            catch {
                bitmapStream = null;
                MessageBox.Show("Couldn't find the icon file in the program's resources. The icon must be a .ico file and it must be placed within the application's resources (embedded resource).");
                if (TkWindow.ShutDownOnInvalidIcons)
                {
                    ApplicationManager.Shutdown();
                }
            }
            if (bitmapStream == null)
            {
                MessageBox.Show("Couldn't find the icon file in the program's resources.");
                if (!TkWindow.ShutDownOnInvalidIcons)
                {
                    return;
                }
                ApplicationManager.Shutdown();
            }
            else
            {
                try {
                    Icon = new IconBitmapDecoder(bitmapStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None).Frames[0];
                }
                catch (Exception) {
                    try {
                        Icon = ApplicationManager.GetResourceImage(icon);
                        return;
                    }
                    catch {
                    }
                    MessageBox.Show("Invalid icon file.");
                    if (!TkWindow.ShutDownOnInvalidIcons)
                    {
                        return;
                    }
                    Application.Current.Shutdown();
                }
            }

            Extensions.GenerateListViewTemplate(_listViewStackTrace, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "File name", DisplayExpression = "FileName", ToolTipBinding = "FileName", TextAlignment = TextAlignment.Right, FixedWidth = 180
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Line", DisplayExpression = "Line", ToolTipBinding = "Line", TextAlignment = TextAlignment.Left, FixedWidth = 60
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Method", DisplayExpression = "Method", ToolTipBinding = "Method", TextAlignment = TextAlignment.Left, IsFill = true
                }
            }, null, new string[] { "Default", "Black" });

            Loaded += _loaded;
            Left    = 0;
            Top     = 0;

            if (!isMain)
            {
                _enableClosing = true;
            }

            new Thread(_backgroundWindowOwnership)
            {
                Name = "GrfEditor - Debugger primary thread"
            }.Start();
        }
예제 #19
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());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            Label label = new Label();

            label.Content   = "Normal drops";
            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;

            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[] { "Deleted", "Red", "Added", "Blue", "Default", "Black", "IsCard", "Green" });

            _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 normal drop", Icon = new Image {
                    Source = ApplicationManager.PreloadResourceImage("add.png")
                }
            };
            MenuItem miAddCardDrop = new MenuItem {
                Header = "Add card", 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);
            _lv.ContextMenu.Items.Add(miAddCardDrop);

            miSelect.Click      += new RoutedEventHandler(_miSelect_Click);
            miEditDrop.Click    += new RoutedEventHandler(_miEditDrop_Click);
            miRemoveDrop.Click  += new RoutedEventHandler(_miRemoveDrop_Click);
            miAddDrop.Click     += new RoutedEventHandler(_miAddDrop_Click);
            miAddCardDrop.Click += new RoutedEventHandler(_miAddCardDrop_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);
            tab.PropertiesGrid.Children.Add(grid);
        }
        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);
        }
예제 #21
0
        private void _miPaste_Click(object sender, RoutedEventArgs e)
        {
            try {
                if (_lv.Items.Count >= 3)
                {
                    ErrorHandler.HandleException("You cannot add more than 3 drops. Delete an item and then add a new one.");
                    return;
                }

                if (_tab.List.SelectedItem == null)
                {
                    return;
                }
                if (!Clipboard.ContainsText())
                {
                    return;
                }

                string   text          = Clipboard.GetText();
                string[] elementsToAdd = text.Split(',');

                if (DbPathLocator.IsYamlMob())
                {
                    if (elementsToAdd.Length % 3 != 0)
                    {
                        throw new Exception("The number of arguments must be even.");
                    }

                    Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

                    try {
                        TValue item = (TValue)_tab.List.SelectedItem;

                        try {
                            btable.Commands.Begin();

                            int startIndex = ServerMobAttributes.Mvp1ID.Index;
                            int i          = 0;

                            for (int j = 0; j < elementsToAdd.Length; j += 3)
                            {
                                string sid       = elementsToAdd[j];
                                string svalue    = elementsToAdd[j + 1];
                                string randGroup = elementsToAdd[j + 2];
                                int    value;
                                int    id;

                                Int32.TryParse(sid, out id);

                                if (id <= 0)
                                {
                                    return;
                                }

                                if (!Extensions.GetIntFromFloatValue(svalue, out value))
                                {
                                    ErrorHandler.HandleException("Invalid format (integer or float value only)");
                                    return;
                                }

                                for (; i < 6; i += 2)
                                {
                                    if (item.GetValue <int>(startIndex + i) == 0)
                                    {
                                        btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id);
                                        btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value);
                                        btable.Commands.Set((ReadableTuple <int>)(object) item, ServerMobAttributes.Mvp1RandomOptionGroup.Index + (i / 2), randGroup);
                                        i += 2;
                                        break;
                                    }
                                }
                            }
                        }
                        finally {
                            btable.Commands.EndEdit();
                        }

                        _lv.ItemsSource = null;
                        _updateAction(item);
                    }
                    catch (Exception err) {
                        ErrorHandler.HandleException(err);
                    }
                }
                else
                {
                    if (elementsToAdd.Length % 2 != 0)
                    {
                        throw new Exception("The number of arguments must be even.");
                    }

                    Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

                    try {
                        TValue item = (TValue)_tab.List.SelectedItem;

                        try {
                            btable.Commands.Begin();

                            int startIndex = ServerMobAttributes.Mvp1ID.Index;
                            int i          = 0;

                            for (int j = 0; j < elementsToAdd.Length; j += 2)
                            {
                                string sid    = elementsToAdd[j];
                                string svalue = elementsToAdd[j + 1];
                                int    value;
                                int    id;

                                Int32.TryParse(sid, out id);

                                if (id <= 0)
                                {
                                    return;
                                }

                                if (!Extensions.GetIntFromFloatValue(svalue, out value))
                                {
                                    ErrorHandler.HandleException("Invalid format (integer or float value only)");
                                    return;
                                }

                                for (; i < 6; i += 2)
                                {
                                    if (item.GetValue <int>(startIndex + i) == 0)
                                    {
                                        btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id);
                                        btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value);
                                        i += 2;
                                        break;
                                    }
                                }
                            }
                        }
                        finally {
                            btable.Commands.EndEdit();
                        }

                        _lv.ItemsSource = null;
                        _updateAction(item);
                    }
                    catch (Exception err) {
                        ErrorHandler.HandleException(err);
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #22
0
        private void _update(TValue item)
        {
            int    id  = item.GetKey <int>();
            string sid = id.ToString(CultureInfo.InvariantCulture);

            if (id == 0)
            {
                _lv.ItemsSource = null;
                return;
            }

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

            try {
                result.AddRange(_skillMobsTable.FastItems.Where(p => p.GetStringValue(ServerMobSkillAttributes.MobId.Index) == sid).Select(p => new MobSkillView(_skillsTable.TryGetTuple(p.GetValue <int>(ServerMobSkillAttributes.SkillId)), p, id)));
            }
            catch {
            }

            _lv.ItemsSource = new RangeObservableCollection <MobSkillView>(result.OrderBy(p => p, Extensions.BindDefaultSearch <MobSkillView>(_lv, "Name")));
        }
예제 #23
0
        private void _miAddDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.Items.Count >= 3)
            {
                ErrorHandler.HandleException("You cannot add more than 3 MVP drops. Delete an item and then add a new one.");
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                DropEditDialog dialog = new DropEditDialog("", "", ServerDbs.Items, _tab.ProjectDatabase, false, (DbPathLocator.IsYamlMob() ? 2 : 0));
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid       = dialog.Id;
                    string svalue    = dialog.DropChance;
                    string randGroup = "";
                    int    value;
                    int    id;

                    if (DbPathLocator.IsYamlMob())
                    {
                        randGroup = dialog.RandGroup;
                    }

                    Int32.TryParse(sid, out id);

                    if (id <= 0)
                    {
                        return;
                    }

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    TValue item = (TValue)_tab.List.SelectedItem;

                    try {
                        btable.Commands.Begin();

                        int startIndex = ServerMobAttributes.Mvp1ID.Index;

                        for (int i = 0; i < 6; i += 2)
                        {
                            if (item.GetValue <int>(startIndex + i) == 0)
                            {
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id);
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value);

                                if (DbPathLocator.IsYamlMob())
                                {
                                    btable.Commands.Set((ReadableTuple <int>)(object) item, ServerMobAttributes.Mvp1RandomOptionGroup.Index + (i / 2), randGroup);
                                }
                                break;
                            }
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    _lv.ItemsSource = null;
                    _updateAction(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #24
0
        private void _miAddCardDrop_Click(object sender, RoutedEventArgs e)
        {
            TValue item = (TValue)_tab.List.SelectedItem;

            if (item.GetValue <int>(ServerMobAttributes.DropCardid) != 0)
            {
                _lv.SelectedItem = _lv.Items.OfType <MobDropView>().FirstOrDefault(p => p.IsCard);
                _miEditDrop_Click(sender, e);
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.GenericDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                DropEdit dialog = new DropEdit("", "", ServerDbs.Items, _tab.GenericDatabase);
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (id <= 0)
                    {
                        return;
                    }

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    try {
                        btable.Commands.BeginEdit(new GroupCommand <TKey, TValue>());

                        int startIndex = ServerMobAttributes.DropCardid.Index;

                        for (int i = 0; i < 2; i += 2)
                        {
                            if (item.GetValue <int>(startIndex + i) == 0)
                            {
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id);
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value);
                                break;
                            }
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    //_lv.Items.OfType<MobDropView>().ToList().ForEach(p => p.RemoveEvents());
                    _lv.ItemsSource = null;
                    _updateAction(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #25
0
        public SdeEditor() : base("Server database editor", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            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);

            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);

            Extensions.GenerateListViewTemplate(_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[] { "Added", "Blue", "Default", "Black" });

            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;
        }
예제 #26
0
        private void _miAddDrop_Click(bool mvp)
        {
            TValue item = (TValue)_tab.List.SelectedItem;

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                DropEditDialog dialog = new DropEditDialog("", "10.0 %", ServerDbs.Mobs, _tab.ProjectDatabase, true);
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (id <= 0)
                    {
                        return;
                    }

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    var tuple = btable.TryGetTuple(id);

                    if (tuple == null)
                    {
                        ErrorHandler.HandleException("Mob id not found.");
                        return;
                    }

                    try {
                        btable.Commands.Begin();
                        bool added = false;

                        if (mvp)
                        {
                            int startIndex = ServerMobAttributes.Mvp1ID.Index;

                            for (int i = 0; i < 6; i += 2)
                            {
                                if (tuple.GetValue <int>(startIndex + i) == 0)
                                {
                                    btable.Commands.Set(tuple, startIndex + i, item.GetKey <int>());
                                    btable.Commands.Set(tuple, startIndex + i + 1, value);
                                    added = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            int startIndex = ServerMobAttributes.Drop1ID.Index;

                            for (int i = 0; i < 18; i += 2)
                            {
                                if (tuple.GetValue <int>(startIndex + i) == 0)
                                {
                                    btable.Commands.Set(tuple, startIndex + i, item.GetKey <int>());
                                    btable.Commands.Set(tuple, startIndex + i + 1, value);
                                    added = true;
                                    break;
                                }
                            }
                        }

                        if (!added)
                        {
                            ErrorHandler.HandleException("Couldn't add the item (no space left).");
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    _lv.ItemsSource = null;
                    _update(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
예제 #27
0
        public void Initialize(GTabSettings <TKey, TValue> settings)
        {
            Settings = settings;
            _unclickableBorder.Init(_cbSubMenu);
            Database     = settings.ClientDatabase;
            DbComponent  = GenericDatabase.GetDb <TKey>(settings.DbData);
            Table        = Settings.Table;
            Header       = Settings.TabName;
            Style        = TryFindResource(settings.Style) as Style ?? Style;
            SearchEngine = settings.SearchEngine;
            SearchEngine.Init(_gridSearchContent, _searchTextBox, this);

            if (Settings.SearchEngine.SetupImageDataGetter != null)
            {
                Extensions.GenerateListViewTemplate(_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", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false");
            }
            else
            {
                Extensions.GenerateListViewTemplate(_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", "Red", "Modified", "Green", "Added", "Blue", "Normal", "Black" }, "generateStyle", "false");
            }

#if SDE_DEBUG
            CLHelper.WA = CLHelper.CP(-10);
#endif
            if (!Settings.CanBeDelayed || Settings.AttributeList.Attributes.Any(p => p.IsSkippable))
            {
                _deployTabControls();
            }
#if SDE_DEBUG
            CLHelper.WA = ", deploy time : " + CLHelper.CS(-10) + CLHelper.CD(-10) + "ms";
#endif
            _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, ((GenericDatabase)Database).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();
            };

            ApplicationShortcut.Link(ApplicationShortcut.Paste, () => ImportFromFile("clipboard"), _listView);
            ApplicationShortcut.Link(ApplicationShortcut.Cut, () => _miCut_Click(null, null), _listView);
        }
예제 #28
0
        private void _miEditDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.SelectedItems.Count <= 0)
            {
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);
            int startIndex;

            try {
                var         selectedItem = (MobDropView)_lv.SelectedItem;
                var         p            = btable.GetTuple(selectedItem.ID);
                string      id           = ((ReadableTuple <int>)_tab.List.SelectedItem).GetKey <int>().ToString(CultureInfo.InvariantCulture);
                InputDialog dialog       = new InputDialog("Enter the new drop rate (integer or float)", "Drop rate", selectedItem.DropOriginal.ToString(CultureInfo.InvariantCulture));
                dialog.Owner = WpfUtilities.TopWindow;
                dialog.TextBoxInput.Loaded += delegate {
                    dialog.TextBoxInput.SelectAll();
                    dialog.TextBoxInput.Focus();
                };

                if (dialog.ShowDialog() == true)
                {
                    string dResult = dialog.Input;
                    int    value;

                    if (!Extensions.GetIntFromFloatValue(dResult, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    btable.Commands.Begin();
                    startIndex = ServerMobAttributes.Mvp1ID.Index;

                    for (int j = 0; j < 6; j += 2)
                    {
                        if ((string)p.GetRawValue(startIndex + j) == id)
                        {
                            btable.Commands.Set(p, startIndex + j + 1, value);
                        }
                    }

                    startIndex = ServerMobAttributes.Drop1ID.Index;

                    for (int j = 0; j < 20; j += 2)
                    {
                        if ((string)p.GetRawValue(startIndex + j) == id)
                        {
                            btable.Commands.Set(p, startIndex + j + 1, value);
                            break;
                        }
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }