private void formSendData_FormClosing(object sender, FormClosingEventArgs e) { if (!this.needtoClose) { e.Cancel = true; return; } try { if (this.process != null) { this.process.Dispose(); this.process = null; } if (this.processFirmware != null) { this.processFirmware.Dispose(); this.processFirmware = null; } if (this.processStringLibrary != null) { this.processStringLibrary.Dispose(); this.processStringLibrary = null; } this.isThreadReceiveEvent = false; this.isThread = false; this.tmrDaemon.Stop(); call.OnDeviceCmdReturnResult -= new EventHandler <DeviceCmdEventArgs>(this.OnDeviceCmdReturn); if (this.thrReceiveEvent != null && this.thrReceiveEvent.ThreadState == ThreadState.Stopped) { this.thrReceiveEvent = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } catch { } }
public void GenerateData() { if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 0; this.lblSendStatus.Text = formMain.ML.GetStr("Prompt_NowIsGeneratingData"); this.lblSendStatus.Refresh(); })); if (!this.isWiFiProductionTest) { Thread.Sleep(100); } if (formMain.ledsys == null) { return; } LedPanel selectedPanel = formMain.ledsys.SelectedPanel; if (selectedPanel == null) { return; } if (this.isUpdataCode) { this.processFirmware = new ProcessFirmware(); this.processFirmware.FirmwareBytes = selectedPanel.ToFirmwareBytes(false); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 100; if (this.processFirmware != null) { this.totalFrame = this.processFirmware.GetBytesFrame(); this.lblTotalFrame.Text = this.totalFrame.ToString(); this.lblTotalFrame.Refresh(); } })); Thread.Sleep(100); return; } else { if (!this.isDownloadStringLibrary) { this.process = new Process(); if (selectedPanel.IsLSeries()) { this.process.PanelBytes = selectedPanel.ToLBytes(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 30; })); if (!this.isWiFiProductionTest) { Thread.Sleep(100); } this.process.ItemTimerLBytes = selectedPanel.ToItemTimerLByte(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 50; })); if (!this.isWiFiProductionTest) { Thread.Sleep(100); } this.process.ItemStartLBytes = selectedPanel.ToItemStartLBytes(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 70; })); if (!this.isWiFiProductionTest) { Thread.Sleep(100); } this.process.ItemLBytes = selectedPanel.ToItemLBytes(); if (!this.isThread) { return; } } else { this.process.PanelBytes = selectedPanel.ToBytes(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 30; })); if (!this.isWiFiProductionTest) { Thread.Sleep(100); } this.process.BmpDataBytes = selectedPanel.ToItemBmpDataBytes(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 70; })); if (!this.isWiFiProductionTest) { Thread.Sleep(100); } this.process.ItemBytes = selectedPanel.ToItemBytes(); if (!this.isThread) { return; } } string overlengthMsg = string.Empty; bool hasContentOverlength = this.HasContentOverlength(selectedPanel, ref overlengthMsg); base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 100; if (this.process != null) { this.totalFrame = this.process.GetBytesFrame(); this.lblTotalFrame.Text = this.totalFrame.ToString(); this.lblTotalFrame.Refresh(); } if (hasContentOverlength) { MessageBox.Show(this, overlengthMsg, formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } })); if (!this.isWiFiProductionTest) { Thread.Sleep(100); } return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Style = ProgressBarStyle.Marquee; })); Thread.Sleep(100); this.processStringLibrary = new ProcessStringLibrary(); this.processStringLibrary.BmpDataBytes = selectedPanel.StringLibrary.ToBmpDataBytes(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Style = ProgressBarStyle.Blocks; this.pgbStatus.Value = 80; })); Thread.Sleep(100); this.processStringLibrary.StartBytes = selectedPanel.StringLibrary.ToBytes(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Style = ProgressBarStyle.Blocks; this.pgbStatus.Value = 90; })); Thread.Sleep(100); this.processStringLibrary.PanelBytes = selectedPanel.ToLBytes(); if (!this.isThread) { return; } base.Invoke(new MethodInvoker(delegate { this.pgbStatus.Value = 100; if (this.processStringLibrary != null) { this.totalFrame = this.processStringLibrary.GetBytesFrame(); this.lblTotalFrame.Text = this.totalFrame.ToString(); this.lblTotalFrame.Refresh(); } })); Thread.Sleep(100); return; } }
private void UsbSaveButton_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.CodeTextBox.Text)) { this.label_Remind.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed"); } else { this.panel.FirmwareFilePath = this.CodeTextBox.Text; ProcessFirmware processFirmware = new ProcessFirmware(); processFirmware.FirmwareBytes = this.panel.ToFirmwareBytes(true); if (processFirmware.FirmwareBytes == null || processFirmware.FirmwareBytes.Length == 0 || this.panel.CardType == LedCardType.Null) { this.label_Remind.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed"); } else { processFirmware.ProtocolVersion = (byte)this.panel.GetProtocolType(); protocol_data_integration protocol_data_integration = new protocol_data_integration(); byte[] array = protocol_data_integration.Upgrade_Program_USB(processFirmware); if (array != null) { string path = string.Empty; path = this.UdiskDirList[this.UsbListComboBox.SelectedIndex] + "ledV3.zh3"; FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write); DriveInfo driveInfo = new DriveInfo(this.UdiskDirList[this.UsbListComboBox.SelectedIndex]); if ((long)array.Length > driveInfo.TotalFreeSpace) { fileStream.Close(); MessageBox.Show(this, formMain.ML.GetStr("formUSBWrite_Message_FileOverUsbSize"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK); } else { fileStream.Write(array, 0, array.Length); fileStream.Close(); Thread.Sleep(500); if (File.Exists(path)) { MessageBox.Show(this, formMain.ML.GetStr("Prompt_DataDownloadSuccessed"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK); base.Close(); } else { this.label_Remind.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed"); } } } else { this.label_Remind.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed"); } } } } catch { this.label_Remind.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed"); } }