IniReadValue() public method

public IniReadValue ( string Section, string Key ) : string
Section string
Key string
return string
Esempio n. 1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            Utils.InitLog(".\\FOMonitor.log");

            System.Drawing.Text.InstalledFontCollection ifc = new System.Drawing.Text.InstalledFontCollection();
            foreach (FontFamily ff in ifc.Families)
            {
                cmbFont.Items.Add(ff.Name);
                if (ff.Name == "Tahoma")
                {
                    cmbFont.SelectedIndex = cmbFont.Items.Count - 1;
                }
            }

            IniReader Fo2238Config = new IniReader(".\\FOnline2238.cfg");

            logPath = Fo2238Config.IniReadValue("2238", "LogfileName");

            if (String.IsNullOrEmpty(logPath))
            {
                logPath = ".\\";
            }
            bool containsTag = containsLogTag(logPath);

            if (containsTag)
            {
                string   validPath = Path.GetPathRoot(logPath);
                string[] parts     = logPath.Split(Path.DirectorySeparatorChar);
                foreach (string part in parts)
                {
                    if (!containsLogTag(part))
                    {
                        validPath += part + Path.DirectorySeparatorChar;
                    }
                    else
                    {
                        break;
                    }
                }
                logExt           = Path.GetExtension(logPath);
                logPath          = validPath;
                lblLogsPath.Text = String.Format("Searching for logs in: {0} (defined in FOnline2238.cfg)", logPath);
            }

            List <string> Colors    = new List <string>(Enum.GetNames(typeof(System.Drawing.KnownColor)));
            Type          colorType = typeof(System.Drawing.Color);

            PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
            foreach (System.Reflection.PropertyInfo c in propInfoList)
            {
                this.cmbBlacklistColor.Items.Add(c.Name);
            }

            this.Text = "FOMonitor " + version;
            this.cmbMapFilterRaw.SelectedIndex   = 0;
            this.cmbSources.SelectedIndex        = 0;
            this.cmbBlacklistColor.SelectedIndex = 0;
            this.cmbMatchMode.SelectedIndex      = 0;

            this.numMapFilter.Maximum = Int32.MaxValue;
            lblInstructions.Text      = "Use ~gameinfo 1 and press F2, then " + Environment.NewLine + "press update.";
            if (!File.Exists("FOnline.exe"))
            {
                MessageBox.Show("FOnline.exe not found." + Environment.NewLine +
                                "Please move this program to same directory as the fonline client", "FOMonitor", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Serializer.Init();
            ReadConfig();
            RestoreTableState();
            if (File.Exists("./whitelist.txt"))
            {
                Whitelist = new Dictionary <int, string>();
                try
                {
                    List <string> lines = new List <string>(File.ReadAllLines("./whitelist.txt"));
                    Whitelist = Utils.ParseWhitelist(lines.ToArray());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to parse whitelist: " + ex.Message);
                }
            }
            else
            {
                File.Create("./whitelist.txt");
            }

            if (File.Exists("./blacklist.txt"))
            {
                Blacklist = new Dictionary <string, string>();
                try
                {
                    List <string> lines = new List <string>(File.ReadAllLines("./blacklist.txt"));
                    Blacklist = Utils.ParseBlacklist(lines.ToArray());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to parse blacklist: " + ex.Message);
                }
            }
            else
            {
                File.Create("./blacklist.txt");
            }
        }
Esempio n. 2
0
 public static void DeserializeTextBox(string section, string key, TextBox box)
 {
     box.Text = ini.IniReadValue(section, key);
 }
Esempio n. 3
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            Utils.InitLog(".\\FOMonitor.log");

            System.Drawing.Text.InstalledFontCollection ifc = new System.Drawing.Text.InstalledFontCollection();
            foreach (FontFamily ff in ifc.Families)
            {
                cmbFont.Items.Add(ff.Name);
                if (ff.Name == "Tahoma")
                    cmbFont.SelectedIndex = cmbFont.Items.Count-1;
            }

            IniReader Fo2238Config = new IniReader(".\\FOnline2238.cfg");
            logPath = Fo2238Config.IniReadValue("2238", "LogfileName");

            if(String.IsNullOrEmpty(logPath))
                logPath = ".\\";
            bool containsTag = containsLogTag(logPath);

            if(containsTag)
            {
                string validPath = Path.GetPathRoot(logPath);
                string[] parts = logPath.Split(Path.DirectorySeparatorChar);
                foreach(string part in parts)
                {
                    if (!containsLogTag(part))
                        validPath += part + Path.DirectorySeparatorChar;
                    else
                        break;
                }
                logExt = Path.GetExtension(logPath);
                logPath = validPath;
                lblLogsPath.Text = String.Format("Searching for logs in: {0} (defined in FOnline2238.cfg)", logPath);
            }

            List<string> Colors = new List<string>(Enum.GetNames(typeof(System.Drawing.KnownColor)));
            Type colorType = typeof(System.Drawing.Color);
            PropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);
            foreach (System.Reflection.PropertyInfo c in propInfoList)
                this.cmbBlacklistColor.Items.Add(c.Name);

            this.Text = "FOMonitor " + version;
            this.cmbMapFilterRaw.SelectedIndex = 0;
            this.cmbSources.SelectedIndex = 0;
            this.cmbBlacklistColor.SelectedIndex = 0;
            this.cmbMatchMode.SelectedIndex = 0;

            this.numMapFilter.Maximum = Int32.MaxValue;
            lblInstructions.Text = "Use ~gameinfo 1 and press F2, then " + Environment.NewLine + "press update.";
            if (!File.Exists("FOnline.exe"))
            {
                MessageBox.Show("FOnline.exe not found." + Environment.NewLine +
                    "Please move this program to same directory as the fonline client", "FOMonitor", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Serializer.Init();
            ReadConfig();
            RestoreTableState();
            if (File.Exists("./whitelist.txt"))
            {
                Whitelist = new Dictionary<int, string>();
                try
                {
                    List<string> lines = new List<string>(File.ReadAllLines("./whitelist.txt"));
                    Whitelist = Utils.ParseWhitelist(lines.ToArray());
                }
                catch(Exception ex)
                {
                    MessageBox.Show("Failed to parse whitelist: " + ex.Message);
                }

            }
            else
                File.Create("./whitelist.txt");

            if (File.Exists("./blacklist.txt"))
            {
                Blacklist = new Dictionary<string, string>();
                try
                {
                    List<string> lines = new List<string>(File.ReadAllLines("./blacklist.txt"));
                    Blacklist = Utils.ParseBlacklist(lines.ToArray());
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed to parse blacklist: " + ex.Message);
                }

            }
            else
                File.Create("./blacklist.txt");
        }