private void Backup_RestoreRequested(object sender, BackupRequestedEventArgs e)
        {
            if (Project == null)
            {
                return;
            }

            if (Editor.Items.Count > 0)
            {
                foreach (PageViewModel page in Editor.Items)
                {
                    if (page.Filename == e.Path)
                    {
                        if (page.IsModified)
                        {
                            string message = String.Format("This file ({0}) has unsaved changes. Are you sure you want to restore from backup?", e.Path);
                            if (Services.MessageBox.ShowQuestion(message) != MessageBoxResult.Yes)
                            {
                                e.Cancel = true;
                                return;
                            }
                        }

                        Editor.Items.Remove(page);

                        break;
                    }
                }
            }

            File.Write(e.Path, e.Contents);
        }
Example #2
0
        private void RaiseRestoreRequested(string original, string contents)
        {
            var handler = RestoreRequested;

            if (handler != null)
            {
                BackupRequestedEventArgs e = new BackupRequestedEventArgs(original, contents);

                handler(this, e);

                if (!e.Cancel)
                {
                    RemoveItem(original);
                }
            }
        }