示例#1
0
 /// <summary>
 /// Saves the current xfont set being modified.
 /// </summary>
 void Save()
 {
     //If the font file doesn't exist, show save as dialog. Otherwise continue
     if (string.IsNullOrEmpty(xFont.File()))
     {
         SaveAs();
     }
     else
     {
         try
         {
             //Apply font information
             xFont.Description  = txtDescription.Text;
             xFont.Name         = txtName.Text;
             xFont.Author       = txtAuthor.Text;
             xFont.DateModified = DateTime.Now;
             //Delete the old font file, or copy it for backup.
             if (System.IO.File.Exists(xFont.File()))
             {
                 System.IO.File.Move(xFont.File(), xFont.File() + ".bak");
             }
             xFont.Export(xFont.File());
             if (System.IO.File.Exists(xFont.File() + "_"))
             {
                 System.IO.File.Delete(xFont.File() + "_");
             }
         }
         catch (Exception ex)
         {
             Logger.Log("Error saving font set at: " + xFont.File() + ". Exception: " + ex.Message, MessagePriority.High, MessageKind.Error);
             //Backup old file.
             Logger.Log("Failed to save font. ");
             if (System.IO.File.Exists(xFont.File() + ".bak"))
             {
                 System.IO.File.Move(xFont.File() + ".bak", xFont.File());
             }
         }
     }
 }