Esempio n. 1
0
 public static Guid NewDocument(EventHandler <NewScriptUserInterfaceArgs> userInterfaceCallback)
 {
     if (userInterfaceCallback != null)
     {
         NewScriptUserInterfaceArgs args = new NewScriptUserInterfaceArgs();
         userInterfaceCallback(null, args);
         if (args.CreateScript)
         {
             string filename = args.FileName;
             string script   = args.Script;
             Guid   rc       = Guid.Empty;
             if (string.IsNullOrEmpty(filename))
             {
                 rc = NewDocument(script, true);
             }
             else
             {
                 // create the file and perform an Open
                 string directory = System.IO.Path.GetDirectoryName(filename);
                 if (!string.IsNullOrEmpty(directory))
                 {
                     if (!System.IO.Directory.Exists(directory))
                     {
                         System.IO.Directory.CreateDirectory(directory);
                     }
                     System.IO.File.WriteAllText(filename, script);
                     rc = OpenDocument(filename, true);
                 }
             }
             return(rc);
         }
     }
     return(Guid.Empty);
 }
Esempio n. 2
0
 public static Guid NewDocument(EventHandler<NewScriptUserInterfaceArgs> userInterfaceCallback)
 {
   if ( userInterfaceCallback != null)
   {
     NewScriptUserInterfaceArgs args = new NewScriptUserInterfaceArgs();
     userInterfaceCallback(null, args);
     if (args.CreateScript)
     {
       string filename = args.FileName;
       string script = args.Script;
       Guid rc = Guid.Empty;
       if (string.IsNullOrEmpty(filename))
       {
         rc = NewDocument(script, true);
       }
       else
       {
         // create the file and perform an Open
         string directory = System.IO.Path.GetDirectoryName(filename);
         if (!string.IsNullOrEmpty(directory))
         {
           if (!System.IO.Directory.Exists(directory))
             System.IO.Directory.CreateDirectory(directory);
           System.IO.File.WriteAllText(filename, script);
           rc = OpenDocument(filename, true);
         }
       }
       return rc;
     }
   }
   return Guid.Empty;
 }