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(); }
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()); } }