示例#1
0
        private async void btnProceed_Click(object source, EventArgs ev)
        {
            btnProceed.Hide();
            btnFail.Hide();

            currentStage        += 1;
            progressStrip.Value += 25;

            DisplayMessage(currentStage);

            if (currentStage is Stage.Good)
            {
                statusIcon.Image = Properties.Resources.check;
                return;
            }
            if (currentStage is Stage.One)
            {
                statusIcon.Image = Properties.Resources.usb;

                await ESPConnection.GenerateInitialSignatureAsync();

                ESPConnection.OnConnect += ESPConnection_OnConnect;
                ESPConnection.BeginSearchingAsync();

                progressStrip.Mode = ProgressStrip.ControlMode.Marquee;
                return;
            }
            if (currentStage is Stage.Two)
            {
                ESPConnection.OnConnect -= ESPConnection_OnConnect;
                return;
            }
            if (currentStage is Stage.Three)
            {
                statusIcon.Image = Properties.Resources.network;

                progressStrip.Mode = ProgressStrip.ControlMode.Marquee;
                bool result = await DriverHelper.DownloadFileAsync(DriverHelper.ImageURI.DEAUTH, "image.bin");

                progressStrip.Mode = ProgressStrip.ControlMode.Regular;

                if (result)
                {
                    btnProceed_Click(source, ev);
                }
                else
                {
                    btnFail_Click(source, ev);
                }

                return;
            }
            if (currentStage is Stage.Four)
            {
                statusIcon.Image = Properties.Resources.icon_32;

                progressStrip.Mode = ProgressStrip.ControlMode.Marquee;
                await ESPFlasher.WipeDeviceAsync();

                bool result = await ESPFlasher.FlashDeviceAsync("image.bin");

                progressStrip.Mode = ProgressStrip.ControlMode.Regular;

                if (result)
                {
                    btnProceed_Click(source, ev);
                }
                else
                {
                    btnFail_Click(source, ev);
                }

                return;
            }
        }