Exemple #1
0
        void CompleteControlValues()
        {
            string presetName = cB_RTSP.Text;
            string id         = "";
            string ip         = "";
            string port       = "";

            if (presetName.Length > 0)
            {
                id   = RTSPPresets.GetValue(PresetColumn.PelcoID, presetName);
                ip   = RTSPPresets.GetValue(PresetColumn.ControlIP, presetName);
                port = RTSPPresets.GetValue(PresetColumn.ControlPort, presetName);
            }

            if (id == "")
            {
                id = "0";
            }

            if (ip == "")
            {
                ip = MainForm.m.setPage.tB_IPCon_Adr.Text;
            }

            if (port == "")
            {
                port = MainForm.m.setPage.cB_IPCon_Port.Text;
            }

            cB_ID.Text   = id;
            tB_IP.Text   = ip;
            cB_Port.Text = port;
        }
Exemple #2
0
        static void UpdateSinglePresetBox(ComboBox box, VideoSettings refreshSettings = null)
        {
            if (refreshSettings != null)
            {
                refreshSettings.refreshBox = false;
            }

            int oldVal = box.SelectedIndex;

            box.Items.Clear();
            foreach (string s in RTSPPresets.GetPresetList())
            {
                box.Items.Add(s);
            }

            box.Items.Add("Add New...");

            if (oldVal <= box.Items.Count - 2)
            {
                box.SelectedIndex = oldVal;
            }

            if (refreshSettings != null)
            {
                refreshSettings.refreshBox = true;
            }
        }
Exemple #3
0
        void UpdateAll()
        {
            if (RTSPPresets.currentPresetCount == 0)
            {
                cB_Clone.Hide();
            }
            else
            {
                cB_Clone.Show();
            }

            cB_Clone.Items.Clear();

            cB_Clone.Items.Clear();
            foreach (string s in RTSPPresets.GetPresetList())
            {
                cB_Clone.Items.Add(s);
            }

            if (!cB_Clone.Items.Contains("Clone...") && !refresh)
            {
                cB_Clone.Items.Add("Clone...");
            }

            cB_Clone.Text = "Clone...";
        }
Exemple #4
0
        public void LoadPlayer(string presetName, bool autoPlay)
        {
            string indexVal    = RTSPPresets.GetValue(PresetColumn.Index, presetName);
            int    presetIndex = 0;

            if (indexVal != "")
            {
                presetIndex = int.Parse(indexVal);
            }

            if (presetIndex >= RTSPPresets.currentPresetCount)
            {
                presetIndex = MainForm.m.mainPlayer.attachedPlayers.IndexOf(myDetached) + 1;
                if (presetIndex >= RTSPPresets.currentPresetCount)
                {
                    return;
                }
            }

            cB_RTSP.SelectedIndex = presetIndex;

            if (autoPlay)
            {
                myDetached.Play(false, false);
            }
            if (isMainPlayer)
            {
                MainForm.m.setPage.cB_IPCon_MainPlayerPreset.SelectedIndex = cB_RTSP.SelectedIndex;
            }
        }
Exemple #5
0
        public static async Task ImportConfig(string name, bool dragdrop)
        {
            try {
                MainForm.m.finishedLoading = false;
                string configFile = ConfigControl.appFolder + ConfigControl.config;
                if (name != configFile)
                {
                    ResetFile(configFile);

                    string[] lines   = File.ReadAllLines(name);
                    bool     isValid = false;
                    foreach (string line in lines)
                    {
                        string val = line.ToLower();
                        if (val.Contains("ssutility2.0") && val.Contains("config"))
                        {
                            isValid = true;
                            break;
                        }
                    }

                    if (!isValid)
                    {
                        MessageBox.Show("Text file is not a config file!");
                        MainForm.m.finishedLoading = true;
                        return;
                    }
                    else if (dragdrop && !ShowPopup("Config file detected!\n(" + name + ")\nImport new settings, replacing current config?", "New Config Detected!", "", false))
                    {
                        MainForm.m.finishedLoading = true;
                        return;
                    }

                    foreach (string line in lines)
                    {
                        File.AppendAllText(configFile, line + "\n");
                    }

                    RTSPPresets.Reload(true);
                    ConfigControl.SetToDefaults();
                    await ConfigControl.SearchForVarsAsync(ConfigControl.appFolder + ConfigControl.config);

                    MainForm.m.setPage.LoadSettings();
                    MessageBox.Show("Updated config file!\n(" + configFile + ")");
                    MainForm.m.AttachPlayers();
                }
                else
                {
                    if (name == configFile)
                    {
                        MessageBox.Show("Please don't try to replace the config file with itself!");
                    }
                }
            } catch (Exception e) {
                ShowPopup("Failed to import config!\nShow more?", "Error Occurred!", e.ToString());
            }

            MainForm.m.finishedLoading = true;
        }
