private void CheckLogin()
 {
     if (File.Exists(GlobalVariables.apppath + @"\coockies.txt"))
     {
         string     username, useravatar;
         YandexInfo yi = new YandexInfo();
         username   = yi.GetUserName();
         useravatar = yi.GetUserAvatar();
         if (username == null)
         {
             YandexLoginWindow ylw = new YandexLoginWindow();
             ylw.mw = this;
             ylw.ShowDialog();
         }
         else
         {
             this.username.Text = username;
             this.useravatar.Load(useravatar);
         }
     }
     else
     {
         YandexLoginWindow ylw = new YandexLoginWindow();
         ylw.mw = this;
         ylw.ShowDialog();
     }
 }
Exemple #2
0
        private void SettingsWindow_Activated(object sender, EventArgs e)
        {
            YandexInfo yi = new YandexInfo();

            label1.Text = yi.GetUserName();
            pictureBox1.Load(yi.GetUserAvatar());
            SettingsReader manager = new SettingsReader(GlobalVariables.apppath + @"\settings.ini");

            label2.Text = manager.GetPrivateString("Main", "CityName");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            CookieContainer test = new CookieContainer();

            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            label3.Text     = "";
            label4.Text     = "";
            try
            {
                Yandex yandex = new Yandex(textBox1.Text, textBox2.Text);
                yandex.Authorize();
                test = yandex.cookies;
                Cookies cs = new Cookies();
                cs.Write(test, GlobalVariables.apppath + @"\coockies.txt");
                YandexInfo yi = new YandexInfo();
                mw.username.Text = yi.GetUserName();
                mw.useravatar.Load(yi.GetUserAvatar());
                closeapp = false;
                this.Close();
            }
            catch (Exceptions ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (YandexExceptions)
            {
                if (textBox1.Text == "")
                {
                    label3.Text = "Поле пустое!";
                }
                if (textBox2.Text == "")
                {
                    label4.Text = "Поле пустое!";
                }
            }

            finally
            {
                button1.Enabled = true;
                button2.Enabled = true;
                button3.Enabled = true;
            }
        }