public GenerateSql(DbSetting dbSetting) { if (dbSetting == null) throw new ArgumentNullException("dbSetting"); this._dbSetting = dbSetting; this._db = new DbAccesser(dbSetting); datatype = new INIFile(); }
static void Main() { INIFile _ini = new INIFile(Application.StartupPath + @"\Settings.ini"); _ini.Write("Settings","Value1","YepYep"); // Writing the ini file. string YepYep = _ini.Read("Settings","Value1") // Reading the ini file as String, you can override func given in the INIFýle Class }
public virtual void Save(string file) { Type iniPropertyNameAttribute = typeof(INIPropertyNameAttribute); INIFile ini = new INIFile(); foreach(PropertyInfo sectprop in this.GetType().GetProperties()) { object[] sectattr = sectprop.GetCustomAttributes(iniPropertyNameAttribute, false); if(sectattr.Length != 0) { string sectname = ((INIPropertyNameAttribute)((sectattr)[0])).Name; INISection section = new INISection(sectname); object sectobj = sectprop.GetValue(this, null); if(section != null) { foreach(PropertyInfo prop in sectprop.PropertyType.GetProperties()) { object[] attr = prop.GetCustomAttributes(iniPropertyNameAttribute, false); if(attr.Length != 0) { string name = ((INIPropertyNameAttribute)((attr)[0])).Name; section.Add(new INIProperty(name, prop.GetValue(sectobj, null))); } } } ini.Add(section); } } ini.Save(file); }
private void PatchForm_Load(object sender, EventArgs e) { tvPatch.Nodes.Clear(); List<String> files = new List<String>(Directory.GetFiles("mge3", "*.mcp", SearchOption.AllDirectories)); files.Add(patchSettings); // last of all foreach (String file in files) { INIFile mcpFile = new INIFile(file, new INIFile.INIVariableDef[] { INIFile.iniDefEmpty }, Encoding.Default); String[] sections = mcpFile.getSections(); foreach (String Section in sections) { Patch patch = new Patch(mcpFile, Section); String[] parents = patch.Parent.Split(new String[] { Patch.SepInternal.ToString() }, StringSplitOptions.RemoveEmptyEntries); TreeNodeCollection nodes = tvPatch.Nodes; TreeNode[] exist; for (int i = 0; i < parents.Length; i++) { exist = nodes.Find(parents[i].ToLower(), false); if (exist.Length > 0) nodes = exist[0].Nodes; else { TreeNode node = nodes.Add(parents[i].ToLower(), parents[i]); node.Checked = true; nodes = node.Nodes; } } exist = nodes.Find(Section.ToLower(), false); if (exist.Length > 0) { Patch existing = (Patch)exist[0].Tag; bool update = existing == null; if (!update) { if (patch.Version <= existing.Version) continue; if (patch.Original == null && patch.Patched == null && patch.Attach == null) { exist[0].Checked = existing.Checked = patch.Checked; existing.Removed = patch.Removed || existing.Removed; existing.Expanded = patch.Expanded; continue; } update = true; } if (update) { exist[0].Checked = patch.Checked; exist[0].Tag = patch; continue; } } else { TreeNode node = nodes.Add(Section.ToLower(), Section); node.Tag = patch; node.Checked = patch.Checked; node.ToolTipText = ""; foreach(String language in Languages) if (node.ToolTipText == "") foreach(Unit description in patch.Description) if (language == description.Name) { node.ToolTipText = description.Hex.Replace("\t", "\n"); break; } } } } RemoveEmptyNodes(tvPatch.Nodes); UpdateColour(tvPatch.Nodes, true); ExpandNodes(tvPatch.Nodes); tvPatch.Sort(); loaded = true; }
private void Init( ) { string path = AppDomain.CurrentDomain.BaseDirectory + @"\datatype.ini"; if (!File.Exists(path)) { Utils.CreateFiles(path, Utils.ini); } datatype = new INIFile(path); }
/// <summary> /// Creates the INI config file with default values /// </summary> public static void CreateIniFile() { if (File.Exists("config.ini") == true) { return; } ini = new INIFile("./config.ini"); File.Create("config.ini").Close(); ini.Write("Display", "CacheDataDisplayMode", "Pretty"); }
/// <summary> /// Create the FormPositionSaver /// </summary> /// <param name="FormObj">Form to deal with</param> /// <param name="configfile">INIFile to load and save</param> /// <param name="alreadyloaded">whether the Load event has fired. If true, will try to set the form position immediately. otherwise, it hooks the Load event and waits.</param> public FormPositionSaver(Form FormObj, INIFile configfile, bool alreadyloaded) { Configuration = configfile; FormObject = FormObj; FormObject.FormClosed += new FormClosedEventHandler(FormObject_FormClosed); if (!alreadyloaded) FormObject.Load += new EventHandler(FormObject_Load); else { FormObject_Load(FormObject, new EventArgs()); } }
/// <summary> /// Loads a database entry from an .ini file. /// </summary> /// <param name="iniFilePath">Path to the .ini file where entry inforation is stored</param> /// <returns>True is successful, false if an error happened</returns> protected override bool OnLoad(string iniFilePath) { using (INIFile ini = new INIFile(iniFilePath)) { // Unit info DCSIDs = (from string u in ini.GetValueArray <string>("Unit", "DCSID") select u.Trim()).ToArray(); if (DCSIDs.Length < 1) { DebugLog.Instance.WriteLine($"Unit {ID} contains no DCS unit ID, unit was ignored.", DebugLogMessageErrorLevel.Warning); return(false); } Families = ini.GetValueArray <UnitFamily>("Unit", "Families"); if (Families.Length == 0) { DebugLog.Instance.WriteLine($"Unit {ID} has no family, unit was ignored.", DebugLogMessageErrorLevel.Warning); return(false); } // Make sure all unit families belong to same category (unit cannot be a helicopter and a ground vehicle at the same time, for instance) Families = (from UnitFamily f in Families where Toolbox.GetUnitCategoryFromUnitFamily(f) == Category select f).Distinct().ToArray(); ExtraLua = ini.GetValue <string>("Unit", "ExtraLua"); Flags = ini.GetValueArrayAsEnumFlags <DBEntryUnitFlags>("Unit", "Flags"); OffsetCoordinates = (from string s in ini.GetValueArray <string>("Unit", "Offset.Coordinates", ';') select new Coordinates(s)).ToArray(); OffsetHeading = ini.GetValueArray <double>("Unit", "Offset.Heading"); RequiredMod = ini.GetValue <string>("Unit", "RequiredMod"); AircraftData = new DBEntryUnitAircraftData(); // Load the list of operators Operators = new Dictionary <string, Decade[]>(StringComparer.InvariantCultureIgnoreCase); foreach (string k in ini.GetKeysInSection("Operators")) { if (Operators.ContainsKey(k)) { continue; } Operators.Add(k, ini.GetValueArrayAsMinMaxEnum <Decade>("Operators", k)); } if (IsAircraft) // Load aircraft-specific data, if required { DCSIDs = new string[] { DCSIDs[0] }; // Aircraft can not have multiple unit types in their group AircraftData = new DBEntryUnitAircraftData(ini); } } return(true); }
public void Construct_WhenHaveCacheFolderSetting_ShouldSetCacheFolderFromThatSetting() { //---------------Set up test pack------------------- var ini = new INIFile(); var expected = GetRandomWindowsPath(); ini.SetValue(Sections.SETTINGS, Keys.CACHE_FOLDER, expected); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var sut = Create(ini); var result = sut.CacheFolder; //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
public static void InitialFile() { if (!DirFile.IsExistFile("config.ini")) { var inifile = new INIFile(); inifile.AddSection("LocalDataBase"); inifile.AddSection("RemoteDataBase"); inifile.AddSection("OutputPicture"); inifile.AddSection("Logging"); inifile.AddSection("LocalData"); inifile.SetValue("LocalDataBase", "HostDir", "DataBase"); inifile.SetValue("RemoteDataBase", "HostName", "127.0.0.1"); inifile.SetValue("RemoteDataBase", "Port", "1433"); inifile.SetValue("RemoteDataBase", "User", "admin"); inifile.SetValue("RemoteDataBase", "Password", "123456"); inifile.SetValue("RemoteDataBase", "Table", "master"); inifile.SetValue("OutputPicture", "Dir", @"C:\Output"); inifile.SetValue("Logging", "Dir", "Logging"); inifile.SetValue("LocalData", "Dir", "LocalData"); inifile.Persist("config.ini"); } if (!DirFile.IsExistDirectory("./LocalData")) { DirFile.CreateDirectory("./LocalData"); } if (!DirFile.IsExistDirectory("./Logging")) { DirFile.CreateDirectory("./Logging"); } if (!DirFile.IsExistDirectory("./LocalData/DataBase")) { DirFile.CreateDirectory("./LocalData/DataBase"); } if (!DirFile.IsExistDirectory("./LocalData/Picture")) { DirFile.CreateDirectory("./LocalData/Picture"); } }
internal void SaveToFile(INIFile ini, string section, string key) { ini.SetValueArray(section, $"{key}.Features", Features.ToArray()); ini.SetValueArray(section, $"{key}.Options", Options.ToArray()); ini.SetValue(section, $"{key}.Preset", Preset); ini.SetValue(section, $"{key}.Task", Task); ini.SetValue(section, $"{key}.Target", Target); ini.SetValue(section, $"{key}.TargetBehavior", TargetBehavior); ini.SetValue(section, $"{key}.TargetCount", TargetCount); var i = 0; foreach (var subTask in SubTasks) { subTask.SaveToFile(ini, section, $"{key}.SubTask{i}"); i++; } }
public void Construct_WhenHaveHostFileSetting_ShouldUseThatSetting() { //---------------Set up test pack------------------- var expected = GetRandomString(); var iniFile = new INIFile(); iniFile.SetValue(Sections.SETTINGS, Keys.HOSTS_FILE, expected); var sut = Create(iniFile); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var result = sut.HostsFile; //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
public void Construct_WhenHaveNoCacheFolderSetting_ShouldUseAppFolderPlusCache() { //---------------Set up test pack------------------- var ini = new INIFile(); var appPath = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath; var appFolder = Path.GetDirectoryName(appPath); var expected = Path.Combine(appFolder, "cache"); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var sut = Create(ini); var result = sut.CacheFolder; //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
public static List <Table> PlayedTableGetter(int i_runId) { INIFile tbIni = new INIFile(iniPath); List <Table> retTable = new List <Table>(); for (int i = 1; i <= Convert.ToInt32(tbIni.GetValue(Const.fileSec, Table.fsX_tableCnt)); i++) { Table table = new Table(); table.Getter(i, i_runId); if (table.teamsOnTable[0] != 0) { retTable.Add(table); } } return(retTable); }
static void ReadINI() { INIFile iniFile = new INIFile("config.ini"); ProgramSettings.settings.Add(new Settings { AssaServer = iniFile.GetValue("ASSACONNECT", "DataSource", (string)null), AssaDataBase = iniFile.GetValue("ASSACONNECT", "InitialCatalog", (string)null), AssaLogin = iniFile.GetValue("ASSACONNECT", "UserID", (string)null), AssaPassword = iniFile.GetValue("ASSACONNECT", "Password", (string)null), PtsServer = iniFile.GetValue("PTSCONNECT", "DataSource", (string)null), PtsDataBase = iniFile.GetValue("PTSCONNECT", "InitialCatalog", (string)null), PtsLogin = iniFile.GetValue("PTSCONNECT", "UserID", (string)null), PtsPassword = iniFile.GetValue("PTSCONNECT", "Password", (string)null), IsDeveloper = iniFile.GetValue("DUBUG", "ISDEVELOPER", (int)0) }); }
protected override bool OnLoad(string iniFilePath) { var ini = new INIFile(iniFilePath); string defaultText = ini.GetValue <string>("BriefingDescription", "Description"); DescriptionText = new string[Toolbox.EnumCount <UnitFamily>()]; for (int i = 0; i < Toolbox.EnumCount <UnitFamily>(); i++) { DescriptionText[i] = ini.GetValue <string>("BriefingDescription", $"Description.{(UnitFamily)i}"); if (string.IsNullOrEmpty(DescriptionText[i])) { DescriptionText[i] = defaultText; } } return(true); }
public void Construct_WhenNoWhitelistsSection_ShouldhaveEmptyWhiteLists() { //---------------Set up test pack------------------- var iniFile = new INIFile(); var sut = Create(iniFile); //---------------Assert Precondition---------------- Assert.IsFalse(iniFile.HasSection(Sections.BLACKLIST)); //---------------Execute Test ---------------------- var result = sut.Whitelist; //---------------Test Result ----------------------- Assert.IsNotNull(result); CollectionAssert.IsEmpty(result); }
public void Construct_ShouldLoadRefreshIntervalInMinutes_FromReader() { //---------------Set up test pack------------------- var iniFile = new INIFile(); var expected = GetRandomInt(); iniFile.SetValue(Constants.Sections.SETTINGS, Constants.Keys.REFRESH_INTERVAL_IN_MINUTES, expected.ToString()); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var sut = Create(iniFile); var result = sut.RefreshIntervalInMinutes; //---------------Test Result ----------------------- Assert.AreEqual(expected, result); }
/// <summary> /// Loads previous signed up teams from .ini-File /// and fills cmbx_signedUpTeams /// </summary> private void FillSignedUpTeams() { cmbx_signedUpTeams.Items.Clear(); List <string> allsuTeams = new List <string>(); INIFile sutIni = new INIFile(SignedUpTeam.iniPath); for (int i = 1; i <= Convert.ToInt32(sutIni.GetValue(Const.fileSec, SignedUpTeam.fsX_suTeamCnt)); i++) { allsuTeams.Add(sutIni.GetValue(SignedUpTeam.suTeamSec + Convert.ToString(i), SignedUpTeam.sutS_suTName)); } foreach (string suTeamName in allsuTeams) { cmbx_signedUpTeams.Items.Add(suTeamName); } }
/// <summary> /// Create the FormPositionSaver /// </summary> /// <param name="FormObj">Form to deal with</param> /// <param name="configfile">INIFile to load and save</param> /// <param name="alreadyloaded">whether the Load event has fired. If true, will try to set the form position immediately. otherwise, it hooks the Load event and waits.</param> public FormPositionSaver(Form FormObj, INIFile configfile, bool alreadyloaded) { Configuration = configfile; FormObject = FormObj; FormObject.FormClosed += new FormClosedEventHandler(FormObject_FormClosed); if (!alreadyloaded) { FormObject.Load += new EventHandler(FormObject_Load); } else { FormObject_Load(FormObject, new EventArgs()); } }
/// <summary> /// Loads a database entry from an .ini file. /// </summary> /// <param name="id">Unique ID of the database entry</param> /// <param name="iniFilePath">Path to the .ini file where entry inforation is stored</param> /// <returns>True is successful, false if an error happened</returns> public bool Load(string id, string iniFilePath) { ID = id; using (INIFile ini = new INIFile(iniFilePath)) { UIDisplayName = new LocalizedString(ini, "UI", "DisplayName"); if (string.IsNullOrEmpty(UIDisplayName.Get())) { UIDisplayName = new LocalizedString(ID); } UIDisplayName = new LocalizedString(ini, "UI", "DisplayName"); UICategory = new LocalizedString(ini, "UI", "Category"); UIDescription = new LocalizedString(ini, "UI", "Description"); } return(OnLoad(iniFilePath)); }
public virtual void LoadSection(string sectionNamePrefix, INIFile file) { if (string.IsNullOrWhiteSpace(sectionNamePrefix)) { return; } foreach (var sectionName in file.ReadSections()) { if (sectionName.IndexOf(sectionNamePrefix) == 0) { var fileWriteSection = new T(); fileWriteSection.LoadSection(sectionName, file); Add(fileWriteSection); } } }
public void WhenHaveTwoSavedWindowsForOneLayout_ShouldProduceOneLayout() { // Arrange var config = new INIFile(); var layout = GetRandomString(10); var processName1 = GetRandomString(10); var processName2 = GetAnother(processName1); config.AddSection($"app-layout: {layout} : {processName1}"); config.AddSection($"app-layout: {layout} : {processName2}"); // Pre-assert // Act var result = config.EnumerateLayouts(); // Assert Expect(result).To.Equal(new[] { layout }); }
/// <summary> /// Loads a campaign template from an .ini file. /// </summary> /// <param name="filePath">Path to the .ini file</param> /// <returns></returns> public bool LoadFromFile(string filePath) { Clear(); if (!File.Exists(filePath)) { return(false); } using (INIFile ini = new INIFile(filePath)) { ContextCoalitionsBlue = ini.GetValue("Context", "Coalitions.Blue", ContextCoalitionsBlue); ContextCoalitionPlayer = ini.GetValue("Context", "Coalition.Player", ContextCoalitionPlayer); ContextCoalitionsRed = ini.GetValue("Context", "Coalitions.Red", ContextCoalitionsRed); ContextDecade = ini.GetValue("Context", "Decade", ContextDecade); ContextTheaterID = ini.GetValue("Context", "TheaterID", ContextTheaterID); EnvironmentBadWeatherChance = ini.GetValue("Environment", "BadWeatherChance", EnvironmentBadWeatherChance); EnvironmentNightMissionChance = ini.GetValue("Environment", "NightMissionChance", EnvironmentNightMissionChance); MissionsCount = ini.GetValue("Missions", "Count", MissionsCount); MissionsDifficultyVariation = ini.GetValue("Missions", "DifficultyVariation", MissionsDifficultyVariation); MissionsObjectiveCount = ini.GetValue("Missions", "ObjectiveCount", MissionsObjectiveCount); MissionsObjectiveDistance = ini.GetValue("Missions", "ObjectiveDistance", MissionsObjectiveDistance); Objectives = ini.GetValueArray <string>("Objectives", "Objectives"); OptionsCivilianTraffic = ini.GetValue("Options", "CivilianTraffic", OptionsCivilianTraffic); OptionsTheaterCountriesCoalitions = ini.GetValue("Options", "TheaterRegionsCoalitions", OptionsTheaterCountriesCoalitions); PlayerAircraft = ini.GetValue("Player", "Aircraft", PlayerAircraft); PlayerStartingAirbase = ini.GetValue("Player", "StartingAirbase", PlayerStartingAirbase); PlayerCarrier = ini.GetValue("Player", "StartingCarrier", PlayerCarrier); PlayerStartLocation = ini.GetValue("Player", "StartLocation", PlayerStartLocation); Realism = ini.GetValueArray <RealismOption>("Realism", "Realism"); SituationEnemyAirDefense = ini.GetValue("Situation", "Enemy.AirDefense", SituationEnemyAirDefense); SituationEnemyAirForce = ini.GetValue("Situation", "Enemy.AirForce", SituationEnemyAirForce); SituationFriendlyAirDefense = ini.GetValue("Situation", "Friendly.AirDefense", SituationFriendlyAirDefense); SituationFriendlyAirForce = ini.GetValue("Situation", "Friendly.AirForce", SituationFriendlyAirForce); UnitMods = ini.GetValueArray <string>("UnitMods", "UnitMods"); } return(true); }
public static void Delete(string i_logContent, bool logSwitch = false, string newIniPath = "") { INIFile logIni; if (logSwitch) { logIni = new INIFile(newIniPath); } else { logIni = new INIFile(iniPath); } string logNumber = Convert.ToString(Convert.ToInt32(logIni.GetValue(Const.fileSec, fsX_logCnt)) + 1); logIni.SetValue(logSec, AddBlankToNumber(logNumber) + Convert.ToString(DateTime.Now), delete + i_logContent); logIni.SetValue(Const.fileSec, fsX_logCnt, logNumber); }
/// <summary> /// 设置COM串口 /// </summary> void OnOpenSerialPort() { if (File.Exists(IniFilePath)) { INIFile inifile = new INIFile(IniFilePath); string portName = inifile.IniReadValue("SerialPort", "PortName"); int baudRate = 9600; Int32.TryParse(inifile.IniReadValue("SerialPort", "BaudRate"), out baudRate); var serialHepler = new SerialPortHelper(); serialHepler.OnRecieveSerialMsg += serialHepler_OnRecieveSerialMsg; serialHepler.OpenSerialPort(portName, baudRate); } else { XtraMessageBox.Show("串口配置文件不存在,请检查"); } }
public INIMRUList(INIFile INISettings, String name) { Name = name; Settings = INISettings; MRUList = new Queue <string>(); oursection = INISettings["recent." + name]; foreach (var loopitem in oursection.getValues()) { MRUList.Enqueue(loopitem.Value); } //remove excess items. while (MRUList.Count > maxsize) { MRUList.Dequeue(); } }
internal bool Load(Database database, string id, string iniFilePath) { Database = database; ID = id; var ini = new INIFile(iniFilePath); UIDisplayName = ini.GetValue <string>("GUI", "DisplayName"); if (string.IsNullOrEmpty(UIDisplayName)) { UIDisplayName = ID; } UICategory = ini.GetValue <string>("GUI", "Category"); UIDescription = ini.GetValue <string>("GUI", "Description"); return(OnLoad(iniFilePath)); }
public override TLauncherEntry ReadLinkFile(string file) { var ini = new INIFile(file); var entry = new TLauncherEntry(); entry.Name = ini.GetValue("Desktop Entry", "Name", ""); var cmd = ini.GetValue("Desktop Entry", "Exec", ""); entry.CommandPath = Path.GetDirectoryName(cmd); entry.CommandFile = Path.GetFileName(cmd); entry.CommandArgs = ""; //TODO entry.Categories = ini.GetValue("Desktop Entry", "Categories", ""); entry.IconName = ini.GetValue("Desktop Entry", "Icon", ""); entry.Description = ini.GetValue("Desktop Entry", "Comment", ""); entry.UpdateMainCategory(); return(entry); }
/// <summary> /// Loads a database entry from an .ini file. /// </summary> /// <param name="iniFilePath">Path to the .ini file where entry inforation is stored</param> /// <returns>True is successful, false if an error happened</returns> protected override bool OnLoad(string iniFilePath) { if (!base.OnLoad(iniFilePath)) { return(false); } using (INIFile ini = new INIFile(iniFilePath)) { UnitGroup = new DBUnitGroup(ini, "UnitGroup"); UnitGroupCoordinates = new DBEntryMissionFeatureUnitGroupLocation[2]; UnitGroupCoordinates[0] = ini.GetValue <DBEntryMissionFeatureUnitGroupLocation>("UnitGroup", "Position.Initial"); UnitGroupCoordinates[1] = ini.GetValue <DBEntryMissionFeatureUnitGroupLocation>("UnitGroup", "Position.Destination"); } return(true); }
/// <summary> /// Read mail database from file /// </summary> /// <param name="filePath">Path to the database</param> /// <returns>Mail database</returns> public static MailDatabase FromFile(string filePath) { MailDatabase database = new MailDatabase(); Dictionary <string, Dictionary <string, string> > iniFileDict = INIFile.ParseFile(FileMonitor.ReadAllLinesWithRetries(filePath)); foreach (KeyValuePair <string, Dictionary <string, string> > iniSection in iniFileDict) { //iniSection.Key is "mailXX" but we don't need it here string sender = iniSection.Value["sender"]; string recipient = iniSection.Value["recipient"]; string content = iniSection.Value["content"]; DateTime timestamp = DateTime.Parse(iniSection.Value["timestamp"]); bool anonymous = INIFile.Str2Bool(iniSection.Value["anonymous"]); database.Add(new Mail(sender, recipient, content, anonymous, timestamp)); } return(database); }
private void rodzajPlatnosci_SelectedIndexChanged(object sender, EventArgs e) { var indeks = rodzajPlatnosci.SelectedIndex + 1; if (indeks == 4 | indeks == 5 | indeks == 6 | indeks == 7) { isPay.Checked = true; dataPlatnosci.Value = DateTime.Now; doZap.Text = "0,00 zł"; } else { isPay.Checked = false; doZap.Text = wartFV.Text; try { var MyIni = new INIFile("WektorSettings.ini"); server = MyIni.Read("server", "Okna"); database = MyIni.Read("database", "Okna"); uid = MyIni.Read("login", "Okna"); password = Decrypt(MyIni.Read("pass", "Okna")); string connectionString; connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD="******";" + "Convert Zero Datetime = True;"; MySqlConnection conn = new MySqlConnection(); conn.ConnectionString = connectionString; conn.Open(); MySqlCommand cmd = new MySqlCommand("SELECT a.dni FROM terminy a WHERE a.id = '" + indeks + "'", conn); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var dni = Convert.ToDouble(rdr[0]); dataPlatnosci.Value = DateTime.Now.AddDays(dni); } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private bool checkAllPlayersPayed() { bool OnenotPayed = false; INIFile playerIni = new INIFile(Player.iniPath); INIFile teamIni = new INIFile(Team.iniPath); int playerCnt = Convert.ToInt32(playerIni.GetValue(Const.fileSec, Player.fsX_playerCnt)); string[] playerNotPayed = new string[playerCnt]; for (int i = 1; i <= playerCnt; i++) { Player newPlayer = new Player(); newPlayer.Getter(i); if (!newPlayer.payedStartFee) { playerNotPayed[i - 1] = newPlayer.playerId + " " + newPlayer.playerFirstname + " " + newPlayer.playerLastname; OnenotPayed = true; } } if (OnenotPayed) { string errorMessage = ""; for (int i = 0; i < playerNotPayed.Length; i++) { if (playerNotPayed[i] != null) { errorMessage += playerNotPayed[i] + " || "; } } //MessageBox.Show("Offene Startgebühr:\n" + errorMessage, "Ausstehnde Zahlung", MessageBoxButton.OK, MessageBoxImage.Error); MessageBar(ErrorMessage, "Ausstehnde Startgebühren", "Das Turnier kann erst gestartet werden, wenn alle Startgebühren gezahlt wurden!" + "\n" + errorMessage); return(false); } else { return(true); } }
public Config(string file) : this() { Type iniPropertyNameAttribute = typeof(INIPropertyNameAttribute); INIFile ini = new INIFile(file); foreach(PropertyInfo sectprop in this.GetType().GetProperties()) { object[] sectattr = sectprop.GetCustomAttributes(iniPropertyNameAttribute, false); if(sectattr.Length != 0) { string sectname = ((INIPropertyNameAttribute)((sectattr)[0])).Name; INISection section = ini[sectname] as INISection; object sectobj = sectprop.GetValue(this, null); if(sectobj == null) { sectobj = Activator.CreateInstance(sectprop.PropertyType); sectprop.SetValue(this, sectobj, null); } if(section != null) { foreach(PropertyInfo prop in sectprop.PropertyType.GetProperties()) { object[] attr = prop.GetCustomAttributes(iniPropertyNameAttribute, false); if(attr.Length != 0) { string name = ((INIPropertyNameAttribute)((attr)[0])).Name; switch(Type.GetTypeCode(prop.PropertyType)) { case TypeCode.Int32: prop.SetValue(sectobj, section.GetProperty(name).ToInt32(), null); break; case TypeCode.Boolean: prop.SetValue(sectobj, section.GetProperty(name).ToBoolean(), null); break; case TypeCode.String: prop.SetValue(sectobj, section.GetProperty(name).Value, null); break; } } } } } } FileName = file; }
private void LoadProfiles() { string[] files = new string[0]; if (!Directory.Exists(profileDirectory)) { MessageBox.Show("Could not find the profile directory (sub-directory called 'Profiles' in the program directory). Aborting.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); Close(); Environment.Exit(1); } else { files = Directory.GetFiles(profileDirectory, "*.ini", SearchOption.TopDirectoryOnly); if (files.Length < 1) { MessageBox.Show("Could not find any conversion profiles in the profile directory (sub-directory called 'Profiles' in the program directory). Aborting.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); Close(); Environment.Exit(1); } } foreach (string s in files) { try { INIFile profile = new INIFile(s); if (!profile.SectionExists("ProfileData")) { continue; } conversionProfiles.Add(new ListBoxProfile(s, profile.GetKey("ProfileData", "Name", Path.GetFileName(s)), profile.GetKey("ProfileData", "Description", "Description Not Available"))); } catch (Exception) { continue; } } conversionProfiles.Sort(); }
private void img_Load(object sender, EventArgs e) { var MyIni = new INIFile("WektorSettings.ini"); server = MyIni.Read("server", "postgres"); port = MyIni.Read("port", "postgres"); uid = MyIni.Read("user", "postgres"); password = Decrypt(MyIni.Read("pass", "postgres")); database = MyIni.Read("db", "postgres"); string connectionString; connectionString = String.Format("Server={0};Port={1};" + "User Id={2};Password={3};Database={4};", server, port, uid, password, database); NpgsqlConnection obj_Conn = new NpgsqlConnection(); obj_Conn.ConnectionString = connectionString; NpgsqlCommand cmd = new NpgsqlCommand("select emf as rys FROM tradedocsitems where idxtradedocitem = '" + dataGridView1.CurrentRow.Cells["item"].Value + "'", obj_Conn); obj_Conn.Open(); NpgsqlDataReader dr; try { dr = cmd.ExecuteReader(); if (dr.Read()) { byte[] picarr = (byte[])dr["rys"]; MemoryStream ms = new MemoryStream(picarr); ms.Seek(0, SeekOrigin.Begin); pictureBox1.Image = Image.FromStream(ms); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { obj_Conn.Close(); } }
private void btnLogin_Click(object sender, EventArgs e) { appLoginService.LoginAsERPUser(txtUser.Text.ToStr(), txtPassword.Text.ToStr(), txtCompany.EditValue.ToStr(), txtCompany.Text.ToStr()); formStyle = this.txtFormStyle.SelectedIndex; INIFile inifile = new INIFile(IniFilePath); inifile.IniWriteValue("Login", "UserName", txtUser.Text); inifile.IniWriteValue("Login", "Company", txtCompany.EditValue.ToStr()); if (this.txtReamberPwd.Checked) { inifile.IniWriteValue("Login", "Pwd", txtPassword.Text); } else { inifile.IniWriteValue("Login", "Pwd", ""); } this.DialogResult = System.Windows.Forms.DialogResult.OK; }
void SaveSettings() { TermDisplay.EnableTimers(false); try { INIFile config = new INIFile(); if (CurrentConnection != null) { CurrentConnection.Save(config); Properties.Settings.Default.LastConnection = config.Text; Properties.Settings.Default.Save(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public LoggingSystem(string applicationName, bool consoleLogging) { this.pLogToConsole = consoleLogging; if (applicationName == null) { throw new ArgumentNullException("applicationName"); } this.pCurrentLoggingLevel = TraceLevel.Info; this.pLoggingSystemName = applicationName; INIFile file = new INIFile(E80Defaults.IniFilePath); string str = file.ReadValue("Logging", applicationName, "Verbose"); try { this.pCurrentLoggingLevel = (TraceLevel)Enum.Parse(typeof(TraceLevel), str); } catch (Exception) { this.pCurrentLoggingLevel = TraceLevel.Info; } file.WriteValue("Logging", applicationName, string.Format("{0}", this.pCurrentLoggingLevel)); this.pLogFilePath = file.ReadValue("Logging", "LogFilePath", "c:/Temp/Log/"); file.WriteValue("Logging", "LogFilePath", this.pLogFilePath); this.pLogFileName = "E80.Ampla.csv"; if (!this.pLogFilePath.EndsWith("/")) { this.pLogFilePath += "/"; } if (!E80Utils.CheckCreateDirectory(this.pLogFilePath)) { this.pInitialised = false; } else { this.pLogFileMutex = new MutexHelper(this.pLogFileName); this.pInitialised = true; } }
public NodeConfig(int NodeID, GlobalConfiguration GlobalConfiguration) { //this.RpcRequestHandler = rpcRequestHandler; WorkDirectory = /*AppDomain.CurrentDomain.BaseDirectory +*/ "NODE_" + NodeID; this.NodeID = NodeID; this.GlobalConfiguration = GlobalConfiguration; if (!Directory.Exists(WorkDirectory)) { Directory.CreateDirectory(WorkDirectory); } iniFile = new INIFile(WorkDirectory + "\\NodeConfig.ini"); masterNodeRandom = GetNodePrivateRandom(iniFile); DisplayUtils.Display(" Node " + NodeID + " | Private Key : " + HexUtil.ToString(masterNodeRandom)); byte[] _PublicKey; Ed25519.KeyPairFromSeed(out _PublicKey, out masterPrivateKeyExpanded, masterNodeRandom); PublicKey = new Hash(_PublicKey); DisplayUtils.Display(" Node " + NodeID + " | Public Key : " + PublicKey); ListenPortProtocol = GetListenPortProtocol(); DisplayUtils.Display(" Node " + NodeID + " | Listen Protocol : " + ListenPortProtocol); ListenPortRPC = GetListenPortRPC(); DisplayUtils.Display(" Node " + NodeID + " | Listen RPC : " + ListenPortRPC); Path_AccountDB = GetAccountDBPath(); DisplayUtils.Display(" Node " + NodeID + " | Acct DB Path : " + Path_AccountDB); Path_TransactionDB = GetTransactionDBPath(); DisplayUtils.Display(" Node " + NodeID + " | Trxn DB Path : " + Path_TransactionDB); // // // // // // // // // Class Initializations // // // // // // // // // // // // NetworkConfig = new NetworkConfig(ListenPortProtocol); // // // // // // // // // // // // // // // // // // // // // // // // // // // //TODO: MAKE THESE LOCAL INI VARIABLES UpdateFrequencyMS = Constants.Node_UpdateFrequencyMS; UpdateFrequencyConsensusMS = Constants.Node_UpdateFrequencyConsensusMS; UpdateFrequencyPacketProcessMS = Constants.Node_UpdateFrequencyPacketProcessMS; UpdateFrequencyLedgerSyncMS = Constants.Node_UpdateFrequencyLedgerSyncMS; UpdateFrequencyLedgerSyncMS_Root = Constants.Node_UpdateFrequencyLedgerSyncMS_Root; Path_BannedNamesDB = GetInitString("PersistentDatabase", "BannedNamesDB", WorkDirectory + "\\BannedNames.sqlite3"); DisplayUtils.Display(" Node " + NodeID + " | Banned Names DB Path : " + Path_BannedNamesDB); Path_CloseHistoryDB = GetInitString("PersistentDatabase", "CloseHistoryDB", WorkDirectory + "\\CloseHistory.sqlite3"); DisplayUtils.Display(" Node " + NodeID + " | Close History DB Path : " + Path_CloseHistoryDB); // ///////////////////// Organisation = GetInitString("Info", "Organisation", "_unspecified_"); Email = GetInitString("Info", "Email", "_unspecified_"); Platform = GetInitString("Info", "Platform", "_unspecified_"); byte[] RAND_PART = new byte[8]; Common.rngCsp.GetBytes(RAND_PART); // TODO: FIX THIS, TAKE THIS FROM, DB Name = GetInitString("Info", "Name", "name" + HexUtil.ToString(RAND_PART).ToLowerInvariant()); }
public void InitEngines() { INIFile engineini = new INIFile(Directory.GetCurrentDirectory() + @"\" + GlobalVar.enginefilename); GlobalVar.iniSections = tt.Clone(engineini._sections); GlobalVar.current_engine = tt.Clone(engineini._sections["BING"]); GC.Collect(); }
private void OpenFile(bool newFile) { loadingForm = true; //OpenFileDialog iniFile; if (!newFile) { try { OpenFileDialog iniFile = new OpenFileDialog(); iniFile.Filter = "INI Files (*.ini)|*.ini"; iniFile.Title = "Open INI file"; if (iniFile.ShowDialog() == DialogResult.Cancel) return; ConfigSettings = new INIFile(iniFile.FileName); this.tabControl1.Enabled = true; } catch (Exception x) { MessageBox.Show("Error opening file - " + x.Message, "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { try { ConfigSettings = new INIFile(Application.StartupPath + "\\default.ini"); this.tabControl1.Enabled = true; } catch (Exception x) { MessageBox.Show("Error opening default INI file - " + x.Message, "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } if (ConfigSettings.TransmissionType == "DVBT") this.cboArea.DataSource = ConfigSettings.Areas; this.cboCountry.DataSource = ConfigSettings.Countries; if (!newFile) this.Text = "EPG Collector Configuration - " + ConfigSettings.IniFileName; else this.Text = "EPG Collector Configuration - New..."; UpdateForm(); loadingForm = false; }
private bool DetectRunningPortable() { PGEEditorPath = Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar; PGEEnginePath = Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar; if (Internals.CurrentOS == InternalOperatingSystem.Windows) { PGEEditorPath += "pge_editor.exe"; PGEEnginePath += "pge_engine.exe"; } else if (Internals.CurrentOS == InternalOperatingSystem.Linux) { PGEEditorPath += "pge_editor"; PGEEnginePath += "pge_engine"; } if (File.Exists(PGEEditorPath) && File.Exists(PGEEnginePath)) { if (File.Exists(Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar + "pge_editor.ini")) { INIFile editorConfig = new INIFile(Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar + "pge_editor.ini"); if(editorConfig.GetValue("Main", "force-portable", "false").ToString().ToLower() == "true") return true; else return false; } else return false; } return false; }
private void tvPatch_AfterEditing(object sender, TreeViewEventArgs e) { if (!loaded) return; UpdateColour(tvPatch.Nodes, true); List<INIFile.INIVariableDef> guimcp = new List<INIFile.INIVariableDef> { INIFile.iniDefEmpty }; SaveNodes(tvPatch.Nodes, guimcp); INIFile mcpFile = new INIFile(patchSettings, guimcp.ToArray(), true); mcpFile.reinitialize(); mcpFile.save(); }
private bool SaveFile(String fileName) { try { File.Delete(fileName); } catch { return false; } List<INIFile.INIVariableDef> defmcp = new List<INIFile.INIVariableDef>(); List<String[]> comments = new List<String[]>(); // 0 - section, 1 - key, 2 - comment above defmcp.Add(INIFile.iniDefEmpty); foreach (String section in selections.Sections.Keys) { Patch patch = selections.Sections[section]; if (patch.Checked != new Patch().Checked) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.Checked], INIFile.INIVariableType.Dictionary, patch.Checked.ToString())); defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.Version], INIFile.INIVariableType.Dictionary, patch.Version.ToString())); Dictionary<Patch.Key, String> str = new Dictionary<Patch.Key, String> { { Patch.Key.Parent, patch.Parent }, { Patch.Key.Author, patch.Author } }; foreach (Patch.Key key in str.Keys) if (str[key].Trim().Length > 0) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[key], INIFile.INIVariableType.Dictionary, str[key].Trim())); if (patch.FileVersion != new Patch().FileVersion) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.FileVersion], INIFile.INIVariableType.Dictionary, patch.FileVersion.ToString())); Dictionary<Patch.Key, Unit[]> array = new Dictionary<Patch.Key, Unit[]> { { Patch.Key.Original, patch.Original }, { Patch.Key.Patch, patch.Patched }, { Patch.Key.Attach, patch.Attach }, { Patch.Key.Description, patch.Description } }; foreach (Patch.Key key in array.Keys) if (array[key] != null) foreach (Unit unit in array[key]) { String[] asm_lines = unit.Asm.Split(new Char[] { '\n' }); String[] hex_lines = unit.Hex.Split(new Char[] { '\n' }); String hex = ""; int comment = 0; foreach (String line in hex_lines) hex += (hex.Length > 0 ? "\t" : "") + ((comment = line.IndexOf(INIFile.INIComment)) < 0 ? line : line.Substring(0, comment)).TrimEnd(null); if (hex.Trim().Length == 0) continue; String variable = Patch.Keys[key] + " " + unit.ToString(); for (int i = 0; i < asm_lines.Length; i++) if (i == asm_lines.Length - 1 ? asm_lines[i].Trim().Length > 0 : true) comments.Add(new String[3] { section, variable, asm_lines[i] }); defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, variable, INIFile.INIVariableType.Dictionary, hex)); } if (patch.Removed != new Patch().Removed) defmcp.Add(new INIFile.INIVariableDef(defmcp.Count.ToString(), section, Patch.Keys[Patch.Key.Removed], INIFile.INIVariableType.Dictionary, patch.Removed.ToString())); } INIFile mcpFile = new INIFile(fileName, defmcp.ToArray(), Encoding.Default, true); mcpFile.initialize(); foreach (String[] triplet in comments) mcpFile.setCommentAbove(triplet[0], triplet[1], triplet[2]); return mcpFile.save(); }
private void bOpen_Click(object sender, EventArgs e) { RestoreButton(); if (!SaveChanges(true)) return; if (openPatch.ShowDialog() != DialogResult.OK) return; INIFile mcpFile = new INIFile(openPatch.FileName, new INIFile.INIVariableDef[] { INIFile.iniDefEmpty }, Encoding.Default); String[] sections = mcpFile.getSections(); if (sections.Length > 0) { selections.Sections.Clear(); lbSections.Items.Clear(); } foreach (String section in sections) { selections.Sections.Add(section, new Patch(mcpFile, section)); lbSections.Items.Add(section); } propertyGrid.SelectedObject = null; currentState = 0; HistoryUpdate(); savePatch.FileName = openPatch.FileName; DisableEditor(); }
// void OnApplicationQuit() // { // KGFUtility.ClearMouseRect(); // } INIFile GetIniFile() { if (itsIniFile == null) { // load ini file string aPathSettingsFile = KGFUtility.ConvertPathToPlatformSpecific(Application.dataPath); aPathSettingsFile = Path.Combine(aPathSettingsFile,".."); aPathSettingsFile = Path.Combine(aPathSettingsFile,"settings.ini"); itsIniFile = new INIFile(aPathSettingsFile); } return itsIniFile; }
//BaseBlock Settings public BBSettings(INIFile settingsFile) { _gameSettings = settingsFile; }
public void IndexedGetter_WhenSectionDoesntExist_ShouldCreateSection() { //---------------Set up test pack------------------- var section = RandomValueGen.GetRandomString(); var key = RandomValueGen.GetRandomString(); var value = RandomValueGen.GetRandomString(); //---------------Assert Precondition---------------- using (var tempFile = new AutoDeletingTempFile(".ini")) { var ini = new INIFile(tempFile.Path); ini[section][key] = value; ini.Persist(); //---------------Execute Test ---------------------- var ini2 = new INIFile(tempFile.Path); var result = ini2[section][key]; //---------------Test Result ----------------------- Assert.AreEqual(value, result); } }
/// <summary> /// /// </summary> /// <param name="server"></param> /// <param name="username"></param> /// <param name="password"></param> /// <param name="timeoutSeconds"></param> /// <param name="port"></param> public FtpClient(string server, string username, string password, int timeoutSeconds, int port, int bufferSize) { this.server = server; this.username = username; this.password = password; this.timeoutSeconds = timeoutSeconds; this.port = port; BUFFER_SIZE = bufferSize; INIFile iniObject = new INIFile(); m_WriteFtpLog = iniObject.IniReadValue("config", "FtpLog", "0") == "0" ? false : true; }
byte[] GetNodePrivateRandom(INIFile _iniFile) { byte[] _RAND = new byte[0]; try { _RAND = HexUtil.GetBytes(_iniFile.IniReadValue("Keys", "PrivateRandom")); } catch { } if (_RAND.Length != 32) { _RAND = new byte[32]; Common.rngCsp.GetBytes(_RAND); DisplayUtils.Display(" Node " + NodeID + " Creating new PrivateKey : " + HexUtil.ToString(_RAND)); _iniFile.IniWriteValue("Keys", "PrivateRandom", HexUtil.ToString(_RAND)); byte[] _PublicKey, _temp; Ed25519.KeyPairFromSeed(out _PublicKey, out _temp, _RAND); // Just for storing / Not used / Can be used for verification of encrypted / NodePrivateRandom data. _iniFile.IniWriteValue("Keys", "PublicKey", HexUtil.ToString(_PublicKey)); } else { return _RAND; } // Read newly created rand-value; // The duplicate read is to make sure the proper values which are written/updated are indeed used. _RAND = new byte[0]; try { _RAND = HexUtil.GetBytes(_iniFile.IniReadValue("Keys", "PrivateRandom")); } catch { } if (_RAND.Length != 32) { throw new Exception("Cannot write Keys/PrivateRandom to config file."); } else { return _RAND; } }
private void Main_Load(object sender, System.EventArgs e) { // Create subdirectories as required... if (Directory.Exists(strExecutionDirectory + "Logs") == false) Directory.CreateDirectory(strExecutionDirectory + "Logs"); if (Directory.Exists(strExecutionDirectory + "Wav") == false) Directory.CreateDirectory(strExecutionDirectory + "Wav"); strWavDirectory = strExecutionDirectory + "Wav\\"; // Set inital window position and size... objIniFile = new INIFile(strExecutionDirectory + "ARDOP_Win TNC.ini"); InitializeFromIni(); objMod = new EncodeModulate(); // initializes all the leaders etc. dttLastSoundCardSample = Now; tmrPoll.Start(); string strFault = ""; tmrStartCODEC.Start(); //Dim objPA As New PortAudioVB ' Enable only for testing PortAudio if (blnInTestMode) ShowTestFormToolStripMenuItem.Enabled = true; // This keeps the size of the graphics panels constant to handle cases where font size (in Control Panel, Display is 125% or 150% and recenters the waterfall panel. Drawing.Point dpWaterfallCorner = pnlWaterfall.Location; pnlWaterfall.Left = (dpWaterfallCorner.X + pnlWaterfall.Width / 2) - 105; pnlWaterfall.Height = 63; pnlWaterfall.Width = 210; pnlConstellation.Height = 91; pnlConstellation.Width = 91; Logs.WriteDebug("[ARDOP_Win TNC.Main.Load] Command line =" + Microsoft.VisualBasic.Command().Trim); // nothing in command line so use ini values if (string.IsNullOrEmpty(Microsoft.VisualBasic.Command().Trim)) { // use ini file values for host and port Globals.MCB.TCPAddress = Globals.objIniFile.GetString("ARDOP Win", "TCPIP Address", "127.0.0.1"); MCB.TCPPort = objIniFile.GetInteger("ARDOP Win", "TCPIP Port", 8515); MCB.HostTCPIP = Convert.ToBoolean(objIniFile.GetString("ARDOP_Win TNC", "HostTCPIP", "True")); if (MCB.HostTCPIP) objHI.TCPIPProperties(MCB.TCPAddress, MCB.TCPPort); // MCB.HostSerial = Convert.ToBoolean(objIniFile.GetString("ARDOP_Win TNC", "HostSerial", "False")); MCB.SerCOMPort = objIniFile.GetString("ARDOP Win", "SerialCOMPort", "none"); MCB.SerBaud = objIniFile.GetInteger("ARDOP Win", "SerialBaud", 19200); if (MCB.HostSerial) objHI.SerialProperties(MCB.SerCOMPort, MCB.SerBaud); // MCB.HostBlueTooth = Convert.ToBoolean(objIniFile.GetString("ARDOP_Win TNC", "HostBlueTooth", "False")); MCB.HostPairing = objIniFile.GetString("ARDOP_Win TNC", "Host Pairing", "none"); if (MCB.HostBlueTooth) objHI.BluetoothProperties(MCB.HostPairing); CloseToolStripMenuItem.Enabled = true; } else { // test command line parameters for validity: "TCPIP TCPIPPort# TCPIPAddress", Serial POrt, or "BLUETOOTH BlueToothPairing" string[] strCmds = Microsoft.VisualBasic.Command().Split(Convert.ToChar(" ")); if (strCmds.Length == 3 && (strCmds(0).ToUpper == "TCPIP" & (Information.IsNumeric(strCmds(1).Trim) & (Convert.ToInt32(strCmds(1).Trim) >= 0 & Convert.ToInt32(strCmds(1).Trim) < 65536)))) { // TCPIP parameters OK so use these in place of ini values MCB.HostTCPIP = true; MCB.HostSerial = false; MCB.HostBlueTooth = false; objHI.TCPIPProperties(strCmds(2).Trim, Convert.ToInt32(strCmds(1).Trim)); MCB.TCPPort = Convert.ToInt32(strCmds(1).Trim); MCB.TCPAddress = strCmds(2).Trim; } else if (strCmds.Length == 3 && (strCmds(0).ToUpper == "SERIAL" & Information.IsNumeric(strCmds(1).Trim) & (Convert.ToInt32(strCmds(1).Trim) >= 9600))) { MCB.HostTCPIP = false; MCB.HostSerial = true; MCB.HostBlueTooth = false; objHI.SerialProperties(strCmds(1).Trim.ToUpper, Convert.ToInt32(strCmds(2).Trim)); MCB.SerCOMPort = strCmds(1).Trim.ToUpper; MCB.SerBaud = Convert.ToInt32(strCmds(2).Trim); // Preliminay ....may need work for bluetooth } else if (strCmds.Length == 2 && strCmds(0).ToUpper == "BLUETOOTH") { MCB.HostTCPIP = false; MCB.HostSerial = false; MCB.HostBlueTooth = true; objHI.BluetoothProperties(strCmds(1)); MCB.HostPairing = strCmds(1); } else { Logs.Exception("[Main.Load] Syntax error in command line: " + Microsoft.VisualBasic.Command() + " ... ini file values used."); } CloseToolStripMenuItem.Enabled = false; } objHI.EnableHostLink(); }
public FormPlacementINI(Form formobject, INIFile inifile) : base(formobject) { mINIFile=inifile; //LoadPlacement(); }
public Patch(INIFile mcpFile, String section) { Dictionary<String, String> keys = mcpFile.getSectionKeys(section); foreach (String sKey in keys.Keys) { String value = mcpFile.getKeyString(section, sKey).Trim(); bool oKey = sKey.StartsWith(Keys[Key.Original], StringComparison.OrdinalIgnoreCase); bool pKey = sKey.StartsWith(Keys[Key.Patch], StringComparison.OrdinalIgnoreCase); bool aKey = sKey.StartsWith(Keys[Key.Attach], StringComparison.OrdinalIgnoreCase); bool dKey = sKey.StartsWith(Keys[Key.Description], StringComparison.OrdinalIgnoreCase); if (aKey || oKey || pKey || dKey) { value = value.Replace("\t", "\n"); String comment = mcpFile.getCommentAbove(section, sKey); Unit[] units = oKey ? Original : pKey ? Patched : aKey ? Attach : Description; List<Unit> array = units != null ? new List<Unit>(units) : new List<Unit>(); String tag = sKey.Substring(Keys[oKey ? Key.Original : pKey ? Key.Patch : aKey ? Key.Attach : Key.Description].Length).Trim(); array.Add(aKey || dKey ? new Unit(tag, 0, value, comment) : new Unit(Convert.ToUInt32(tag, 16), value, comment)); if (oKey) Original = array.ToArray(); else if (pKey) Patched = array.ToArray(); else if (aKey) Attach = array.ToArray(); else Description = array.ToArray(); continue; } foreach (Key key in Keys.Keys) { if (sKey.ToLower() == Keys[key].ToLower()) { NumberFormatInfo provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = "."; switch (key) { case Key.Checked: { try { Checked = Convert.ToBoolean(value.ToLower()); } catch { } break; } case Key.Parent: { Parent = value; break; } case Key.Version: { try { version = Math.Abs((float)Convert.ToDouble(value, provider)); } catch { } break; } case Key.FileVersion: { try { fileVersion = Math.Abs(Convert.ToInt32(value)); } catch { } break; } case Key.Author: { Author = value; break; } case Key.Removed: { try { Removed = Convert.ToBoolean(value.ToLower()); } catch { } break; } case Key.Expanded: { try { Expanded = Convert.ToBoolean(value.ToLower()); } catch { } break; } } break; } } } }