コード例 #1
0
        private static void MasterIpButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string ip = InputDialogCtrl.Show("Enter PB IP and Domain");

            if (ip != null)
            {
                string[] a = ip.Split(' ');
                if (a.Length >= 2)
                {
                    Match match = Regex.Match(a[0], @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$");

                    if (match.Success && int.TryParse(a[1], out int domain))
                    {
                        Connect(a[0], domain);
                        MidiController.Connect(ip);
                    }
                    else
                    {
                        DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't connect to PB!", "You entered an invalid IP or domain.");
                    }
                }
                else
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't connect to PB!", "You entered an invalid IP or domain.");
                }
            }
        }
コード例 #2
0
        private static void AddBeamerButton_Click(object sender, RoutedEventArgs e)
        {
            string s = InputDialogCtrl.Show("Enter: ID IP");

            if (s != null)
            {
                string[] a = s.Split(' ');
                if (a.Length >= 2)
                {
                    int id;
                    if (!int.TryParse(a[0], out id))
                    {
                        DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't add beamer!", "Invalid ID.");
                    }
                    else
                    {
                        Match match = Regex.Match(a[1], @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$");
                        if (!match.Success)
                        {
                            DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't add beamer!", "Invalid IP.");
                        }
                        else
                        {
                            AddProjector(id, a[1]);
                        }
                    }
                    CuelistCtrl.saved = false;
                }
                else
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't add beamer!", "Invalid text input.");
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// If user closes window, check if cuelist is saved.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (!CuelistCtrl.saved)
     {
         Nullable <bool> result = DialogCtrl.Show(DialogType.QUESTION, OptionType.YESNO, "Cuelist has changed.", "Do you wan't to save the Cuelist?");
         if (result == true && !ReadWriteCtrl.Write(false))
         {
             e.Cancel = true;
         }
     }
 }
コード例 #4
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);
         }
     }
 }
コード例 #5
0
        private static void MatrixIpButton_Click(object sender, RoutedEventArgs e)
        {
            string s = InputDialogCtrl.Show("Enter Master IP");

            if (s != null)
            {
                Match match = Regex.Match(s, @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$");
                if (match.Success)
                {
                    SetIp(s);
                }
                else
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't set Matrix IP!", "You entered an invalid IP address.");
                }
            }
        }
コード例 #6
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);
     }
 }
コード例 #7
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);
         }
     }
 }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
0
        private static void MatrixPresetButton_Click(object sender, RoutedEventArgs e)
        {
            string s = InputDialogCtrl.Show("Enter preset number");

            if (s != null)
            {
                int preset;
                if (int.TryParse(s, out preset))
                {
                    MatrixCmd cmdBuff = MatrixCmd.getMatrixCmd("P" + preset);
                    SendMatrixCmd(cmdBuff);
                }
                else
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't load preset!", "You entered an invalid preset number.");
                }
            }
        }
コード例 #11
0
        private static void AddOscButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string s = InputDialogCtrl.Show("Enter: Keyword Prefix IP Port", 300);

            if (s != null)
            {
                string[] buff = s.Split(' ');
                if (buff.Length >= 4)
                {
                    if (!buff[1].StartsWith("/"))
                    {
                        DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Wrong prefix format.", "OSC addresses have to start with /");
                    }
                    else if (buff[1].EndsWith("/"))
                    {
                        DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Wrong prefix format.", "Prefix cannot end with /");
                    }
                    else
                    {
                        Match match = Regex.Match(buff[2], @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$");
                        if (!match.Success)
                        {
                            DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't add OSC target!", "Invalid IP.");
                        }
                        else
                        {
                            if (!int.TryParse(buff[3], out int port))
                            {
                                DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Can't add OSC target!", "Invalid Port.");
                            }
                            else
                            {
                                AddOscTarget(buff[0], buff[1], IPAddress.Parse(buff[2]), port, s);
                            }
                        }
                    }
                }
                else
                {
                    DialogCtrl.Show(DialogType.ERROR, OptionType.OKCANCEL, "Wrong Format!", "Enter ID (chosen by you), IP and Port.");
                }
            }
        }
コード例 #12
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.");
                }
            }
        }
コード例 #13
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);
            }
        }
コード例 #14
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.");
        }
コード例 #15
0
 private static void NewButton_Click(object sender, RoutedEventArgs e)
 {
     if (!CuelistCtrl.saved)
     {
         bool?result = DialogCtrl.Show(DialogType.QUESTION, OptionType.YESNO, "Create new Cuelist", "Do you want to save the current cuelist?");
         if (result == true)
         {
             if (Write(false))
             {
                 ClearCuelist();
             }
         }
         else
         {
             ClearCuelist();
         }
     }
     else
     {
         ClearCuelist();
     }
 }
コード例 #16
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);
        }