private void EditCommand() { // Make sure at least one item is selected if (lstAvailableActions.SelectedItems.Count == 0) { return; } // Get first item selected, associated action, and selected application CommandInfo selectedItem = (CommandInfo)lstAvailableActions.SelectedItem; var selectedAction = selectedItem.Action; var selectedCommand = selectedItem.Command; if (selectedCommand == null) { return; } CommandDialog commandDialog = new CommandDialog(selectedCommand, selectedAction); var result = commandDialog.ShowDialog(); if (result != null && result.Value) { int index = selectedAction.Commands.ToList().IndexOf(selectedCommand); selectedAction.RemoveCommand(selectedCommand); selectedAction.InsertCommand(index, selectedCommand); } }
private void EditCommand() { // Make sure at least one item is selected if (lstAvailableActions.SelectedItems.Count == 0) { return; } // Get first item selected, associated action, and selected application CommandInfo selectedItem = (CommandInfo)lstAvailableActions.SelectedItem; var selectedCommand = selectedItem.Command; if (selectedCommand == null) { return; } CommandDialog commandDialog = new CommandDialog(selectedCommand, selectedItem.Action); var result = commandDialog.ShowDialog(); if (result != null && result.Value) { int index = CommandInfos.IndexOf(selectedItem); var newActionInfo = CommandInfo.FromCommand(selectedCommand, selectedItem.Action); CommandInfos[index] = newActionInfo; RefreshActionGroup(newActionInfo.Action); SelectCommands(newActionInfo); } }
public void mod(CommandDialog modable) { if (modable == null) { return; } mod(this, modable); }
public override IModable copyDeep() { var result = new CommandDialog(); result.DialogID = Modable.copyDeep(DialogID); result.Settings = Modable.copyDeep(Settings); return(result); }
public override void mod(IModable modable) { CommandDialog modCommand = modable as CommandDialog; if (modCommand == null) { Debug.LogError("Type mismatch"); return; } mod(modCommand); }
public bool ChangeCommand(WshShortcut shortcut) { using (CommandDialog dlg = new CommandDialog()) { dlg.Command = shortcut.TargetPath; dlg.Arguments = shortcut.Arguments; if (dlg.ShowDialog() != DialogResult.OK) { return(false); } shortcut.TargetPath = dlg.Command; shortcut.Arguments = dlg.Arguments; shortcut.Save(); return(true); } }
public bool ChangeCommand(ShellLink shellLink) { using (CommandDialog dlg = new CommandDialog()) { dlg.Command = shellLink.TargetPath; dlg.Arguments = shellLink.Arguments; if (dlg.ShowDialog() != DialogResult.OK) { return(false); } shellLink.TargetPath = dlg.Command; shellLink.Arguments = dlg.Arguments; shellLink.Save(); return(true); } }
private bool DoAutocomplete(Controller controller) { string text = GetCurrentLine(); int quotesCount = 0; int quotesIndex = 0; while (true) { quotesIndex = text.IndexOf('"', quotesIndex); if (quotesIndex == -1) { break; } quotesIndex++; if (quotesIndex >= text.Length) { break; } quotesCount++; } string path = ""; int index = text.Length; while (true) { if (index <= 0) { path = text; break; } index--; if (quotesCount % 2 == 0 && (text[index] == ' ' || text[index] == '\t' || text[index] == '"') || quotesCount % 2 == 1 && text[index] == '"') { path = text.Substring(index + 1); break; } } CommandDialog.AutocompletePath(Frame.TextBox, path, null); return(true); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Command result; JObject jo = JObject.Load(reader); if (!Enum.TryParse((string)jo["Type"], out Command.Type commandType)) { Debug.LogError($"CommandType {jo["Type"]} not recognized in {jo}"); return(new CommandNone()); } switch (commandType) { case (Command.Type.Break): result = new CommandBreak(); break; case (Command.Type.Call): result = new CommandCall(); break; case (Command.Type.Conditional): result = new CommandConditional(); break; case (Command.Type.Consume): result = new CommandConsume(); break; case (Command.Type.Continue): result = new CommandContinue(); break; case (Command.Type.Debug): result = new CommandDebug(); break; case (Command.Type.Dialog): result = new CommandDialog(); break; case (Command.Type.Dialogue): result = new CommandDialogue(); break; case (Command.Type.Event): result = new CommandEvent(); break; case (Command.Type.EventEnd): result = new CommandEventEnd(); break; case (Command.Type.Flush): result = new CommandFlush(); break; case (Command.Type.GotoLocation): result = new CommandGotoLocation(); break; case (Command.Type.Interrupt): result = new CommandInterrupt(); break; case (Command.Type.ItemAdd): result = new CommandItemAdd(); break; case (Command.Type.ItemRemove): result = new CommandItemRemove(); break; case (Command.Type.NoteAdd): result = new CommandNoteAdd(); break; case (Command.Type.NoteRemove): result = new CommandNoteRemove(); break; case (Command.Type.Outfit): result = new CommandOutfit(); break; case (Command.Type.OutfitManage): result = new CommandOutfitManage(); break; case (Command.Type.Pause): result = new CommandPause(); break; case (Command.Type.Services): result = new CommandServices(); break; case (Command.Type.Set): result = new CommandSet(); break; case (Command.Type.Shop): result = new CommandShop(); break; case (Command.Type.Sleep): result = new CommandSleep(); break; case (Command.Type.TimePass): result = new CommandTimePass(); break; case (Command.Type.None): default: result = new CommandNone(); break; } serializer.Populate(jo.CreateReader(), result); return(result); /*if (reader.TokenType == JsonToken.Null) * return new CText(); * * if (reader.TokenType == JsonToken.StartObject) * { * //https://stackoverflow.com/questions/35586987/json-net-custom-serialization-with-jsonconverter-how-to-get-the-default-beha * existingValue = existingValue ?? serializer.ContractResolver.ResolveContract(objectType).DefaultCreator(); * serializer.Populate(reader, existingValue); * return existingValue; * } * * if (reader.TokenType == JsonToken.String) * return new CText((string)reader.Value); * */ //throw new JsonSerializationException(); }
private void mod(CommandDialog original, CommandDialog mod) { DialogID = Modable.mod(original.DialogID, mod.DialogID); Settings = Modable.mod(original.Settings, mod.Settings); }
async void DoSendCommandClick(object sender, ActionRequested how) { NodeBase data = (NodeBase)(sender as ToolStripItem).Tag; CommandParams cPar = ctrl.PrepareSendCommand(data); if (cPar != null) { CommandDialog cdlg = new CommandDialog(cPar); if (cdlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { if (cPar.SBOrun) { string sName = (cPar.CommandFlowFlag == CommandCtrlModel.Select_Before_Operate_With_Enhanced_Security) ? "SBOw" : "SBO"; NodeData d = (NodeData)data.Parent; NodeData op = null, sel = null; if (d != null) { if (d.Name == "SBOw" || d.Name == "SBO") { sName = "Oper"; sel = (NodeData)data; } else { op = (NodeData)data; } NodeBase dd = d.Parent; if (dd != null) { NodeData d2 = (NodeData)dd.FindChildNode(sName); if (d2 != null) { NodeData d3 = (NodeData)d2.FindChildNode("ctlVal"); if (d3 != null) { if (op == null) { op = d3; } else { sel = d3; } ctrl.SendCommand(sel, cPar, how); await PutTaskDelay(cPar.SBOtimeout); ctrl.SendCommand(op, cPar, how); } else { Logger.getLogger().LogWarning("Cannot send SBO command sequence, ctlVal not found in " + d2.IecAddress); } } else { Logger.getLogger().LogWarning("Cannot send SBO command sequence, " + sName + " not found in " + dd.IecAddress); } } else { Logger.getLogger().LogWarning("Cannot send SBO command sequence, null parent of " + d.IecAddress); } } else { Logger.getLogger().LogWarning("Cannot send SBO command sequence, null parent of " + data.IecAddress); } } else { ctrl.SendCommand(data, cPar, how); } } } }
public bool LaunchProcess(string args, CommandDialog cd, bool bShowProgress = false, string sDestination = "") { try { strMessage = string.Empty; Process build = new Process(); Thread thDialog = null; if (bShowProgress) { if (cd == CommandDialog.Copy) { if (pf == null) { pf = new ProgressForm(); } pf.SetProcess(build); pf.SetProgress(string.Empty, 0, sDestination); thDialog = new Thread(() => ThreadProcCopy()); thDialog.Start(); } else if (cd == CommandDialog.Connect) { if (cf == null) { cf = new ConnectForm(); } DeviseAddr addr = new DeviseAddr(); if (!string.IsNullOrEmpty(addr.ConnectionType) && addr.ConnectionType.Equals("usb") && !string.IsNullOrEmpty(addr.UsbDevice)) { cf.SetIP(addr.UsbDevice); } else { cf.SetIP(addr.ToString()); } thDialog = new Thread(() => ThreadProcConnect()); thDialog.Start(); } else if (cd == CommandDialog.CreateScreenShot) { if (of == null) { of = new OperationForm(OperationForm.TypeOp.CreateScreenShot); } of.SetOperation("Creating ScreenShot"); thDialog = new Thread(() => ThreadProcOperation()); thDialog.Start(); } else if (cd == CommandDialog.Install) { if (of == null) { of = new OperationForm(OperationForm.TypeOp.Install); } of.SetOperation("Install " + args.Substring(args.LastIndexOf("\\") + 1).TrimEnd('\"')); thDialog = new Thread(() => ThreadProcOperation()); thDialog.Start(); } else if (cd == CommandDialog.Delete) { if (of == null) { of = new OperationForm(OperationForm.TypeOp.Delete); } of.SetOperation("Deleting"); thDialog = new Thread(() => ThreadProcOperation()); thDialog.Start(); } } build.StartInfo.WorkingDirectory = Path.GetDirectoryName(FindADB()); if (string.IsNullOrEmpty(build.StartInfo.WorkingDirectory)) { if (bShowProgress && pf != null) { pf.SetProgress(string.Empty, 0); pf.InternalCloseDialog(); pf = null; } if (bShowProgress && cf != null) { cf.InternalCloseDialog(); cf = null; } if (bShowProgress && of != null) { of.InternalCloseDialog(); of = null; } strMessage = "Can not find adb.exe"; return(false); } build.StartInfo.FileName = FindADB(); build.StartInfo.Arguments = args; build.StartInfo.UseShellExecute = false; build.StartInfo.RedirectStandardOutput = true; build.StartInfo.RedirectStandardError = true; build.StartInfo.CreateNoWindow = true; build.ErrorDataReceived += build_ErrorDataReceived; build.OutputDataReceived += build_ErrorDataReceived; build.EnableRaisingEvents = true; build.Start(); build.BeginOutputReadLine(); build.BeginErrorReadLine(); build.WaitForExit(); if (bShowProgress) { if (cd == CommandDialog.Copy) { if (build.ExitCode < 0) { if (!string.IsNullOrEmpty(sDestination)) { if (File.Exists(sDestination)) { File.Delete(sDestination); } else if (Directory.Exists(sDestination)) { //Directory.Delete(sDestination, true); } } } if (pf != null) { pf.SetProgress(string.Empty, 0); pf.InternalCloseDialog(); pf = null; } } else if (cd == CommandDialog.Connect) { cf.InternalCloseDialog(); cf = null; } else if (cd == CommandDialog.CreateScreenShot || cd == CommandDialog.Delete || cd == CommandDialog.Install) { of.InternalCloseDialog(); of = null; } } return(true); } catch (Exception e) { if (bShowProgress) { if (cd == CommandDialog.Copy) { if (pf != null) { pf.SetProgress(string.Empty, 0); pf.InternalCloseDialog(); pf = null; } } else if (cd == CommandDialog.Connect) { cf.InternalCloseDialog(); cf = null; } else if (cd == CommandDialog.CreateScreenShot || cd == CommandDialog.Delete) { of.InternalCloseDialog(); of = null; } } strMessage = e.Message; return(false); } }
public bool LaunchProcess(List <FileOperation> lstItems, CommandDialog cd, bool bShowProgress = false) { string sAdb = FindADB(); if (string.IsNullOrEmpty(sAdb)) { strMessage = "Can not find adb.exe"; return(false); } Thread thCopy = null; if (bShowProgress) { if (cd == CommandDialog.Copy) { if (pf == null) { pf = new ProgressForm(); pf.Files = lstItems; } thCopy = new Thread(() => ThreadProcCopy()); thCopy.Start(); } if (cd == CommandDialog.Delete) { if (of == null) { of = new OperationForm(OperationForm.TypeOp.Delete); of.SetOperation("Deleting"); } thCopy = new Thread(() => ThreadProcOperation()); thCopy.Start(); } } int iFile = 0; bool bRet = true; foreach (FileOperation fileOperation in lstItems) { Process build = new Process(); if (cd == CommandDialog.Copy) { if (bShowProgress && pf != null) { pf.SetProgressVisible(false); pf.CurrentPosition = iFile; pf.SetProcess(build, fileOperation.IsFolder ? "1" : "0"); pf.SetProgress(fileOperation.Source, 0, fileOperation.Destination); } } build.StartInfo.WorkingDirectory = Path.GetDirectoryName(sAdb); build.StartInfo.FileName = sAdb; build.StartInfo.Arguments = fileOperation.Command; build.StartInfo.UseShellExecute = false; build.StartInfo.RedirectStandardOutput = true; build.StartInfo.RedirectStandardError = true; build.StartInfo.CreateNoWindow = true; build.ErrorDataReceived += build_ErrorDataReceived; build.OutputDataReceived += build_ErrorDataReceived; build.EnableRaisingEvents = true; build.Start(); build.BeginOutputReadLine(); build.BeginErrorReadLine(); build.WaitForExit(); if (bShowProgress) { if (cd == CommandDialog.Copy) { if (build.ExitCode < 0) { if (!string.IsNullOrEmpty(fileOperation.Destination)) { if (File.Exists(fileOperation.Destination)) { File.Delete(fileOperation.Destination); } else if (Directory.Exists(fileOperation.Destination)) { //Directory.Delete(sDestination, true); } } if (pf != null) { pf.SetProgress(string.Empty, 0); pf.InternalCloseDialog(); pf = null; } break; } else { if (pf != null) { pf.SetProgress(string.Empty, 0); } } } } if (strMessage != null && (strMessage.Contains("adb: error:") || strMessage.Contains("Read-only file system") || strMessage.Contains(": Permission denied"))) { bRet = false; break; } iFile++; } if (bShowProgress) { if (cd == CommandDialog.Copy) { if (pf != null) { pf.SetProgress(string.Empty, 0); pf.InternalCloseDialog(); pf = null; } } if (cd == CommandDialog.Delete) { if (of != null) { of.InternalCloseDialog(); of = null; } } } return(bRet); }