/// <summary> /// Retrieve the setting from the config file as a decimal value. /// </summary> /// <param name="config">The configuration object,</param> /// <param name="section">The required section.</param> /// <param name="key">The required key.</param> /// <param name="defaultValue">The default value.</param> /// <returns>The decimal value of the setting or the default value.</returns> public decimal GetConfigSetting( SharpConfig.Configuration config, string section, string key, decimal defaultValue = 0) { // Set up the result anad get the raw value. decimal result = defaultValue; string rawValue = config[section][key].RawValue; // Check to see if the raw value is null or empty. if (!string.IsNullOrEmpty(rawValue)) { // We have a non-null, non-empty value so try to get the decimal value and // set the result to the default value if there is an exception. try { result = config[section][key].DecimalValue; } catch { result = defaultValue; } } return(result); }
public AppConfig( string configFile ) { this.saveFile = configFile; this.configState = ConfigState.Loading; this.currencies = new List<Currency>(24); try { config = Configuration.LoadFromFile(configFile, Encoding.UTF8); foreach (Section sec in config) { Currency c = sec.CreateObject<Currency>(); if (sec["Name"].StringValue.Contains("Chaos")) { c.Value = 1; } this.currencies.Add(c); } } catch (Exception) { InitializeCurrency(); config = new Configuration(); byte id = 0; var currencyData = currencies.OfType<Currency>().OrderBy(item => item.Name).GetEnumerator(); while (currencyData.MoveNext()) { config.Add(Section.FromObject(SECTION_CURRENCY + id, currencyData.Current)); id++; } config.SaveToFile(configFile, Encoding.UTF8); } configState = ConfigState.Clean; }
private static void CreateConfig() { var myConfig = new Configuration(); myConfig["ConfigInit"]["CreateTime"].Value = DateTime.Now.ToYYYYHHMM(); myConfig["ConfigInit"]["Message"].Value = "此为爬虫项目的配置文件。"; myConfig.Save(ConfigFileName); }
public void OptionsTab_PlayerPressed() { OptionsTabActivate(false, false, true); SharpConfig.Configuration config = gm.GetConfiguration(); GameSettings settings = gm.ConfigurationToGameSettings(config); SetUISettings(settings); }
/// <summary> /// Checks if the given section/setting combination exists in this configuration. /// </summary> /// <param name="config"></param> /// <param name="section"></param> /// <param name="key"></param> /// <param name="loggingLevel"></param> /// <returns></returns> public static bool Exists(this SharpConfig.Configuration config, string section, string key, Logging.Level loggingLevel = Logging.Level.Error) { var exists = config.Contains(section) && config[section].Contains(key); if (!exists) { Logging.Log(config, "Could not find [" + section + "] [" + key + "]", Logging.Level.Warning, loggingLevel); } return(exists); }
/// <summary> /// Tries the get named section or returns null. /// </summary> /// <returns>The get.</returns> /// <param name="config">Config.</param> /// <param name="section">Section.</param> public static SharpConfig.Section TryGet(this SharpConfig.Configuration config, string section) { Debug.Assert(config != null); Debug.Assert(!string.IsNullOrEmpty(section)); if (config.Contains(section)) { return(config[section]); } return(null); }
public void OptionsTab_ControlsPressed() { OptionsTabActivate(false, true, false); foreach (Button b in controlButtons) // Have to do this manually, unfortunately { b.GetComponent <ControlButton>().SetUp(); } SharpConfig.Configuration config = gm.GetConfiguration(); InputKeys keys = gm.ConfigurationToInputKeys(config); SetUIKeys(keys); }
public Configuration(string path) { this.Path = path; if (!File.Exists(path)) { SharpConfig.Configuration settings = new SharpConfig.Configuration(); settings.Add("Server"); settings["Server"].Add("IP", "127.0.0.1"); settings["Server"].Add("Port", 31651); settings.SaveToFile(this.Path); } this.Settings = SharpConfig.Configuration.LoadFromFile(this.Path); }
private static Configuration DeserializeBinary(BinaryReader reader, Stream stream) { if (stream == null) throw new ArgumentNullException("stream"); bool ownReader = false; if (reader == null) { reader = new BinaryReader(stream); ownReader = true; } try { var config = new Configuration(); int sectionCount = reader.ReadInt32(); for (int i = 0; i < sectionCount; i++) { string sectionName = reader.ReadString(); int settingCount = reader.ReadInt32(); Section section = new Section(sectionName); DeserializeComments(reader, section); for (int j = 0; j < settingCount; j++) { Setting setting = new Setting( reader.ReadString(), reader.ReadString()); DeserializeComments(reader, setting); section.Add(setting); } config.Add(section); } return config; } finally { if (ownReader) reader.Close(); } }
/// <summary> /// Populate the list of available ships and set the current selection /// and set the appropriate values. /// </summary> /// <param name="refreshList">Set to true to refresh the drop down list.</param> public void SetShipList(bool refreshList = false) { if (refreshList) { validConfigs = SetAvailableShips(); altConfigBox.DataSource = null; altConfigBox.DataSource = validConfigs; } TDSettings settings = MainForm.settingsRef; SharpConfig.Configuration config = SharpConfig.Configuration.LoadFromFile(configFile); if (string.IsNullOrEmpty(settings.LastUsedConfig)) { settings.LastUsedConfig = "Default"; } bool hasSection = config.FirstOrDefault(x => x.Name == settings.LastUsedConfig) != null; if (hasSection) { settings.Capacity = GetConfigSetting(config, settings.LastUsedConfig, "Capacity"); settings.Insurance = GetConfigSetting(config, settings.LastUsedConfig, "Insurance"); settings.LadenLY = GetConfigSetting(config, settings.LastUsedConfig, "LadenLY"); settings.Padsizes = config[settings.LastUsedConfig]["Padsizes"].StringValue; settings.UnladenLY = GetConfigSetting(config, settings.LastUsedConfig, "UnladenLY"); } else { settings.Capacity = 1; settings.Insurance = 0; settings.LadenLY = 1; settings.Padsizes = "?"; settings.UnladenLY = 1; } altConfigBox.SelectedIndex = !string.IsNullOrEmpty(settings.LastUsedConfig) ? altConfigBox.FindStringExact(settings.LastUsedConfig) : 0; capacityBox.Value = settings.Capacity; insuranceBox.Value = Math.Max(settings.Insurance, insuranceBox.Minimum); ladenLYBox.Value = Math.Max(settings.LadenLY, ladenLYBox.Minimum); padSizeBox.Text = settings.Padsizes; unladenLYBox.Value = Math.Max(settings.UnladenLY, unladenLYBox.Minimum); }
private void InitializeGameConfiguration() { if (File.Exists(PathGameConfigFile)) GameConfiguration = SharpConfig.Configuration.LoadFromFile(PathGameConfigFile); else { GameConfiguration = new Configuration(); GameConfigurationItem _item = new GameConfigurationItem(); _item.CurrentVersion = new Version(0, 1); Section _currentSection = Section.FromObject("Game", _item); GameConfiguration.Add(_currentSection); GameConfiguration.SaveToFile(PathGameConfigFile); } }
public void MainMenu_OptionsPressed() { animator.SetFloat("IntroToOptionsSpeed", 1); animator.Play("UI_IntroToOptions", 0, 0); // Get settings from Game Manager and apply to UI elements SharpConfig.Configuration config = gm.GetConfiguration(); GameSettings settings = gm.ConfigurationToGameSettings(config); SetUISettings(settings); foreach (Button b in controlButtons) { b.GetComponent <Image>().color = Color.white; } fovSlider.minValue = gm.cameraFovClamp.x; fovSlider.maxValue = gm.cameraFovClamp.y; }
public void Load() { if (File.Exists(filename)) { try { cfg = Configuration.LoadFromFile(filename); } catch (ParserException) { MessageBoxResult result = MessageBox.Show("An error occured during loading of the configuration.\nDo you want to generate a new blank configuration?", "Configuration Error", MessageBoxButton.OKCancel, MessageBoxImage.Error); if (result == MessageBoxResult.OK) cfg = new Configuration(); else Environment.Exit(1); } } else cfg = new Configuration(); VerifyConfiguration(); Save(); }
private void InitializeProjectileConfiguration() { if (File.Exists(PathProjectileConfigFile)) ProjectileConfiguration = SharpConfig.Configuration.LoadFromFile(PathProjectileConfigFile); else { ProjectileConfiguration = new Configuration(); for (int i = 1; i <= 4; i++) { ProjectileConfigItem _item = new ProjectileConfigItem(); _item.ID = i; switch (i) { case 1: _item.PrefabPath = "Prefab/Projectile/Prototype_Pistol_Projectile"; break; case 2: _item.PrefabPath = "Prefab/Projectile/Prototype_Rifle_Projectile"; break; case 3: _item.PrefabPath = "Prefab/Projectile/Prototype_Shotgun_Projectile"; break; case 4: _item.PrefabPath = "Prefab/Projectile/Prototype_SniperRifle_Projectile"; break; } Section _newSection = Section.FromObject(i.ToString(), _item); ProjectileConfiguration.Add(_newSection); } ProjectileConfiguration.SaveToFile(PathProjectileConfigFile); } }
//------------------------------------------------------------------------- void _load() { SharpConfig.Configuration.ValidCommentChars = new char[] { '#', ';' }; var cfg_file = Resources.Load <TextAsset>("Config/ClientConfig"); Cfg = SharpConfig.Configuration.LoadFromString(cfg_file.text); // 游戏服务器配置信息 var baseserver = Cfg["BaseServer"]; BaseIp = baseserver["BaseIp"].StringValue; BasePort = baseserver["BasePort"].IntValue; ProjectName = baseserver["ProjectName"].StringValue; ChannelName = baseserver["ChannelName"].StringValue; ProtocolVersion = baseserver["ProtocolVersion"].StringValue; // 自动更新配置信息 var autopatcher = Cfg["AutoPatcher"]; RemoteVersionInfoUrl = autopatcher["RemoteVersionInfoUrl"].StringValue; SysNoticeInfoUrl = autopatcher["SysNoticeInfoUrl"].StringValue; // UCenter配置信息 var ucenter = Cfg["UCenter"]; UCenterDomain = ucenter["UCenterDomain"].StringValue; UCenterUseSsl = bool.Parse(ucenter["UCenterUseSsl"].StringValue); // 退出游戏提示语 var quitgametip = Cfg["QuitGameTip"]; ListTip = quitgametip["ListTip"].GetValueArray <string>(); EbLog.Note("ProjectName=" + ProjectName + " ProtocolVersion=" + ProtocolVersion + " ChannelName=" + ChannelName); EbLog.Note("BaseIpPort=" + BaseIp + ":" + BasePort); }
private void Window_Loaded(object sender, RoutedEventArgs e) { string ServiceAdress = null; string ServiceAdress2 = null; if (ConfigurationManager.AppSettings["ServiceAdressSource"] != null) { ServiceAdress = ConfigurationManager.AppSettings["ServiceAdressSource"]; } else { ServiceAdress = "mongodb://192.168.1.103:27017"; } if (ConfigurationManager.AppSettings["ServiceAdressTarget"] != null) { ServiceAdress2 = ConfigurationManager.AppSettings["ServiceAdressTarget"]; } else { ServiceAdress2 = "mongodb://localhost:27017"; } Console.WriteLine("serverAdress: " + ServiceAdress); //string ServiceAdress = "mongodb://192.168.1.103:27017"; DBTranslateFactory.DBReaderHelper = new MongoDBReaderHelper(); if (!DBTranslateFactory.DBReaderHelper.InitMongoDB(ServiceAdress, ServiceAdress2)) { System.Windows.Forms.MessageBox.Show("数据库连接失败", "Error"); this.Close(); } DBTranslateFactory.statusChanged += DBTranslateFactory_statusChanged; DBTranslateFactory.ProgressChanged += DBTranslateFactory_ProgressChanged; DBTranslateFactory.TaskFinished += DBTranslateFactory_TaskFinished; if (DBTranslateFactory.DBReaderHelper.DBNames != null) { listBoxSourceDB.ItemsSource = DBTranslateFactory.DBReaderHelper.DBNames; } if (DBTranslateFactory.DBReaderHelper.DBNamesTarget != null) { listBoxTargetDB.ItemsSource = DBTranslateFactory.DBReaderHelper.DBNamesTarget; } themes.ItemsSource = ThemeManager.GetThemes(); try { config = SharpConfig.Configuration.LoadFromFile("Config.ini"); if (config != null && config.Contains("Record") && config["Record"].SettingCount == 13) { TransformConfigion tConfig = config["Record"].CreateObject <TransformConfigion>(); if (tConfig != null) { //SUM_MinX.Text = tConfig.minLon.ToString(); //SUM_MinY.Text = tConfig.minLat.ToString(); //SUM_MaxX.Text = tConfig.maxLon.ToString(); //SUM_MaxY.Text = tConfig.maxLat.ToString(); //StartLevel.Text = tConfig.sLevel.ToString(); //EndLevel.Text = tConfig.eLevel.ToString(); //foreach (ComboBoxItem s in this.CBOX.Items) //{ // if (tConfig.OperateFunction == s.Content as string) // { // this.CBOX.SelectedItem = s; // } //} List <string> item = new List <string>(); item.Add(string.Format("Min Longitude: {0}", tConfig.minLon)); item.Add(string.Format("Max Longitude: {0}", tConfig.maxLon)); item.Add(string.Format("Min Latitude: {0}", tConfig.minLat)); item.Add(string.Format("Max Latitude: {0}", tConfig.maxLat)); item.Add(string.Format("Start Level: {0}", tConfig.sLevel)); item.Add(string.Format("End Level: {0}", tConfig.eLevel)); item.Add(string.Format("Function: {0}", tConfig.OperateFunction)); item.Add(string.Format("Start Time: {0}", tConfig.StartTime)); item.Add(string.Format("Last Time: {0}", tConfig.LastTime)); item.Add(string.Format("Tiles Amount: {0}", tConfig.TotalTilesNum)); item.Add(string.Format("Tiles Finished: {0}", tConfig.NowTileNum)); item.Add(string.Format("Tiles Succeed: {0}", tConfig.SuccessNum)); item.Add(string.Format("Save Path: {0}", tConfig.SavePath)); listBoxConfig.ItemsSource = item; } } } catch (Exception) { throw; } SpeedChanged += MainWindow_SpeedChanged; load = true; this.UpdateTree(); //SpeedLabel.Content = "fgfgfgfgfgfgfgfgfgfgfgfgfgfg"; //SpeedLabel1.Content = "fgfgfgfgfgf"; //int x = 123, y = 321, z = 113; //ProgressLabel.Content = string.Format("Complete\r\n{0}/{1}\r\n{2:f2}% ", x, y, (double)x / (double)y * 100); //ProgressLabel1.Content = string.Format("Successed\r\n{1}/{0}\r\n{2:f2}%", x, z, (double)z / (double)x * 100); }
public static SharpConfig.Section LoadConfig(string SectionKey) { SharpConfig.Configuration cfg = SharpConfig.Configuration.LoadFromFile(string.Format("{0}\\Config.ini", System.Windows.Forms.Application.StartupPath)); return(cfg[SectionKey]); }
static void Test2() { var myConfig = new Configuration(); //节点Video myConfig["Video"]["Width"].Value = "1920"; myConfig["Video"]["Height"].Value = "1080"; //设置数组 myConfig["Video"]["Formats"].SetValue(new string[] { "RGB32", "RGBA32" }); //可以使用循环获取节点以及节点的所有项目,进行操作 foreach ( var section in myConfig ) { foreach ( var setting in section ) { //TODO: } } //也可以直接使用节点和项目的名称来访问: myConfig.Save("example.ini"); Console.WriteLine("Width:{0}", myConfig["Video"]["Width"].GetValue<Int32>()); Console.WriteLine("Height:{0}", myConfig["Video"]["Height"].GetValue<Int32>()); }
// Parses the configuration that is written in the TextBox, // and represents its contents in a logical structure inside the TreeView. private void ParseConfig() { // Clear the TreeView first. trViewCfg.Nodes.Clear(); if ( string.IsNullOrEmpty( txtBox.Text ) ) return; //try //{ // We want to measure how long SharpConfig needs to parse the configuration. var watch = Stopwatch.StartNew(); Configuration.ValidCommentChars = txtCommentChars.Text.ToCharArray(); // Load the configuration from the TextBox's text. currentConfig = Configuration.LoadFromText( txtBox.Text ); // Stop measuring the time. watch.Stop(); double timeMs = (double)( (double)watch.ElapsedTicks / TimeSpan.TicksPerMillisecond ); // Just a simple notification for the user. LogMessage( string.Format( CultureInfo.InvariantCulture.NumberFormat, "I just needed {0}ms to parse the configuration!", Math.Round( timeMs, 2 ) ), Color.Green ); // List the contents of the configuration in the TreeView. foreach ( var section in currentConfig ) { var sectionNode = new TreeNode( section.Name ); sectionNode.ForeColor = Color.Blue; TreeNode commentNode = null; if ( section.Comment != null ) { commentNode = new TreeNode( "[Comment]: " + section.Comment.ToString() ); commentNode.ForeColor = Color.Green; sectionNode.Nodes.Add( commentNode ); } foreach ( var setting in section ) { var settingNode = new TreeNode( setting.Name ); var valNode = new TreeNode( string.Format( "[Value]{0}: {1}", setting.IsArray ? " [Array]" : "", setting.Value ) ); valNode.ForeColor = Color.Goldenrod; settingNode.Nodes.Add( valNode ); if ( setting.Comment != null ) { commentNode = new TreeNode( "[Comment]: " + setting.Comment.ToString() ); commentNode.ForeColor = Color.Green; settingNode.Nodes.Add( commentNode ); } sectionNode.Nodes.Add( settingNode ); } trViewCfg.Nodes.Add( sectionNode ); } trViewCfg.ExpandAll(); //} //catch ( Exception ex ) //{ // // Some error occurred! Notify the user. // LogMessage( ex.Message, Color.Red ); //} }
private static void SaveConfiguration(Configuration config) { config["ConfigInit"]["LastEditTime"].Value = DateTime.Now.ToYYYYHHMM(); config.Save(ConfigFileName); }
private void InitializeCharacterConfiguration() { if (File.Exists(PathCharacterConfigFile)) CharacterConfiguration = SharpConfig.Configuration.LoadFromFile(PathCharacterConfigFile); else { CharacterConfiguration = new Configuration(); CharacterConfiguration.SaveToFile(PathCharacterConfigFile); } }
private void saveCGMButton_Click(object sender, EventArgs e) { var saveFile = String.Empty; using (var sfd = new SaveFileDialog()) { sfd.Title = "Select a location to store your CGM file"; sfd.Filter = "CGM file (*.cgm)|*.cgm"; sfd.InitialDirectory = Path.Combine(workDir, "cgm"); sfd.FileName = InlayName.GetValidName(true, false, true, Frets24) + "_" + GeneralExtensions.Acronym(Author) + ".cgm"; if (sfd.ShowDialog() != DialogResult.OK) return; saveFile = sfd.FileName; } // Create workDir folder var tmpWorkDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(saveFile)); if (Directory.Exists(tmpWorkDir)) DirectoryExtension.SafeDelete(tmpWorkDir); if (!Directory.Exists(tmpWorkDir)) Directory.CreateDirectory(tmpWorkDir); // Convert PNG to DDS var iconArgs = String.Format(" -file \"{0}\" -output \"{1}\" -prescale 512 512 -quality_highest -max -32 dxt5 -dxt5 -overwrite -alpha", IconFile, Path.Combine(tmpWorkDir, "icon.dds")); GeneralExtensions.RunExternalExecutable(APP_NVDXT, true, true, true, iconArgs); var inlayArgs = String.Format(" -file \"{0}\" -output \"{1}\" -prescale 1024 512 -quality_highest -max -32 dxt5 -dxt5 -overwrite -alpha", InlayFile, Path.Combine(tmpWorkDir, "inlay.dds")); GeneralExtensions.RunExternalExecutable(APP_NVDXT, true, true, true, inlayArgs); // Create setup.smb var iniFile = Path.Combine(tmpWorkDir, "setup.smb"); Configuration iniCFG = new Configuration(); // sharpconfig.dll automatically creates a new [General] section in the INI file iniCFG.Categories["General"].Settings.Add(new Setting("author", String.IsNullOrEmpty(Author) ? "CSC" : Author)); iniCFG.Categories["General"].Settings.Add(new Setting("inlayname", InlayName)); iniCFG.Categories["General"].Settings.Add(new Setting("24frets", Convert.ToString(Convert.ToInt32(Frets24)))); iniCFG.Categories["General"].Settings.Add(new Setting("colored", Convert.ToString(Convert.ToInt32(Colored)))); iniCFG.Categories["General"].Settings.Add(new Setting("cscvers", ToolkitVersion.version.Replace("-00000000", ""))); iniCFG.Categories["General"].Settings.Add(new Setting("modified", DateTime.Now.ToShortDateString())); iniCFG.Save(iniFile); // Pack file into a .cgm file (7zip file format) var zipArgs = String.Format(" a \"{0}\" \"{1}\\*\"", saveFile, tmpWorkDir); GeneralExtensions.RunExternalExecutable(APP_7Z, true, true, true, zipArgs); // Delete temp work dir if (Directory.Exists(tmpWorkDir)) DirectoryExtension.SafeDelete(tmpWorkDir); if (MessageBox.Show("Inlay template was saved." + Environment.NewLine + "Would you like to open the folder?", MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start(Path.GetDirectoryName(saveFile)); } if (Path.GetDirectoryName(saveFile) == Path.Combine(workDir, "cgm")) { inlayTemplateCombo.Items.Add(Path.GetFileNameWithoutExtension(saveFile)); inlayTemplateCombo.SelectedIndex = (inlayTemplateCombo.Items.Count - 1); } }
private void InitializeSkillConfiguration() { if (File.Exists(PathSkillConfigFile)) SkillConfiguration = SharpConfig.Configuration.LoadFromFile(PathSkillConfigFile); else { SkillConfiguration = new Configuration(); SkillConfigurationItem _skillItem = new SkillConfigurationItem(); _skillItem.ID = 0; //_skillItem.ActivationType = SpellActivationEnum.Action; _skillItem.SpellName = "Medkit"; _skillItem.CoolDown = 3; _skillItem.Damage = 0; _skillItem.ManaCost = 50; _skillItem.NeedTarget = false; _skillItem.Speed = 0; _skillItem.Prefab = ""; // TODO: Configurar prefab do medkit _skillItem.Class = ""; _skillItem.AttributeModifiers = new AttributeModifier[CONSTANTS.ATTRIBUTES.ATTRIBUTE_MODIFIERS_COUNT]; _skillItem.AttributeModifiers[0] = new AttributeModifier(); _skillItem.AttributeModifiers[0].ApplyTo = ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Current; _skillItem.AttributeModifiers[0].AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.HitPoint; _skillItem.AttributeModifiers[0].CalcType = ENUMERATORS.Attribute.AttributeModifierCalcTypeEnum.Percent; _skillItem.AttributeModifiers[0].ModifierType = ENUMERATORS.Attribute.AttributeModifierTypeEnum.OneTimeOnly; _skillItem.AttributeModifiers[0].OriginID = 0; _skillItem.AttributeModifiers[0].TimeInSeconds = 0; _skillItem.AttributeModifiers[0].Value = 20; string jsonTeste = JsonUtility.ToJson(_skillItem); _skillItem = new SkillConfigurationItem(); _skillItem.ID = 1; //_skillItem.ActivationType = SpellActivationEnum.Action; _skillItem.SpellName = "AmmoBox"; _skillItem.CoolDown = 3; _skillItem.Damage = 0; _skillItem.ManaCost = 50; _skillItem.NeedTarget = false; _skillItem.Speed = 0; _skillItem.Prefab = ""; // TODO: Configurar prefab do medkit _skillItem.Class = ""; _skillItem.AttributeModifiers = new AttributeModifier[CONSTANTS.ATTRIBUTES.ATTRIBUTE_MODIFIERS_COUNT]; _skillItem.AttributeModifiers[0] = new AttributeModifier(); _skillItem.AttributeModifiers[0].ApplyTo = ENUMERATORS.Attribute.AttributeModifierApplyToEnum.Current; _skillItem.AttributeModifiers[0].AttributeType = (int)ENUMERATORS.Attribute.CharacterAttributeTypeEnum.HitPoint; // TODO: AMMO Modifier _skillItem.AttributeModifiers[0].CalcType = ENUMERATORS.Attribute.AttributeModifierCalcTypeEnum.Percent; _skillItem.AttributeModifiers[0].ModifierType = ENUMERATORS.Attribute.AttributeModifierTypeEnum.OneTimeOnly; _skillItem.AttributeModifiers[0].OriginID = 0; _skillItem.AttributeModifiers[0].TimeInSeconds = 0; _skillItem.AttributeModifiers[0].Value = 20; jsonTeste = JsonUtility.ToJson(_skillItem); SkillConfiguration.SaveToFile(PathSkillConfigFile); } }
//------------------------------------------------------------------------- void _load() { SharpConfig.Configuration.ValidCommentChars = new char[] { '#', ';' }; var cfg_file = Resources.Load<TextAsset>("Config/ClientConfig"); Cfg = SharpConfig.Configuration.LoadFromString(cfg_file.text); // 游戏服务器配置信息 var baseserver = Cfg["BaseServer"]; BaseIp = baseserver["BaseIp"].StringValue; BasePort = baseserver["BasePort"].IntValue; ProjectName = baseserver["ProjectName"].StringValue; ChannelName = baseserver["ChannelName"].StringValue; ProtocolVersion = baseserver["ProtocolVersion"].StringValue; // 自动更新配置信息 var autopatcher = Cfg["AutoPatcher"]; RemoteVersionInfoUrl = autopatcher["RemoteVersionInfoUrl"].StringValue; SysNoticeInfoUrl = autopatcher["SysNoticeInfoUrl"].StringValue; // UCenter配置信息 var ucenter = Cfg["UCenter"]; UCenterDomain = ucenter["UCenterDomain"].StringValue; UCenterUseSsl = bool.Parse(ucenter["UCenterUseSsl"].StringValue); // 退出游戏提示语 var quitgametip = Cfg["QuitGameTip"]; ListTip = quitgametip["ListTip"].GetValueArray<string>(); EbLog.Note("ProjectName=" + ProjectName + " ProtocolVersion=" + ProtocolVersion + " ChannelName=" + ChannelName); EbLog.Note("BaseIpPort=" + BaseIp + ":" + BasePort); }
private void InitializeEnemyConfiguration() { if (File.Exists(PathEnemyConfigFile)) EnemyConfiguration = SharpConfig.Configuration.LoadFromFile(PathEnemyConfigFile); else { EnemyConfiguration = new Configuration(); EnemyConfiguration.SaveToFile(PathEnemyConfigFile); } }
private void InitializeWeaponConfiguration() { if (File.Exists(PathWeaponConfigFile)) WeaponConfiguration = SharpConfig.Configuration.LoadFromFile(PathWeaponConfigFile); else { WeaponConfiguration = new Configuration(); for (int i = 1; i <= 4; i++) { string _sectionName = string.Empty; WeaponConfigurationItem _item = new WeaponConfigurationItem(); _item.ID = i; switch (i) { case 1: _sectionName = "Prototype_Rifle"; _item.WeaponName = "Prototype Rifle"; _item.WeaponType = 0; // TODO: ALTERAR PARA ENUMERADOR!!! _item.Automatic = true; _item.ProjectileID = 2; _item.AmmoMax = 30; _item.Damage = 15; _item.FirePerSecond = 12.5f; _item.ReloadTimeInSeconds = 1.25f; _item.PrefabPath = "Resources/Prefab/Weapon/Prototype_Rifle"; break; case 2: _sectionName = "Prototype_Shotgun"; _item.WeaponName = "Prototype Shotgun"; _item.WeaponType = 1; // TODO: ALTERAR PARA ENUMERADOR!!! _item.Automatic = false; _item.ProjectileID = 3; _item.AmmoMax = 8; _item.Damage = 50; _item.FirePerSecond = 1.5f; _item.ReloadTimeInSeconds = 3f; _item.PrefabPath = "Resources/Prefab/Weapon/Prototype_Shotgun"; break; case 3: _sectionName = "Prototype_SniperRifle"; _item.WeaponName = "Prototype SniperRifle"; _item.WeaponType = 0; // TODO: ALTERAR PARA ENUMERADOR!!! _item.Automatic = false; _item.ProjectileID = 4; _item.AmmoMax = 12; _item.Damage = 40; _item.FirePerSecond = 3.5f; _item.ReloadTimeInSeconds = 2.16f; _item.PrefabPath = "Resources/Prefab/Weapon/Prototype_SniperRifle"; break; case 4: _sectionName = "Prototype_Pistol"; _item.WeaponName = "Prototype Pistol"; _item.WeaponType = 2; // TODO: ALTERAR PARA ENUMERADOR!!! _item.Automatic = false; _item.ProjectileID = 1; _item.AmmoMax = 16; _item.Damage = 15; _item.FirePerSecond = 12f; _item.ReloadTimeInSeconds = 0.7f; _item.PrefabPath = "Resources/Prefab/Weapon/Prototype_Pistol"; break; } Section _newSection = Section.FromObject(_sectionName, _item); WeaponConfiguration.Add(_newSection); } WeaponConfiguration.SaveToFile(PathWeaponConfigFile); } }
// Parses a configuration from a source string. // This is the core parsing function. private static Configuration Parse(string source) { // Reset temporary fields. mLineNumber = 0; Configuration config = new Configuration(); Section currentSection = null; var preComments = new List<Comment>(); using (var reader = new StringReader(source)) { string line = null; // Read until EOF. while ((line = reader.ReadLine()) != null) { mLineNumber++; // Remove all leading / trailing white-spaces. line = line.Trim(); // Empty line? If so, skip. if (string.IsNullOrEmpty(line)) continue; int commentIndex = 0; var comment = ParseComment(line, out commentIndex); if (!IgnorePreComments && commentIndex == 0) { // This is a comment line (pre-comment). // Add it to the list of pre-comments. preComments.Add(comment.Value); continue; } else if (!IgnoreInlineComments && commentIndex > 0) { // Strip away the comments of this line. line = line.Remove(commentIndex).Trim(); } // Sections start with a '['. if (line.StartsWith("[")) { currentSection = ParseSection(line); if (!IgnoreInlineComments) currentSection.Comment = comment; if (config.Contains(currentSection.Name)) { if (IgnoreDuplicateSections) { continue; } throw new ParserException(string.Format( "The section '{0}' was already declared in the configuration.", currentSection.Name), mLineNumber); } if (!IgnorePreComments && preComments.Count > 0) { currentSection.mPreComments = new List<Comment>(preComments); preComments.Clear(); } config.mSections.Add(currentSection); } else { Setting setting = ParseSetting(line); if (!IgnoreInlineComments) setting.Comment = comment; if (currentSection == null) { throw new ParserException(string.Format( "The setting '{0}' has to be in a section.", setting.Name), mLineNumber); } if (currentSection.Contains(setting.Name)) { if (IgnoreDuplicateSettings) { continue; } throw new ParserException(string.Format( "The setting '{0}' was already declared in the section.", setting.Name), mLineNumber); } if (!IgnorePreComments && preComments.Count > 0) { setting.mPreComments = new List<Comment>(preComments); preComments.Clear(); } currentSection.Add(setting); } } } return config; }
public ConfigManager() { config = Configuration.LoadFromFile("settings.txt"); }
private void InitializeQuestConfiguration() { if (File.Exists(PathQuestConfigFile)) QuestConfiguration = SharpConfig.Configuration.LoadFromFile(PathQuestConfigFile); else { QuestConfiguration = new Configuration(); QuestConfiguration.SaveToFile(PathQuestConfigFile); } }
/// <summary> /// according to the longitude latitude box and level range insert tile data to kq database file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void start_Click(object sender, RoutedEventArgs e) { if (start.Content.ToString() == "Start" || start.Content.ToString() == "Config") { if (start.Content.ToString() == "Config") { string configPath = ""; System.Windows.Forms.OpenFileDialog odlg = new OpenFileDialog(); odlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); odlg.Filter = "config files (*.ini)|*.ini"; if (odlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { configPath = odlg.FileName; } else { return; } tConfig = new TransformConfigion(); try { SharpConfig.Configuration configi = SharpConfig.Configuration.LoadFromFile(configPath); if (configi != null && configi.Contains("Record") && configi["Record"].SettingCount == 13) { tConfig = configi["Record"].CreateObject <TransformConfigion>(); if (tConfig != null) { SUM_MinX.Text = tConfig.minLon.ToString(); SUM_MinY.Text = tConfig.minLat.ToString(); SUM_MaxX.Text = tConfig.maxLon.ToString(); SUM_MaxY.Text = tConfig.maxLat.ToString(); StartLevel.Text = tConfig.sLevel.ToString(); EndLevel.Text = tConfig.eLevel.ToString(); foreach (ComboBoxItem s in this.CBOX.Items) { if (tConfig.OperateFunction == s.Content as string) { this.CBOX.SelectedItem = s; } } List <string> item = new List <string>(); item.Add(string.Format("Min Longitude :{0}", tConfig.minLon)); item.Add(string.Format("Max Longitude :{0}", tConfig.maxLon)); item.Add(string.Format("Min Latitude :{0}", tConfig.minLat)); item.Add(string.Format("Max Latitude :{0}", tConfig.maxLat)); item.Add(string.Format("Start Level :{0}", tConfig.sLevel)); item.Add(string.Format("End Level :{0}", tConfig.eLevel)); item.Add(string.Format("Function :{0}", tConfig.OperateFunction)); item.Add(string.Format("Start Time :{0}", tConfig.StartTime)); item.Add(string.Format("Last Time :{0}", tConfig.LastTime)); item.Add(string.Format("Tiles Amount :{0}", tConfig.TotalTilesNum)); item.Add(string.Format("Tiles Finished :{0}", tConfig.NowTileNum)); item.Add(string.Format("Tiles Succeed :{0}", tConfig.SuccessNum)); item.Add(string.Format("Save Path :{0}", tConfig.SavePath)); listBoxConfig.ItemsSource = item; DBTranslateFactory.configSucceed = tConfig.SuccessNum; DBTranslateFactory.configFinished = tConfig.NowTileNum; } } } catch (Exception ex) { Console.WriteLine(ex.Message); return; } } double minX = 0, minY = 0, maxX = 0, maxY = 0; int sLevel = 0, eLevel = 0, threatNum = 0; string func = this.CBOX.SelectionBoxItem as string; if (!(double.TryParse(SUM_MinX.Text, out minX)) || !(double.TryParse(SUM_MinY.Text, out minY)) || !(double.TryParse(SUM_MaxX.Text, out maxX)) || !(double.TryParse(SUM_MaxY.Text, out maxY))) { StatusLable.Content = "Try to enter anther valuable longitude and latitude range."; return; } if (!(int.TryParse(StartLevel.Text, out sLevel)) || !(int.TryParse(EndLevel.Text, out eLevel)) || !(int.TryParse(ThreatNum.Text, out threatNum))) { StatusLable.Content = "Try to enter anther valuable StartLevel and EndLevel , Threat Number."; return; } if (minX > maxX || minY > maxY || minX < -180 || minY < -90 || maxX > 180 || maxY > 90) { StatusLable.Content = "Try to enter anther valuable longitude and latitude range."; return; } if (sLevel < 0 || sLevel > 21 || eLevel < 0 || eLevel > 21 || sLevel > eLevel || threatNum < 1 || threatNum > 25) { StatusLable.Content = "Try to enter anther valuable StartLevel and EndLevel."; return; } imagebox.Visibility = Visibility.Hidden; bigiamgebox.Visibility = Visibility.Hidden; KQLable.Visibility = Visibility.Hidden; GoogleLbel.Visibility = Visibility.Hidden; ProgressInfo.Visibility = Visibility.Visible; //start.IsEnabled = false; tConfig = new TransformConfigion(); tConfig.sLevel = sLevel; tConfig.eLevel = eLevel; tConfig.minLat = minY; tConfig.minLon = minX; tConfig.maxLat = maxY; tConfig.maxLon = maxX; tConfig.TotalTilesNum = 0; tConfig.NowTileNum = 0; tConfig.SuccessNum = 0; tConfig.OperateFunction = func; tConfig.StartTime = DateTime.Now.ToString(); tConfig.LastTime = DateTime.Now.ToString(); tConfig.SavePath = DBTranslateFactory.kqpath; tileAmount = 0; tileFinished = 0; tileSucceed = 0; lastFinished = 0; StatusLable.Content = "Transformation is beginning."; bool result = false; if (func == "MongoDB To KQDB") { if (DBTranslateFactory.InsertOperationByMultiThreading(threatNum, sLevel, eLevel, maxX, maxY, minX, minY)) { result = true; StatusLable.Content = "Transformation has launched successfully."; } } if (func == "MongoDB To File") { if (DBTranslateFactory.CreatGoogleFileByMultiThreading(threatNum, sLevel, eLevel, maxX, maxY, minX, minY)) { result = true; StatusLable.Content = "Transformation has launched successfully."; } } if (func == "Get Partial MongoDB") { if (DBTranslateFactory.CreatPartialMongoDB(threatNum, sLevel, eLevel, maxX, maxY, minX, minY)) { result = true; StatusLable.Content = "Transformation has launched successfully."; } } //DBTranslateFactory.InsertKQImageByLonLatRange(6, 115, 25, 110, 20); if (!result) { return; } timeCount = new System.Windows.Forms.Timer(); timeCount.Tick += timeCount_Tick; timeCount.Enabled = true; timeCount.Interval = 1000; timeCount.Start(); start.Content = "Pause"; if (config != null && config.Contains("Record") && config["Record"].SettingCount == 13) { config["Record"]["NowTileNum"].SetValue <ulong>(tConfig.NowTileNum); config["Record"]["SuccessNum"].SetValue <ulong>(tConfig.SuccessNum); config["Record"]["minLon"].SetValue <double>(tConfig.minLon); config["Record"]["minLat"].SetValue <double>(tConfig.minLat); config["Record"]["maxLon"].SetValue <double>(tConfig.maxLon); config["Record"]["maxLat"].SetValue <double>(tConfig.maxLat); config["Record"]["sLevel"].SetValue <int>(tConfig.sLevel); config["Record"]["eLevel"].SetValue <int>(tConfig.eLevel); config["Record"]["OperateFunction"].SetValue <string>(tConfig.OperateFunction); config["Record"]["StartTime"].SetValue <string>(tConfig.StartTime); config["Record"]["LastTime"].SetValue <string>(tConfig.LastTime); config["Record"]["TotalTilesNum"].SetValue <ulong>(tConfig.TotalTilesNum); config["Record"]["SavePath"].SetValue <string>(tConfig.SavePath); config.Save("Config.ini"); } return; } else if (start.Content.ToString() == "Pause") { DBTranslateFactory.Pause = true; timeCount.Stop(); start.Content = "Continue"; return; } else if (start.Content.ToString() == "Continue") { DBTranslateFactory.Pause = false; timeCount.Start(); start.Content = "Pause"; return; } }
public static Setting Get(this SharpConfig.Configuration config, ConfigEntry entry) { return(config[entry.section][entry.setting]); }
private void Button_Click(object sender, RoutedEventArgs e) { string configPath = ""; System.Windows.Forms.OpenFileDialog odlg = new OpenFileDialog(); odlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory(); odlg.Filter = "config files (*.ini)|*.ini"; if (odlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { configPath = odlg.FileName; } else { return; } tConfig = new TransformConfigion(); try { SharpConfig.Configuration configi = SharpConfig.Configuration.LoadFromFile(configPath); if (configi != null && configi.Contains("Record") && configi["Record"].SettingCount == 13) { tConfig = configi["Record"].CreateObject <TransformConfigion>(); if (tConfig != null) { SUM_MinX.Text = tConfig.minLon.ToString(); SUM_MinY.Text = tConfig.minLat.ToString(); SUM_MaxX.Text = tConfig.maxLon.ToString(); SUM_MaxY.Text = tConfig.maxLat.ToString(); StartLevel.Text = tConfig.sLevel.ToString(); EndLevel.Text = tConfig.eLevel.ToString(); foreach (ComboBoxItem s in this.CBOX.Items) { if (tConfig.OperateFunction == s.Content as string) { this.CBOX.SelectedItem = s; } } List <string> item = new List <string>(); item.Add(string.Format("Min Longitude: {0}", tConfig.minLon)); item.Add(string.Format("Max Longitude: {0}", tConfig.maxLon)); item.Add(string.Format("Min Latitude: {0}", tConfig.minLat)); item.Add(string.Format("Max Latitude: {0}", tConfig.maxLat)); item.Add(string.Format("Start Level: {0}", tConfig.sLevel)); item.Add(string.Format("End Level: {0}", tConfig.eLevel)); item.Add(string.Format("Function: {0}", tConfig.OperateFunction)); item.Add(string.Format("Start Time: {0}", tConfig.StartTime)); item.Add(string.Format("Last Time: {0}", tConfig.LastTime)); item.Add(string.Format("Tiles Amount: {0}", tConfig.TotalTilesNum)); item.Add(string.Format("Tiles Finished: {0}", tConfig.NowTileNum)); item.Add(string.Format("Tiles Succeed: {0}", tConfig.SuccessNum)); item.Add(string.Format("Save Path: {0}", tConfig.SavePath)); listBoxConfig.ItemsSource = item; DBTranslateFactory.configSucceed = tConfig.SuccessNum; DBTranslateFactory.configFinished = tConfig.NowTileNum; } } } catch (Exception ex) { Console.WriteLine(ex.Message); return; } }
private void SaveImages(object sender, DoWorkEventArgs e) { // method using Background Worker to report progress var savePath = e.Argument as string; const int numSteps = 7; // max number of times progress change is reported var step = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0); var progress = 0; // Create temp folder for zipping files var tmpZipDir = Path.Combine(tmpWorkDir, "cis_zip"); if (Directory.Exists(tmpZipDir)) DirectoryExtension.SafeDelete(tmpZipDir, true); Directory.CreateDirectory(tmpZipDir); // convert user png images to dds images for (int i = 0; i < imageArray.GetUpperBound(0); i++) { progress += step; bwSaveImages.ReportProgress(progress, "Converting user PNG images ... " + i.ToString()); if (imageArray[i, 3] != null) // user has specified a replacement image { // CRITICAL PATH AND ARGS var srcPath = imageArray[i, 3]; var destPath = Path.Combine(tmpZipDir, Path.GetFileName(imageArray[i, 2])); ExternalApps.Png2Dds(srcPath, destPath, ImageHandler.Size2IntX(imageArray[i, 1]), ImageHandler.Size2IntY(imageArray[i, 1])); } } progress += step; bwSaveImages.ReportProgress(progress, "Saving Intro Screens Template file ... "); // Write ini file setup.smb var iniFile = Path.Combine(tmpZipDir, "setup.smb"); Configuration iniCFG = new Configuration(); iniCFG["General"].Add(new Setting("author", String.IsNullOrEmpty(txtAuthor.Text) ? "CSC" : txtAuthor.Text)); iniCFG["General"].Add(new Setting("seqname", String.IsNullOrEmpty(txtSeqName.Text) ? "SystemSaved" : txtSeqName.Text)); iniCFG["General"].Add(new Setting("cscvers", ToolkitVersion.version)); iniCFG["General"].Add(new Setting("modified", DateTime.Now.ToShortDateString())); iniCFG.Save(iniFile); // Zip intro sequence *.cis file ExternalApps.InjectZip(tmpZipDir, savePath, false, true); }
private void saveCGMButton_Click(object sender, EventArgs e) { var saveFile = String.Empty; using (var sfd = new SaveFileDialog()) { sfd.Title = "Select a location to store your CGM file"; sfd.Filter = "CGM file (*.cgm)|*.cgm"; sfd.InitialDirectory = Path.Combine(workDir, "cgm"); sfd.FileName = (InlayName.GetValidInlayName(Frets24)) + "_" + StringExtensions.GetValidAcronym(Author) + ".cgm".GetValidFileName(); if (sfd.ShowDialog() != DialogResult.OK) return; saveFile = sfd.FileName; } // Create workDir folder var tmpWorkDir = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(saveFile)); if (Directory.Exists(tmpWorkDir)) DirectoryExtension.SafeDelete(tmpWorkDir); if (!Directory.Exists(tmpWorkDir)) Directory.CreateDirectory(tmpWorkDir); // Convert PNG to DDS ExternalApps.Png2Dds(IconFile, Path.Combine(tmpWorkDir, "icon.dds"), 512, 512); ExternalApps.Png2Dds(InlayFile, Path.Combine(tmpWorkDir, "inlay.dds"), 1024, 512); // Create setup.smb var iniFile = Path.Combine(tmpWorkDir, "setup.smb"); Configuration iniCFG = new Configuration(); // sharpconfig.dll automatically creates a new [General] section in the INI file iniCFG["General"].Add(new Setting("author", String.IsNullOrEmpty(Author) ? "CSC" : Author)); iniCFG["General"].Add(new Setting("inlayname", String.IsNullOrEmpty(InlayName) ? "null" : InlayName)); iniCFG["General"].Add(new Setting("24frets", Convert.ToString(Convert.ToInt32(Frets24)))); iniCFG["General"].Add(new Setting("colored", Convert.ToString(Convert.ToInt32(Colored)))); iniCFG["General"].Add(new Setting("cscvers", ToolkitVersion.version.Replace("-00000000", ""))); iniCFG["General"].Add(new Setting("modified", DateTime.Now.ToShortDateString())); iniCFG.Save(iniFile); // Pack file into a .cgm file (7zip file format) ExternalApps.InjectZip(tmpWorkDir, saveFile, false, true); // Delete temp work dir if (Directory.Exists(tmpWorkDir)) DirectoryExtension.SafeDelete(tmpWorkDir); if (MessageBox.Show("Inlay template was saved." + Environment.NewLine + "Would you like to open the folder?", MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Process.Start(Path.GetDirectoryName(saveFile)); } if (Path.GetDirectoryName(saveFile) == Path.Combine(workDir, "cgm")) { inlayTemplateCombo.Items.Add(Path.GetFileNameWithoutExtension(saveFile)); inlayTemplateCombo.SelectedIndex = (inlayTemplateCombo.Items.Count - 1); } }
public static void Main (string[] args) { Console.WriteLine ("ArduConsole"); //sPort.Close; try { cfg = Configuration.LoadFromFile(path); } catch { Console.WriteLine ("Config missing"); } cfg = Configuration.LoadFromFile(path); string serialPort = cfg ["General"] ["serialPort"].StringValue; int baudRate = cfg["General"] ["baudRate"].IntValue; #region defs string input1 = ""; string input2 = ""; string input3 = ""; string input4 = ""; string input5 = ""; string input6 = ""; string input7 = ""; string input8 = ""; string input9 = ""; string input10 = ""; string input11 = ""; string input12 = ""; string input13 = ""; string input14 = ""; string input15 = ""; string output1 = ""; string output2 = ""; string output3 = ""; string output4 = ""; string output5 = ""; string output6 = ""; string output7 = ""; string output8 = ""; string output9 = ""; string output10 = ""; string output11 = ""; string output12 = ""; string output13 = ""; string output14 = ""; string output15 = ""; string console1 = ""; string console2 = ""; string console3 = ""; string console4 = ""; string console5 = ""; string console6 = ""; string console7 = ""; string console8 = ""; string console9 = ""; string console10 = ""; string console11 = ""; string console12 = ""; string console13 = ""; string console14 = ""; string console15 = ""; #endregion #region inputs try { input1 = cfg["Inputs"]["input1"].StringValue; input2 = cfg["Inputs"]["input2"].StringValue; input3 = cfg["Inputs"]["input3"].StringValue; input4 = cfg["Inputs"]["input4"].StringValue; input5 = cfg["Inputs"]["input5"].StringValue; input6 = cfg["Inputs"]["input6"].StringValue; input7 = cfg["Inputs"]["input7"].StringValue; input8 = cfg["Inputs"]["input8"].StringValue; input9 = cfg["Inputs"]["input9"].StringValue; input10 = cfg["Inputs"]["input10"].StringValue; input11 = cfg["Inputs"]["input11"].StringValue; input12 = cfg["Inputs"]["input12"].StringValue; input13 = cfg["Inputs"]["input13"].StringValue; input14 = cfg["Inputs"]["input14"].StringValue; input15 = cfg["Inputs"]["input15"].StringValue; } catch { Console.WriteLine("Some config values are missing. Please check \"settings.cfg\" and make sure it has the correct data."); } #endregion #region outputs try { output1 = cfg["Outputs"]["output1"].StringValue; output2 = cfg["Outputs"]["output2"].StringValue; output3 = cfg["Outputs"]["output3"].StringValue; output4 = cfg["Outputs"]["output4"].StringValue; output5 = cfg["Outputs"]["output5"].StringValue; output6 = cfg["Outputs"]["output6"].StringValue; output7 = cfg["Outputs"]["output7"].StringValue; output8 = cfg["Outputs"]["output8"].StringValue; output9 = cfg["Outputs"]["output9"].StringValue; output10 = cfg["Outputs"]["output10"].StringValue; output11 = cfg["Outputs"]["output11"].StringValue; output12 = cfg["Outputs"]["output12"].StringValue; output13 = cfg["Outputs"]["output13"].StringValue; output14 = cfg["Outputs"]["output14"].StringValue; output15 = cfg["Outputs"]["output15"].StringValue; } catch { Console.WriteLine("Some config values are missing. Please check \"settings.cfg\" and make sure it has the correct data."); } #endregion #region consoleOutputs try { console1 = cfg["ConsoleOutputs"]["console1"].StringValue; console2 = cfg["ConsoleOutputs"]["console2"].StringValue; console3 = cfg["ConsoleOutputs"]["console3"].StringValue; console4 = cfg["ConsoleOutputs"]["console4"].StringValue; console5 = cfg["ConsoleOutputs"]["console5"].StringValue; console6 = cfg["ConsoleOutputs"]["console6"].StringValue; console7 = cfg["ConsoleOutputs"]["console7"].StringValue; console8 = cfg["ConsoleOutputs"]["console8"].StringValue; console9 = cfg["ConsoleOutputs"]["console9"].StringValue; console10 = cfg["ConsoleOutputs"]["console10"].StringValue; console11 = cfg["ConsoleOutputs"]["console11"].StringValue; console12 = cfg["ConsoleOutputs"]["console12"].StringValue; console13 = cfg["ConsoleOutputs"]["console13"].StringValue; console14 = cfg["ConsoleOutputs"]["console14"].StringValue; console15 = cfg["ConsoleOutputs"]["console15"].StringValue; } catch { Console.WriteLine("Some config values are missing. Please check \"settings.cfg\" and make sure it has the correct data."); } #endregion port (serialPort, baudRate); //sPort.Open (); Console.WriteLine (cfg["General"]["serialPort"].StringValue); while (loop) { input = Console.ReadLine (); if (input == input1) { sPort.WriteLine (output1); Console.WriteLine (console1); } if (input == input2) { sPort.WriteLine (output2); Console.WriteLine (console2); } if (input == input3) { sPort.WriteLine (output3); Console.WriteLine (console3); } if (input == input4) { sPort.WriteLine (output4); Console.WriteLine (console4); } if (input == input5) { sPort.WriteLine (output5); Console.WriteLine (console5); } if (input == input6) { sPort.WriteLine (output6); Console.WriteLine (console6); } if (input == input7) { sPort.WriteLine (output7); Console.WriteLine (console7); } if (input == input8) { sPort.WriteLine (output8); Console.WriteLine (console8); } if (input == input9) { sPort.WriteLine (output9); Console.WriteLine (console9); } if (input == input10) { sPort.WriteLine (output10); Console.WriteLine (console10); } if (input == input11) { sPort.WriteLine (output11); Console.WriteLine (console11); } if (input == input12) { sPort.WriteLine (output12); Console.WriteLine (console12); } if (input == input13) { sPort.WriteLine (output13); Console.WriteLine (console13); } if (input == input14) { sPort.WriteLine (output14); Console.WriteLine (console14); } if (input == input15) { sPort.WriteLine (output15); Console.WriteLine (console15); } if (input == "quit") { Console.WriteLine ("Quitting..."); sPort.Close (); Environment.Exit (1); } } }