예제 #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 CWintabContext 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;

            CWintabContext 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>
        /// Write out an image to a tablet's OLED (Organic Light Emitting Diode)
        /// if supported by the tablet (eg: Intuos4).
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="imageFilePath_I">path to PNG image file</param>
        private static bool SetIcon(
            CWintabContext context_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 tabletIndex_I,
            UInt32 controlIndex_I,
            UInt32 functionIndex_I,
            String imageFilePath_I)
        {
            try
            {
                if (!CWintabExtensions.ControlPropertySetImage(
                        context_I.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_OVERRIDE_ICON,
                        imageFilePath_I))
                {
                    throw new Exception("Oops - FAILED ControlPropertySet for TABLET_PROPERTY_OVERRIDE");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Returns the default system 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 CWintabContext 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;

            CWintabContext 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);
        }
예제 #4
0
파일: CWintabData.cs 프로젝트: Bgoon/GKit
        /// <summary>
        /// Initialize this data object.
        /// </summary>
        /// <param name="context_I">logical context for this data object</param>
        private void Init(CWintabContext context_I)
        {
            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.
            MessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKET);

            // Watch for the Wintab WT_PACKETEXT event.
            MessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKETEXT);
        }
 /// <summary>
 /// Initialize this data object.
 /// </summary>
 /// <param name="context_I">logical context for this data object</param>
 private void Init(CWintabContext context_I)
 {
     try
     {
         if (context_I == null)
         {
             throw new Exception("Trying to init CWintabData with null context.");
         }
         m_context = context_I;
     }
     catch (Exception ex)
     {
         MessageBox.Show("FAILED CWintabData.Init: " + ex.ToString());
     }
 }
예제 #6
0
        private CWintabContext OpenQueryDigitizerContext()
        {
            bool           status     = false;
            CWintabContext logContext = null;

            try
            {
                // Get the default digitizing context.  Turn off events.  Control system cursor.
                logContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_SYSTEM);

                logContext.Options |= (uint)ECTXOptionValues.CXO_MESSAGES;
                logContext.Options &= ~(uint)ECTXOptionValues.CXO_SYSTEM;

                if (logContext == null)
                {
                    TraceMsg("OpenQueryDigitizerContext: FAILED to get default digitizing context.\n");
                    //System.Diagnostics.Debug.WriteLine("FAILED to get default digitizing context.");
                    return(null);
                }

                // Modify the digitizing region.
                logContext.Name = "WintabDN Query Data Context";

                //WintabAxis tabletX = CWintabInfo.GetTabletAxis(EAxisDimension.AXIS_X);
                //WintabAxis tabletY = CWintabInfo.GetTabletAxis(EAxisDimension.AXIS_Y);

                //// Output X/Y values 1-1 with tablet dimensions.
                // logContext.OutOrgX = logContext.OutOrgY = 0;
                // logContext.OutExtX = tabletX.axMax;
                // logContext.OutExtY = tabletY.axMax;

                logContext.SysOrgX = logContext.SysOrgY = 0;
                logContext.SysExtX = SystemInformation.PrimaryMonitorSize.Width;
                logContext.SysExtY = SystemInformation.PrimaryMonitorSize.Height;

                // Open the context, which will also tell Wintab to send data packets.
                status = logContext.Open();

                TraceMsg("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED") + "\n");
                //System.Diagnostics.Debug.WriteLine("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED"));
            }
            catch (Exception ex)
            {
                TraceMsg("OpenQueryDigitizerContext: ERROR : " + ex.ToString());
            }

            return(logContext);
        }
예제 #7
0
파일: CWintabInfo.cs 프로젝트: Bgoon/GKit
        /// <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 CWintabContext GetDefaultContext(EWTICategoryIndex contextIndex_I)
        {
            CWintabContext context = new CWintabContext();
            IntPtr         buf     = CMemUtils.AllocUnmanagedBuf(context.LogContext);

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

                context.LogContext = CMemUtils.MarshalUnmanagedBuf <WintabLogContext>(buf, size);
            }
            finally
            {
                CMemUtils.FreeUnmanagedBuf(buf);
            }

            return(context);
        }
