예제 #1
0
        private void m_buttonFile_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog fileDialog = new OpenFileDialog
                {
                    Multiselect     = false,
                    CheckFileExists = true,
                    DefaultExt      = ".txt",
                    Filter          = ResString.GetEnumDisplayName(typeof(FileFilter), FileFilter.Txt)
                };
                if (fileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    string path = fileDialog.FileName;

                    if (!File.Exists(path) ||
                        numHBIndexW.SelectedIndex < 0 ||
                        headList.All(head => { return(!head.Checked); }) ||
                        abList.All(cbk => { return(!cbk.Checked); }))
                    {
                        MessageBox.Show(@"Input is wrong.");
                        return;
                    }
                    groupBox4.Enabled = false;
                    int             hbindex       = numHBIndexW.SelectedIndex;
                    string          info          = "";
                    HEAD_BOARD_TYPE headBoardType = (HEAD_BOARD_TYPE)CoreInterface.get_HeadBoardType(true);
                    byte[]          wfdata;
                    if (m_printerProperty.ePrinterHead == PrinterHeadEnum.Kyocera_KJ4A_RH06 || m_printerProperty.ePrinterHead == PrinterHeadEnum.Kyocera_KJ4B_YH06_5pl)
                    {
                        wfdata = PubFunc.GetAllDataFromFileKyocera_KJ4A_RH06_Des(path, ref info);
                        //wfdata = PubFunc.GetAllDataFromFileKyocera_KJ4A_RH06(m_UpdaterFileName);
                    }
                    else
                    {
                        wfdata = PubFunc.GetAllDataFromFileKyocera_Des(path, ref info);
                        //wfdata = PubFunc.GetAllDataFromFileKyocera(m_UpdaterFileName);
                    }
                    if (null == wfdata)
                    {
                        if (info == "")
                        {
                            MessageBox.Show("wavefrom file error!");
                            return;
                        }
                        else
                        {
                            MessageBox.Show(info);
                            return;
                        }
                    }
                    Task.Factory.StartNew(new Action(() =>
                    {
                        downloadEvent.Reset();
                        for (int i = 0; i < headList.Count; i++)
                        {
                            for (int j = 0; j < abList.Count; j++)
                            {
                                if (headList[i].Checked && abList[j].Checked)
                                {
                                    ColorEnum type = ColorEnum.Cyan;//(ColorEnum)(Enum.Parse(typeof(ColorEnum), m_Ctrls.InkGroupers[i].Text));
                                    Decimal saveID = hbindex * 8 + i * 2 + j;
                                    if (m_printerProperty.ePrinterHead == PrinterHeadEnum.Kyocera_KJ4A_TA06_6pl ||
                                        m_printerProperty.ePrinterHead == PrinterHeadEnum.Kyocera_KJ4A_RH06 ||
                                        m_printerProperty.ePrinterHead == PrinterHeadEnum.Kyocera_KJ4B_YH06_5pl ||
                                        m_printerProperty.ePrinterHead == PrinterHeadEnum.Kyocera_KJ4B_QA06_5pl ||
                                        m_printerProperty.ePrinterHead == PrinterHeadEnum.Kyocera_KJ4A_AA06_3pl)
                                    {
                                        saveID = hbindex * 4 + i;
                                    }
                                    //m_nHeadId = (int)saveID;
                                    {
                                        UpdateCoreBoard(wfdata, type, (byte)saveID);
                                        //progressBarStatu.Maximum = ++nCount;
                                    }
                                    downloadEvent.WaitOne();
                                    downloadEvent.Reset();
                                }
                            }
                        }
                        MessageBox.Show(@"Download complete");
                    }));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }