Exemple #1
0
 private static void StandaloneModeButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     Properties.Settings.Default.backup = "NONE";
     Properties.Settings.Default.Save();
     LogCtrl.Warning("Setting to Standalone Mode.");
     LogCtrl.Warning("Restart CueController now.");
 }
Exemple #2
0
        private static Script CreateScript(string title, string scriptString)
        {
            string[] lines  = scriptString.Split('\n');
            Script   script = new Script(title, lines, scriptString);

            if (script.cues.Count == lines.Length)
            {
                LogCtrl.Status("Script created successfully.");
            }
            else
            {
                LogCtrl.Warning("Not all commands could be added to the script!");
            }
            return(script);
        }
Exemple #3
0
 public static void SendMSC(MscCommand mscCommand)
 {
     if (outputDevice != null && outputDevice.IsOpen && !MidiInputCtrl.mscMute)
     {
         try
         {
             outputDevice.SendSysEx(mscCommand.byteMessage);
             LogCtrl.Status("Send: " + mscCommand.message);
         }
         catch (Exception e)
         {
             LogCtrl.Error("Couldn't send MSC command!");
             LogCtrl.Error(e.ToString());
         }
     }
     else
     {
         LogCtrl.Warning("Send: " + mscCommand.message);
     }
 }
Exemple #4
0
        private static void MainModeButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string ip = InputDialogCtrl.Show("Enter Backup IP:");

            if (ip != null)
            {
                Match match = Regex.Match(ip, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}");
                if (match.Success)
                {
                    Properties.Settings.Default.backup = ip;
                    Properties.Settings.Default.Save();
                    LogCtrl.Warning("Setting to Main. (Backup: " + ip + ")");
                    LogCtrl.Warning("Restart CueController now.");
                }
                else
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't set to Main!", "You entered an invalid IP address.");
                }
            }
        }
Exemple #5
0
 public static void SendNote(MidiNote note)
 {
     if (outputDevice != null && outputDevice.IsOpen && !MidiInputCtrl.noteMute)
     {
         try
         {
             Pitch pitch = (Pitch)note.pitch;
             outputDevice.SendNoteOn(Channel.Channel1, pitch, 127);
             outputDevice.SendNoteOn(Channel.Channel1, pitch, 0);
             LogCtrl.Status("Send: " + note.note + " (" + note.pitch + ")");
         }
         catch (Exception e)
         {
             LogCtrl.Error("Couldn't send MIDI note!");
             LogCtrl.Error(e.ToString());
         }
     }
     else
     {
         LogCtrl.Warning("Send: " + note.note + " (" + note.pitch + ")");
     }
 }
Exemple #6
0
        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);
                    }
                }
            }));
        }
Exemple #7
0
        public static void Send(OscCmd oscCmd)
        {
            if (oscMute)
            {
                switch (oscCmd.type)
                {
                case DataType.FLOAT:
                    LogCtrl.Warning("Send OSC: " + oscCmd.oscAddress + " " + oscCmd.floatVal);
                    break;

                case DataType.INT:
                    LogCtrl.Warning("Send OSC: " + oscCmd.oscAddress + " " + oscCmd.intVal);
                    break;

                default:
                    LogCtrl.Warning("Send OSC: " + oscCmd.oscAddress + " " + oscCmd.stringVal);
                    break;
                }
                return;
            }

            foreach (OscTarget target in oscTargets)
            {
                if (target.keyword == oscCmd.keyword)
                {
                    using (OscSender sender = new OscSender(target.ip, target.port))
                    {
                        sender.Connect();

                        if (oscCmd.type == DataType.INT)
                        {
                            sender.Send(new OscMessage(target.prefix + oscCmd.oscAddress, oscCmd.intVal));
                        }

                        else if (oscCmd.type == DataType.FLOAT)
                        {
                            sender.Send(new OscMessage(target.prefix + oscCmd.oscAddress, oscCmd.floatVal));
                        }

                        else
                        {
                            sender.Send(new OscMessage(target.prefix + oscCmd.oscAddress, oscCmd.stringVal));
                        }
                    }
                    switch (oscCmd.type)
                    {
                    case DataType.FLOAT:
                        LogCtrl.Status("Send OSC: " + oscCmd.oscAddress + " " + oscCmd.floatVal);
                        break;

                    case DataType.INT:
                        LogCtrl.Status("Send OSC: " + oscCmd.oscAddress + " " + oscCmd.intVal);
                        break;

                    default:
                        LogCtrl.Status("Send OSC: " + oscCmd.oscAddress + " " + oscCmd.stringVal);
                        break;
                    }
                    return;
                }
            }
            LogCtrl.Error("Couldn't find OSC target " + oscCmd.keyword + ".");
        }
Exemple #8
0
        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);
                }));
            }
        }
Exemple #9
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 + ")");
                        }
                    }
                }
            }));
        }