void OnBrowseCommand(object sender) { UIService.ShowMessage("Drag folder from explorer"); RunExternal runner = new RunExternal("explorer.exe", "."); runner.RunWithoutWaiting(Directory); }
/// <summary>Run this job.</summary> /// <param name="sender">A system telling us to go </param> /// <param name="e">Arguments to same </param> public void Run(object sender, System.ComponentModel.DoWorkEventArgs e) { // Extract the path from the filespec. If non specified then assume // current working directory. string path = Path.GetDirectoryName(fileSpec); if (path == null | path == "") { path = Directory.GetCurrentDirectory(); } List <string> files = Directory.GetFiles( path, Path.GetFileName(fileSpec), recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).ToList(); // See above. FIXME! files.RemoveAll(s => s.Contains("UnitTests")); files.RemoveAll(s => s.Contains("UserInterface")); files.RemoveAll(s => s.Contains("ApsimNG")); // Get a reference to the JobManager so that we can add jobs to it. JobManager jobManager = e.Argument as JobManager; // For each .apsimx file - read it in and create a job for each simulation it contains. string workingDirectory = Directory.GetCurrentDirectory(); string binDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string apsimExe = Path.Combine(binDirectory, "Models.exe"); List <JobManager.IRunnable> jobs = new List <JobManager.IRunnable>(); foreach (string apsimxFileName in files) { JobManager.IRunnable job = new RunExternal(apsimExe, StringUtilities.DQuote(apsimxFileName), workingDirectory); jobs.Add(job); jobManager.AddJob(job); } // Wait until all our jobs are all finished. while (AreSomeJobsRunning(jobs)) { Thread.Sleep(200); } // Collect all error messages. foreach (JobManager.IRunnable job in jobs) { if (job.ErrorMessage != null) { ErrorMessage += job.ErrorMessage + Environment.NewLine; } } if (ErrorMessage != null) { throw new Exception(ErrorMessage); } }
public void OnOpenSelectedFileCommand(object parameter) { if (_gitRepository.TryGetTarget(out IGitRepository gitRepository) == false) { return; } foreach (var item in SelectedModifiedFilePathList) { string directory = gitRepository.GetRepositoryDirectory(); string directory_name = System.IO.Path.GetDirectoryName(directory + "\\" + item); RunExternal runner = new RunExternal("explorer.exe", directory_name); runner.RunWithoutWaiting(directory + "\\" + item); } }
public void OnOpenExplorerSelectedFileCommand(object parameter) { if (_gitRepository.TryGetTarget(out IGitRepository gitRepository) == false) { return; } foreach (var item in SelectedModifiedFilePathList) { string full_path = Path.GetFullPath(Path.Combine(gitRepository.GetRepositoryDirectory(), item)); string directory_name = System.IO.Path.GetDirectoryName(full_path); RunExternal runner = new RunExternal("explorer.exe", directory_name); runner.RunWithoutWaiting(string.Format("/select, \"{0}\"", full_path)); } }
public static void AddToolbarButton(PluginData pluginData, ToolBar toolBar, IGitRepository gitRepository) { Button button = new Button(); button.Width = 100; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; BitmapImage bitmapImage = new BitmapImage(new Uri(pluginData.IconPath, UriKind.RelativeOrAbsolute)); Image image = new Image(); image.Source = bitmapImage; image.Width = 32; image.Height = 32; TextBlock textBlock = new TextBlock(); textBlock.HorizontalAlignment = HorizontalAlignment.Center; textBlock.Text = pluginData.Title; stackPanel.Children.Add(image); stackPanel.Children.Add(textBlock); button.Content = stackPanel; button.Command = new DelegateCommand(async(object parameter) => { string workingDirectory = gitRepository.GetRepositoryDirectory(); switch (pluginData.ExecutionType) { case ExecutionType.WithoutShellAndNoWaiting: { RunExternal runner = new RunExternal(pluginData.Command, workingDirectory); try { runner.RunWithoutWaiting(pluginData.Argument); } catch (System.Exception exception) { UIService.ShowMessage("Cannot execute. " + exception.Message); } return; } case ExecutionType.WimyGitInnerShellAndRefreshRepositoryStatus: { RunExternal runner = new RunExternal(pluginData.Command, workingDirectory); try { runner.RunInConsoleProgressWindow(pluginData.Argument); await gitRepository.Refresh(); } catch (System.Exception exception) { UIService.ShowMessage("Cannot execute. " + exception.Message); } return; } } }); toolBar.Items.Add(button); }
private void OnOpenGitBashCommand(object sender) { RunExternal runner = new RunExternal(ProgramPathFinder.GetGitShell(), Directory); runner.RunInShell("--login -i"); }
private void OnOpenExplorerCommand(object sender) { RunExternal runner = new RunExternal("explorer.exe", Directory); runner.RunWithoutWaiting(Directory); }