public static string GetSetting(string Setting) { var IniFile = new IniFile.IniFile("Settings.ini"); switch (Setting) { case "Server": case "Channel": case "Username": case "Nickname": case "Password": if (!IniFile.KeyExists(Setting, "Settings.IRC")) { if (Setting.Equals("Server")) { IniFile.Write(Setting, Default[1], "Settings.IRC"); } else if (Setting.Equals("Channel")) { IniFile.Write(Setting, Default[2], "Settings.IRC"); } else if (Setting.Equals("Username") || Setting.Equals("Nickname")) { IniFile.Write(Setting, Default[3], "Settings.IRC"); } else if (Setting.Equals("Password")) { IniFile.Write(Setting, Default[4], "Settings.IRC"); } return(IniFile.Read(Setting, "Settings.IRC")); } else { return(IniFile.Read(Setting, "Settings.IRC")); } case "TimeOut": if (!IniFile.KeyExists(Setting, "Settings.Other")) { IniFile.Write(Setting, Default[0], "Settings.Other"); return(IniFile.Read(Setting, "Settings.Other")); } else { return(IniFile.Read(Setting, "Settings.Other")); } } return(null); }
public void ReadFromFile(string Filename) { Reset(); if (File.Exists(Filename)) { IniFile.IniFile IniFile = new IniFile.IniFile(Filename); if (IniFile.KeyExists("AutoResizeForm", Units.Class.APPNAME)) { bool tmp; int tmpInt; AutoResizeForm = Boolean.TryParse(IniFile.Read("AutoResizeForm", Units.Class.APPNAME), out tmp) ? tmp : true; UseRedForPlayerA = Boolean.TryParse(IniFile.Read("UseRedForPlayerA", Units.Class.APPNAME), out tmp) ? tmp : false; ShortLoseRound = Int32.TryParse(IniFile.Read("ShortLoseRound", Units.Class.APPNAME), out tmpInt) ? tmpInt : 6; FightDuration = Int32.TryParse(IniFile.Read("FightDuration", Units.Class.APPNAME), out tmpInt) ? tmpInt : 180; SwitchStepsSystemAt32 = Boolean.TryParse(IniFile.Read("SwitchStepsSystemAt32", Units.Class.APPNAME), out tmp) ? tmp : true; SwitchJumpSlotOrderAt32 = Boolean.TryParse(IniFile.Read("SwitchJumpSlotOrderAt32", Units.Class.APPNAME), out tmp) ? tmp : true; SaveToIni = true; // obviously, there would not be a file otherwise } } }