AniDBmini.ConfigFile.Read C# (CSharp) Method

Read() public static method

Read data value from the ini file
public static Read ( string Key ) : ConfigValue
Key string
return ConfigValue
        public static ConfigValue Read(string Key)
        {
            CheckDefaultConfig();

            StringBuilder temp = new StringBuilder(255);
            WinAPI.GetPrivateProfileString(configSection, Key, null, temp, 255, configPath);

            if ((string.IsNullOrWhiteSpace(temp.ToString()) && !string.IsNullOrWhiteSpace(Default[Key])) ||
                ((Key == "aLang" || Key == "eLang") && !configLangs.Contains(temp.ToString())))
            {
                Write(Key, Default[Key]);
                return new ConfigValue(Default[Key]);
            }
            else
                return new ConfigValue(temp.ToString());
        }

Usage Example

Example #1
0
        private void LoadOptions()
        {
            adbmUsernameTextBox.Text           = ConfigFile.Read("username").ToString();
            adbmPasswordPasswordBox.Password   = ConfigFile.Read("password").ToString();
            adbmLocalPortTextBox.Text          = ConfigFile.Read("localPort").ToString();
            adbmAutoLoginCheckBox.IsChecked    = ConfigFile.Read("autoLogin").ToBoolean();
            adbmRememberUserCheckBox.IsChecked = ConfigFile.Read("rememberUser").ToBoolean();

            MPCAPI.MPC_WATCHED mpcMarkedWatched = (MPCAPI.MPC_WATCHED)ConfigFile.Read("mpcMarkWatched").ToInt32();

            mpchcLocationTextBox.Text = ConfigFile.Read("mpcPath").ToString();

            if (mpcMarkedWatched == MPCAPI.MPC_WATCHED.AFTER_FINISHED)
            {
                mpcMarkAfter.IsChecked = true;
            }
            else if (mpcMarkedWatched == MPCAPI.MPC_WATCHED.DURING_TICKS)
            {
                mpcMarkDuring.IsChecked = true;
            }

            mpcWatchedPercSlider.Value   = ConfigFile.Read("mpcMarkWatchedPerc").ToInt32();
            mpcShowFileInTitle.IsChecked = ConfigFile.Read("mpcShowTitle").ToBoolean();
            mpcShowWatchedOSD.IsChecked  = ConfigFile.Read("mpcShowOSD").ToBoolean();
            mpcClose.IsChecked           = ConfigFile.Read("mpcClose").ToBoolean();
            mpcOSDPos.SelectedIndex      = ConfigFile.Read("mpcOSDPos").ToInt32() - 1;
            mpcOSDDurMS.SelectedIndex    = ConfigFile.Read("mpcOSDDurMS").ToInt32() / 1000 - 1;
        }
All Usage Examples Of AniDBmini.ConfigFile::Read