Ejemplo n.º 1
0
        private void mnuChangeUser_Click(object sender, EventArgs e)
        {
            clsUpdate.isStop = true;

            #region удаление старого fileID_and_Psss
            clsUpdate.id = String.Empty;
            clsUpdate.pass = String.Empty;
            try { System.IO.File.Delete(fileID_and_Psss); }
            catch (Exception) { }
            #endregion

            #region очистка скроллов от старых данных
            try
            {
                scrollMessages.Controls.Clear();
                scrollMessDialog.Controls.Clear();
                scrollFeed.Controls.Clear();
                lstFeeds.Clear();
                scrollProjects.Controls.Clear();
                scrollSearchedProject.Controls.Clear();
            }
            catch (Exception) { }
            #endregion

            notify.Visible = false;

            #region запрос ввода новых данных

            using (frmLogin frm = new frmLogin())
            {
                while (frm.ShowDialog() == DialogResult.OK)
                {

                    #region проверка данных
                    if (string.IsNullOrEmpty(frm.txtLogin.Text) || string.IsNullOrEmpty(frm.txtPass.Text)) { continue; }
                    #endregion

                    clsUpdate.id = frm.txtLogin.Text;
                    clsUpdate.pass = frm.txtPass.Text;

                    using (StreamWriter wr = new StreamWriter(fileID_and_Psss, false, Encoding.GetEncoding(1251)))
                    {
                        //wr.WriteLine(clsUpdate.id + "," + clsUpdate.pass);
                        wr.WriteLine(encode(clsUpdate.id + "," + clsUpdate.pass));
                        wr.Flush();
                        wr.Close();
                    }
                    this.WindowState = FormWindowState.Maximized;
                    break;

                }
            }

            #endregion

            is_init = is_init_f = is_init_m = is_init_p = is_init_ps = is_init_u = true;

            clsUpdate.proFile = "me";

            tabControl1.SelectedTab = tabControl1.TabPages["tabLoading"];

            timerProgress.Start();

            notify.Visible = true;

            this.Show();
            this.WindowState = FormWindowState.Maximized;

            //clsUpdate.evRefresh += new clsUpdate.evRefreshHandle(clsMeessages_evRefresh);
            //clsUpdate.evRefreshStart += new clsUpdate.evRefreshStartHandle(clsUpdate_evRefreshStart);
            //clsUpdate.evRefreshEnd += new clsUpdate.evRefreshEndHandle(clsUpdate_evRefreshEnd);

            //clsPing.evInternetConnectChange += new clsPing.evInternetConnectChangeHandle(clsPing_evInternetConnectChange);

            clsUpdate.isStop = false;
            Thread th = new Thread(clsUpdate.autoRefresh);
            th.Start();
        }
Ejemplo n.º 2
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            if (!File.Exists(fileID_and_Psss))
            {
                using (frmLogin frm = new frmLogin())
                {
                    while (frm.ShowDialog() == DialogResult.OK )
                    {

                            #region проверка данных
                            if (string.IsNullOrEmpty(frm.txtLogin.Text) || string.IsNullOrEmpty(frm.txtPass.Text)) { continue; }
                            #endregion

                            clsUpdate.id = frm.txtLogin.Text;
                            clsUpdate.pass = frm.txtPass.Text;

                            using (StreamWriter wr = new StreamWriter(fileID_and_Psss, false, Encoding.GetEncoding(1251)))
                            {
                                //wr.WriteLine(clsUpdate.id + "," + clsUpdate.pass);
                                wr.WriteLine(encode(clsUpdate.id + "," + clsUpdate.pass));
                                wr.Flush();
                                wr.Close();
                            }
                            this.WindowState = FormWindowState.Maximized;
                            break;

                    }
                }
            }
            else
            {
                using (StreamReader rd = new StreamReader(fileID_and_Psss, Encoding.GetEncoding(1251)))
                {
                    try
                    {
                        string[] data = decode(rd.ReadLine()).Split(',');
                        rd.Close();

                        if (data.Count() == 2)
                        {
                            clsUpdate.id = data[0];
                            clsUpdate.pass = data[1];
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Ошибка в ключах", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        mnuExit.PerformClick();
                        return;
                    }
                }
            }

            if (string.IsNullOrEmpty(clsUpdate.id) || string.IsNullOrEmpty(clsUpdate.pass))
            {
                Close();
                return;
            }

            timerProgress.Start();

            clsUpdate.evRefresh += new clsUpdate.evRefreshHandle(clsMeessages_evRefresh);
            clsUpdate.evRefreshStart += new clsUpdate.evRefreshStartHandle(clsUpdate_evRefreshStart);
            clsUpdate.evRefreshEnd += new clsUpdate.evRefreshEndHandle(clsUpdate_evRefreshEnd);

            clsPing.evInternetConnectChange += new clsPing.evInternetConnectChangeHandle(clsPing_evInternetConnectChange);

            Thread th = new Thread(clsUpdate.autoRefresh);
            th.Start();
            //is_init = true;
        }