Example #1
0
 private void ConnectForm_Load(object sender, EventArgs e)
 {
     while (true)//Проверка интернета
     {
         try
         {
             // Create a request for the URL.
             HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.google.ru/");
             request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";
             request.Timeout   = 10000;
             HttpWebResponse response           = (HttpWebResponse)request.GetResponse();
             Stream          ReceiveStream1     = response.GetResponseStream();
             StreamReader    sr                 = new StreamReader(ReceiveStream1, true);
             string          responseFromServer = sr.ReadToEnd();
             response.Close();
             break;
         }
         catch (Exception ex)
         {
             DialogResult = MessageBox.Show($"Нет подключения к интернету\n{ex.Message}", "", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
             if (DialogResult == DialogResult.Cancel)
             {
                 Environment.Exit(0);
             }
             continue;
         }
     }
     if (!Program.IF.KeyExists("ConnSett", "Adress") || !Program.IF.KeyExists("ConnSett", "DBname") || !Program.IF.KeyExists("ConnSett", "Port"))//Проверка файла настроек
     {
         SetForm = new SettingsConnectForm();
         Hide();
         MessageBox.Show("Первый запуск. Введите настройки.", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Error);
         SetForm.FormClosing += (obj, arg) =>
         {
             Show();
         };
         SetForm.ShowDialog();
     }
 }
Example #2
0
 private void ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SetForm = new SettingsConnectForm();
     SetForm.ShowDialog();
 }