Example #1
0
 public void LoadAccounts()
 {
     storedAccounts.Clear();
     string[] fileNames = Directory.GetFiles( Paths.DataDirectory, "*.account" );
     foreach( string fileName in fileNames ) {
         try {
             SettingsFile sf = new SettingsFile();
             sf.Load( fileName );
             SignInAccount newAccount = new SignInAccount {
                 SignInUsername = sf.GetString( "SignInUsername", "" ),
                 PlayerName = sf.GetString( "PlayerName", "" ),
                 Password = sf.GetString( "Password", "" ),
                 LastUrl = sf.GetString( "LastUrl", "" )
             };
             if( newAccount.Password.Length > 0 ) {
                 newAccount.Password = PasswordSecurity.DecryptPassword( newAccount.Password );
             }
             string tickString = sf.GetString( "SignInDate", "0" );
             long ticks;
             if( Int64.TryParse( tickString, out ticks ) && ticks > DateTime.MinValue.Ticks &&
                 ticks <= DateTime.MaxValue.Ticks ) {
                 newAccount.SignInDate = new DateTime( ticks );
             } else {
                 newAccount.SignInDate = DateTime.MinValue;
             }
             AddAccount( newAccount );
         } catch( Exception ex ) {
             MainForm.Log( "AccountManager.LoadAccounts: " + ex );
         }
     }
     SaveAllAccounts();
 }
 public string Get(string sectionName, string settingName, string defaultValue = null)
 {
     lock (SyncRoot)
     {
         return(SettingsFile.GetString(sectionName, settingName, defaultValue));
     }
 }
Example #3
0
 void LoadResumeInfo()
 {
     if( File.Exists( Paths.GameSettingsFile ) ) {
         SettingsFile gameSettings = new SettingsFile();
         gameSettings.Load( Paths.GameSettingsFile );
         string resumeUri = gameSettings.GetString( "mc.lastMcUrl", "" );
         if( resumeUri.Length > 0 ) {
             Match match = PlayLinkDirect.Match( resumeUri );
             if( match.Success ) {
                 tResumeUri.Text = resumeUri;
                 tResumeServerIP.Text = match.Groups[1].Value;
                 tResumeUsername.Text = match.Groups[7].Value;
                 string resumeServerName = gameSettings.GetString( "mc.lastClassicServer", "" );
                 if( resumeServerName.Length > 0 ) {
                     tResumeServerName.Text = resumeServerName;
                 } else {
                     tResumeServerName.Text = "?";
                 }
                 bResume.Enabled = true;
                 return;
             }
         }
     }
     ResetResumeInfo();
 }