예제 #1
0
파일: Form1.cs 프로젝트: 6555355/Scan_yan1
        private void ProceedKernelMessage(IntPtr wParam, IntPtr lParam)
        {
            CoreMsgEnum kParam = (CoreMsgEnum)wParam.ToInt64();

            switch (kParam)
            {
            case CoreMsgEnum.UpdaterPercentage:
            {
                int percentage = (int)lParam.ToInt64();
                //OnPrintingProgressChanged(percentage);
                string info            = "";
                string mPrintingFormat = ResString.GetUpdatingProgress();
                info += "\n" + string.Format(mPrintingFormat, percentage);
                this.m_StatusBarPanelPercent.Text = info;
                break;
            }

            case CoreMsgEnum.Percentage:
            {
                int percentage = (int)lParam.ToInt64();
                OnPrintingProgressChanged(percentage);

                break;
            }

            case CoreMsgEnum.Job_Begin:
            {
                int startType = (int)lParam.ToInt64();

                if (startType == 0)
                {
                }
                else if (startType == 1)
                {
                    //OnPrintingStart();
                }

                break;
            }

            case CoreMsgEnum.Job_End:
            {
                int endType = (int)lParam.ToInt64();

                if (endType == 0)
                {
                }
                else if (endType == 1)
                {
                    //OnPrintingEnd();
                }

                break;
            }

            case CoreMsgEnum.Power_On:
            {
                int bPowerOn = (int)lParam.ToInt64();
                if (bPowerOn != 0)
                {
                    int bPropertyChanged, bSettingChanged;
                    SPrinterProperty sPrinterProperty;
                    SPrinterSetting  sPrinterSetting;

                    m_allParam.PowerOnEvent(out bPropertyChanged, out bSettingChanged, out sPrinterProperty, out sPrinterSetting);
                    if (bPropertyChanged != 0)
                    {
                        OnPrinterPropertyChange(sPrinterProperty);
                    }
                    if (bSettingChanged != 0)
                    {
                        OnPrinterSettingChange(sPrinterSetting);
                    }
                }
                else
                {
                    m_allParam.PowerOffEvent();
                }
                break;
            }

            case CoreMsgEnum.Status_Change:
            {
                int status = (int)lParam.ToInt64();
                OnPrinterStatusChanged((JetStatusEnum)status);
                break;
            }

            case CoreMsgEnum.ErrorCode:
            {
                OnErrorCodeChanged((int)lParam.ToInt64());
                //For Updateing
                int        errorcode  = (int)lParam.ToInt64();
                SErrorCode serrorcode = new SErrorCode(errorcode);
                ErrorCause cause      = (ErrorCause)serrorcode.nErrorCause;
                if (cause == ErrorCause.CoreBoard && (ErrorAction)serrorcode.nErrorAction == ErrorAction.Updating)
                {
                    if (0 != serrorcode.n16ErrorCode)
                    {
                        if (serrorcode.n16ErrorCode == 1)
                        {
                            string info = ResString.GetEnumDisplayName(typeof(UISuccess), UISuccess.UpdateSuccess);
                            MessageBox.Show(info, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            string info = ResString.GetEnumDisplayName(typeof(UIError), UIError.UpdateFail);
                            MessageBox.Show(info, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
#if !LIYUUSB
                        CoreInterface.SendJetCommand((int)JetCmdEnum.ClearUpdatingStatus, 0);
#endif
                    }
                }

                break;
            }

            case CoreMsgEnum.Parameter_Change:
            {
                //m_LockUpdate = true;
                SPrinterSetting sPrinterSetting = m_allParam.PrinterSetting;
                if (CoreInterface.GetPrinterSetting(ref sPrinterSetting) == 0)
                {
                    Debug.Assert(false);
                }
                else
                {
                    OnPrinterSettingChange(sPrinterSetting);
                }
                //m_LockUpdate = false;
                break;
            }

            case CoreMsgEnum.Ep6Pipe:
            {
                int    ep6Cmd = (int)lParam.ToInt64() & 0x0000ffff;
                int    index  = (((int)lParam.ToInt64()) >> 16);
                byte[] bufep6 = null;
                int    buflen = 0;
                int    ret    = (CoreInterface.GetEp6PipeData(ep6Cmd, index, bufep6, ref buflen));
                if (ret != 0 && buflen > 0)
                {
                    bufep6 = new byte[buflen];
                    if (CoreInterface.GetEp6PipeData(ep6Cmd, index, bufep6, ref buflen) != 0)
                    {
                        switch (bufep6[0])
                        {
                        case 0xD4:
                            if (QRCodeForm != null)
                            {
                                QRCodeForm.SetQrCode(bufep6);
                            }
                            break;

                        case 0xD3:
                            if (QRCodeForm != null)
                            {
                                QRCodeForm.FeedBack(bufep6);
                            }
                            break;

                        case 0xE6:
                            if (QRCodeForm != null)
                            {
                                QRCodeForm.SetQrCodeFromHead(bufep6);
                            }
                            break;
                        }
                    }
                    else
                    {
                        MessageBox.Show(ResString.GetResString("GetEp6PipeDatafail"));
                    }
                }
                //else
                //{
                //    MessageBox.Show("GetEp6PipeData  buflen fail!");
                //}
            }
            break;
            }
        }