Exemple #1
0
        private void saveSinglePanelWifiData(string pSavePath)
        {
            LedPanel selectedPanel = formMain.ledsys.SelectedPanel;

            if (selectedPanel == null)
            {
                MessageBox.Show(formMain.ML.GetStr("NETCARD_message_Save_Failed"));
                return;
            }
            ProcessWiFi processWiFi = new ProcessWiFi();

            processWiFi.PanelBytes       = selectedPanel.ToBytes();
            processWiFi.TimerSwitchBytes = selectedPanel.TimerSwitch.ToBytes();
            processWiFi.LuminanceBytes   = selectedPanel.Luminance.ToBytes();
            processWiFi.BmpDataBytes     = selectedPanel.ToItemBmpDataBytes();
            processWiFi.ItemBytes        = selectedPanel.ToItemBytes();
            protocol_data_integration protocol_data_integration = new protocol_data_integration();

            byte[] array = protocol_data_integration.WritingData_WIFI_Pack(processWiFi);
            if (array != null)
            {
                FileStream fileStream = new FileStream(pSavePath, FileMode.Create);
                fileStream.Write(array, 0, array.Length);
                fileStream.Close();
                MessageBox.Show(formMain.ML.GetStr("NETCARD_message_Save_Successed"));
                base.Close();
                return;
            }
            MessageBox.Show(formMain.ML.GetStr("NETCARD_message_Save_Failed"));
        }
