コード例 #1
0
ファイル: Task.cs プロジェクト: x-cubed/Second-Law
 public static Task Load(DirectoryInfo folder)
 {
     try {
         var task = new Task(folder);
         return task;
     } catch (Exception x) {
         Debug.Print(x.ToString());
         return null;
     }
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: x-cubed/Second-Law
        private void RunTask(Task task, DeviceInstance device)
        {
            tslStatus.Text = string.Format("Running task \"{0}\" for the \"{1}\"...", task.Name, device.Metadata.ProductName);
            lsvScripts.Enabled = false;

            string oldDirectory = Environment.CurrentDirectory;
            Action<PipelineStateInfo> completed = null;
            completed = state => {
                if (InvokeRequired) {
                    Invoke(new Action(() => completed(state)));
                    return;
                }

                Environment.CurrentDirectory = oldDirectory;
              lsvScripts.Enabled = true;

              // Update the device information and available task list
              DisplayCurrentDevice();
            };

            // Run the script
            Environment.CurrentDirectory = task.Folder.FullName;
            _psHost.RunAsync(task.Name, task.ScriptFile, completed,
                new KeyValuePair<string, object>("Device", device),
                new KeyValuePair<string, object>("UI", new ExposedUI(_psHost.UI, _psHost.WindowHandle))
            );
        }