private void btn_login2selected_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(SelectedUser)) { InfoForm.InfoHelper.CustomMessageBox.Show("Info", "Please select an account!"); return; } var list = JsonConvert.DeserializeObject <RootObject>(File.ReadAllText(Program.AccountsJsonFile)); foreach (var a in list.Accounts) { if (a.username == SelectedUser) { if (string.IsNullOrEmpty(a.password)) { InfoForm.InfoHelper.CustomMessageBox.Show("Info", "Please add password to: " + a.username); return; } usernameJSON = a.username; passwordJSON = a.password; } } // Start Login Thread doLogin = new Thread(() => AccountLogin.UserSettingsGather(usernameJSON, passwordJSON)); doLogin.Start(); btn_login2selected.Enabled = false; }
private void Main_Shown(object sender, EventArgs e) { var Settingslist = JsonConvert.DeserializeObject <ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile)); DateTime now = DateTime.Now; if (Settingslist.LastTimeCheckedUpdate == null || Settingslist.LastTimeCheckedUpdate.Length == 0) { Settingslist.LastTimeCheckedUpdate = now.ToString(); } DateTime old = DateTime.Parse(Settingslist.LastTimeCheckedUpdate); if (Settingslist.LastTimeCheckedUpdate.Length > 0 && (now - old).TotalDays > 30) //check for update 30 days later { RafadexAutoUpdate600IQ(); } File.WriteAllText(Program.SettingsJsonFile, JsonConvert.SerializeObject(Settingslist, Formatting.Indented)); if (Settingslist.startupAcc != 0) { var list = JsonConvert.DeserializeObject <RootObject>(File.ReadAllText(Program.AccountsJsonFile)); foreach (var a in list.Accounts) { if (a.SteamID == Settingslist.startupAcc) { usernameJSON = a.username; passwordJSON = a.password; } } // Start Login Thread doLogin = new Thread(() => AccountLogin.UserSettingsGather(usernameJSON, passwordJSON)); doLogin.Start(); } System.Windows.Forms.Timer t = new System.Windows.Forms.Timer(); t.Tick += new EventHandler(Trolha_Tick); t.Interval = 2000; t.Start(); combox_Colors.SelectedIndex = Settingslist.startupColor; // if (Settingslist.Separator.Length > 0) { txtBox_saveSeparator.Text = Settingslist.Separator; } if (Settingslist.PathLogs.Length > 0) { // txtBox_logDir.Text = Settingslist.PathLogs.Replace(@"\\", @"\"); txtBox_logDir.Text = Settingslist.PathLogs; } else { Settingslist.PathLogs = Program.ChatLogsFolder; txtBox_logDir.Text = Program.ChatLogsFolder; var convertedJson = JsonConvert.SerializeObject(Settingslist, new JsonSerializerSettings { Formatting = Formatting.Indented }); File.WriteAllText(Program.SettingsJsonFile, convertedJson); } //Settings LOAD to Main Form toggle_startWindows.Checked = Settingslist.startup; combox_historysettings.SelectedIndex = Settingslist.HistorySettings; if (Settingslist.hideInTaskBar) { toggle_hideInTask.Checked = true; this.ShowInTaskbar = false; } else { this.ShowInTaskbar = true; toggle_hideInTask.Checked = false; } if (Settingslist.startMinimized) { chck_Minimized.Checked = true; this.WindowState = FormWindowState.Minimized; } else { chck_Minimized.Checked = false; this.WindowState = FormWindowState.Normal; } if (Settingslist.playsound) { toggle_playSound.Checked = true; Stream str = Properties.Resources.ChatLogger_Success; SoundPlayer snd = new SoundPlayer(str); snd.Play(); } else { toggle_playSound.Checked = false; } }