예제 #1
0
파일: Main.cs 프로젝트: sp0ok3r/ChatLogger
        private void Trolha_Tick(object sender, EventArgs e)
        {
            try
            {
                if (AccountLogin.IsLoggedIn == true)
                {
                    btn_login2selected.Enabled = false;

                    // se timer estiver desligado e combo estiver fora do 0 iniciar
                    if ((!TrolhaHistory.Enabled) && combox_historysettings.SelectedIndex != 0)
                    {
                        TrolhaHistory.Start();

                        richtxtbox_HistoryLogs.Clear();
                        richtxtbox_HistoryLogs.Text      = "Waiting for new messages...";
                        richtxtbox_HistoryLogs.ForeColor = SystemColors.GrayText;
                    }



                    lbl_connecting.Visible          = true;
                    lbl_currentUsername.Visible     = true;
                    btnLabel_PersonaAndFlag.Visible = true;
                    btn_logout.Visible         = true;
                    panel_steamStates.Visible  = true;
                    picBox_SteamAvatar.Visible = true;

                    if (picBox_SteamAvatar.Image == null && btnLabel_PersonaAndFlag.Image == null)
                    {
                        picBox_SteamAvatar.ImageLocation = AccountLogin.GetAvatarLink(AccountLogin.CurrentSteamID);

                        // byte[] data = new WebClient().DownloadData("https://www.countryflags.io/" + AccountLogin.UserCountry + "/flat/16.png");
                        byte[] data = new WebClient().DownloadData("https://flagcdn.com/16x12/" + AccountLogin.UserCountry.ToLower() + ".png");

                        MemoryStream ms = new MemoryStream(data);
                        btnLabel_PersonaAndFlag.Image = Image.FromStream(ms);
                    }

                    btnLabel_PersonaAndFlag.Invoke(new Action(() => btnLabel_PersonaAndFlag.Text = AccountLogin.UserPersonaName));

                    panel_steamStates.BackColor = Color.LightSkyBlue;
                    lbl_currentUsername.Invoke(new Action(() => lbl_currentUsername.Text = AccountLogin.CurrentUsername));

                    progressRecord.Visible = true;
                    lbl_recording.Visible  = true;
                }
                else
                {
                    TrolhaHistory.Stop();

                    richtxtbox_HistoryLogs.Clear();
                    richtxtbox_HistoryLogs.Text      = "Waiting for loggin...";
                    richtxtbox_HistoryLogs.ForeColor = SystemColors.GrayText;

                    lbl_recording.Visible  = false;
                    progressRecord.Visible = false;

                    lbl_connecting.Visible          = false;
                    lbl_currentUsername.Visible     = false;
                    btnLabel_PersonaAndFlag.Visible = false;
                    btn_logout.Visible         = false;
                    panel_steamStates.Visible  = false;
                    picBox_SteamAvatar.Visible = false;


                    btn_login2selected.Enabled = true;
                    btnLabel_PersonaAndFlag.Invoke(new Action(() => btnLabel_PersonaAndFlag.Text = "None"));


                    panel_steamStates.BackColor  = Color.Gray;
                    picBox_SteamAvatar.BackColor = Color.FromArgb(255, 25, 25, 25);
                    lbl_currentUsername.Invoke(new Action(() => lbl_currentUsername.Text = "None"));
                }
            }
            catch (Exception ewe)
            {
                InfoForm.InfoHelper.CustomMessageBox.Show("Error", e.ToString());
                Console.WriteLine(ewe);
            }
        }
예제 #2
0
        private void Trolha_Tick(object sender, EventArgs e)
        {
            try
            {
                if (AccountLogin.IsLoggedIn == true)
                {
                    btn_login2selected.Enabled = false;

                    lbl_connecting.Visible          = true;
                    lbl_currentUsername.Visible     = true;
                    btnLabel_PersonaAndFlag.Visible = true;
                    btn_logout.Visible         = true;
                    panel_steamStates.Visible  = true;
                    picBox_SteamAvatar.Visible = true;

                    if (picBox_SteamAvatar.Image == null && btnLabel_PersonaAndFlag.Image == null)
                    {
                        picBox_SteamAvatar.ImageLocation = AccountLogin.GetAvatarLink(AccountLogin.CurrentSteamID);

                        byte[] data = new WebClient().DownloadData("https://www.countryflags.io/" + AccountLogin.UserCountry + "/flat/16.png");

                        MemoryStream ms = new MemoryStream(data);
                        btnLabel_PersonaAndFlag.Image = Image.FromStream(ms);
                    }

                    btnLabel_PersonaAndFlag.Invoke(new Action(() => btnLabel_PersonaAndFlag.Text = AccountLogin.UserPersonaName));

                    panel_steamStates.BackColor = Color.LightSkyBlue;
                    lbl_currentUsername.Invoke(new Action(() => lbl_currentUsername.Text = AccountLogin.CurrentUsername));

                    progressRecord.Visible = true;
                    lbl_recording.Visible  = true;
                }
                else
                {
                    lbl_recording.Visible  = false;
                    progressRecord.Visible = false;

                    lbl_connecting.Visible          = false;
                    lbl_currentUsername.Visible     = false;
                    btnLabel_PersonaAndFlag.Visible = false;
                    btn_logout.Visible         = false;
                    panel_steamStates.Visible  = false;
                    picBox_SteamAvatar.Visible = false;


                    btn_login2selected.Enabled = true;
                    btnLabel_PersonaAndFlag.Invoke(new Action(() => btnLabel_PersonaAndFlag.Text = "None"));


                    panel_steamStates.BackColor  = Color.Gray;
                    picBox_SteamAvatar.BackColor = Color.FromArgb(255, 25, 25, 25);
                    lbl_currentUsername.Invoke(new Action(() => lbl_currentUsername.Text = "None"));
                }
            }
            catch (Exception ewe)
            {
                InfoForm.InfoHelper.CustomMessageBox.Show("Error", e.ToString());
                Console.WriteLine(ewe);
            }
        }