protected ComObjectBase(IComObject parent, Func<object> createAction) { _parent = parent; _children = new List<IComObject>(); if (_parent != null) _parent.RegisterChild(this); try { Object = createAction.Invoke(); } catch { Object = null; } }
public static bool TryGet <T>(this IComObject <IMFAttributes> input, Guid key, IFormatProvider provider, out T value) => TryGet(input?.Object, key, provider, out value);
public static T Get <T>(this IComObject <IMFAttributes> input, Guid key, T defaultValue = default, IFormatProvider provider = null) => Get(input?.Object, key, defaultValue, provider);
public static void Set(this IComObject <IMFAttributes> input, Guid key, bool value) => input?.Object.SetUINT32(key, (uint)(value ? 1 : 0)).ThrowOnError();
public static IComObject <T> GetBitmap <T>(this IComObject <ID2D1BitmapRenderTarget> renderTarget) where T : ID2D1Bitmap => GetBitmap <T>(renderTarget?.Object);
public static IComObject <ID2D1Bitmap> GetBitmap(this IComObject <ID2D1BitmapRenderTarget> renderTarget) => GetBitmap <ID2D1Bitmap>(renderTarget?.Object);
public static void PopAxisAlignedClip(this IComObject <ID2D1RenderTarget> renderTarget) => PopAxisAlignedClip(renderTarget?.Object);
public static void PopLayer(this IComObject <ID2D1RenderTarget> context) => PopLayer(context?.Object);
public static IComObject <ID2D1BitmapRenderTarget> CreateCompatibleRenderTarget(this IComObject <ID2D1RenderTarget> context, D2D_SIZE_F?desiredSize = null, D2D_SIZE_U?desiredPixelSize = null, D2D1_PIXEL_FORMAT?desiredFormat = null, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS options = D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS.D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE) => CreateCompatibleRenderTarget(context?.Object, desiredSize, desiredPixelSize, desiredFormat, options);
public static void FillGeometry(this IComObject <ID2D1RenderTarget> context, IComObject <ID2D1Geometry> geometry, IComObject <ID2D1Brush> brush, IComObject <ID2D1Brush> opacityBrush = null) => FillGeometry(context?.Object, geometry?.Object, brush?.Object, opacityBrush?.Object);
public static void DrawTextLayout(this IComObject <ID2D1RenderTarget> context, D2D_POINT_2F origin, IDWriteTextLayout layout, ID2D1Brush defaultFillBrush = null, D2D1_DRAW_TEXT_OPTIONS options = D2D1_DRAW_TEXT_OPTIONS.D2D1_DRAW_TEXT_OPTIONS_NONE) => DrawTextLayout(context?.Object, origin, layout, defaultFillBrush, options);
public static void Clear(this IComObject <ID2D1RenderTarget> renderTarget, _D3DCOLORVALUE?clearColor = null) => Clear(renderTarget?.Object, clearColor);
public static void EndDraw(this IComObject <ID2D1RenderTarget> renderTarget) => EndDraw(renderTarget?.Object);
public static void SetTags(this IComObject <ID2D1RenderTarget> context, ulong tag1, ulong tag2 = 0) => SetTags(context?.Object, tag1, tag2);
public void RegisterChild(IComObject child) { _children.Add(child); }
public static D2D1_PIXEL_FORMAT GetPixelFormat(this IComObject <ID2D1RenderTarget> context) => GetPixelFormat(context?.Object);
public static void DrawLine(this IComObject <ID2D1RenderTarget> context, D2D_POINT_2F point0, D2D_POINT_2F point1, IComObject <ID2D1Brush> brush, float strokeWidth, IComObject <ID2D1StrokeStyle> strokeStyle = null) => DrawLine(context?.Object, point0, point1, brush?.Object, strokeWidth, strokeStyle?.Object);
public static void PushAxisAlignedClip(this IComObject <ID2D1RenderTarget> renderTarget, D2D_RECT_F clipRect, D2D1_ANTIALIAS_MODE antialiasMode = D2D1_ANTIALIAS_MODE.D2D1_ANTIALIAS_MODE_PER_PRIMITIVE) => PushAxisAlignedClip(renderTarget?.Object, clipRect, antialiasMode);
public static void FillRoundedRectangle(this IComObject <ID2D1RenderTarget> context, D2D1_ROUNDED_RECT roundedRect, IComObject <ID2D1Brush> brush) => FillRoundedRectangle(context?.Object, roundedRect, brush?.Object);
public static IComObject <T> CreateSolidColorBrush <T>(this IComObject <ID2D1RenderTarget> renderTarget, _D3DCOLORVALUE color, D2D1_BRUSH_PROPERTIES?properties = null) where T : ID2D1SolidColorBrush => CreateSolidColorBrush <T>(renderTarget?.Object, color, properties);
public static void DrawRectangle(this IComObject <ID2D1RenderTarget> context, D2D_RECT_F rect, IComObject <ID2D1Brush> brush, float strokeWidth, IComObject <ID2D1StrokeStyle> strokeStyle = null) => DrawRectangle(context?.Object, rect, brush?.Object, strokeWidth, strokeStyle?.Object);
public static IComObject <ID2D1RadialGradientBrush> CreateRadialGradientBrush(this IComObject <ID2D1RenderTarget> context, D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES gradientBrushProperties, IComObject <ID2D1GradientStopCollection> stops, D2D1_BRUSH_PROPERTIES?brushProperties = null) => CreateRadialGradientBrush(context?.Object, gradientBrushProperties, stops?.Object, brushProperties);
public static void FillRectangle(this IComObject <ID2D1RenderTarget> context, D2D_RECT_F rect, IComObject <ID2D1Brush> brush) => FillRectangle(context?.Object, rect, brush?.Object);
public static void Set(this IComObject <IMFAttributes> input, Guid key, uint value) => input?.Object.SetUINT32(key, value).ThrowOnError();
public static void DrawEllipse(this IComObject <ID2D1RenderTarget> context, D2D1_ELLIPSE ellipse, IComObject <ID2D1Brush> brush, float strokeWidth, IComObject <ID2D1StrokeStyle> strokeStyle = null) => DrawEllipse(context?.Object, ellipse, brush?.Object, strokeWidth, strokeStyle?.Object);
public static void Set(this IComObject <IMFAttributes> input, Guid key, Enum value) => input?.Object.SetUINT32(key, (uint)Convert.ChangeType(value, typeof(uint), CultureInfo.InvariantCulture)).ThrowOnError();
public static void FillEllipse(this IComObject <ID2D1RenderTarget> context, D2D1_ELLIPSE ellipse, IComObject <ID2D1Brush> brush) => FillEllipse(context?.Object, ellipse, brush?.Object);
public static bool TryGet <T>(this IComObject <IMFAttributes> input, Guid key, out T value) => TryGet(input?.Object, key, null, out value);
public static void DrawBitmap(this IComObject <ID2D1RenderTarget> renderTarget, IComObject <ID2D1Bitmap> bitmap, float opacity = 1, D2D1_BITMAP_INTERPOLATION_MODE interpolationMode = D2D1_BITMAP_INTERPOLATION_MODE.D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, D2D_RECT_F?destinationRectangle = null, D2D_RECT_F?sourceRectangle = null) => DrawBitmap(renderTarget?.Object, bitmap?.Object, opacity, interpolationMode, destinationRectangle, sourceRectangle);
public static void DrawGeometry(this IComObject <ID2D1RenderTarget> renderTarget, IComObject <ID2D1Geometry> geometry, IComObject <ID2D1Brush> brush, float strokeWidth, IComObject <ID2D1StrokeStyle> strokeStyle = null) => DrawGeometry(renderTarget?.Object, geometry?.Object, brush?.Object, strokeWidth, strokeStyle?.Object);
public static void PushLayer(this IComObject <ID2D1RenderTarget> context, D2D1_LAYER_PARAMETERS parameters) => PushLayer(context?.Object, parameters);
public void UnregisterChild(IComObject child) { _children.Remove(child); }
public static IComObject <T> CreateBitmap <T>(this IComObject <ID2D1RenderTarget> renderTarget, D2D_SIZE_U size, IntPtr srcData, uint pitch, D2D1_BITMAP_PROPERTIES properties) where T : ID2D1Bitmap => CreateBitmap <T>(renderTarget?.Object, size, srcData, pitch, properties);