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]);
            }
        }
示例#2
0
        public static void SendMatrixCmd(MatrixCmd matrixCmd)
        {
            LogCtrl.Status(matrixCmd.description);
            Thread thread = new Thread(() => ExecuteMatrixCmd(matrixCmd));

            thread.Start();
        }
示例#3
0
 private static void SetIp(string _ip)
 {
     ip = _ip;
     Properties.Settings.Default.matrixIp = ip;
     Properties.Settings.Default.Save();
     LogCtrl.Status("Set Matrix IP: " + ip);
 }
示例#4
0
 public static void Connect(string ip, int domain)
 {
     Auto.UnInitialize();
     Auto.InitializeTCP(ip, domain, true);
     LogCtrl.Status("Connecting to PB: " + ip + " (Domain " + domain + ")");
     Properties.Settings.Default.masterIp = ip;
     Properties.Settings.Default.domain   = domain;
     Properties.Settings.Default.Save();
 }
示例#5
0
 private static void SetBackup()
 {
     isMain = false;
     if (!server.Init())
     {
         LogCtrl.Error("Can't set to Backup.");
     }
     else
     {
         server.Start();
         LogCtrl.Status("Set to Backup Mode.");
     }
 }
示例#6
0
 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.");
     }
 }
示例#7
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);
        }
示例#8
0
 public void Shutter(bool open)
 {
     if (open)
     {
         LogCtrl.Status("Beamer " + id + ": Open (" + ip + ")");
         Thread thread = new Thread(() => ShutterMethod(true));
         thread.Start();
     }
     else
     {
         LogCtrl.Status("Beamer " + id + ": Close (" + ip + ")");
         Thread thread = new Thread(() => ShutterMethod(false));
         thread.Start();
     }
 }
示例#9
0
 public static void Close()
 {
     if (outputDevice != null && outputDevice.IsOpen)
     {
         try
         {
             outputDevice.Close();
             LogCtrl.Status("Close MIDI Out: " + outputDevice.Name);
         }
         catch (Exception e)
         {
             LogCtrl.Error(e.Message);
             DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't close " + outputDevice.Name);
         }
     }
 }
示例#10
0
        public static void Play(int[] seqCue)
        {
            LogCtrl.Status("Start: Sequence " + seqCue[0] + " Cue " + seqCue[1]);

            if (!Auto.MoveSequenceToCue(seqCue[0], seqCue[1]))
            {
                LogCtrl.Error("PB Error: " + Auto.GetLastError().ToString());
            }

            Thread.Sleep(2);

            if (!Auto.SetSequenceTransportMode(seqCue[0], "Play"))
            {
                LogCtrl.Error("PB Error: " + Auto.GetLastError().ToString());
            }
        }
示例#11
0
 public static void Close()
 {
     if (inputDevice != null && inputDevice.IsOpen)
     {
         try
         {
             inputDevice.StopReceiving();
             inputDevice.Close();
             LogCtrl.Status("Close MIDI In: " + inputDevice.Name);
         }
         catch (Exception e)
         {
             LogCtrl.Error(e.Message);
             DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't close " + inputDevice.Name);
         }
     }
 }
示例#12
0
 public static void Open(OutputDevice device)
 {
     Close();
     try
     {
         outputDevice = device;
         outputDevice.Open();
         Properties.Settings.Default.midiOutputDeviceName = outputDevice.Name;
         Properties.Settings.Default.Save();
         LogCtrl.Status("Open MIDI Out: " + outputDevice.Name);
     }
     catch (Exception e)
     {
         LogCtrl.Error(e.Message);
         DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't open " + outputDevice.Name);
     }
 }
示例#13
0
 public static bool Open(InputDevice device)
 {
     try
     {
         inputDevice = device;
         inputDevice.Open();
         inputDevice.StartReceiving(null, true);
         inputDevice.ControlChange += InputDevice_ControlChange;
         LogCtrl.Status("Connect: " + inputDevice.Name);
         return(true);
     }
     catch
     {
         LogCtrl.Error("Coudn't connect to " + inputDevice.Name);
         return(false);
     }
 }
示例#14
0
        public static void AddProjector(int id, string ip)
        {
            foreach (BeamerCtrl b in beamers)
            {
                if (b.id == id)
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't add beamer.", "Beamer ID already exists!");
                    return;
                }
            }

            beamers.Add(new BeamerCtrl(id, ip));
            beamers.Sort((x, y) => x.id.CompareTo(y.id));
            RefreshBeamerMenus();

            LogCtrl.Status("Added Beamer " + id + " " + ip);
        }
