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 void ClearPadB(bool isSelected) { bool previousWarning = false; bool ret = false; //false means everything went OK if (dispatcherTimer.IsEnabled) { previousWarning = true; dispatcherTimer.Stop(); } if (!m_tablet.isConnected()) { ret |= connectB(); } try { m_tablet.setClearScreen(); } catch (Exception e) { ret = true; if (DebugInfo.IsDebuggerAttached()) { MessageBoxResult result = MessageBox.Show("Error clearing Pad screen. Error value: " + e.ToString(), "Confirmation", MessageBoxButton.OK, MessageBoxImage.Question); } } if (isSelected) { ret |= disconnectB(); } if (ret) { RemoveHandlers(dispatcherTimer); dispatcherTimer.Tick += delegate { ClearPadB(isSelected); }; dispatcherTimer.Start(); if (!previousWarning) { SetWarning(true); } } else { if (previousWarning) { SetWarning(false); } } }
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(); }