/// <summary> /// Returns one packet of Wintab data from the packet queue. /// </summary> /// <param name="hCtx_I">Wintab context to be used when asking for the data</param> /// <param name="pktID_I">Identifier for the tablet event packet to return.</param> /// <returns>Returns a data packet with non-null context if successful.</returns> public WintabPacket GetDataPacket(HCTX hCtx_I, UInt32 pktID_I) { IntPtr buf = CMemUtils.AllocUnmanagedBuf(Marshal.SizeOf(typeof(WintabPacket))); WintabPacket packet = new WintabPacket(); if (pktID_I == 0) { throw new Exception("GetDataPacket - invalid pktID"); } CheckForValidHCTX("GetDataPacket"); if (CWintabFuncs.WTPacket(hCtx_I, pktID_I, buf)) { packet = (WintabPacket)Marshal.PtrToStructure(buf, typeof(WintabPacket)); } else { // // If fails, make sure context is zero. // packet.pkContext = HCTX.Zero; } CMemUtils.FreeUnmanagedBuf(buf); return(packet); }
/// <summary> /// Returns one packet of Wintab data from the packet queue. /// </summary> /// <param name="hCtx_I">Wintab context to be used when asking for the data</param> /// <param name="pktID_I">Identifier for the tablet event packet to return.</param> /// <returns>Returns a data packet with non-null context if successful.</returns> public WintabPacket GetDataPacket(UInt32 hCtx_I, UInt32 pktID_I) { IntPtr buf = CMemUtils.AllocUnmanagedBuf(Marshal.SizeOf(typeof(WintabPacket))); WintabPacket packet = new WintabPacket(); if (pktID_I == 0) { throw new Exception("GetDataPacket - invalid pktID"); } CheckForValidHCTX("GetDataPacket"); if (CWintabFuncs.WTPacket(hCtx_I, pktID_I, buf)) { packet = (WintabPacket)Marshal.PtrToStructure(buf, typeof(WintabPacket)); } else { // // If fails, make sure context is zero. // packet.pkContext = 0; } /** * PERFORMANCE FIX: without this line, the memory consume of .NET apps increase * exponentially when the PEN is used for long time (or worse when the pen is leaved alone on the tablet screen) * causing the app to crash now or later... * Author: Alessandro del Gobbo ([email protected]) */ CMemUtils.FreeUnmanagedBuf(buf); return(packet); }
/// <summary> /// Returns one packet of WintabPacketExt data from the packet queue. /// </summary> /// <param name="hCtx_I">Wintab context to be used when asking for the data</param> /// <param name="pktID_I">Identifier for the tablet event packet to return.</param> /// <returns>Returns a data packet with non-null context if successful.</returns> public WintabPacketExt GetDataPacketExt(UInt32 hCtx_I, UInt32 pktID_I) { int size = (int)(Marshal.SizeOf(new WintabPacketExt())); IntPtr buf = CMemUtils.AllocUnmanagedBuf(size); WintabPacketExt[] packets = null; try { bool status = false; if (pktID_I == 0) { throw new Exception("GetDataPacket - invalid pktID"); } CheckForValidHCTX("GetDataPacket"); status = CWintabFuncs.WTPacket(hCtx_I, pktID_I, buf); if (status) { packets = CMemUtils.MarshalDataExtPackets(1, buf); } else { // If fails, make sure context is zero. packets[0].pkBase.nContext = 0; } } catch (Exception ex) { MessageBox.Show("FAILED GetDataPacketExt: " + ex.ToString()); } /** * PERFORMANCE FIX: without this line, the memory consume of .NET apps increase * exponentially when the PEN is used for long time (or worse when the pen is leaved alone on the tablet screen) * causing the app to crash now or later... * Author: Alessandro del Gobbo ([email protected]) */ CMemUtils.FreeUnmanagedBuf(buf); return(packets[0]); }
/// <summary> /// Returns one packet of WintabPacketExt data from the packet queue. /// </summary> /// <param name="hCtx_I">Wintab context to be used when asking for the data</param> /// <param name="pktID_I">Identifier for the tablet event packet to return.</param> /// <returns>Returns a data packet with non-null context if successful.</returns> public WintabPacketExt GetDataPacketExt(HCTX hCtx_I, UInt32 pktID_I) { int size = (int)(Marshal.SizeOf(new WintabPacketExt())); IntPtr buf = CMemUtils.AllocUnmanagedBuf(size); WintabPacketExt[] packets = null; try { bool status = false; if (pktID_I == 0) { throw new Exception("GetDataPacket - invalid pktID"); } CheckForValidHCTX("GetDataPacket"); status = CWintabFuncs.WTPacket(hCtx_I, pktID_I, buf); if (status) { packets = CMemUtils.MarshalDataExtPackets(1, buf); } else { // If fails, make sure context is zero. packets[0].pkBase.nContext = HCTX.Zero; } } catch (Exception ex) { MessageBox.Show("FAILED GetDataPacketExt: " + ex.ToString()); } CMemUtils.FreeUnmanagedBuf(buf); return(packets[0]); }