Пример #1
0
        /// <summary>
        /// Returns the default digitizing context, with useful context overrides.
        /// </summary>
        /// <param name="options_I">caller's options; OR'd into context options</param>
        /// <returns>A valid context object or null on error.</returns>
        public static WContext GetDefaultDigitizingContext(ECTXOptionValues options_I = 0)
        {
            // Send all possible data bits (not including extended data).
            // This is redundant with CWintabContext initialization, which
            // also inits with PK_PKTBITS_ALL.
            uint PACKETDATA = (uint)EWintabPacketBit.PK_PKTBITS_ALL;              // The Full Monty
            uint PACKETMODE = (uint)EWintabPacketBit.PK_BUTTONS;

            WContext context = GetDefaultContext(EWTICategoryIndex.WTI_DEFCONTEXT);

            if (context != null)
            {
                // Add digitizer-specific context tweaks.
                context.PktMode = 0;                        // all data in absolute mode (set EWintabPacketBit bit(s) for relative mode)
                context.SysMode = false;                    // system cursor tracks in absolute mode (zero)

                // Add caller's options.
                context.Options |= (uint)options_I;

                // Set the context data bits.
                context.PktData   = PACKETDATA;
                context.PktMode   = PACKETMODE;
                context.MoveMask  = PACKETDATA;
                context.BtnUpMask = context.BtnDnMask;
            }

            return(context);
        }
Пример #2
0
        /// <summary>
        /// Returns the default system context, with useful context overrides.
        /// </summary>
        /// <returns>A valid context object or null on error.</returns>
        public static WContext GetDefaultSystemContext(ECTXOptionValues options_I = 0)
        {
            // Send all possible data bits (not including extended data).
            // This is redundant with CWintabContext initialization, which
            // also inits with PK_PKTBITS_ALL.
            uint PACKETDATA = (uint)EWintabPacketBit.PK_PKTBITS_ALL;              // The Full Monty
            uint PACKETMODE = (uint)EWintabPacketBit.PK_BUTTONS;

            WContext context = GetDefaultContext(EWTICategoryIndex.WTI_DEFSYSCTX);

            if (context != null)
            {
                // TODO: Add system-specific context tweaks.

                // Add caller's options.
                context.Options |= (uint)options_I;

                // Make sure we get data packet messages.
                context.Options |= (uint)ECTXOptionValues.CXO_MESSAGES;

                // Set the context data bits.
                context.PktData   = PACKETDATA;
                context.PktMode   = PACKETMODE;
                context.MoveMask  = PACKETDATA;
                context.BtnUpMask = context.BtnDnMask;
            }

            return(context);
        }
Пример #3
0
        /// <summary>
        /// Initialize this data object.
        /// </summary>
        /// <param name="context_I">logical context for this data object</param>
        private void Init(WContext context_I)
        {
            try {
                if (context_I == null)
                {
                    throw new Exception("Trying to init CWintabData with null context.");
                }
                m_context = context_I;

                // Watch for the Wintab WT_PACKET event.
                WMessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKET);
            } catch (Exception ex) {
                throw new Exception("FAILED CWintabData.Init: " + ex.ToString());
            }
        }
Пример #4
0
        /// <summary>
        /// Helper function to get digitizing or system default context.
        /// </summary>
        /// <param name="contextType_I">Use WTI_DEFCONTEXT for digital context or WTI_DEFSYSCTX for system context</param>
        /// <returns>Returns the default context or null on error.</returns>
        private static WContext GetDefaultContext(EWTICategoryIndex contextIndex_I)
        {
            WContext context = new WContext();
            IntPtr   buf     = WMemUtils.AllocUnmanagedBuf(context.LogContext);

            try {
                int size = (int)WNativeMethods.WTInfo((uint)contextIndex_I, 0, buf);

                context.LogContext = WMemUtils.MarshalUnmanagedBuf <WintabLogContext>(buf, size);
            } catch (Exception ex) {
                throw new Exception("FAILED GetDefaultContext: " + ex.ToString());
            }

            WMemUtils.FreeUnmanagedBuf(buf);

            return(context);
        }
Пример #5
0
 /// <summary>
 /// CWintabData constructor
 /// </summary>
 /// <param name="context_I">logical context for this data object</param>
 public WData(WContext context_I)
 {
     Init(context_I);
 }