// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; using System.Runtime.InteropServices; using SharpDX.Mathematics.Interop; namespace SharpDX.Direct2D1 { public partial class Properties { /// /// Gets or sets Cached property. /// public bool Cached { get { return GetBoolValue((int)Property.Cached); } set { SetValue((int)Property.Cached, value); } } /// /// Gets the number of characters for the given property name. /// /// The index of the property for which the name is being returned. /// The name of the property /// /// This method returns an empty string if index is invalid. /// /// HRESULT ID2D1Properties::GetPropertyName([In] unsigned int index,[Out, Buffer] wchar_t* name,[In] unsigned int nameCount) public unsafe string GetPropertyName(int index) { int length = GetPropertyNameLength(index); if (length == 0) return null; // D2D runtime returns the property name as a null-terminated string, so we need an additional char at the end var bufferLength = length + 1; var pText = stackalloc char[bufferLength]; GetPropertyName(index, new IntPtr(pText), bufferLength); return new string(pText, 0, length); // do not use the last '\0' char } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe int GetIntValue(int index) { int value; this.GetValue(index, PropertyType.Int32, new IntPtr(&value), sizeof(int)); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe uint GetUIntValue(int index) { uint value; this.GetValue(index, PropertyType.UInt32, new IntPtr(&value), sizeof(uint)); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe float GetFloatValue(int index) { float value; this.GetValue(index, PropertyType.Float, new IntPtr(&value), sizeof(float)); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe bool GetBoolValue(int index) { int value; this.GetValue(index, PropertyType.Bool, new IntPtr(&value), sizeof(int)); return value != 0; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe Guid GetGuidValue(int index) { Guid value; this.GetValue(index, PropertyType.Clsid, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawVector2 GetVector2Value(int index) { RawVector2 value; this.GetValue(index, PropertyType.Vector2, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawVector3 GetVector3Value(int index) { RawVector3 value; this.GetValue(index, PropertyType.Vector3, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawColor3 GetColor3Value(int index) { RawColor3 value; this.GetValue(index, PropertyType.Vector3, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawVector4 GetVector4Value(int index) { RawVector4 value; this.GetValue(index, PropertyType.Vector4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawRectangleF GetRectangleFValue(int index) { RawRectangleF value; this.GetValue(index, PropertyType.Vector4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawColor4 GetColor4Value(int index) { RawColor4 value; this.GetValue(index, PropertyType.Vector4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawMatrix GetMatrixValue(int index) { RawMatrix value; this.GetValue(index, PropertyType.Matrix4x4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawMatrix3x2 GetMatrix3x2Value(int index) { RawMatrix3x2 value; this.GetValue(index, PropertyType.Matrix3x2, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawMatrix5x4 GetMatrix5x4Value(int index) { RawMatrix5x4 value; this.GetValue(index, PropertyType.Matrix5x4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe T GetEnumValue(int index) where T : struct { if (Utilities.SizeOf() != sizeof(int)) throw new ArgumentException("value", "enum must be sizeof(int)"); T value = default(T); this.GetValue(index, PropertyType.Enum, (IntPtr)Interop.Cast(ref value), sizeof(int)); return value; } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe T GetComObjectValue(int index) where T : ComObject { IntPtr ptr; this.GetValue(index, PropertyType.IUnknown, new IntPtr(&ptr), Utilities.SizeOf()); return ptr == IntPtr.Zero ? null : As(ptr); } /// /// Gets the value of the specified property by index. /// /// The index of the property from which the data is to be obtained. /// The value of the specified property by index. /// HRESULT ID2D1Properties::GetValue([In] unsigned int index,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe T GetValue(int index, PropertyType type) where T : struct { T value = default(T); this.GetValue(index, type, (IntPtr)Interop.Cast(ref value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe uint GetUIntValueByName(string name) { uint value; this.GetValueByName(name, PropertyType.UInt32, new IntPtr(&value), sizeof(uint)); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe float GetFloatValueByName(string name) { float value; this.GetValueByName(name, PropertyType.Float, new IntPtr(&value), sizeof(float)); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe bool GetBoolValueByName(string name) { int value; this.GetValueByName(name, PropertyType.Bool, new IntPtr(&value), sizeof(int)); return value != 0; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe Guid GetGuidValueByName(string name) { Guid value; this.GetValueByName(name, PropertyType.Clsid, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawVector2 GetVector2ValueByName(string name) { RawVector2 value; this.GetValueByName(name, PropertyType.Vector2, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawVector3 GetVector3ValueByName(string name) { RawVector3 value; this.GetValueByName(name, PropertyType.Vector3, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawColor3 GetColor3ValueByName(string name) { RawColor3 value; this.GetValueByName(name, PropertyType.Vector3, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawVector4 GetVector4ValueByName(string name) { RawVector4 value; this.GetValueByName(name, PropertyType.Vector4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawRectangleF GetRectangleFValueByName(string name) { RawRectangleF value; this.GetValueByName(name, PropertyType.Vector4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawColor4 GetColor4ValueByName(string name) { RawColor4 value; this.GetValueByName(name, PropertyType.Vector4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawMatrix GetMatrixValueByName(string name) { RawMatrix value; this.GetValueByName(name, PropertyType.Matrix4x4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawMatrix3x2 GetMatrix3x2ValueByName(string name) { RawMatrix3x2 value; this.GetValueByName(name, PropertyType.Matrix3x2, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe RawMatrix5x4 GetMatrix5x4ValueByName(string name) { RawMatrix5x4 value; this.GetValueByName(name, PropertyType.Matrix5x4, new IntPtr(&value), Utilities.SizeOf()); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe T GetEnumValueByName(string name) where T : struct { if (Utilities.SizeOf() != sizeof(int)) throw new ArgumentException("value", "enum must be sizeof(int)"); T value = default(T); this.GetValueByName(name, PropertyType.Enum, (IntPtr)Interop.Cast(ref value), sizeof(int)); return value; } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe T GetComObjectValueByName(string name) where T : ComObject { IntPtr ptr; this.GetValueByName(name, PropertyType.IUnknown, new IntPtr(&ptr), Utilities.SizeOf()); return ptr == IntPtr.Zero ? null : As(ptr); } /// /// Gets the value of the specified property by name. /// /// The name of the property. /// Specifies the type of property to get. /// The value of the specified property by name. /// HRESULT ID2D1Properties::GetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[Out, Buffer] void* data,[In] unsigned int dataSize) public unsafe T GetValue(string name, PropertyType type) where T : struct { T value = default(T); this.GetValueByName(name, type, (IntPtr)Interop.Cast(ref value), Utilities.SizeOf()); return value; } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, int value) { SetValueByName(name, PropertyType.Int32, new IntPtr(&value), sizeof(int)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, uint value) { SetValueByName(name, PropertyType.UInt32, new IntPtr(&value), sizeof(uint)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, bool value) { int boolValue = value ? 1 : 0; SetValueByName(name, PropertyType.Bool, new IntPtr(&boolValue), sizeof(int)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, Guid value) { SetValueByName(name, PropertyType.Clsid, new IntPtr(&value), Utilities.SizeOf()); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, float value) { SetValueByName(name, PropertyType.Float, new IntPtr(&value), sizeof(float)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawVector2 value) { SetValueByName(name, PropertyType.Vector2, new IntPtr(&value), sizeof(RawVector2)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawColor3 value) { SetValueByName(name, PropertyType.Vector3, new IntPtr(&value), sizeof(RawColor3)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawVector4 value) { SetValueByName(name, PropertyType.Vector4, new IntPtr(&value), sizeof(RawVector4)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawRectangleF value) { SetValueByName(name, PropertyType.Vector4, new IntPtr(&value), sizeof(RawRectangleF)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawColor4 value) { SetValueByName(name, PropertyType.Vector4, new IntPtr(&value), sizeof(RawColor4)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawMatrix3x2 value) { SetValueByName(name, PropertyType.Matrix3x2, new IntPtr(&value), sizeof(RawMatrix3x2)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawMatrix value) { SetValueByName(name, PropertyType.Matrix4x4, new IntPtr(&value), sizeof(RawMatrix)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, RawMatrix5x4 value) { SetValueByName(name, PropertyType.Matrix5x4, new IntPtr(&value), sizeof(RawMatrix5x4)); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, string value) { var pValue = Marshal.StringToHGlobalUni(value); SetValueByName(name, PropertyType.String, pValue, value != null ? value.Length : 0); Marshal.FreeHGlobal(pValue); } /// /// Sets the named property to the given value. /// /// Name of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, T value) where T : ComObject { var pValue = value == null ? IntPtr.Zero : value.NativePointer; SetValueByName(name, PropertyType.IUnknown, new IntPtr(&pValue), Utilities.SizeOf()); } /// /// Sets the named property to the given value. /// /// Name of the property /// Specifies the type of property to set. /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValueByName(string name, PropertyType type, T value) where T : struct { SetValueByName(name, type, (IntPtr)Interop.Cast(ref value), Utilities.SizeOf()); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValueByName([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, int value) { SetValue(index, PropertyType.Int32, new IntPtr(&value), sizeof(int)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, uint value) { SetValue(index, PropertyType.UInt32, new IntPtr(&value), sizeof(uint)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, bool value) { int boolValue = value ? 1 : 0; SetValue(index, PropertyType.Bool, new IntPtr(&boolValue), sizeof(int)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, Guid value) { SetValue(index, PropertyType.Clsid, new IntPtr(&value), Utilities.SizeOf()); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, float value) { SetValue(index, PropertyType.Float, new IntPtr(&value), sizeof(float)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawVector2 value) { SetValue(index, PropertyType.Vector2, new IntPtr(&value), sizeof(RawVector2)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawVector3 value) { SetValue(index, PropertyType.Vector3, new IntPtr(&value), sizeof(RawVector3)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawColor3 value) { SetValue(index, PropertyType.Vector3, new IntPtr(&value), sizeof(RawColor3)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawVector4 value) { SetValue(index, PropertyType.Vector4, new IntPtr(&value), sizeof(RawVector4)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawRectangleF value) { SetValue(index, PropertyType.Vector4, new IntPtr(&value), sizeof(RawRectangleF)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawColor4 value) { SetValue(index, PropertyType.Vector4, new IntPtr(&value), sizeof(RawColor4)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawMatrix3x2 value) { SetValue(index, PropertyType.Matrix3x2, new IntPtr(&value), sizeof(RawMatrix3x2)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawMatrix value) { SetValue(index, PropertyType.Matrix4x4, new IntPtr(&value), sizeof(RawMatrix)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, RawMatrix5x4 value) { SetValue(index, PropertyType.Matrix5x4, new IntPtr(&value), sizeof(RawMatrix5x4)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, string value) { var pValue = Marshal.StringToHGlobalUni(value); SetValue(index, PropertyType.String, pValue, value != null ? value.Length : 0); Marshal.FreeHGlobal(pValue); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetEnumValue(int index, T value) where T : struct { if (Utilities.SizeOf() != sizeof(int)) throw new ArgumentException("value", "enum must be sizeof(int)"); SetValue(index, PropertyType.Enum, (IntPtr)Interop.Cast(ref value), sizeof(int)); } /// /// Sets the named property to the given value. /// /// Index of the property /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, T value) where T : ComObject { var pValue = value == null ? IntPtr.Zero : value.NativePointer; SetValue(index, PropertyType.IUnknown, new IntPtr(&pValue), Utilities.SizeOf()); } /// /// Sets the named property to the given value. /// /// Index of the property /// Specifies the type of property to set. /// Value of the property /// HRESULT ID2D1Properties::SetValue([In] const wchar_t* name,[In] D2D1_PROPERTY_TYPE type,[In, Buffer] const void* data,[In] unsigned int dataSize) public unsafe void SetValue(int index, PropertyType type, T value) where T : struct { SetValue(index, type, (IntPtr)Interop.Cast(ref value), Utilities.SizeOf()); } } }