private void Form2_FormClosed(object sender, FormClosedEventArgs e)
        {
            // Ensure that you correctly disconnect from the tablet, otherwise you are
            // likely to get errors when wanting to connect a second time.
            if (m_tablet != null)
            {
                m_tablet.onGetReportException -= new wgssSTU.ITabletEvents2_onGetReportExceptionEventHandler(onGetReportException);

                m_tablet.onPenData          -= new wgssSTU.ITabletEvents2_onPenDataEventHandler(onPenData);
                m_tablet.onPenDataEncrypted -= new wgssSTU.ITabletEvents2_onPenDataEncryptedEventHandler(onPenDataEncrypted);

                m_tablet.onPenDataTimeCountSequence          -= new wgssSTU.ITabletEvents2_onPenDataTimeCountSequenceEventHandler(onPenDataTimeCountSequence);
                m_tablet.onPenDataTimeCountSequenceEncrypted -= new wgssSTU.ITabletEvents2_onPenDataTimeCountSequenceEncryptedEventHandler(onPenDataTimeCountSequenceEncrypted);


                m_tablet.onGetReportException -= new wgssSTU.ITabletEvents2_onGetReportExceptionEventHandler(onGetReportException);

                m_tablet.setInkingMode(0x00);

                // We have to disable encryption before sending any image to the pad (even just to clear it)
                if (m_useEncryption)
                {
                    m_tablet.endCapture();
                }

                m_tablet.setClearScreen();
                m_tablet.disconnect();
            }

            m_penInk.Dispose();
        }
        private bool disconnectB(bool repeat = false)
        {
            bool previousWarning = false;

            if (dispatcherTimer.IsEnabled)
            {
                previousWarning = true;
                dispatcherTimer.Stop();
            }
            bool ret = false; //this means everything is OK

            if (null != m_tablet)
            {
                if (m_tablet.isConnected())
                {
                    try
                    {
                        m_tablet.disconnect();
                        if (previousWarning)
                        {
                            SetWarning(false);
                        }
                    }
                    catch (Exception e)
                    {
                        ret = true;
                        if (DebugInfo.IsDebuggerAttached())
                        {
                            MessageBoxResult result = MessageBox.Show("Error disconnecting from a Pad. Exception: " + e.ToString(),
                                                                      "Confirmation", MessageBoxButton.OK, MessageBoxImage.Question);
                        }
                        if (repeat)
                        {
                            RemoveHandlers(dispatcherTimer);
                            dispatcherTimer.Tick += delegate { disconnectB(repeat); };
                            dispatcherTimer.Start();
                            if (!previousWarning)
                            {
                                SetWarning(true);
                            }
                        }
                    }
                }
                else
                {
                    if (previousWarning)
                    {
                        SetWarning(false);
                    }
                }
            }
            return(ret);
        }
Beispiel #3
0
        private void Form2_FormClosed(object sender, FormClosedEventArgs e)
        {
            // Ensure that you correctly disconnect from the tablet, otherwise you are
            // likely to get errors when wanting to connect a second time.
            if (m_tablet != null)
            {
                m_tablet.onPenData            -= new wgssSTU.ITabletEvents2_onPenDataEventHandler(onPenData);
                m_tablet.onGetReportException -= new wgssSTU.ITabletEvents2_onGetReportExceptionEventHandler(onGetReportException);

                m_tablet.setInkingMode(0x00);
                m_tablet.setClearScreen();
                m_tablet.disconnect();
            }

            m_penInk.Dispose();
        }