예제 #8
0
        public QueryDataForm()
        {
            InitializeComponent();
            this.FormClosing += QueryDataForm_FormClosing;
            try
            {
                // Open a Wintab context that does not send Wintab data events.
                m_logContext = OpenQueryDigitizerContext();

                // Create a data object.
                m_wtData = new CWintabData(m_logContext);

                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #9
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 CWintabContext GetDefaultContext(EWTICategoryIndex contextIndex_I)
        {
            CWintabContext context = new CWintabContext();
            IntPtr         buf     = CMemUtils.AllocUnmanagedBuf(context.LogContext);

            try
            {
                int size = (int)CWintabFuncs.WTInfoA((uint)contextIndex_I, 0, buf);

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

            CMemUtils.FreeUnmanagedBuf(buf);

            return(context);
        }
예제 #10
0
        public QueryDataForm()
        {
            InitializeComponent();

            try
            {
                // Open a Wintab context that does not send Wintab data events.
                m_logContext = OpenQueryDigitizerContext();

                // Create a data object.
                m_wtData = new CWintabData(m_logContext);

                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);

                //TraceMsg("Press \"Test\" and touch pen to tablet.\n");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #11
0
        ///////////////////////////////////////////////////////////////////////

        private void QueryDataForm_FormClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                TraceMsg("QueryDataForm - Closing context...\n");
                if (m_wtData != null)
                {
                    m_wtData.RemoveWTPacketEventHandler(MyWTPacketEventHandler);
                    m_wtData = null;
                }
                if (m_logContext != null)
                {
                    m_logContext.Close();
                    m_logContext = null;
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
예제 #12
0
        /// <summary>
        /// Initialize this data object.
        /// </summary>
        /// <param name="context_I">logical context for this data object</param>
        private void Init(CWintabContext 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.
                MessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKET);

                // Watch for the Wintab WT_PACKETEXT event.
                MessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKETEXT);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED CWintabData.Init: " + ex.ToString());
            }
        }
예제 #13
0
        public QueryDataForm()
        {
            InitializeComponent();

            try
            {
                // Open a Wintab context that does not send Wintab data events.
                m_logContext = OpenQueryDigitizerContext();

                // Create a data object.
                m_wtData = new CWintabData(m_logContext);

                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);

                //TraceMsg("Press \"Test\" and touch pen to tablet.\n");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #14
0
        private CWintabContext OpenQueryDigitizerContext()
        {
            bool           status     = false;
            CWintabContext logContext = null;

            try
            {
                // Get the default digitizing context.  Turn off events.  Control system cursor.
                logContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_SYSTEM);

                logContext.Options |= (uint)ECTXOptionValues.CXO_MESSAGES;

                if (logContext == null)
                {
                    TraceMsg("OpenQueryDigitizerContext: FAILED to get default digitizing context.\n");
                    //System.Diagnostics.Debug.WriteLine("FAILED to get default digitizing context.");
                    return(null);
                }

                // Modify the digitizing region.
                logContext.Name = "WintabDN Query Data Context";

                // output in a 5000 x 5000 grid
                logContext.OutOrgX = logContext.OutOrgY = 0;
                logContext.OutExtX = 5000;
                logContext.OutExtY = 5000;

                // Open the context, which will also tell Wintab to send data packets.
                status = logContext.Open();

                TraceMsg("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED") + "\n");
                //System.Diagnostics.Debug.WriteLine("Context Open: " + (status ? "PASSED [ctx=" + logContext.HCtx + "]" : "FAILED"));
            }
            catch (Exception ex)
            {
                TraceMsg("OpenQueryDigitizerContext: ERROR : " + ex.ToString());
            }

            return(logContext);
        }
예제 #15
0
        ///////////////////////////////////////////////////////////////////////
        // Helper functions
        //
        ///////////////////////////////////////////////////////////////////////
        private void InitDataCapture(
				int ctxWidth_I = m_TABEXTX, int ctxHeight_I = m_TABEXTY, bool ctrlSysCursor_I = true)
        {
            try
            {
                // Close context from any previous test.
                CloseCurrentContext();

                TraceMsg("Opening context...\n");

                m_logContext = OpenTestSystemContext(ctxWidth_I, ctxHeight_I, ctrlSysCursor_I);

                if (m_logContext == null)
                {
                    TraceMsg("Test_DataPacketQueueSize: FAILED OpenTestSystemContext - bailing out...\n");
                    return;
                }

                // Create a data object and set its WT_PACKET handler.
                m_wtData = new CWintabData(m_logContext);
                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
예제 #16
0
 /// <summary>
 /// CWintabData constructor
 /// </summary>
 /// <param name="context_I">logical context for this data object</param>
 public CWintabData(CWintabContext context_I)
 {
     Init(context_I);
 }
예제 #17
0
        /// <summary>
        /// Set tablet OLED display property.
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="imageFilePath_I">path to PNG image file</param>
        /// <returns>true if successful and tablet supports property</returns>
        public static bool SetDisplayProperty(
            CWintabContext context_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 tabletIndex_I,
            UInt32 controlIndex_I,
            UInt32 functionIndex_I,
            String imageFilePath_I)
        {
            UInt32 iconFmt = 0;

            // Bail out if image file not found.
            if (imageFilePath_I == "" ||
                !System.IO.File.Exists(imageFilePath_I))
            {
                return(false);
            }

            try
            {
                if (!CWintabExtensions.ControlPropertyGet(
                        context_I.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_ICON_FORMAT,
                        ref iconFmt))
                {
                    throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_ICON_FORMAT");
                }

                if ((EWTExtensionIconProperty)iconFmt != EWTExtensionIconProperty.TABLET_ICON_FMT_NONE)
                {
                    // Get the width and height of the display icon.
                    UInt32 iconWidth  = 0;
                    UInt32 iconHeight = 0;

                    if (!CWintabExtensions.ControlPropertyGet(
                            context_I.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_ICON_WIDTH,
                            ref iconWidth))
                    {
                        throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_ICON_WIDTH");
                    }

                    if (!CWintabExtensions.ControlPropertyGet(
                            context_I.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_ICON_HEIGHT,
                            ref iconHeight))
                    {
                        throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_ICON_HEIGHT");
                    }

                    return(SetIcon(context_I, extTagIndex_I, tabletIndex_I, controlIndex_I, functionIndex_I, imageFilePath_I));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            // Not supported by tablet.
            return(false);
        }
예제 #18
0
        private bool InitWintab()
        {
            bool status = false;

            try
            {
                mLogContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);
                if (mLogContext == null)
                {
                    return false;
                    //throw new Exception("Oops - FAILED GetDefaultDigitizingContext");
                }

                // Control system cursor.
                mLogContext.Options |= (UInt32)ECTXOptionValues.CXO_SYSTEM;

                // Verify which extensions are available for targeting.
                // Once we know what the tablet supports, we can set up the data packet
                // definition to be sent events from those control types.

                // All tablets should have at least expresskeys.
                mExpKeysMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_EXPKEYS2);

                if (mExpKeysMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mExpKeysMask;
                }
                else
                {
                    Debug.WriteLine("InitWintab: WTX_EXPKEYS2 mask not found!");
                    throw new Exception("Oops - FAILED GetWTExtensionMask for WTX_EXPKEYS2");
                }

                // It's not an error if either / both of these are zero.  It simply means
                // that those control types are not supported.
                mTouchRingMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHRING);
                if (mTouchRingMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mTouchRingMask;
                }

                mTouchStripMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHSTRIP);
                if (mTouchStripMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mTouchStripMask;
                }

                status = mLogContext.Open();
                if (!status)
                {
                    //throw new Exception("Oops - failed logContext.Open()");
                    return false;
                }

                // Setup controls and overrides for first tablet.
                SetupControlsForTablet(mTabletIndexDefault);

                // Create a data object and set its WT_PACKET handler.
                m_wtData = new CWintabData(mLogContext);
                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);

            }
            catch (Exception ex)
            {
                MessageBox.Show("FormExtTestApp: InitWintab: " + ex.ToString());
            }

            return true;
        }