Exemple #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     this.tmrUsb.Stop();
     try
     {
         this.btnSave.Enabled = false;
         this.lblUsbHint.Text = formMain.ML.GetStr("USB_SavingData");
         Thread.Sleep(500);
         this.lblUsbHint.ForeColor = System.Drawing.Color.Black;
         if (this.cboUsb.SelectedIndex == -1)
         {
             MessageBox.Show(this, formMain.ML.GetStr("Prompt_NoFlashDisk"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
         }
         else
         {
             this.panel.ButtonFunctionType = (LedButtonFunctionType)this.cboOption.SelectedIndex;
             base.Enabled = false;
             ProcessUSB processUSB = new ProcessUSB();
             processUSB.PanelBytes          = this.panel.ToLBytes();
             processUSB.ButtonFunctionBytes = this.panel.ToButtonFunctionBytes();
             processUSB.ProtocolVersion     = (byte)this.panel.GetProtocolType();
             protocol_data_integration protocol_data_integration = new protocol_data_integration();
             byte[] array = protocol_data_integration.WritingData_USB_Pack(processUSB, false, true);
             if (array == null)
             {
                 base.Enabled = true;
                 this.lblUsbHint.ForeColor = System.Drawing.Color.Red;
                 this.lblUsbHint.Text      = formMain.ML.GetStr("USB_Save_Failed");
                 this.btnSave.Enabled      = true;
                 Thread.Sleep(1000);
                 this.tmrUsb.Start();
                 this.LastMessage = "save";
             }
             else if (array.Length > this.panel.GetFlashCapacity())
             {
                 MessageBox.Show(this, formMain.ML.GetStr("Prompt_MemeoryOverSize"));
                 base.Enabled         = true;
                 this.btnSave.Enabled = true;
                 Thread.Sleep(1000);
                 this.tmrUsb.Start();
                 this.LastMessage = "save";
             }
             else
             {
                 int i = 10;
                 while (i > 0)
                 {
                     try
                     {
                         i--;
                         FileStream fileStream = new FileStream(this.UsbDeviceList[this.cboUsb.SelectedIndex] + "ledV3.zh3", FileMode.Create, FileAccess.Write);
                         fileStream.Write(array, 0, array.Length);
                         fileStream.Close();
                         break;
                     }
                     catch (Exception ex)
                     {
                         if (i == 0)
                         {
                             this.btnSave.Enabled      = true;
                             this.lblUsbHint.ForeColor = System.Drawing.Color.Red;
                             this.lblUsbHint.Text      = formMain.ML.GetStr("USB_Save_Failed") + "(" + ex.Message + ")";
                             base.Enabled = true;
                             Thread.Sleep(1000);
                             this.tmrUsb.Start();
                             this.LastMessage = "save";
                             return;
                         }
                         Thread.Sleep(200);
                     }
                 }
                 Thread.Sleep(500);
                 if (!File.Exists(this.UsbDeviceList[this.cboUsb.SelectedIndex] + "\\ledV3.zh3"))
                 {
                     MessageBox.Show(this, formMain.ML.GetStr("Prompt_DataDownloadFailed"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
                 }
                 this.lblUsbHint.ForeColor = System.Drawing.Color.Blue;
                 this.lblUsbHint.Text      = formMain.ML.GetStr("USB_Save_Success");
                 this.btnSave.Enabled      = true;
                 base.Enabled = true;
                 Thread.Sleep(1000);
                 this.tmrUsb.Start();
                 this.LastMessage = "save";
             }
         }
     }
     catch (Exception ex2)
     {
         this.btnSave.Enabled      = true;
         this.lblUsbHint.ForeColor = System.Drawing.Color.Red;
         this.lblUsbHint.Text      = formMain.ML.GetStr("USB_Save_Failed") + "(" + ex2.Message + ")";
         base.Enabled = true;
         Thread.Sleep(1000);
         this.tmrUsb.Start();
         this.LastMessage = "save";
     }
 }
Exemple #3
0
 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");
     }
 }
        private void btnCloudServerSave_Click(object sender, EventArgs e)
        {
            this.tmrUsb.Stop();
            string text = this.txtCloudServerUserName.Text;

            if (string.IsNullOrEmpty(text))
            {
                MessageBox.Show(this, formMain.ML.GetStr("Message_CloudServer_UserName_Cannot_Be_Empty"));
                this.txtCloudServerUserName.Focus();
                this.tmrUsb.Start();
                return;
            }
            if (Encoding.Default.GetByteCount(text) > 30)
            {
                MessageBox.Show(this, formMain.ML.GetStr("Message_CloudServer_UserName_Cannot_Be_More_Than_30_Characters"));
                this.txtCloudServerUserName.Focus();
                this.tmrUsb.Start();
                return;
            }
            bool flag = true;

            for (int i = 0; i < text.Length; i++)
            {
                int num = (int)text[i];
                if (num > 127 || num < 8 || (num > 8 && num < 21))
                {
                    flag = false;
                    break;
                }
            }
            if (!flag)
            {
                MessageBox.Show(this, formMain.ML.GetStr("Message_CloudServer_UserName_Can_Only_Support_Alphabet_Numbers_And_Special_Characters"));
                this.txtCloudServerUserName.Focus();
                this.tmrUsb.Start();
                return;
            }
            string text2 = this.txtAPN.Text;

            if (this.chkAPN.Checked)
            {
                if (string.IsNullOrEmpty(text2))
                {
                    MessageBox.Show(this, formMain.ML.GetStr("Message_APN_Cannot_Be_Empty"));
                    this.txtAPN.Focus();
                    this.tmrUsb.Start();
                    return;
                }
                if (Encoding.Default.GetByteCount(text2) > 31)
                {
                    MessageBox.Show(this, formMain.ML.GetStr("Message_APN_Cannot_Be_More_Than_31_Characters"));
                    this.txtAPN.Focus();
                    this.tmrUsb.Start();
                    return;
                }
                bool flag2 = true;
                for (int j = 0; j < text2.Length; j++)
                {
                    int num2 = (int)text2[j];
                    if (num2 > 122 || num2 < 46 || (num2 > 46 && num2 < 48) || (num2 > 57 && num2 < 65) || (num2 > 90 && num2 < 97))
                    {
                        break;
                    }
                }
                if (!flag2)
                {
                    MessageBox.Show(this, formMain.ML.GetStr("Message_APN_Can_Only_Support_Alphabet_And_Decimal"));
                    this.txtAPN.Focus();
                    this.tmrUsb.Start();
                    return;
                }
            }
            try
            {
                this.btnCloudServerSave.Enabled = false;
                this.lblUsbHint.Text            = formMain.ML.GetStr("USB_SavingData");
                Thread.Sleep(500);
                this.lblUsbHint.ForeColor = System.Drawing.Color.Black;
                if (this.cboUsb.SelectedIndex == -1)
                {
                    MessageBox.Show(this, formMain.ML.GetStr("Prompt_NoFlashDisk"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
                    this.tmrUsb.Start();
                }
                else
                {
                    LedCardCommunication ledCardCommunication = new LedCardCommunication();
                    ledCardCommunication.CloudServerMode          = LedCloudServerMode.Enabled;
                    ledCardCommunication.CloudServerUserName      = text;
                    ledCardCommunication.CloudServerHeartbeatTime = 0;
                    if (this.chkAPN.Checked)
                    {
                        ledCardCommunication.GPRSAPN = text2;
                    }
                    base.Enabled = false;
                    LedCommunicationSetting ledCommunicationSetting = LedCommunicationSetting.CloudServer;
                    if (this.chkAPN.Checked)
                    {
                        ledCommunicationSetting |= LedCommunicationSetting.GPRSAPN;
                    }
                    ProcessUSB processUSB = new ProcessUSB();
                    processUSB.PanelBytes = this.panel.ToLBytes();
                    processUSB.CloudServerUserNameBytes = ledCardCommunication.ToCloudServerUserNameBytes();
                    processUSB.CommunicationBytes       = ledCardCommunication.ToCommunicationBytes(ledCommunicationSetting);
                    processUSB.ProtocolVersion          = (byte)this.panel.GetProtocolType();
                    protocol_data_integration protocol_data_integration = new protocol_data_integration();
                    byte[] array = protocol_data_integration.WritingData_USB_Pack(processUSB, false, false);
                    if (array == null)
                    {
                        base.Enabled = true;
                        this.lblUsbHint.ForeColor       = System.Drawing.Color.Red;
                        this.lblUsbHint.Text            = formMain.ML.GetStr("USB_Save_Failed");
                        this.btnCloudServerSave.Enabled = true;
                        Thread.Sleep(1000);
                        this.tmrUsb.Start();
                        this.LastMessage = "save";
                    }
                    else if (array.Length > this.panel.GetFlashCapacity())
                    {
                        MessageBox.Show(this, formMain.ML.GetStr("Prompt_MemeoryOverSize"));
                        base.Enabled = true;
                        this.btnCloudServerSave.Enabled = true;
                        Thread.Sleep(1000);
                        this.tmrUsb.Start();
                        this.LastMessage = "save";
                    }
                    else
                    {
                        int k = 10;
                        while (k > 0)
                        {
                            try
                            {
                                k--;
                                FileStream fileStream = new FileStream(this.UsbDeviceList[this.cboUsb.SelectedIndex] + "ledV3.zh3", FileMode.Create, FileAccess.Write);
                                fileStream.Write(array, 0, array.Length);
                                fileStream.Close();
                                break;
                            }
                            catch (Exception ex)
                            {
                                if (k == 0)
                                {
                                    this.btnCloudServerSave.Enabled = true;
                                    this.lblUsbHint.ForeColor       = System.Drawing.Color.Red;
                                    this.lblUsbHint.Text            = formMain.ML.GetStr("USB_Save_Failed") + "(" + ex.Message + ")";
                                    base.Enabled = true;
                                    Thread.Sleep(1000);
                                    this.tmrUsb.Start();
                                    this.LastMessage = "save";
                                    return;
                                }
                                Thread.Sleep(200);
                            }
                        }
                        Thread.Sleep(500);
                        if (!File.Exists(this.UsbDeviceList[this.cboUsb.SelectedIndex] + "\\ledV3.zh3"))
                        {
                            MessageBox.Show(this, formMain.ML.GetStr("Prompt_DataDownloadFailed"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
                        }
                        this.lblUsbHint.ForeColor       = System.Drawing.Color.Blue;
                        this.lblUsbHint.Text            = formMain.ML.GetStr("USB_Save_Success");
                        this.btnCloudServerSave.Enabled = true;
                        this.panel.CloudServerMode      = LedCloudServerMode.Enabled;
                        this.panel.CloudServerUserName  = ledCardCommunication.CloudServerUserName;
                        if (this.chkAPN.Checked)
                        {
                            this.panel.GPRSAPN = ledCardCommunication.GPRSAPN;
                        }
                        this.isModified = false;
                        base.Enabled    = true;
                        Thread.Sleep(1000);
                        this.tmrUsb.Start();
                        this.LastMessage = "save";
                    }
                }
            }
            catch (Exception ex2)
            {
                this.btnCloudServerSave.Enabled = true;
                this.lblUsbHint.ForeColor       = System.Drawing.Color.Red;
                this.lblUsbHint.Text            = formMain.ML.GetStr("USB_Save_Failed") + "(" + ex2.Message + ")";
                base.Enabled = true;
                Thread.Sleep(1000);
                this.tmrUsb.Start();
                this.LastMessage = "save";
            }
        }
        private void SendData(int index)
        {
            if (index < 0)
            {
                return;
            }
            Screen_Display_Class sdc      = formCloudGroupSending.screenSendGroup[index];
            LedPanel             panel_NO = sdc.Panel_NO;

            new DataOperating();
            DataGridViewCell dgvc         = this.dgvSendState.Rows[index].Cells[4];
            DataGridViewCell dgvcProgress = this.dgvSendState.Rows[index].Cells[5];

            sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_ReadyToSend");
            this.StateColor   = 0;
            base.Invoke(new MethodInvoker(delegate
            {
                dgvc.Value           = sdc.State_Message;
                dgvc.Style.ForeColor = this.StateOfColor(this.StateColor);
            }));
            Thread.Sleep(500);
            bool flag = false;

            if (sdc.Send_Data != null)
            {
                if (sdc.Send_Data.GetBytesLength() > panel_NO.GetFlashCapacity() && !formMain.IsforeignTradeMode)
                {
                    sdc.Fault_Message = formMain.ML.GetStr("Prompt_MemoryOverSize");
                    sdc.State_Message = formMain.ML.GetStr("Prompt_MemoryOverSize");
                    this.StateColor   = 2;
                    sdc.SendCompleted = true;
                    base.Invoke(new MethodInvoker(delegate
                    {
                        dgvc.Value           = sdc.State_Message;
                        dgvc.Style.ForeColor = this.StateOfColor(this.StateColor);
                    }));
                    return;
                }
                flag = true;
            }
            if (flag)
            {
                sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_StartSending");
                this.StateColor   = 0;
                base.Invoke(new MethodInvoker(delegate
                {
                    dgvc.Value           = sdc.State_Message;
                    dgvc.Style.ForeColor = this.StateOfColor(this.StateColor);
                }));
                Thread.Sleep(500);
                IList <byte[]> list = new protocol_data_integration().Program_Packaging_data_L(sdc.Send_Data, panel_NO.CardAddress, panel_NO.ProtocolVersion, true);
                if (list == null || list.Count == 0)
                {
                    this.failureCount++;
                    string str = formMain.ML.GetStr("Display_CommunicationFailed");
                    this.StateColor   = 2;
                    sdc.Fault_Message = str;
                    sdc.State_Message = str;
                    sdc.SendCompleted = true;
                }
                else
                {
                    int  i     = 0;
                    bool flag2 = false;
                    bool flag3 = false;
                    sdc.State_Message = formMain.ML.GetStr("Prompt_NowIsSendingData");
                    this.StateColor   = 0;
                    base.Invoke(new MethodInvoker(delegate
                    {
                        dgvc.Value           = sdc.State_Message;
                        dgvc.Style.ForeColor = this.StateOfColor(this.StateColor);
                    }));
                    Thread.Sleep(500);
                    string dataFilePath = string.Format("{0}\\Cloud\\{1}\\{2}", LedCommonConst.ProjectSaveDirectory, LedGlobal.CloudAccount.UserName, panel_NO.ID);
                    while (i < 5)
                    {
                        i++;
                        flag2 = new TransDataService().Send(LedGlobal.CloudAccount.SessionID, panel_NO.CloudID, list, dataFilePath, formMain.ML.GetStr("Message_Send_Item_Data"), ref flag3);
                        if (flag2)
                        {
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        this.failureCount++;
                        string str2 = formMain.ML.GetStr("Display_CommunicationFailed");
                        this.StateColor   = 2;
                        sdc.Fault_Message = str2;
                        sdc.State_Message = str2;
                        sdc.SendCompleted = true;
                    }
                    else
                    {
                        sdc.State_Message = formMain.ML.GetStr("Message_Upload_To_Cloud_Success");
                        if (flag3)
                        {
                            Screen_Display_Class expr_366 = sdc;
                            expr_366.State_Message = expr_366.State_Message + "," + formMain.ML.GetStr("Message_Send_Complete_By_Reviewing");
                        }
                        sdc.SendCompleted = true;
                        this.StateColor   = 1;
                        if (sdc.Send_Data != null)
                        {
                            sdc.Send_Data.Dispose();
                            sdc.Send_Data = null;
                        }
                    }
                }
                base.Invoke(new MethodInvoker(delegate
                {
                    if (this.StateColor == 1)
                    {
                        dgvcProgress.Value = 100;
                    }
                    dgvc.Value           = sdc.State_Message;
                    dgvc.Style.ForeColor = this.StateOfColor(this.StateColor);
                }));
                Thread.Sleep(500);
            }
        }
Exemple #6
0
 private void btnUSBSave_Click(object sender, EventArgs e)
 {
     this.needtoClose = false;
     this.panel.SetStringLibrary();
     this.tmrUSB.Stop();
     this.cmbFontName.Enabled            = false;
     this.cmbFontSize.Enabled            = false;
     this.cmbEncoding.Enabled            = false;
     this.chkUSBUpdate.Enabled           = false;
     this.cmbUSB.Enabled                 = false;
     this.btnUSBSave.Enabled             = false;
     this.nudWidth.Enabled               = false;
     this.nudHeight.Enabled              = false;
     this.btnVerticalStretchUp.Enabled   = false;
     this.btnVerticalStretchDown.Enabled = false;
     this.btnZoomIn.Enabled              = false;
     this.btnZoomOut.Enabled             = false;
     this.btnZoomOriginal.Enabled        = false;
     try
     {
         this.lblHint.Text = formMain.ML.GetStr("USB_SavingData");
         this.lblHint.Refresh();
         Thread.Sleep(500);
         this.isProcessString = true;
         Thread thread = new Thread(new ThreadStart(this.ProcessString));
         thread.Start();
         Thread.Sleep(100);
         while (this.isProcessString)
         {
             Application.DoEvents();
             Thread.Sleep(100);
         }
         protocol_data_integration protocol_data_integration = new protocol_data_integration();
         byte[] array = protocol_data_integration.String_Library_USB(this.processStringLibrary);
         if (array != null)
         {
             string path = string.Empty;
             if (formMain.IsforeignTradeMode)
             {
                 string text = this.panel.CardType.ToString();
                 if (text.IndexOf("ZH_5W") > -1)
                 {
                     text = "ZH-5WX";
                 }
                 else
                 {
                     text = "ZH-XXL";
                 }
                 path = this.USBDirList[this.cmbUSB.SelectedIndex] + "ZH_LED\\" + text + "\\led_data.zh";
                 Directory.CreateDirectory(this.USBDirList[this.cmbUSB.SelectedIndex] + "ZH_LED\\" + text);
             }
             else
             {
                 path = this.USBDirList[this.cmbUSB.SelectedIndex] + "ledV3.zh3";
             }
             FileStream fileStream = new FileStream(path, FileMode.Create, FileAccess.Write);
             DriveInfo  driveInfo  = new DriveInfo(this.USBDirList[this.cmbUSB.SelectedIndex]);
             if ((long)array.Length > driveInfo.TotalFreeSpace)
             {
                 this.lblHint.Text = string.Empty;
                 this.lblHint.Refresh();
                 Thread.Sleep(500);
                 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);
                 this.lblHint.Text = string.Empty;
                 this.lblHint.Refresh();
                 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.lblHint.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed");
                 }
             }
         }
         else
         {
             this.lblHint.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed");
         }
     }
     catch
     {
         this.lblHint.Text = formMain.ML.GetStr("Prompt_DataDownloadFailed");
     }
     finally
     {
         this.cmbFontName.Enabled            = true;
         this.cmbFontSize.Enabled            = true;
         this.cmbEncoding.Enabled            = true;
         this.chkUSBUpdate.Enabled           = true;
         this.cmbUSB.Enabled                 = true;
         this.btnUSBSave.Enabled             = true;
         this.nudWidth.Enabled               = true;
         this.nudHeight.Enabled              = true;
         this.btnVerticalStretchUp.Enabled   = true;
         this.btnVerticalStretchDown.Enabled = true;
         this.btnZoomIn.Enabled              = true;
         this.btnZoomOut.Enabled             = true;
         this.btnZoomOriginal.Enabled        = true;
         this.tmrUSB.Start();
         this.needtoClose = true;
     }
 }
Exemple #7
0
        public bool SaveForeignTradeModeData()
        {
            bool result;

            try
            {
                ProcessUSB processUSB = new ProcessUSB();
                processUSB.ItemStartLBytes  = this.panel.ToItemStartLBytes();
                processUSB.ItemLBytes       = this.panel.ToItemLBytes();
                processUSB.ItemTimerLBytes  = this.panel.ToItemTimerLByte();
                processUSB.TimerSwitchBytes = this.panel.TimerSwitch.ToLBytes();
                processUSB.LuminanceBytes   = this.panel.Luminance.ToLBytes();
                processUSB.ProtocolVersion  = 52;
                if (this.TimingCheckBox.Checked)
                {
                    processUSB.SetTimingBytes(this.TimingDateTimePicker.Value);
                }
                protocol_data_integration protocol_data_integration = new protocol_data_integration();
                byte[] array = protocol_data_integration.WritingData_USB_Pack(processUSB, false, true);
                processUSB.TimerSwitchBytes = null;
                processUSB.LuminanceBytes   = null;
                processUSB.PanelBytes       = this.panel.ToBytes();
                processUSB.BmpDataBytes     = this.panel.ToItemBmpDataBytes();
                processUSB.ItemBytes        = this.panel.ToItemBytes();
                processUSB.TimerSwitchBytes = this.panel.TimerSwitch.ToBytes();
                processUSB.LuminanceBytes   = this.panel.Luminance.ToBytes();
                processUSB.ProtocolVersion  = 49;
                byte[] array2 = protocol_data_integration.WritingData_USB_Pack(processUSB, false, false);
                if (array2 == null || array == null)
                {
                    this.UsbDataMessagePrompt("USB_Save_Failed", 2, System.Drawing.Color.Red);
                    result = false;
                }
                else if (array2.Length > this.panel.GetFlashCapacity() || array.Length > this.panel.GetFlashCapacity())
                {
                    this.UsbDataMessagePrompt("Prompt_MemeoryOverSize", 2, System.Drawing.Color.Red);
                    result = false;
                }
                else
                {
                    string str = this.UdiskDirList[this.UsbListComboBox.SelectedIndex];
                    Dictionary <string, byte[]> dictionary = new Dictionary <string, byte[]>();
                    Directory.CreateDirectory(str + "ZH_LED\\ZH-5WX");
                    Directory.CreateDirectory(str + "ZH_LED\\ZH-XXL");
                    string key  = str + "ZH_LED\\ZH-5WX\\led_data.zh";
                    string key2 = str + "ZH_LED\\ZH-XXL\\led_data.zh";
                    dictionary.Add(key, array2);
                    dictionary.Add(key2, array);
                    foreach (string current in dictionary.Keys)
                    {
                        int i = 10;
                        while (i > 0)
                        {
                            try
                            {
                                i--;
                                FileStream fileStream = new FileStream(current, FileMode.Create, FileAccess.Write);
                                DriveInfo  driveInfo  = new DriveInfo(this.UdiskDirList[this.UsbListComboBox.SelectedIndex]);
                                if ((long)dictionary[current].Length > driveInfo.TotalFreeSpace)
                                {
                                    fileStream.Close();
                                    this.UsbDataMessagePrompt("formUSBWrite_Message_FileOverUsbSize", 2, System.Drawing.Color.Red);
                                    result = false;
                                    return(result);
                                }
                                fileStream.Write(dictionary[current], 0, dictionary[current].Length);
                                fileStream.Close();
                                break;
                            }
                            catch
                            {
                                if (i == 0)
                                {
                                    this.UsbDataMessagePrompt("USB_Save_Failed", 2, System.Drawing.Color.Red);
                                    result = false;
                                    return(result);
                                }
                                Thread.Sleep(200);
                            }
                        }
                    }
                    Thread.Sleep(500);
                    foreach (string current2 in dictionary.Keys)
                    {
                        if (!File.Exists(current2))
                        {
                            MessageBox.Show(this, formMain.ML.GetStr("Prompt_DataDownloadFailed"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
                            result = false;
                            return(result);
                        }
                    }
                    this.UsbDataMessagePrompt("USB_Save_Success", 3, System.Drawing.Color.Blue);
                    result = true;
                }
            }
            catch
            {
                this.UsbDataMessagePrompt("USB_Save_Failed", 2, System.Drawing.Color.Red);
                result = false;
            }
            return(result);
        }
Exemple #8
0
 private void UsbSaveButton_Click(object sender, EventArgs e)
 {
     this.timer1.Stop();
     try
     {
         this.UsbSaveButton.Enabled = false;
         this.label_Remind.Text     = formMain.ML.GetStr("USB_SavingData");
         Thread.Sleep(500);
         this.label_Remind.ForeColor = System.Drawing.Color.Black;
         this.WarningLevel           = 0;
         if (this.UsbListComboBox.SelectedIndex == -1)
         {
             MessageBox.Show(this, formMain.ML.GetStr("Prompt_NoFlashDisk"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
         }
         else
         {
             base.Enabled = false;
             ProcessUSB processUSB = new ProcessUSB();
             if (this.panel.IsLSeries())
             {
                 processUSB.PanelBytes       = this.panel.ToLBytes();
                 processUSB.ItemStartLBytes  = this.panel.ToItemStartLBytes();
                 processUSB.ItemLBytes       = this.panel.ToItemLBytes();
                 processUSB.ItemTimerLBytes  = this.panel.ToItemTimerLByte();
                 processUSB.TimerSwitchBytes = this.panel.TimerSwitch.ToLBytes();
                 processUSB.LuminanceBytes   = this.panel.Luminance.ToLBytes();
             }
             else
             {
                 processUSB.PanelBytes       = this.panel.ToBytes();
                 processUSB.BmpDataBytes     = this.panel.ToItemBmpDataBytes();
                 processUSB.ItemBytes        = this.panel.ToItemBytes();
                 processUSB.TimerSwitchBytes = this.panel.TimerSwitch.ToBytes();
                 processUSB.LuminanceBytes   = this.panel.Luminance.ToBytes();
             }
             processUSB.ProtocolVersion = (byte)this.panel.GetProtocolType();
             if (this.TimingCheckBox.Checked)
             {
                 processUSB.SetTimingBytes(this.TimingDateTimePicker.Value);
             }
             protocol_data_integration protocol_data_integration = new protocol_data_integration();
             byte[] array = protocol_data_integration.WritingData_USB_Pack(processUSB, false, false);
             if (array == null)
             {
                 this.UsbDataMessagePrompt("USB_Save_Failed", 2, System.Drawing.Color.Red);
             }
             else if (array.Length > this.panel.GetFlashCapacity())
             {
                 this.UsbDataMessagePrompt("Prompt_MemeoryOverSize", 2, System.Drawing.Color.Red);
             }
             else
             {
                 int i = 10;
                 while (i > 0)
                 {
                     try
                     {
                         i--;
                         FileStream fileStream = new FileStream(this.UdiskDirList[this.UsbListComboBox.SelectedIndex] + "ledV3.zh3", FileMode.Create, FileAccess.Write);
                         DriveInfo  driveInfo  = new DriveInfo(this.UdiskDirList[this.UsbListComboBox.SelectedIndex]);
                         if ((long)array.Length > driveInfo.TotalFreeSpace)
                         {
                             fileStream.Close();
                             this.UsbDataMessagePrompt("formUSBWrite_Message_FileOverUsbSize", 2, System.Drawing.Color.Red);
                             return;
                         }
                         fileStream.Write(array, 0, array.Length);
                         fileStream.Close();
                         break;
                     }
                     catch
                     {
                         if (i == 0)
                         {
                             this.UsbDataMessagePrompt("USB_Save_Failed", 2, System.Drawing.Color.Red);
                             return;
                         }
                         Thread.Sleep(200);
                     }
                 }
                 Thread.Sleep(500);
                 if (!File.Exists(this.UdiskDirList[this.UsbListComboBox.SelectedIndex] + "\\ledV3.zh3"))
                 {
                     MessageBox.Show(this, formMain.ML.GetStr("Prompt_DataDownloadFailed"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
                 }
                 this.UsbDataMessagePrompt("USB_Save_Success", 3, System.Drawing.Color.Blue);
             }
         }
     }
     catch
     {
         this.UsbDataMessagePrompt("USB_Save_Failed", 2, System.Drawing.Color.Red);
     }
 }
Exemple #9
0
 private void UsbSaveButton_Click(object sender, EventArgs e)
 {
     this.timer1.Stop();
     try
     {
         this.UsbSaveButton.Enabled = false;
         this.label_Remind.Text     = formMain.ML.GetStr("USB_SavingData");
         Thread.Sleep(500);
         this.label_Remind.ForeColor = System.Drawing.Color.Black;
         if (this.UsbListComboBox.SelectedIndex == -1)
         {
             MessageBox.Show(this, formMain.ML.GetStr("Prompt_NoFlashDisk"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
         }
         else
         {
             LedTimeSequence ledTimeSequence = new LedTimeSequence();
             ledTimeSequence.CKCPHA          = (byte)this.nudCKCPHA.Value;
             ledTimeSequence.CKCDC           = (byte)this.nudCKCDC.Value;
             ledTimeSequence.LTDelay         = (int)this.nudLTDelay.Value;
             this.panel.TimeSequence.CKCPHA  = ledTimeSequence.CKCPHA;
             this.panel.TimeSequence.CKCDC   = ledTimeSequence.CKCDC;
             this.panel.TimeSequence.LTDelay = ledTimeSequence.LTDelay;
             this.panel.TimeSequence.Changed = true;
             base.Enabled = false;
             ProcessUSB processUSB = new ProcessUSB();
             processUSB.PanelBytes        = this.panel.ToLBytes();
             processUSB.TimeSequenceBytes = this.panel.TimeSequence.ToBytes();
             processUSB.ProtocolVersion   = this.panel.ProtocolVersion;
             protocol_data_integration protocol_data_integration = new protocol_data_integration();
             byte[] array = protocol_data_integration.WritingData_USB_Pack(processUSB, true, false);
             if (array == null)
             {
                 base.Enabled = true;
                 this.label_Remind.ForeColor = System.Drawing.Color.Red;
                 this.label_Remind.Text      = formMain.ML.GetStr("USB_Save_Failed");
                 this.UsbSaveButton.Enabled  = true;
                 Thread.Sleep(1000);
                 this.timer1.Start();
                 this.LastMessage = "save";
             }
             else if (array.Length > this.panel.GetFlashCapacity())
             {
                 MessageBox.Show(this, formMain.ML.GetStr("Prompt_MemeoryOverSize"));
                 base.Enabled = true;
                 this.UsbSaveButton.Enabled = true;
                 Thread.Sleep(1000);
                 this.timer1.Start();
                 this.LastMessage = "save";
             }
             else
             {
                 int i = 10;
                 while (i > 0)
                 {
                     try
                     {
                         i--;
                         FileStream fileStream = new FileStream(this.UdiskDirList[this.UsbListComboBox.SelectedIndex] + "ledV3.zh3", FileMode.Create, FileAccess.Write);
                         fileStream.Write(array, 0, array.Length);
                         fileStream.Close();
                         break;
                     }
                     catch (Exception ex)
                     {
                         if (i == 0)
                         {
                             this.UsbSaveButton.Enabled  = true;
                             this.label_Remind.ForeColor = System.Drawing.Color.Red;
                             this.label_Remind.Text      = formMain.ML.GetStr("USB_Save_Failed") + "(" + ex.Message + ")";
                             base.Enabled = true;
                             Thread.Sleep(1000);
                             this.timer1.Start();
                             this.LastMessage = "save";
                             return;
                         }
                         Thread.Sleep(200);
                     }
                 }
                 Thread.Sleep(500);
                 if (!File.Exists(this.UdiskDirList[this.UsbListComboBox.SelectedIndex] + "\\ledV3.zh3"))
                 {
                     MessageBox.Show(this, formMain.ML.GetStr("Prompt_DataDownloadFailed"), formMain.ML.GetStr("Display_Prompt"), MessageBoxButtons.OK);
                 }
                 this.label_Remind.ForeColor = System.Drawing.Color.Blue;
                 this.label_Remind.Text      = formMain.ML.GetStr("USB_Save_Success");
                 this.UsbSaveButton.Enabled  = true;
                 base.Enabled = true;
                 Thread.Sleep(1000);
                 this.timer1.Start();
                 this.LastMessage = "save";
             }
         }
     }
     catch (Exception ex2)
     {
         this.UsbSaveButton.Enabled  = true;
         this.label_Remind.ForeColor = System.Drawing.Color.Red;
         this.label_Remind.Text      = formMain.ML.GetStr("USB_Save_Failed") + "(" + ex2.Message + ")";
         base.Enabled = true;
         Thread.Sleep(1000);
         this.timer1.Start();
         this.LastMessage = "save";
     }
 }