コード例 #1
0
ファイル: Form1.cs プロジェクト: zyounan/scut_WiFi_Helper
        private void IPTryAgain_Tick(object sender, EventArgs e)
        {
            if (FailedTimes == 5)
            {
                FailedTimes            = 0;
                tWaitToConnect.Enabled = false;
                IPTryAgain.Enabled     = false;
                ExitTimer.Enabled      = true;
                //ConnectNow.Visible = false;
                cnt = 3;
                //label1.Text = "Something goes wrong with WiFi...";
                NotificationHelper.Popup("Something goes wrong with WiFi :(");
                //Program.form1.pictureBox1.Image = Properties.Resources.error;

                return;
            }
            if (cnt == 0)
            {
                ++FailedTimes;
                IPTryAgain.Enabled = false;
                cnt = 3;
                ConnectWiFi.ConnectToScut_student();
                Thread.Sleep(100);
                connectWiFi.GetIP();
                connectWiFi.Work();
            }
            else
            {
                label1.Text = string.Format(sWaitinfo, cnt--);
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zyounan/scut_WiFi_Helper
        private void Form1_Shown(object sender, EventArgs e)
        {
            try {
                this.Visible = false;
                connectWiFi  = new ConnectWiFi();
                int x = ConnectWiFi.CreateMutexA(IntPtr.Zero, true, "ConnectWiFiSCUT");
                if (x == 0)
                {
                    Application.Exit();
                }
                connectWiFi.Getuser();
                if (!ConnectWiFi.IsInTargetArea())
                {
                    NotificationHelper.Popup("Ooops, it seems that you are not in the dormitory.", 2);
                    label1.Text        = "You are not in the dorm.";
                    pictureBox1.Image  = Properties.Resources.error;
                    ExitTimer.Interval = 1000;
                    ExitTimer.Enabled  = true;
                    return;
                }
                ConnectWiFi.ConnectToScut_student();
                Thread.Sleep(100);
                connectWiFi.GetIP();
                if (connectWiFi.status && this.label1.Text == "You are online.")
                {
                    //pictureBox1.Image = Properties.Resources.success;
                    //OK.Focus();
                    SetTimerInterval(2);
                    ExitTimer.Interval = 1000;
                    ExitTimer.Enabled  = true;
                    return;
                }
                else if (connectWiFi.status)
                {
                    tWaitToConnect.Interval = 1000;
                    SetTimerInterval(2);
                    tWaitToConnect.Enabled = true;
                    //ConnectNow.Visible = true;
                }

                //MessageBox.Show("233333");
                return;
            } catch (DllNotFoundException) {
                //label1.Text = "Missing ConnectWiFi_x64.dll";
                NotificationHelper.Popup("Make sure you have ConnectWiFi_x64.dll!", 2);
                //Program.form1.pictureBox1.Image = Properties.Resources.error;
                SetTimerInterval(2);
                ExitTimer.Interval = 1000;
                ExitTimer.Enabled  = true;
                return;
            }
        }