/// <summary> /// Sets an extension control property string. /// </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="propertyID_I">ID of the property being set</param> /// <param name="value_I">value of the property being set (a string)</param> /// <returns>true if successful</returns> public static bool ControlPropertySet( HCTX context_I, byte extTagIndex_I, byte tabletIndex_I, byte controlIndex_I, byte functionIndex_I, ushort propertyID_I, String value_I ) { bool retStatus = false; WTExtensionProperty extProperty = new WTExtensionProperty(); IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty); try { // Convert unicode string value_I to UTF8-encoded bytes byte[] utf8Bytes = System.Text.Encoding.Convert(Encoding.Unicode, Encoding.UTF8, Encoding.Unicode.GetBytes(value_I)); extProperty.extBase.version = 0; extProperty.extBase.tabletIndex = tabletIndex_I; extProperty.extBase.controlIndex = controlIndex_I; extProperty.extBase.functionIndex = functionIndex_I; extProperty.extBase.propertyID = propertyID_I; extProperty.extBase.reserved = 0; extProperty.extBase.dataSize = (uint)utf8Bytes.Length; extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes]; // Send input value as an array of UTF8-encoded bytes. System.Buffer.BlockCopy(utf8Bytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize); Marshal.StructureToPtr(extProperty, buf, false); retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } CMemUtils.FreeUnmanagedBuf(buf); return(retStatus); }
/// <summary> /// Get a property value from an extension. /// </summary> /// <param name="context_I">Wintab context</param> /// <param name="extTagIndex_I">extension index tag</param> /// <param name="tabletIndex_I">tablet index</param> /// <param name="controlIndex_I">control index on the tablet</param> /// <param name="functionIndex_I">function index on the control</param> /// <param name="propertyID_I">ID of the property requested</param> /// <param name="result_O">value of the property requested</param> /// <returns>true if property obtained</returns> public static bool ControlPropertyGet( HCTX context_I, byte extTagIndex_I, byte tabletIndex_I, byte controlIndex_I, byte functionIndex_I, ushort propertyID_I, ref UInt32 result_O ) { bool retStatus = false; WTExtensionProperty extProperty = new WTExtensionProperty(); IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty); extProperty.extBase.version = 0; extProperty.extBase.tabletIndex = tabletIndex_I; extProperty.extBase.controlIndex = controlIndex_I; extProperty.extBase.functionIndex = functionIndex_I; extProperty.extBase.propertyID = propertyID_I; extProperty.extBase.reserved = 0; extProperty.extBase.dataSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(result_O); Marshal.StructureToPtr(extProperty, buf, false); try { bool status = CWintabFuncs.WTExtGet((UInt32)context_I, (UInt32)extTagIndex_I, buf); if (status) { WTExtensionProperty retProp = (WTExtensionProperty)Marshal.PtrToStructure(buf, typeof(WTExtensionProperty)); result_O = retProp.data[0]; retStatus = true; } } catch (Exception ex) { MessageBox.Show("FAILED ControlPropertyGet: " + ex.ToString()); } CMemUtils.FreeUnmanagedBuf(buf); return(retStatus); }
/// <summary> /// Sets an extension control property value. /// </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="propertyID_I">ID of the property being set</param> /// <param name="value_I">value of the property being set</param> /// <returns>true if successful</returns> public static bool ControlPropertySet( HCTX context_I, byte extTagIndex_I, byte tabletIndex_I, byte controlIndex_I, byte functionIndex_I, ushort propertyID_I, UInt32 value_I ) { bool retStatus = false; WTExtensionProperty extProperty = new WTExtensionProperty(); IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty); try { byte[] valueBytes = BitConverter.GetBytes(value_I); extProperty.extBase.version = 0; extProperty.extBase.tabletIndex = tabletIndex_I; extProperty.extBase.controlIndex = controlIndex_I; extProperty.extBase.functionIndex = functionIndex_I; extProperty.extBase.propertyID = propertyID_I; extProperty.extBase.reserved = 0; extProperty.extBase.dataSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(value_I); extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes]; // Send input value as an array of bytes. System.Buffer.BlockCopy(valueBytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize); Marshal.StructureToPtr(extProperty, buf, false); retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } CMemUtils.FreeUnmanagedBuf(buf); return(retStatus); }
/// <summary> /// Sets an extension control property string. /// </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="propertyID_I">ID of the property being set</param> /// <param name="value_I">value of the property being set (a string)</param> /// <returns>true if successful</returns> public static bool ControlPropertySet( HCTX context_I, byte extTagIndex_I, byte tabletIndex_I, byte controlIndex_I, byte functionIndex_I, ushort propertyID_I, String value_I ) { bool retStatus = false; WTExtensionProperty extProperty = new WTExtensionProperty(); IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty); try { // Convert unicode string value_I to UTF8-encoded bytes byte[] utf8Bytes = System.Text.Encoding.Convert(Encoding.Unicode, Encoding.UTF8, Encoding.Unicode.GetBytes(value_I)); extProperty.extBase.version = 0; extProperty.extBase.tabletIndex = tabletIndex_I; extProperty.extBase.controlIndex = controlIndex_I; extProperty.extBase.functionIndex = functionIndex_I; extProperty.extBase.propertyID = propertyID_I; extProperty.extBase.reserved = 0; extProperty.extBase.dataSize = (uint)utf8Bytes.Length; extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes]; // Send input value as an array of UTF8-encoded bytes. System.Buffer.BlockCopy(utf8Bytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize); Marshal.StructureToPtr(extProperty, buf, false); retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } CMemUtils.FreeUnmanagedBuf(buf); return retStatus; }
/// <summary> /// Sets an extension control property value. /// </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="propertyID_I">ID of the property being set</param> /// <param name="value_I">value of the property being set</param> /// <returns>true if successful</returns> public static bool ControlPropertySet( HCTX context_I, byte extTagIndex_I, byte tabletIndex_I, byte controlIndex_I, byte functionIndex_I, ushort propertyID_I, UInt32 value_I ) { bool retStatus = false; WTExtensionProperty extProperty = new WTExtensionProperty(); IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty); try { byte[] valueBytes = BitConverter.GetBytes(value_I); extProperty.extBase.version = 0; extProperty.extBase.tabletIndex = tabletIndex_I; extProperty.extBase.controlIndex = controlIndex_I; extProperty.extBase.functionIndex = functionIndex_I; extProperty.extBase.propertyID = propertyID_I; extProperty.extBase.reserved = 0; extProperty.extBase.dataSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(value_I); extProperty.data = new byte[WTExtensionsGlobal.WTExtensionPropertyMaxDataBytes]; // Send input value as an array of bytes. System.Buffer.BlockCopy(valueBytes, 0, extProperty.data, 0, (int)extProperty.extBase.dataSize); Marshal.StructureToPtr(extProperty, buf, false); retStatus = CWintabFuncs.WTExtSet((UInt32)context_I, (UInt32)extTagIndex_I, buf); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } CMemUtils.FreeUnmanagedBuf(buf); return retStatus; }
/// <summary> /// Get a property value from an extension. /// </summary> /// <param name="context_I">Wintab context</param> /// <param name="extTagIndex_I">extension index tag</param> /// <param name="tabletIndex_I">tablet index</param> /// <param name="controlIndex_I">control index on the tablet</param> /// <param name="functionIndex_I">function index on the control</param> /// <param name="propertyID_I">ID of the property requested</param> /// <param name="result_O">value of the property requested</param> /// <returns>true if property obtained</returns> public static bool ControlPropertyGet( HCTX context_I, byte extTagIndex_I, byte tabletIndex_I, byte controlIndex_I, byte functionIndex_I, ushort propertyID_I, ref UInt32 result_O ) { bool retStatus = false; WTExtensionProperty extProperty = new WTExtensionProperty(); IntPtr buf = CMemUtils.AllocUnmanagedBuf(extProperty); extProperty.extBase.version = 0; extProperty.extBase.tabletIndex = tabletIndex_I; extProperty.extBase.controlIndex = controlIndex_I; extProperty.extBase.functionIndex = functionIndex_I; extProperty.extBase.propertyID = propertyID_I; extProperty.extBase.reserved = 0; extProperty.extBase.dataSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(result_O); Marshal.StructureToPtr(extProperty, buf, false); try { bool status = CWintabFuncs.WTExtGet((UInt32)context_I, (UInt32)extTagIndex_I, buf); if (status) { WTExtensionProperty retProp = (WTExtensionProperty)Marshal.PtrToStructure(buf, typeof(WTExtensionProperty)); result_O = retProp.data[0]; retStatus = true; } } catch (Exception ex) { MessageBox.Show("FAILED ControlPropertyGet: " + ex.ToString()); } CMemUtils.FreeUnmanagedBuf(buf); return retStatus; }