Example #1
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case user32.WM_COPYDATA:
            {
                string text = WinMsg.ReceiveText(m.LParam);
                if (text.CompareNoCase(Strings.VScan_DesktopUnlock))
                {
                    DialogResult = DialogResult.OK;
                    if (Unlocked != null)
                    {
                        Unlocked(this, EventArgs.Empty);
                    }
                    ms_Thread = null;
                    ms_This   = IntPtr.Zero;
                    Application.ExitThread();
                }
                else
                {
                    Message = text;
                    Invalidate();
                }
            }
            break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
Example #2
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case user32.WM_COPYDATA:
            {
                IntPtr sender;
                string text = WinMsg.ReceiveText(m.LParam, out sender);
                if (text.CompareNoCase(Strings.VScan_StopTheScanner))
                {
                    Close();
                }
            }
            break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
Example #3
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case user32.WM_COPYDATA:
            {
                string text = WinMsg.ReceiveText(m.LParam);
                if (text.CompareNoCase(Strings.VScan_SinglentonFormClose))
                {
                    DialogResult = DialogResult.OK;
                    OnClosed(EventArgs.Empty);
                    Application.ExitThread();
                }
            }
            break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
Example #4
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case user32.WM_COPYDATA:
            {
                string text = WinMsg.ReceiveText(m.LParam);
                if (text.CompareNoCase(Strings.VScan_SinglentonFormClose))
                {
                    DialogResult = DialogResult.OK;
                    OnClosed(EventArgs.Empty);
                    Application.ExitThread();
                }
                else if (text.StartsWith(Strings.VScan_EditItem))
                {
                    var data = DataSlot.Get <Voucher>(text);
                    Debug.Assert(data != null);
                    MoveImage((Bitmap)data.VoucherImage.Clone());
                    DataSlot.Free(text);
                }
                else if (text.StartsWith(Strings.VScan_ItemSaved))
                {
                    var data = DataSlot.Get <Voucher>(text);
                    Debug.Assert(data != null);
                    MoveImage((Bitmap)data.VoucherImage.Clone());
                    DataSlot.Free(text);
                }

                if (tsmiShowNumber.Checked)
                {
                    this.TitleBar.TitleBarCaption = "Voucher monitor ".concat(SettingsTable.Get <int>(Strings.VScan_ScanCount, 0));
                }
            }
            break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
Example #5
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case user32.WM_COPYDATA:
            {
                //The scaning Form sends ready status
                //Get image from appslot
                IntPtr sender;
                string text = WinMsg.ReceiveText(m.LParam, out sender);
                if (!string.IsNullOrEmpty(text))
                {
                    if (text.StartsWith(Strings.VScan_EditItem))
                    {
                        new MethodInvoker(() =>
                            {
                                const int MAX_OPENED_FORMS = 5;
                                int openedForms            = ScanAppContext.Default.OpenFormsOf <VoucherForm>().Count();
                                int settings = SettingsTable.Get <int>(Strings.VScan_MaximumOpenedScanForms, MAX_OPENED_FORMS);
                                if (openedForms > settings)
                                {
                                    WinMsg.SendText(sender, Strings.VScan_StopTheScanner);
                                    throw new AppExclamationException("Too many opened windows in editor.\nStop scanning.");
                                }
                            }).FireAndForget();

                        var data = DataSlot.Get <Voucher>(text);
                        Debug.Assert(data != null && data.VoucherImage != null && !string.IsNullOrEmpty(data.Message),
                                     "MainForm.WndProc");
                        try
                        {
                            VoucherForm form = AddNewChild();
                            form.Canvas.Update(data);
                        }
                        finally
                        {
                            if (VoucherMonitorForm.IsStarted)
                            {
                                VoucherMonitorForm.ShowImage(text);
                            }
                            DataSlot.Free(text);
                        }
                    }
                    else if (text.StartsWith(Strings.VScan_ItemSaved))
                    {
                        string[] msgs = text.Split('|');
                        if (msgs.Length > 1)
                        {
                            tssLabel1.Text = msgs[0];
                            tssLabel2.Text = msgs[1];
                        }

                        if (VoucherMonitorForm.IsStarted)
                        {
                            VoucherMonitorForm.ShowImage(text);
                        }
                        DataSlot.Free(text);
                    }
                    else if (text.CompareNoCase(Strings.VScan_ScanIsDoneEvent))
                    {
                        WaitForm.Stop(this);
                    }
                    else if (string.Compare(text, Strings.Transferring_RemoteLock) == 0)
                    {
                        Lock();
                    }
                }
            }
            break;

            default:
                base.WndProc(ref m);
                break;
            }
        }