Beispiel #1
0
 public static Mashup OpenMashupInteractive(string fileName, out MashupFileWarningList warningList)
 {
     if (File.Exists(Mashup.GetAutoSaveName(fileName)))
     {
         RecoverAutoSavedFileDialog recoverAutoSavedFileDialog = new RecoverAutoSavedFileDialog();
         recoverAutoSavedFileDialog.Initialize(Mashup.GetAutoSaveName(fileName));
         DialogResult dialogResult = recoverAutoSavedFileDialog.ShowDialog();
         if (dialogResult == DialogResult.Yes)
         {
             Mashup mashup = new Mashup(Mashup.GetAutoSaveName(fileName), out warningList);
             mashup.fileName = Path.Combine(Path.GetDirectoryName(fileName), "Copy of " + Path.GetFileName(fileName));
             mashup.SetDirty();
             mashup.AutoSaveBackup();
             File.Delete(Mashup.GetAutoSaveName(fileName));
             return(mashup);
         }
         if (dialogResult == DialogResult.Ignore)
         {
             File.Delete(Mashup.GetAutoSaveName(fileName));
         }
         else
         {
             if (dialogResult == DialogResult.Cancel)
             {
                 warningList = null;
                 return(null);
             }
             D.Assert(false, "Invalid enum");
         }
     }
     return(new Mashup(fileName, out warningList));
 }
Beispiel #2
0
 private void RemoveAutoSaveBackup()
 {
     try
     {
         File.Delete(Mashup.GetAutoSaveName(this.fileName));
     }
     catch (Exception ex)
     {
         D.Say(0, "Mashup.Close(): " + ex.ToString());
     }
 }
Beispiel #3
0
 public void SetFilename(string fileName)
 {
     if (File.Exists(Mashup.GetAutoSaveName(this.fileName)))
     {
         this.RemoveAutoSaveBackup();
         this.autoSaveDirty = true;
     }
     this.fileName = fileName;
     D.Assert(Path.GetFullPath(fileName).ToLower().Equals(fileName.ToLower()));
     if (this.autoSaveDirty)
     {
         this.AutoSaveBackup();
     }
 }
Beispiel #4
0
 internal void AutoSaveBackup()
 {
     if (!this.autoSaveDirty)
     {
         return;
     }
     try
     {
         this.WriteXML(Mashup.GetAutoSaveName(this.fileName));
         this.autoSaveDirty        = false;
         this.autoSaveFailNotified = false;
     }
     catch (Exception ex)
     {
         if (!this.autoSaveFailNotified)
         {
             this.autoSaveFailNotified = true;
             MessageBox.Show(string.Format("Failed to autosave {0}:\n{1}", Mashup.GetAutoSaveName(this.fileName), ex.Message), "AutoSave Failed", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         }
     }
 }