Exemple #6
0
        public static void OpenEdit(VideoSettings sets)
        {
            string rtspName = sets.cB_RTSP.Text;

            if (rtspName.Length > 0 && rtspName.Trim().Length > 0)
            {
                RTSPPresets.OpenPreset(sets.cB_RTSP.Text, sets);
                return;
            }
        }
Exemple #7
0
        public int GetPelcoID()
        {
            string val = RTSPPresets.GetValue(PresetColumn.PelcoID, ConfigControl.mainPlayerPreset.stringVal);
            int    returnVal;

            if (!int.TryParse(val, out returnVal))
            {
                returnVal = -1;
            }

            return(returnVal);
        }
Exemple #8
0
        private void b_Forget_Click(object sender, EventArgs e)
        {
            RTSPPresets.ForgetPreset(editIndex);
            CloseWindow();
            int index = mySets.cB_RTSP.SelectedIndex;

            if (index > 0)
            {
                mySets.cB_RTSP.SelectedIndex = index - 1;
            }
            else
            {
                mySets.Text = "";
            }
        }
Exemple #9
0
        private void cB_Clone_DropDownClosed(object sender, EventArgs e)
        {
            if (!cB_Clone.Items.Contains("Clone..."))
            {
                cB_Clone.Items.Add("Clone...");
            }

            if (cB_Clone.Items.Count > 0 && cB_Clone.SelectedIndex >= 0 && cB_Clone.Items[cB_Clone.SelectedIndex].ToString() != "Clone...")
            {
                OpenPreset(RTSPPresets.GetPreset(cB_Clone.Text));
                editIndex = -1;
            }

            cB_Clone.SelectedIndex = cB_Clone.FindStringExact("Clone...");
        }
Exemple #10
0
        private void b_Confirm_Click(object sender, EventArgs e)
        {
            //Name;FullAdr;RTSPIP;RTSPPort;RTSP;Username;Password;PelcoID;ControlIP;ControlPort;

            string name        = tB_Name.Text;
            string fullAdr     = tB_FullAdr.Text;
            string ipaddress   = tB_RTSPIP.Text;
            string port        = tB_RTSPPort.Text;
            string url         = tB_RTSPString.Text;
            string username    = tB_Username.Text;
            string password    = tB_Password.Text;
            string pelco       = tB_PelcoID.Text;
            string controlip   = tB_ControlIP.Text;
            string controlport = cB_ControlPort.Text;

            string full = name + ";" + fullAdr + ";" + ipaddress + ";" + port + ";" + url + ";" + username
                          + ";" + password + ";" + pelco + ";" + controlip + ";" + controlport + ";";

            if (name.Length <= 0 || fullAdr.Length <= 0 || pelco.Length <= 0)
            {
                MessageBox.Show("Invalid RTSP values!\nPreset Name, Full Address, and Pelco ID must be completed!");
                return;
            }

            string stringCheckIndex = RTSPPresets.GetValue(RTSPPresets.PresetColumn.Index, tB_Name.Text);
            int    checkIndex       = -1;

            if (stringCheckIndex != "")
            {
                checkIndex = int.Parse(stringCheckIndex);
            }

            if (editIndex >= 0)   //existing
            {
                mySets.cB_RTSP.SelectedIndex = RTSPPresets.LoadPreset(full, editIndex);
            }
            else if (checkIndex != -1)     //duplicate
            {
                MessageBox.Show("Duplicate preset name!");
                return;
            }
            else     //new
            {
                mySets.cB_RTSP.SelectedIndex = RTSPPresets.LoadPreset(full);
            }

            CloseWindow();
        }
Exemple #11
0
        private void cB_IPCon_MainPlayerPreset_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!MainForm.m.finishedLoading)
            {
                return;
            }

            if (cB_IPCon_MainPlayerPreset.SelectedIndex == cB_IPCon_MainPlayerPreset.Items.Count - 1 &&
                RTSPPresets.currentPresetCount == 0)    //if no presets exist and the user clicks Add New...
            {
                RTSPPresets.CreateNew(MainForm.m.mainPlayer.settings);
            }
            else
            {
                MainForm.m.mainPlayer.settings.cB_RTSP.SelectedIndex = cB_IPCon_MainPlayerPreset.SelectedIndex;
            }
        }
