Example #1
0
        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);
                    }));
                }
            }
        }
        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;
                }
            }));
        }
Example #3
0
        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 + ")");
                        }
                    }
                }
            }));
        }