/// <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); }
/// <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); }