private void MainWindow_Loaded(object sender, RoutedEventArgs e) { Core.SetWnd(this); CuelistCtrl.Init(); FollowCtrl.Init(); GoCtrl.Init(); LogCtrl.Init(); LogCtrl.Status("CueController 3.43b"); MidiController.Init(); MidiInputCtrl.Init(); MidiOutputCtrl.Init(); PbCtrl.Init(); BeamerlistCtrl.Init(); RecentFilesCtrl.Init(); ReadWriteCtrl.Init(); MatrixCtrl.Init(); ScriptlistCtrl.Init(); CopyCutCtrl.Init(); OscCtrl.Init(); OscListCtrl.Init(); string[] args = Environment.GetCommandLineArgs(); if (args.Length >= 2) { ReadWriteCtrl.Read(args[1]); } }
private void StartReceive() { try { while (!_shouldStop) { data = client.Receive(ref sender); string[] message = Encoding.ASCII.GetString(data, 0, data.Length).Split(' '); if (message.Length == 2) { int cueNr; if (int.TryParse(message[1], out cueNr)) { switch (message[0]) { case "GO": Application.Current.Dispatcher.Invoke(new Action(() => { GoCtrl.Go(cueNr); })); break; case "BACK": Application.Current.Dispatcher.Invoke(new Action(() => { GoCtrl.GoBack(); })); break; } } } } } catch (SocketException se) { if (se.SocketErrorCode == SocketError.TimedOut) { Start(); } else { Application.Current.Dispatcher.Invoke(new Action(() => { LogCtrl.Error("Backup listener thread crashed!"); LogCtrl.Error(se.Message); })); } } }
public static void ExecuteScript(int nr) { if (scripts[nr - 1] != null) { LogCtrl.Status("Execute Script " + nr + ": " + scripts[nr - 1].title); foreach (Cue cue in scripts[nr - 1].cues) { GoCtrl.ExecuteCueSend(cue); } } else { LogCtrl.Error("Script doesn't exist."); } }
private void MainWindow_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Space && !CuelistCtrl.editMode) { GoCtrl.GoWithThresh(); } else if (!CuelistCtrl.editMode && e.Key == Key.Up) { CuelistCtrl.SelectPrevCue(); e.Handled = true; } else if (!CuelistCtrl.editMode && e.Key == Key.Down) { CuelistCtrl.SelectNextCue(); e.Handled = true; } }
private static void InputDevice_SysEx(SysExMessage msg) { Application.Current.Dispatcher.Invoke(new Action(() => { MscCommand mscCommand = MscCommand.getMscCommand(msg.Data); if (mscCommand != null) { if (!mscMute) { for (int i = 0; i < CuelistCtrl.cues.Count; ++i) { Cue cue = CuelistCtrl.cues[i]; if (cue.trigger != null && cue.trigger.type == TriggerType.MSC && MscCommand.Compare(mscCommand, cue.trigger.mscCmd)) { if (Core.win.saveTriggerCheckbox.IsChecked && Core.win.cueTable.SelectedIndex != i) { LogCtrl.Error("In: " + mscCommand.message); } else { LogCtrl.Success("In: " + mscCommand.message); GoCtrl.Go(i); } return; } } LogCtrl.Status("In: " + mscCommand.message); } else { LogCtrl.Warning("In: " + mscCommand.message); } } })); }
private static void OscWorker_DoWork(object sender, DoWorkEventArgs e) { try { while (receiver.State != OscSocketState.Closed) { if (oscWorker.CancellationPending) { return; } if (receiver.State == OscSocketState.Connected) { string command = receiver.Receive().ToString(); Application.Current.Dispatcher.Invoke(new Action(() => { if (!oscMute) { if ((command.StartsWith("/video") || command.StartsWith("/eos/out"))) { Match match = Regex.Match(command, @".*/(\d+)/fire.*$"); if (match.Success) { Debug.WriteLine(match.Groups[1].Value); if (int.TryParse(match.Groups[1].Value, out int cueNr)) { for (int i = 0; i < CuelistCtrl.cues.Count; ++i) { Cue cue = CuelistCtrl.cues[i]; if (cue.trigger != null && cue.trigger.type == TriggerType.OSC && cue.trigger.oscCmd.intVal == cueNr) { if (Core.win.saveTriggerCheckbox.IsChecked && Core.win.cueTable.SelectedIndex != i) { LogCtrl.Error("In: " + command); } else { LogCtrl.Success("In: " + command); GoCtrl.Go(i); } return; } } } } LogCtrl.Status("In: " + command); } else { LogCtrl.Status("In: " + command); } } else { LogCtrl.Warning("In: " + command); } })); } } } catch (Exception ex) { Application.Current.Dispatcher.Invoke(new Action(() => { LogCtrl.Error(ex.Message); })); } }
private static void ExecuteCcCmd(string cmd) { Application.Current.Dispatcher.Invoke(new Action(() => { switch (cmd) { case "Go": GoCtrl.GoWithThresh(); break; case "Back": GoCtrl.GoBack(); break; case "Up": CuelistCtrl.SelectPrevCue(); break; case "Down": CuelistCtrl.SelectNextCue(); break; case "Mute All": MidiInputCtrl.NoteMute(true); MidiInputCtrl.MscMute(true); break; case "Unmute All": MidiInputCtrl.NoteMute(false); MidiInputCtrl.MscMute(false); break; case "Mute Note": MidiInputCtrl.NoteMute(true); break; case "Unmute Note": MidiInputCtrl.NoteMute(false); break; case "Mute MSC": MidiInputCtrl.MscMute(true); break; case "Unmute MSC": MidiInputCtrl.MscMute(false); break; default: string[] buff = cmd.Split(' '); if (buff.Length == 2 && buff[0] == "Script") { int nr; if (int.TryParse(buff[1], out nr)) { ScriptlistCtrl.ExecuteScript(nr); } } break; } })); }
private static void InputDevice_NoteOn(NoteOnMessage msg) { Application.Current.Dispatcher.Invoke(new Action(() => { if (msg.Velocity > 0) { int pitch = (int)msg.Pitch; MidiNote note = MidiNote.getMidiNote(pitch); if (note != null) { if (!noteMute) { if (pitch < 108) { for (int i = 0; i < CuelistCtrl.cues.Count; ++i) { Cue cue = CuelistCtrl.cues[i]; if (cue.trigger != null && cue.trigger.type == TriggerType.NOTE && cue.trigger.note.pitch == pitch) { if (Core.win.saveTriggerCheckbox.IsChecked && Core.win.cueTable.SelectedIndex != i) { LogCtrl.Error("In: " + note.note + " (" + note.pitch + ")"); } else { LogCtrl.Success("In: " + note.note + " (" + note.pitch + ")"); GoCtrl.Go(i); } return; } } LogCtrl.Status("In: " + note.note + " (" + note.pitch + ")"); } else { LogCtrl.Status("In: " + note.note + " (" + note.pitch + ")"); if (pitch == 108) { GoCtrl.GoNextCue(); } else if (pitch == 109) { GoCtrl.GoBack(); } else if (pitch == 110) { CuelistCtrl.SelectPrevCue(); } else if (pitch == 111) { CuelistCtrl.SelectNextCue(); } else if (pitch >= 112 && pitch <= 121) { ScriptlistCtrl.ExecuteScript(note.pitch - 111); } } } else { LogCtrl.Warning("In: " + note.note + " (" + note.pitch + ")"); } } } })); }