public void Decode() { FullCommand = FullCommand.Replace("---", "\""); Command = Command.Replace("---", "\""); ArgString = ArgString.Replace("---", "\""); var args = new Dictionary <string, string>(); foreach (var arg in Args) { args.Add(arg.Key.Replace("---", "\""), arg.Value.Replace("---", "\"")); } Args = args; var switches = new Dictionary <string, string>(); foreach (var switch1 in Switches) { switches.Add(switch1.Key.Replace("---", "\""), switch1.Value.Replace("---", "\"")); } Switches = switches; for (var i = 0; i < FreeArgs.Count; i++) { FreeArgs[i] = FreeArgs[i].Replace("---", "\""); } for (var i = 0; i < SimpleArgs.Count; i++) { SimpleArgs[i] = SimpleArgs[i].Replace("---", "\""); } }
protected override void InitializeComponents() { base.InitializeComponents(); this.Text = AppString.Dialog.NewOpenWithItem; btnBrowse.Click += (sender, e) => BrowseFile(); btnOk.Click += (sender, e) => { if (string.IsNullOrEmpty(ItemText)) { MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty); return; } if (FullCommand.IsNullOrWhiteSpace()) { MessageBoxEx.Show(AppString.MessageBox.CommandCannotBeEmpty); return; } FilePath = ObjectPath.ExtractFilePath(Command); AppRegPath = $@"HKEY_CLASSES_ROOT\Applications\{Path.GetFileName(FilePath)}"; if (FilePath == null || RegistryEx.GetRegistryKey(AppRegPath) != null) { MessageBoxEx.Show(AppString.MessageBox.UnsupportedFilename); return; } AddNewItem(); this.DialogResult = DialogResult.OK; }; }
private void AddNewItem() { using (var shellKey = RegistryEx.GetRegistryKey(ShellPath, true, true)) { string keyName = "Item"; NewItemRegPath = ObjectPath.GetNewPathWithIndex($@"{ShellPath}\{keyName}", ObjectPath.PathType.Registry); keyName = RegistryEx.GetKeyName(NewItemRegPath); using (var key = shellKey.CreateSubKey(keyName, true)) { key.SetValue("MUIVerb", ItemText); if (rdoMulti.Checked) { key.SetValue("SubCommands", ""); } else { if (!FullCommand.IsNullOrWhiteSpace()) { key.CreateSubKey("command", true).SetValue("", FullCommand); } } } } }
private static void startProcessWithCommand(FullCommand fullCommand) { var p = new Process(); p.StartInfo.FileName = "Grid.exe"; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.StartInfo.Arguments = $"problem={fullCommand.filename} {fullCommand.args[0]} {fullCommand.args[1]} {fullCommand.args[2]} {fullCommand.args[3]}"; p.StartInfo.UseShellExecute = true; p.StartInfo.CreateNoWindow = false; p.EnableRaisingEvents = true; p.Exited += StartNewCommand; p.Start(); p.PriorityClass = ProcessPriorityClass.RealTime; Console.WriteLine($"Grid.exe Started: {p.StartInfo.Arguments}"); }
private static void createNeededCommands() { foreach (var file in grdFileList) { string alg = "", heuristic = "", bccinit = "", prune = ""; foreach (var profileArg in profileArgs) { foreach (var str in profileArg) { var kv = str.Split('='); kv[1] = kv[1].ToLower(); if (kv[0] == "alg") { switch (kv[1]) { case "astar": alg = "AStarMax"; break; case "dfbnb": alg = "DfBnbMax"; break; } } if (kv[0] == "prune") { switch (kv[1]) { case "none": prune = "A None_Pr"; break; case "bsd": prune = "B BSD_Pr"; break; case "hbsd": prune = "C HBSD_Pr"; break; case "rsd": prune = "D RSD_Pr"; break; } } if (kv[0] == "heuristic") { switch (kv[1]) { case "none": heuristic = "A None_H"; break; case "untouched": heuristic = "B Reachable_H"; break; case "alternate": heuristic = "C Alt_Reachable_H"; break; case "bcc": heuristic = "D BCC_H"; break; case "altbcc": heuristic = "E Alt_BCC_H"; break; case "sepaltbcc": heuristic = "F SEP_ALT_BCC_H"; break; } } if (kv[0] == "bcc-init") { switch (kv[1]) { case "true": bccinit = "True"; break; case "false": bccinit = "False"; break; } } } bool needToAdd = true; if (existingLoggedRuns.Keys.Contains(file.Name.ToLower())) { if (existingLoggedRuns[file.Name.ToLower()].Keys.Contains(alg)) { if (existingLoggedRuns[file.Name.ToLower()][alg].Keys.Contains(heuristic)) { if (existingLoggedRuns[file.Name.ToLower()][alg].Keys.Contains(heuristic)) { if (existingLoggedRuns[file.Name.ToLower()][alg][heuristic].Keys.Contains(bccinit)) { if (existingLoggedRuns[file.Name.ToLower()][alg][heuristic][bccinit].Keys .Contains(prune)) { var howEnded = existingLoggedRuns[file.Name.ToLower()][alg][heuristic][bccinit][prune]; switch (howEnded) { case "Searching": break; case "Ended": needToAdd = false; break; case "StoppedByTime": needToAdd = retryStoppedByTime; Console.Out.WriteLine($"StoppedByTime: {file}, {alg}, {prune}"); break; case "IllegalStartState": Console.Out.WriteLine($"IllegalStartState: {file}, {alg}, {prune}"); break; case "StoppedByMemoryLimit": Console.Out.WriteLine( $"StoppedByMemoryLimit: {file}, {alg}, {prune}"); break; } } } } } } } if (needToAdd) { var cmd = new FullCommand(); cmd.filename = file.Name; cmd.args = profileArg; commandToBeDone.Add(cmd); } } } }