Beispiel #1
0
		public TabletForm() : base()
		{
			try {
				this.Closed += new System.EventHandler(TabletFormClosed);
				this.Activated += new System.EventHandler(TabletFormActivated);
				this.Deactivate += new System.EventHandler(TabletFormDeactivate);
				
				LOGCONTEXT lc = new LOGCONTEXT();
				AXIS npAxis = new AXIS();
				bool boolResult;
				uint uintResult;
				
				/* get default settings */
				uintResult = WinTab.WTInfo(WinTab.WTI_DEFSYSCTX/*WinTab.WTI_DEFCONTEXT*/, 0, out lc);
				Log("WTInfo result = "+uintResult);
			
				/* modify settings */
				lc.lcName = "TabletForm" + this.Handle.ToString();
				lc.lcOptions |= WinTab.CXO_SYSTEM | WinTab.CXO_MESSAGES;
				if (useMessages) lc.lcOptions |= WinTab.CXO_MESSAGES;
				lc.lcMsgBase = WinTab.WT_DEFBASE;
				lc.lcPktData = WinTab.PACKETDATA;
				lc.lcPktMode = WinTab.PACKETMODE;
				lc.lcMoveMask = WinTab.PACKETDATA;
				lc.lcBtnUpMask = lc.lcBtnDnMask;
			
				/* modify output size */
				lc.lcOutOrgX = lc.lcOutOrgY = 0;
				tabletSettings.MaxX = lc.lcOutExtX = lc.lcInExtX - lc.lcInOrgX;
				tabletSettings.MaxY = lc.lcOutExtY = lc.lcInExtY - lc.lcInOrgY;
				
				/* update settings and open context */
				tabletSettings.Handle = WinTab.WTOpen(this.Handle.ToInt32(), ref lc, true);
			  			
				if (tabletSettings.Handle == 0) {
					Log("Can't init Tablet (WTOpen handle = 0)");
					throw new TabletNotFoundException("A tablet is installed but not connected");
				}
	  		    else {
	  		    	Log("Tablet initialized (WTOpen handle = "+tabletSettings.Handle+")");
	  		    	Log("lcInExtX = "+lc.lcInExtX+" lcInExtY = "+lc.lcOutExtY);
	  		    	Log("lcOutExtX = "+lc.lcOutExtX+" lcOutExtY = "+lc.lcOutExtY);
	  		    }
	  		    
	  		    uintResult = WinTab.WTInfo(WinTab.WTI_DEVICES + lc.lcDevice, WinTab.DVC_NPRESSURE, out npAxis);
	  		    Log("WTInfo result = "+uintResult);
	  		    
	  		    tabletSettings.MaxNPressure = npAxis.axMax;
	  		    Log("Tablet MaxNormalPressure = "+tabletSettings.MaxNPressure);
	
	  		    boolResult = WinTab.WTEnable(tabletSettings.Handle, true);
	  		    if (boolResult) Log("Tablet enabled");
	  		    else Log("Can't enable tablet");
	  		    
	  		    if(!useMessages) {
	  		    	tabletThread = new Thread(new ThreadStart(TabletThread));
	  		    	tabletThread.IsBackground = true;
	  		    	tabletThread.Name = "TabletThread";
	  		    	tabletThread.Priority = ThreadPriority.AboveNormal;
	  		    	tabletThread.Start();
	  		    	Log("Tablet thread started");
	  		    }
			} catch (System.DllNotFoundException ex) {
				throw new TabletNotInstalledException("No tablet installed : " + ex.Message);
			}
		}
Beispiel #2
0
 		public static extern Int32 WTOpen(Int32 hWnd, ref LOGCONTEXT lpLogCtx, Boolean fEnable);