Example #1
0
        public void ReloadSettings(string fileNameSettings = null)
        {
            try {
                if (ShouldCancelDbReload())
                {
                    return;
                }

                if (fileNameSettings != null)
                {
                    if (fileNameSettings == ProjectConfiguration.DefaultFileName)
                    {
                        GrfPath.Delete(ProjectConfiguration.DefaultFileName);
                    }

                    ProjectConfiguration.ConfigAsker = new ConfigAsker(fileNameSettings);
                    _recentFilesManager.AddRecentFile(fileNameSettings);
                }

                _setTitle(Methods.CutFileName(ProjectConfiguration.ConfigAsker.ConfigFile), false);

                _loadDatabaseFiles();
                _loadItemTxtFiles();
                _loadItemLuaFiles();
                _cbUseLuaFiles.IsChecked  = ProjectConfiguration.UseLuaFiles;
                _cbClientDbSync.IsChecked = ProjectConfiguration.SynchronizeWithClientDatabases;
                _metaGrfViewer.LoadResourcesInfo();
                _asyncOperation.SetAndRunOperation(new GrfThread(_updateMetaGrf, this, 200, null, false, true));
                IOHelper.Close();
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Example #2
0
        public void ReloadSettings(string fileNameSettings = null)
        {
            try {
                if (ShouldCancelDbReload())
                {
                    return;
                }

                if (fileNameSettings != null)
                {
                    if (fileNameSettings == ProjectConfiguration.DefaultFileName)
                    {
                        GrfPath.Delete(ProjectConfiguration.DefaultFileName);
                    }

                    ProjectConfiguration.ConfigAsker = new ConfigAsker(fileNameSettings);
                    _recentFilesManager.AddRecentFile(fileNameSettings);
                }

                Title = "Server database editor - " + Methods.CutFileName(ProjectConfiguration.ConfigAsker.ConfigFile);

                _loadDatabaseFiles();
                _metaGrfViewer.LoadResourcesInfo();
                _asyncOperation.SetAndRunOperation(new GrfThread(_updateMetaGrf, this, 200, null, false, true));
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Example #3
0
        private void _menuItemProjectSaveAs_Click(object sender, RoutedEventArgs e)
        {
            try {
                string file = PathRequest.SaveFileCde(
                    "filter", FileFormat.MergeFilters(Format.Sde),
                    "fileName", Path.GetFileName(ProjectConfiguration.ConfigAsker.ConfigFile));

                if (file != null)
                {
                    if (file == ProjectConfiguration.ConfigAsker.ConfigFile)
                    {
                    }
                    else
                    {
                        try {
                            GrfPath.Delete(file);
                            File.Copy(ProjectConfiguration.ConfigAsker.ConfigFile, file);
                        }
                        catch (Exception err) {
                            ErrorHandler.HandleException(err);
                            return;
                        }

                        _recentFilesManager.AddRecentFile(file);
                        ReloadSettings(file);
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err.Message, ErrorLevel.Warning);
            }
        }
Example #4
0
        public SettingsDialog() : base("Advanced settings", "settings.png")
        {
            InitializeComponent();
            int row;

            Binder.Bind(_pbNotepad.TextBox, () => SdeAppConfiguration.NotepadPath);

            _add(_gridComments, row = 0, "Add comments in item_trade.txt", "Displays the item name as a comment at the end of the line for item_trade.txt.", () => SdeAppConfiguration.AddCommentForItemTrade, v => SdeAppConfiguration.AddCommentForItemTrade = v);
            _add(_gridComments, ++row, "Add comments in item_avail.txt", "Displays the item names as a comment at the end of the line for item_avail.txt.", () => SdeAppConfiguration.AddCommentForItemAvail, v => SdeAppConfiguration.AddCommentForItemAvail = v);
            _add(_gridComments, ++row, "Add comments in item_nouse.txt", "Displays the item names as a comment at the end of the line for item_nouse.txt.", () => SdeAppConfiguration.AddCommentForItemNoUse, v => SdeAppConfiguration.AddCommentForItemNoUse = v);

            _add(_gridGeneral, row = 3, "Switch item types 4 and 5 for text based databases (requires a software restart)", "Switches the armor and weapon types when reading the databases.", () => SdeAppConfiguration.RevertItemTypes, v => SdeAppConfiguration.RevertItemTypes = v);
            _add(_gridGeneral, ++row, "Always reopen the latest opened project", "Always reopen the most recently opened project when starting the application.", () => SdeAppConfiguration.AlwaysReopenLatestProject, v => SdeAppConfiguration.AlwaysReopenLatestProject = v);
            _add(_gridGeneral, ++row, "Associate the .sde file extension with this tool", null, () => (SdeAppConfiguration.FileShellAssociated & FileAssociation.Sde) == FileAssociation.Sde, v => {
                if (v)
                {
                    SdeAppConfiguration.FileShellAssociated |= FileAssociation.Sde;
                    ApplicationManager.AddExtension(Methods.ApplicationFullPath, "Server database editor", ".sde", true);
                }
                else
                {
                    SdeAppConfiguration.FileShellAssociated &= ~FileAssociation.Sde;
                    GrfPath.Delete(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "sde.ico"));
                    ApplicationManager.RemoveExtension(Methods.ApplicationFullPath, ".sde");
                }
            });
            _add(_gridGeneral, ++row, "Enable backups manager", null, () => SdeAppConfiguration.BackupsManagerState, v => SdeAppConfiguration.BackupsManagerState = v);
            _add(_gridGeneral, ++row, "Apply modifications to all selected items", "If checked, every field that you edit will modify all the currently selected items.", () => SdeAppConfiguration.EnableMultipleSetters, v => SdeAppConfiguration.EnableMultipleSetters = v);
            _add(_gridGeneral, ++row, "Bind item tabs together", "If checked, both the Client Items and Items tab will sync.", () => SdeAppConfiguration.BindItemTabs, v => SdeAppConfiguration.BindItemTabs = v);
            _add(_gridGeneral, ++row, "Always overwrite non-modified files", "If checked, non-modified files will be overwritten in your db folder.", () => SdeAppConfiguration.AlwaysOverwriteFiles, v => SdeAppConfiguration.AlwaysOverwriteFiles = v);

            _add(_gridDbWriter, row = 0, "Remove NoUse entry if the flag is 0 (ignore override)", "This will remove the line regardless of the override property, which must be normally at 100 for the line to be removed.", () => SdeAppConfiguration.DbNouseIgnoreOverride, v => SdeAppConfiguration.DbNouseIgnoreOverride = v);
            _add(_gridDbWriter, ++row, "Remove Trade entry if the flag is 0 (ignore override)", "This will remove the line regardless of the override property, which must be normally at 100 for the line to be removed.", () => SdeAppConfiguration.DbTradeIgnoreOverride, v => SdeAppConfiguration.DbTradeIgnoreOverride = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write unidentifiedDisplayName", null, () => SdeAppConfiguration.DbWriterItemInfoUnDisplayName, v => SdeAppConfiguration.DbWriterItemInfoUnDisplayName     = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write unidentifiedResourceName", null, () => SdeAppConfiguration.DbWriterItemInfoUnResource, v => SdeAppConfiguration.DbWriterItemInfoUnResource          = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write unidentifiedDescriptionName", null, () => SdeAppConfiguration.DbWriterItemInfoUnDescription, v => SdeAppConfiguration.DbWriterItemInfoUnDescription = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write identifiedDisplayName", null, () => SdeAppConfiguration.DbWriterItemInfoIdDisplayName, v => SdeAppConfiguration.DbWriterItemInfoIdDisplayName       = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write identifiedResourceName", null, () => SdeAppConfiguration.DbWriterItemInfoIdResource, v => SdeAppConfiguration.DbWriterItemInfoIdResource            = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write identifiedDescriptionName", null, () => SdeAppConfiguration.DbWriterItemInfoIdDescription, v => SdeAppConfiguration.DbWriterItemInfoIdDescription   = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write slotCount", null, () => SdeAppConfiguration.DbWriterItemInfoSlotCount, v => SdeAppConfiguration.DbWriterItemInfoSlotCount = v);
            _add(_gridDbWriter, ++row, "itemInfo.lua : Write ClassNum", null, () => SdeAppConfiguration.DbWriterItemInfoClassNum, v => SdeAppConfiguration.DbWriterItemInfoClassNum    = v);
            _add(_gridDbWriter, ++row, "item_group : force write in single file", "'Import' fields won't be used when saving the item groups", () => SdeAppConfiguration.DbWriterItemInfoClassNum, v => SdeAppConfiguration.DbWriterItemInfoClassNum = v);

            _add(_gridDialogs, row = 0, "Use integrated dialogs for flags", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForFlags, v => SdeAppConfiguration.UseIntegratedDialogsForFlags = v);
            _add(_gridDialogs, ++row, "Use integrated dialogs for scripts", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForScripts, v => SdeAppConfiguration.UseIntegratedDialogsForScripts = v);
            _add(_gridDialogs, ++row, "Use integrated dialogs for levels", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForLevels, v => SdeAppConfiguration.UseIntegratedDialogsForLevels    = v);
            _add(_gridDialogs, ++row, "Use integrated dialogs for jobs", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForJobs, v => SdeAppConfiguration.UseIntegratedDialogsForJobs          = v);
            _add(_gridDialogs, ++row, "Use integrated dialogs for time", "If unchecked, this will open dialogs on all the '...' buttons.", () => SdeAppConfiguration.UseIntegratedDialogsForTime, v => SdeAppConfiguration.UseIntegratedDialogsForTime          = v);

            _add(_gridRAthena, row = 0, "Use old rAthena mob mode", "If checked, this will use the old mob mode.", () => ProjectConfiguration.UseOldRAthenaMode, v => ProjectConfiguration.UseOldRAthenaMode = v);

            _loadEncoding();
            _comboBoxCompression.Init();
            _loadAutocomplete();
            _loadShortcuts();
        }
Example #5
0
        public void Set(string dataPath, string urlPath, ChannelSftp.LsEntry entry)
        {
            urlPath          = _convertPath(urlPath);
            _config[urlPath] = entry.getAttrs().getMTime().ToString(CultureInfo.InvariantCulture);

            var dest = _convertLocalPath(urlPath);

            GrfPath.CreateDirectoryFromFile(dest);
            GrfPath.Delete(dest);
            File.Copy(dataPath, dest);
        }
Example #6
0
 public static void UpdateStoredFiles()
 {
     foreach (var pair in _storedFiles)
     {
         if (File.Exists(pair.Key))
         {
             if (GrfPath.Delete(pair.Value))
             {
                 File.Copy(pair.Key, pair.Value);
             }
         }
     }
 }
 public static void DbDirectCopyWriter <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
 {
     try {
         if (debug.OldPath != debug.FilePath)
         {
             GrfPath.Delete(debug.FilePath);
             File.Copy(debug.OldPath, debug.FilePath);
         }
     }
     catch (Exception err) {
         debug.ReportException(err);
     }
 }
Example #8
0
        /// <summary>
        /// Clears the temporary files, this method is different than GRFE's (and it is better).
        /// </summary>
        public static void ClearTemporaryFiles()
        {
            GrfThread.Start(delegate {
                int errorCount = 0;

                // Clear root files only
                if (Directory.Exists(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp")))
                {
                    foreach (string file in Directory.GetFiles(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp"), "*", SearchOption.TopDirectoryOnly))
                    {
                        if (!GrfPath.Delete(file))
                        {
                            errorCount++;
                        }

                        if (errorCount > 20)
                        {
                            break;
                        }
                    }

                    // There will be no files in the temporary folder anymore
                    foreach (var directory in Directory.GetDirectories(GrfPath.Combine(SdeAppConfiguration.ProgramDataPath, "~tmp"), "*"))
                    {
                        string folderName = Path.GetFileName(directory);
                        int processId;

                        if (Int32.TryParse(folderName, out processId))
                        {
                            try {
                                Process.GetProcessById(processId);
                                // Do not bother if the process exists, even if it's not SDE
                            }
                            catch (ArgumentException) {
                                // The process is not running
                                try {
                                    Directory.Delete(directory, true);
                                }
                                catch { }
                            }
                            catch {
                                // Do nothing
                            }
                        }
                    }
                }
            }, "GRF - TemporaryFilesManager cleanup");
        }
        private void _buttonOk_Click(object sender, RoutedEventArgs e)
        {
            string tempFile = TemporaryFilesManager.GetTemporaryFilePath("script_tmp_{0:0000}.py");

            try {
                if (_oldHeight != default(GridLength) && _rowConsole.Height.Value > 0)
                {
                    _oldHeight = new GridLength(_rowConsole.Height.Value);
                }

                if (!_editor.ProjectDatabase.AllTables.Any(p => p.Value.IsLoaded))
                {
                    throw new Exception("No databases loaded.");
                }

                File.WriteAllText(tempFile, _textEditor.Text);

                _tbOutput.Text = new ScriptInterpreter().Execute(_editor.FindTopmostTab(), tempFile);

                if (_tbOutput.Text != "")
                {
                    _tbOutput.Text       = ">>> CONSOLE OUTPUT\r\n" + _tbOutput.Text;
                    _tbOutput.Visibility = Visibility.Visible;

                    if (_oldHeight == default(GridLength))
                    {
                        _oldHeight = new GridLength(150);
                    }

                    _rowConsole.Height = _oldHeight;
                }
                else
                {
                    _button_ConsoleClose_Click(null, null);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
            finally {
                GrfPath.Delete(tempFile);
            }
        }
Example #10
0
        public void Save(string filename)
        {
            if (!File.Exists(filename))
            {
                GrfPath.CreateDirectoryFromFile(filename);

                using (var writer = File.Create(filename)) {
                    Save(writer);
                }

                return;
            }

            string tempFile = TemporaryFilesManager.GetTemporaryFilePath(Process.GetCurrentProcess().Id + "_mapcache_{0:0000}.dat");

            using (var writer = File.Create(tempFile)) {
                Save(writer);
            }

            GrfPath.CreateDirectoryFromFile(filename);
            GrfPath.Delete(filename);
            File.Copy(tempFile, filename);
            GrfPath.Delete(tempFile);
        }
Example #11
0
        public void _start()
        {
            try {
                while (true)
                {
                    Pause();

                    var keys = _pendingBackups.Keys.ToList();

                    foreach (var key in keys.Where(p => p > _backupId).OrderBy(p => p))
                    {
                        string grfPath = GrfPath.Combine(Settings.TempPath, "backup_" + _backupId + ".grf");

                        using (GrfHolder grf = new GrfHolder(grfPath, GrfLoadOptions.New)) {
                            foreach (var entry in _pendingBackups[key])
                            {
                                grf.Commands.AddFileAbsolute(entry.Value, entry.Key);
                            }

                            grf.Save();
                            grf.Reload();

                            // Currently saving another file, stop before breaking anything
                            if (BackupEngine.Instance.IsStarted)
                            {
                                break;
                            }

                            // Save to primary backup file
                            BackupEngine.Instance.Grf.QuickMerge(grf);
                            BackupEngine.Instance.Grf.Reload();
                        }

                        GrfPath.Delete(grfPath);

                        // Deletes unused files, it's not necessary but it can pile up quickly
                        foreach (var file in _pendingBackups[key].Keys)
                        {
                            GrfPath.Delete(file);
                        }

                        _backupId = key;
                    }

                    // Remove old backups
                    if (!BackupEngine.Instance.IsStarted)
                    {
                        List <string> paths = BackupEngine.Instance.GetBackupFiles().OrderBy(long.Parse).ToList();

                        // Only delete if it's worth it.
                        if (paths.Count > BackupEngine.MaximumNumberOfBackups + 15)
                        {
                            while (paths.Count > BackupEngine.MaximumNumberOfBackups)
                            {
                                BackupEngine.Instance.Grf.Commands.RemoveFolder(paths[0]);
                                paths.RemoveAt(0);
                            }

                            BackupEngine.Instance.Grf.QuickSave();
                        }

                        // The GRF must always be closed
                        BackupEngine.Instance.Grf.Close();
                    }
                }
            }
            catch (Exception err) {
                IsCrashed = true;
                ErrorHandler.HandleException(err);
                ErrorHandler.HandleException("The backup engine has failed to save your files. It will be disabled until you reload the application.", ErrorLevel.NotSpecified);
            }
        }
Example #12
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;
        }
Example #13
0
 public override bool Delete(string path)
 {
     return(GrfPath.Delete(path));
 }
Example #14
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;
                });
            };
        }