Ejemplo n.º 1
0
        /// <summary>
        /// Restores this character from a pre-death backup.
        /// </summary>
        public void Resurrect()
        {
            if (this.preDeathBackup == null)
            {
                return;
            }

            if (!File.Exists(this.preDeathBackup))
            {
                this.preDeathBackup = null;
                return;
            }

            this.watcher.EnableRaisingEvents = false;
            CharacterBackups.PauseMonitoring();

            if (File.Exists(this.mainFile))
            {
                File.Delete(this.mainFile);
            }
            File.Move(this.preDeathBackup, this.mainFile);
            this.preDeathBackup = null;

            this.watcher.EnableRaisingEvents = true;
            CharacterBackups.ResumeMonitoring();

            this.Backup(this, new FileSystemEventArgs(WatcherChangeTypes.Created,
                                                      CharacterBackups.GamePath, this.FileName));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        /// <summary>
        /// Creates a new window.
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();

            CharacterBackups.CharacterListChanged += this.CharacterBackupsOnCharacterListChanged;

            CharacterBackups.CommenceMonitoring();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Restores an archived character into the active one.
        /// </summary>
        public void Unpack()
        {
            var nameNoExt = FindViableName("game", CharacterBackups.CharacterFileExtension);

            this.watcher.EnableRaisingEvents = false;
            CharacterBackups.PauseMonitoring();

            this.RenameFiles(nameNoExt, CharacterBackups.CharacterFileExtension,
                             CharacterBackups.ArchivedFileExtension);

            this.watcher.EnableRaisingEvents = true;
            CharacterBackups.ResumeMonitoring();

            this.archived = false;
            this.OnChanged();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Restores the character from a specified backup.
        /// </summary>
        /// <param name="backupIndex">Zero-based index of the backup to choose for restoration.</param>
        public void Restore(int backupIndex)
        {
            this.watcher.EnableRaisingEvents = false;
            CharacterBackups.PauseMonitoring();

            // Check just in case.
            if (File.Exists(this.mainFile))
            {
                File.Delete(this.mainFile);
            }
            File.Move(this.backups[backupIndex], this.mainFile);

            this.watcher.EnableRaisingEvents = true;
            CharacterBackups.ResumeMonitoring();

            this.Backup(this, new FileSystemEventArgs(WatcherChangeTypes.Changed, CharacterBackups.GamePath,
                                                      Path.GetFileName(this.mainFile)));
        }