Exemple #12
0
        void OpenPreset(string[] preset)
        {
            if (preset != null)
            {
                string retVal = RTSPPresets.GetValue(RTSPPresets.PresetColumn.Index, preset[0], RTSPPresets.PresetColumn.Name);
                if (retVal != "")
                {
                    editIndex = int.Parse(retVal);
                }

                if (editIndex != -1)
                {
                    LoadPreset(preset);
                    b_Forget.Visible = true;
                }

                check_Manual.Checked = (preset[RTSPPresets.TableValue(RTSPPresets.PresetColumn.ControlIP)] != "" ||
                                        preset[RTSPPresets.TableValue(RTSPPresets.PresetColumn.ControlPort)] != "" ||
                                        preset[RTSPPresets.TableValue(RTSPPresets.PresetColumn.PelcoID)] != "1");
            }
        }
Exemple #13
0
        public static void CreateConfig(string path)
        {
            try {
                Tools.ResetFile(path);

                File.AppendAllText(path, "#SSUtility2.0 " + MainForm.version + " Config\n\n");

                foreach (ConfigSetting setting in configArray)
                {
                    if (!portableMode.boolVal && (setting.settingName == finalSource.settingName || setting.settingName == finalDestination.settingName))
                    {
                        continue;
                    }

                    ConfigLine(path, setting.settingName, setting.stringVal, configVarPrefix);
                }

                List <string> rtspPresets = RTSPPresets.GetAll();
                ConfigLine(path, "RTSPPresets", RTSPPresets.currentPresetCount.ToString(), rtspPresetPrefix);
                foreach (string line in rtspPresets)
                {
                    File.AppendAllText(path, subPrefix + line + "\n");
                }

                SaveDGV(path, MainForm.m.setPage.dgv_Custom_Buttons, "CustomButtons", customButtonsPrefix);

                CommandListWindow clw = MainForm.m.clw;
                SaveDGV(path, MainForm.m.clw.dgv_Coms, "UserAddedCommands", userAddedComPrefix, clw.defaultCommandCount);

                if (MainForm.m.finalMode)
                {
                    Tools.CopySingleFile(MainForm.m.finalDest + @"\SSUtility2\" + config, path);
                }
            } catch (Exception e) {
                Tools.ShowPopup("Failed to write config!\nShow more?", "Critical Error Occurred!", e.ToString());
            }
        }
Exemple #14
0
        private void check_Manual_CheckedChanged(object sender, EventArgs e)
        {
            bool enabled = check_Manual.Checked;

            l_PelcoID.Enabled = enabled;
            cB_ID.Enabled     = enabled;

            l_IP.Enabled  = enabled;
            tB_IP.Enabled = enabled;

            l_Port.Enabled  = enabled;
            cB_Port.Enabled = enabled;

            MainForm.m.setPage.ToggleOverridePreset(enabled);

            if (!enabled)
            {
                string[] preset = RTSPPresets.GetPreset(ConfigControl.mainPlayerPreset.stringVal);

                tB_IP.Text   = preset[TableValue(PresetColumn.ControlIP)];
                cB_Port.Text = preset[TableValue(PresetColumn.ControlPort)];
                cB_ID.Text   = preset[TableValue(PresetColumn.PelcoID)];
            }
        }
Exemple #15
0
 public string GetCombined()
 {
     return(RTSPPresets.GetValue(PresetColumn.FullAdr, cB_RTSP.Text));
 }
Exemple #16
0
 public string GetRTSPIP()
 {
     return(RTSPPresets.GetValue(PresetColumn.RTSPIP, cB_RTSP.Text));
 }
Exemple #17
0
        public async static Task SearchForVarsAsync(string path)
        {
            try {
                string[] lines = File.ReadAllLines(path);

                List <ConfigVar>         varFound     = new List <ConfigVar>();
                List <List <ConfigVar> > playersFound = new List <List <ConfigVar> >();

                for (int i = 0; i < lines.Length; i++)
                {
                    string line = lines[i];

                    if (line.StartsWith("//") || line.StartsWith("#") ||
                        line.StartsWith(@"\\") || line.StartsWith(" "))
                    {
                        continue;
                    }

                    if (line.StartsWith(configVarPrefix))
                    {
                        varFound.Add(CreateConfigVar(line));
                    }
                    else
                    {
                        int valPos = line.IndexOf(":") + 1;
                        if (valPos <= 0)
                        {
                            continue;
                        }

                        int val = 0;
                        if (!int.TryParse(line.Substring(valPos), out val))
                        {
                            continue;
                        }

                        if (line.StartsWith(playerPrefix))
                        {
                            List <ConfigVar> config = new List <ConfigVar>();

                            for (int o = 0; o < val; o++)
                            {
                                if (lines.Length - 1 >= i + o)
                                {
                                    config.Add(CreateConfigVar(lines[i + o]));
                                }
                            }

                            playersFound.Add(config);
                            i += val;
                        }
                        else if (line.StartsWith(customButtonsPrefix))
                        {
                            i++;

                            for (int o = 0; o < val; o++)
                            {
                                if (lines.Length - 1 >= i + o)
                                {
                                    MainForm.m.setPage.AddCustomButton(lines[i + o]);
                                }
                            }

                            i += val - 1;
                        }
                        else if (line.StartsWith(userAddedComPrefix))
                        {
                            i++;

                            for (int o = 0; o < val; o++)
                            {
                                if (lines.Length - 1 >= i + o)
                                {
                                    MainForm.m.clw.LoadCommand(lines[i + o]);
                                }
                            }

                            i += val - 1;
                        }
                        else if (line.StartsWith(rtspPresetPrefix))
                        {
                            i++;

                            for (int o = 0; o < val; o++)
                            {
                                if (lines.Length - 1 >= i + o)
                                {
                                    RTSPPresets.LoadPreset(lines[i + o]);
                                }
                            }

                            i += val - 1;
                        }
                    }
                }

                foreach (ConfigVar v in varFound)
                {
                    foreach (ConfigSetting setting in configArray)
                    {
                        if (v.name == setting.settingName)
                        {
                            setting.UpdateValue(v.value);
                        }
                    }
                }

                if (playersFound.Count > 0)
                {
                    for (int o = 1; o < playersFound.Count; o++)
                    {
                        MainForm.m.playerConfigList.Add(playersFound[o]);
                    }
                }
            } catch (Exception e) {
                MessageBox.Show("LOAD CONFIG\n" + e.ToString());
            }
        }
Exemple #18
0
        private void cB_RTSP_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!MainForm.m.finishedLoading || !refreshBox)
            {
                return;
            }

            previousIndex = cB_RTSP.SelectedIndex;

            if (cB_RTSP.Text == "")
            {
                toolTip1.SetToolTip(cB_RTSP, "Select a camera preset");
                return;
            }

            bool visibleBool = false;

            if (cB_RTSP.SelectedIndex == cB_RTSP.Items.Count - 1)
            {
                if (previousIndex != -1 || isMainPlayer)
                {
                    RTSPPresets.CreateNew(this);
                }
            }
            else
            {
                //Use new settings
                if (cB_RTSP.Text != "")
                {
                    visibleBool = true;
                }

                if (isMainPlayer)
                {
                    MainForm.m.setPage.cB_IPCon_MainPlayerPreset.SelectedIndex = cB_RTSP.SelectedIndex;
                }

                if (!check_Manual.Checked)
                {
                    CompleteControlValues();
                }
            }

            UpdateButtonVisibility(visibleBool);

            string rtspText = cB_RTSP.Text;

            if (isMainPlayer)
            {
                ConfigControl.mainPlayerPreset.UpdateValue(rtspText);
                MainForm.m.setPage.b_IPCon_Edit.Visible = visibleBool;
            }
            else if (myLinkedPage != null)
            {
                int pageIndex = MainForm.m.mainPlayer.settings.tC_PlayerSettings.TabPages.IndexOf(myLinkedPage);
                if (pageIndex == 1)
                {
                    ConfigControl.player2Preset.UpdateValue(rtspText);
                }
                else if (pageIndex == 2)
                {
                    ConfigControl.player3Preset.UpdateValue(rtspText);
                }
            }

            string fullAdr = RTSPPresets.GetValue(PresetColumn.FullAdr, cB_RTSP.Text);

            toolTip1.SetToolTip(cB_RTSP, fullAdr);
            myDetached.Play(false, false);
        }