private Send(PbCmd pbCmd) { type = SendType.PB; this.pbCmd = pbCmd; name = "PB"; }
public static Send GetSend(string value, string pbScript) { string[] array = value == null ? new string[] { } : value.Trim().Split(' '); if (array.Length >= 2) { Match match = Regex.Match(array[0], @"B(\d+)", RegexOptions.IgnoreCase); if (match.Success && match.Groups.Count == 2) { if (array[1].ToUpper() == "CLOSE") { return(new Send(new Tuple <int, bool>(int.Parse(match.Groups[1].Value), false), array[0].ToUpper() + " close")); } else if (array[1].ToUpper() == "OPEN") { return(new Send(new Tuple <int, bool>(int.Parse(match.Groups[1].Value), true), array[0].ToUpper() + " open")); } } else { switch (array[0].ToUpper()) { case "CUE": MscCommand mscCmd1 = MscCommand.getCue(array[1]); if (mscCmd1 != null) { return(new Send(mscCmd1)); } break; case "MACRO": MscCommand mscCmd2 = MscCommand.getMacro(array[1]); if (mscCmd2 != null) { return(new Send(mscCmd2)); } break; case "MATRIX": MatrixCmd matrixCmd = MatrixCmd.getMatrixCmd(array[1]); if (matrixCmd != null) { return(new Send(matrixCmd)); } break; case "MUTE": switch (array[1].ToUpper()) { case "ALL": return(new Send(new Tuple <MuteType, bool>(MuteType.ALL, true), "Mute All")); case "NOTE": return(new Send(new Tuple <MuteType, bool>(MuteType.NOTE, true), "Mute Note")); case "MSC": return(new Send(new Tuple <MuteType, bool>(MuteType.MSC, true), "Mute MSC")); case "OSC": return(new Send(new Tuple <MuteType, bool>(MuteType.OSC, true), "Mute OSC")); } break; case "UNMUTE": switch (array[1].ToUpper()) { case "ALL": return(new Send(new Tuple <MuteType, bool>(MuteType.ALL, false), "Unmute All")); case "NOTE": return(new Send(new Tuple <MuteType, bool>(MuteType.NOTE, false), "Unmute Note")); case "MSC": return(new Send(new Tuple <MuteType, bool>(MuteType.MSC, false), "Unmute MSC")); case "OSC": return(new Model.Send(new Tuple <MuteType, bool>(MuteType.OSC, false), "Unmute OSC")); } break; case "NOTE": MidiNote note = MidiNote.getMidiNote(array[1]); if (note != null && note.pitch < 108) { return(new Send(note, "Note " + array[1])); } break; case "SC": string[] s = array[1].Split(','); if (s.Length >= 2) { int sequence, cue; if (int.TryParse(s[0], out sequence) && int.TryParse(s[1], out cue)) { return(new Send(sequence, cue, "SC " + array[1])); } } break; case "SCRIPT": int scriptNr; if (int.TryParse(array[1], out scriptNr) && scriptNr > 0 && scriptNr < 11) { return(new Send(scriptNr, "Script " + array[1])); } break; } } } else if (array.Length == 1) { if (array[0].ToUpper() == "PB" && pbScript != null) { PbCmd pbCmd = PbCmd.GetPbCmd(pbScript); if (pbCmd != null) { return(new Send(pbCmd)); } } else if (array[0].ToUpper() == "OSC" && pbScript != null) { OscCmd oscCmd = OscCmd.GetOscCmd(pbScript); if (oscCmd != null) { return(new Send(oscCmd)); } } } return(null); }
public ControllerValues(string[] _cmds) { Init(); cmds = _cmds; for (int i = 0; i < 51; ++i) { string cmd = _cmds[i]; if (string.IsNullOrWhiteSpace(cmd)) { continue; } string[] lines = cmd.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string line in lines) { if (string.IsNullOrWhiteSpace(line)) { continue; } string[] buffArray = line.Split('-'); if (buffArray.Length < 2) { NotFound(line); continue; } string buff1 = buffArray[1].Trim().ToUpper(); string buff0 = buffArray[0].Trim(); switch (buff1) { case "ON": if (buff0.StartsWith("Auto")) { PbCmd buff = PbCmd.GetPbCmd(buff0); if (buff != null) { pbCmdOn[i].Add(buff); } else { NotFound(line); } } else { int pos = Array.IndexOf(ControllerLists.GetCcCmdList(), buff0); if (pos > -1) { ccCmdOn[i].Add(buff0); } else { NotFound(line); } } break; case "OFF": if (buff0.StartsWith("Auto")) { PbCmd buff = PbCmd.GetPbCmd(buff0); if (buff != null) { pbCmdOff[i].Add(buff); } else { NotFound(line); } } else { int pos = Array.IndexOf(ControllerLists.GetCcCmdList(), buff0); if (pos > -1) { ccCmdOff[i].Add(buff0); } else { NotFound(line); } } break; default: if (buff0.StartsWith("Auto")) { string[] vals = buff1.Split(','); if (vals.Length < 3) { NotFound(line); break; } int min, max, interp; if (!int.TryParse(vals[0], out min) || !int.TryParse(vals[1], out max) || !int.TryParse(vals[2], out interp)) { NotFound(line); break; } PbCmdArg pbCmdArg = PbCmdArg.GetPbCmdArg(buff0, min, max, interp); if (pbCmdArg == null) { NotFound(line); break; } pbCmdArgs[i].Add(pbCmdArg); } else { NotFound(line); } break; } } } }