示例#15
0
        public static bool Write(bool overwrite)
        {
            string filename;

            if (overwrite && path != null)
            {
                filename = path;
            }
            else
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.Filter = "CC Files (*.cc)|*.cc";
                bool?result = dlg.ShowDialog();
                if (result == false)
                {
                    return(false);
                }
                filename = dlg.FileName;
            }

            string p = Path.ChangeExtension(filename, ".cc");

            using (DataSet dataSet = new DataSet("Cuelist"))
            {
                dataSet.Tables.Add(GetSettingsTable());
                dataSet.Tables.Add(CuelistCtrl.GetCueTable());
                dataSet.Tables.Add(ScriptlistCtrl.GetScriptTable());
                dataSet.Tables.Add(BeamerlistCtrl.GetBeamerTable());
                dataSet.Tables.Add(MidiController.GetMidiMapTable());

                try { dataSet.WriteXml(p); }
                catch (Exception e)
                {
                    LogCtrl.Error(e.Message);
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Couldn't write file!");
                    return(false);
                }
            }

            SetPath(p);
            CuelistCtrl.saved = true;
            RecentFilesCtrl.Add(p);
            LogCtrl.Status("Saved file: " + p);
            return(true);
        }
示例#16
0
        public static void ExecuteCmd(PbCmd cmd)
        {
            cmd.method.Invoke(null, cmd.args);

            if (Auto.GetLastError() != AutoError.None)
            {
                LogCtrl.Error("PB Error: " + Auto.GetLastError().ToString());
            }

            if (cmd.args.Length > 0)
            {
                LogCtrl.Status("PB: " + cmd.method.Name + "," + string.Join(",", cmd.args));
            }
            else
            {
                LogCtrl.Status("PB: " + cmd.method.Name);
            }
        }
示例#17
0
        public static void Close()
        {
            RequestStop();

            if (inputDevice != null && inputDevice.IsOpen)
            {
                try
                {
                    Auto2.UnInitialize();
                    inputDevice.StopReceiving();
                    inputDevice.Close();
                    LogCtrl.Status("Close MIDI In: " + inputDevice.Name);
                }
                catch (Exception e)
                {
                    LogCtrl.Error(e.Message);
                }
            }
        }
示例#18
0
        private static void RemoveOscTarget_Click(object sender, RoutedEventArgs e)
        {
            MenuItem sendItem = sender as MenuItem;
            string   keyword  = sendItem.Header.ToString().Split(' ')[0];

            foreach (OscTarget target in oscTargets)
            {
                if (target.keyword == keyword)
                {
                    oscTargets.Remove(target);
                    Properties.Settings.Default.oscTargets.Remove(target.wholeString);
                    Properties.Settings.Default.Save();
                    Core.win.removeOscMenu.Items.Remove(sendItem);
                    break;
                }
            }

            LogCtrl.Status("Removed OSC Target.");
        }
示例#19
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);
     }
 }
示例#20
0
        public static void Open(InputDevice device)
        {
            Close();

            try
            {
                inputDevice = device;
                inputDevice.Open();
                inputDevice.StartReceiving(null, true);
                inputDevice.SysEx  += InputDevice_SysEx;
                inputDevice.NoteOn += InputDevice_NoteOn;
                Properties.Settings.Default.midiInputDeviceName = inputDevice.Name;
                Properties.Settings.Default.Save();
                LogCtrl.Status("Open MIDI In: " + inputDevice.Name);
            }
            catch (Exception e)
            {
                LogCtrl.Error(e.Message);
                DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Coudn't open " + inputDevice.Name);
            }
        }
示例#21
0
        private static void AddOscTarget(string keyword, string prefix, IPAddress ip, int port, string wholeString)
        {
            foreach (OscTarget oscTarget in oscTargets)
            {
                if (oscTarget.keyword == keyword)
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't add OSC target!", "Keyword was already assigned.");
                    return;
                }
            }

            oscTargets.Add(new OscTarget(keyword, prefix, ip, port, wholeString));

            Properties.Settings.Default.oscTargets.Add(wholeString);
            Properties.Settings.Default.Save();

            oscTargets.Sort((x, y) => x.keyword.CompareTo(y.keyword));
            RefreshOscMenu();

            LogCtrl.Status("Added OSC Target.");
        }