예제 #19
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 CWintabContext GetDefaultContext(EWTICategoryIndex contextIndex_I)        
        {
            CWintabContext context = new CWintabContext();
            IntPtr buf = CMemUtils.AllocUnmanagedBuf(context.LogContext);

            try
            {
                int size = (int)CWintabFuncs.WTInfoA((uint)contextIndex_I, 0, buf);

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

            CMemUtils.FreeUnmanagedBuf(buf);

            return context;
        }
예제 #20
0
        ///////////////////////////////////////////////////////////////////////
        private void CloseCurrentContext()
        {
            try
            {
                TraceMsg("Closing context...\n");
                if (m_logContext != null)
                {
                    m_logContext.Close();
                    m_logContext = null;
                    m_wtData = null;
                }

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
예제 #21
0
        /// <summary>
        /// Initialize this data object.
        /// </summary>
        /// <param name="context_I">logical context for this data object</param>
        private void Init(CWintabContext 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.
                MessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKET);

                // Watch for the Wintab WT_PACKETEXT event.
                MessageEvents.WatchMessage((int)EWintabEventMessage.WT_PACKETEXT);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FAILED CWintabData.Init: " + ex.ToString());
            }
        }
예제 #22
0
 /// <summary>
 /// CWintabData constructor
 /// </summary>
 /// <param name="context_I">logical context for this data object</param>
 public CWintabData(CWintabContext context_I)
 {
     Init(context_I);
 }
예제 #23
0
        //---------------------------------------------------------------------
        // Prepare to take tablet input
        //---------------------------------------------------------------------
        private void PrepareForTabletInput(object sender, EventArgs e)
        {
            // Set up the tablet context
            CWintabContext context = new CWintabContext();
            context = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);

            // Allow the mouse to move
            context.Options |= (uint)ECTXOptionValues.CXO_SYSTEM;

            context.Name = "Tablet event data context";
            context.OutOrgX = 0;
            context.OutOrgY = 0;
            context.OutExtX = 800;
            context.OutExtY = 600;

            bool status = context.Open();

            // Prepare to take data
            data = new CWintabData(context);
            data.SetWTPacketEventHandler(TabletEventHandler);
        }
        /// <summary>
        /// Set tablet OLED display property.
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="imageFilePath_I">path to PNG image file</param>
        /// <returns>true if successful and tablet supports property</returns>
        public static bool SetDisplayProperty(
            CWintabContext context_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 tabletIndex_I,
            UInt32 controlIndex_I,
            UInt32 functionIndex_I,
            String imageFilePath_I)
        {
            UInt32 iconFmt = 0;

            // Bail out if image file not found.
            if (imageFilePath_I == "" ||
                 !System.IO.File.Exists(imageFilePath_I))
            {
                return false;
            }

            try
            {
                if (!CWintabExtensions.ControlPropertyGet(
                    context_I.HCtx,
                    (byte)extTagIndex_I,
                    (byte)tabletIndex_I,
                    (byte)controlIndex_I,
                    (byte)functionIndex_I,
                    (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_ICON_FORMAT,
                    ref iconFmt))
                { throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_ICON_FORMAT"); }

                if ((EWTExtensionIconProperty)iconFmt != EWTExtensionIconProperty.TABLET_ICON_FMT_NONE)
                {
                    // Get the width and height of the display icon.
                    UInt32 iconWidth = 0;
                    UInt32 iconHeight = 0;

                    if (!CWintabExtensions.ControlPropertyGet(
                        context_I.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_ICON_WIDTH,
                        ref iconWidth))
                    { throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_ICON_WIDTH"); }

                    if (!CWintabExtensions.ControlPropertyGet(
                        context_I.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_ICON_HEIGHT,
                        ref iconHeight))
                    { throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_ICON_HEIGHT"); }

                    return SetIcon(context_I, extTagIndex_I, tabletIndex_I, controlIndex_I, functionIndex_I, imageFilePath_I);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            // Not supported by tablet.
            return false;
        }
        /// <summary>
        /// Write out an image to a tablet's OLED (Organic Light Emitting Diode)
        /// if supported by the tablet (eg: Intuos4).
        /// </summary>
        /// <param name="context_I">wintab context</param>
        /// <param name="extTagIndex_I">which extension tag we're setting</param>
        /// <param name="tabletIndex_I">index of the tablet being set</param>
        /// <param name="controlIndex_I">the index of the control being set</param>
        /// <param name="functionIndex_I">the index of the control function being set</param>
        /// <param name="imageFilePath_I">path to PNG image file</param>
        private static bool SetIcon(
            CWintabContext context_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 tabletIndex_I,
            UInt32 controlIndex_I,
            UInt32 functionIndex_I,
            String imageFilePath_I)
        {
            try
            {
                if (!CWintabExtensions.ControlPropertySetImage(
                    context_I.HCtx,
                    (byte)extTagIndex_I,
                    (byte)tabletIndex_I,
                    (byte)controlIndex_I,
                    (byte)functionIndex_I,
                    (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_OVERRIDE_ICON,
                    imageFilePath_I))
                { throw new Exception("Oops - FAILED ControlPropertySet for TABLET_PROPERTY_OVERRIDE"); }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return true;
        }
예제 #26
0
        ///////////////////////////////////////////////////////////////////////
        // Sets logContext.Out
        //
        // Note:
        // SystemParameters.VirtualScreenLeft{Top} and SystemParameters.VirtualScreenWidth{Height}
        // don't always give correct answers.
        //
        // Uncomment the TODO code below that enumerates all system displays
        // if you want to customize.
        // Else assume the passed-in extents were already set by call to WTInfo,
        // in which case we still have to invert the Y extent.
        private void SetSystemExtents(ref CWintabContext logContext)
        {
            //TODO Rectangle rect = new Rectangle(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue);

               //TODO foreach (Screen screen in Screen.AllScreens)
               //TODO    rect = Rectangle.Union(rect, screen.Bounds);

               //TODO logContext.OutOrgX = rect.Left;
               //TODO logContext.OutOrgY = rect.Top;
               //TODO logContext.OutExtX = rect.Width;
               //TODO logContext.OutExtY = rect.Height;

               // In Wintab, the tablet origin is lower left.  Move origin to upper left
               // so that it coincides with screen origin.
               logContext.OutExtY = -logContext.OutExtY;
        }