示例#22
0
        private static void RemoveBeamer_Click(object sender, RoutedEventArgs e)
        {
            MenuItem sendItem = sender as MenuItem;
            int      id;

            if (int.TryParse(sendItem.Header.ToString().Split(' ')[0], out id))
            {
                foreach (BeamerCtrl b in beamers)
                {
                    if (b.id == id)
                    {
                        beamers.Remove(b);
                        Core.win.removeBeamerMenu.Items.Remove(sendItem);

                        foreach (MenuItem mi in Core.win.openShutterMenu.Items)
                        {
                            if (mi.Header.ToString().StartsWith(id.ToString()))
                            {
                                Core.win.openShutterMenu.Items.Remove(mi);
                                break;
                            }
                        }

                        foreach (MenuItem mi in Core.win.closeShutterMenu.Items)
                        {
                            if (mi.Header.ToString().StartsWith(id.ToString()))
                            {
                                Core.win.closeShutterMenu.Items.Remove(mi);
                                break;
                            }
                        }

                        break;
                    }
                }
                CuelistCtrl.saved = false;
                LogCtrl.Status("Removed Beamer " + id);
            }
        }
示例#23
0
        private static void EditScript(int nr)
        {
            string[] buff = Show(nr);

            if (buff != null)
            {
                if (buff.Length == 2)
                {
                    Script script = CreateScript(buff[0], buff[1]);

                    if (script != null && script.cues.Count > 0)
                    {
                        scripts[nr - 1]             = script;
                        editItems[nr - 1].Header    = nr + " " + script.title;
                        executeItems[nr - 1].Header = nr + " " + script.title;

                        foreach (Cue cue in script.cues)
                        {
                            if (cue.SendString == "PB")
                            {
                                LogCtrl.Status("Added: " + cue.SendString + " " + cue.Description);
                            }
                            else
                            {
                                LogCtrl.Status("Added: " + cue.SendString);
                            }
                        }
                    }
                }
                else if (buff.Length == 1)
                {
                    scripts[nr - 1]             = null;
                    editItems[nr - 1].Header    = nr.ToString();
                    executeItems[nr - 1].Header = nr.ToString();
                    LogCtrl.Status("Script " + nr + " cleared.");
                }
                CuelistCtrl.saved = false;
            }
        }
示例#24
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 + ")");
     }
 }
示例#25
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);
                    }
                }
            }));
        }
示例#26
0
        public static void Read(string filename)
        {
            if (!CuelistCtrl.saved)
            {
                bool?result = DialogCtrl.Show(DialogType.QUESTION, OptionType.YESNO, "Open Cuelist", "Do you want to save the current cuelist?");
                if (result == true)
                {
                    if (!Write(false))
                    {
                        return;
                    }
                }
            }

            if (filename == null)
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.Filter = "CC Files (*.cc)|*.cc";
                bool?result = dlg.ShowDialog();

                if (result == true)
                {
                    filename = dlg.FileName;
                }
                else
                {
                    return;
                }
            }

            using (DataSet dataSet = new DataSet("Cuelist"))
            {
                try { dataSet.ReadXml(filename); }
                catch (Exception e)
                {
                    LogCtrl.Error(e.Message);
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Error", "Can't open file!");
                    return;
                }
                DataTableCollection collection = dataSet.Tables;

                ClearCuelist();

                for (int i = 0; i < collection.Count; i++)
                {
                    DataTable table = collection[i];
                    switch (table.TableName)
                    {
                    case "Settings":
                        SetSettingsFromTable(table);
                        break;

                    case "Script":
                        ScriptlistCtrl.LoadScripts(table);
                        break;

                    case "Beamer":
                        BeamerlistCtrl.LoadBeamers(table);
                        break;

                    case "MidiMap":
                        MidiController.LoadMidiMap(table);
                        break;

                    default:
                        CuelistCtrl.SetCuesFromTable(table);
                        break;
                    }
                }
            }

            CuelistCtrl.saved = true;
            SetPath(filename);
            CuelistCtrl.DisableEditMode();
            RecentFilesCtrl.Add(filename);
            LogCtrl.Status("Open file: " + filename);
        }
示例#27
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 + ")");
                        }
                    }
                }
            }));
        }
示例#28
0
 private static void SetButton_Click(object sender, RoutedEventArgs e)
 {
     SetCtrlVals(dialog.getValues());
     CuelistCtrl.saved = false;
     LogCtrl.Status("MIDI map set.");
 }
示例#29
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 + ".");
        }
示例#30
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);
                }));
            }
        }