diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-11-24 03:00:25 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-11-24 03:00:25 +0100 |
| commit | f005d76468dc4c6a368b6f1f6eca69da25214e80 (patch) | |
| tree | 14a70c7fb9a58be9083dbd7492ecd94d030c18a9 /Backends/CairoBackend/src/Pattern.cs | |
| parent | 362d83b9556355b1d3dfb6cb892896ed33371521 (diff) | |
default Crow.CairoBackend ok
Diffstat (limited to 'Backends/CairoBackend/src/Pattern.cs')
| -rw-r--r-- | Backends/CairoBackend/src/Pattern.cs | 113 |
1 files changed, 43 insertions, 70 deletions
diff --git a/Backends/CairoBackend/src/Pattern.cs b/Backends/CairoBackend/src/Pattern.cs index 545dda36..137f67fe 100644 --- a/Backends/CairoBackend/src/Pattern.cs +++ b/Backends/CairoBackend/src/Pattern.cs @@ -14,10 +14,10 @@ // 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 @@ -28,21 +28,19 @@ // using System; -using System.Collections; using Drawing2D; -namespace Crow.CairoBackend { - - public class Pattern : IDisposable +namespace Crow.CairoBackend +{ + public class Pattern : IPattern { - [Obsolete] - protected IntPtr pattern = IntPtr.Zero; - + internal IntPtr handle; + public IntPtr Handle => handle; public static Pattern Lookup (IntPtr pattern, bool owner) { if (pattern == IntPtr.Zero) return null; - + PatternType pt = NativeMethods.cairo_pattern_get_type (pattern); switch (pt) { case PatternType.Solid: @@ -58,98 +56,73 @@ namespace Crow.CairoBackend { } } - [Obsolete] - protected Pattern () - { - } - internal Pattern (IntPtr handle, bool owned) { - Handle = handle; + this.handle = handle; if (!owned) NativeMethods.cairo_pattern_reference (handle); if (CairoDebug.Enabled) CairoDebug.OnAllocated (handle); } - ~Pattern () - { - Dispose (false); - } - [Obsolete ("Use the SurfacePattern constructor")] public Pattern (Surface surface) : this ( NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true) { } - + [Obsolete] protected void Reference () { - NativeMethods.cairo_pattern_reference (pattern); - } - - public void Dispose () - { - Dispose (true); - GC.SuppressFinalize (this); - } - - protected virtual void Dispose (bool disposing) - { - if (!disposing || CairoDebug.Enabled) - CairoDebug.OnDisposed<Pattern> (Handle, disposing); - - if (!disposing|| Handle == IntPtr.Zero) - return; - - NativeMethods.cairo_pattern_destroy (Handle); - Handle = IntPtr.Zero; + NativeMethods.cairo_pattern_reference (handle); } - [Obsolete ("Use Dispose()")] - public void Destroy () - { - Dispose (); - } - public Status Status - { - get { return NativeMethods.cairo_pattern_status (Handle); } - } - public Extend Extend - { - get { return NativeMethods.cairo_pattern_get_extend (Handle); } - set { NativeMethods.cairo_pattern_set_extend (Handle, value); } - } + public Status Status => NativeMethods.cairo_pattern_status (handle); public Matrix Matrix { - set { - NativeMethods.cairo_pattern_set_matrix (Handle, value); - } - + set => NativeMethods.cairo_pattern_set_matrix (handle, value); get { Matrix m = new Matrix (); - NativeMethods.cairo_pattern_get_matrix (Handle, m); + NativeMethods.cairo_pattern_get_matrix (handle, m); return m; } } -#pragma warning disable 612 - public IntPtr Handle { - get { return pattern; } - private set { pattern = value; } + public PatternType PatternType => NativeMethods.cairo_pattern_get_type (handle); + + #region IPattern implementation + public Extend Extend + { + get { return NativeMethods.cairo_pattern_get_extend (handle); } + set { NativeMethods.cairo_pattern_set_extend (handle, value); } + } + public Filter Filter { + get => NativeMethods.cairo_pattern_get_filter (handle); + set => NativeMethods.cairo_pattern_set_filter (handle, value); } -#pragma warning restore 612 + #endregion - [Obsolete] - public IntPtr Pointer { - get { return pattern; } + ~Pattern () + { + Dispose (false); } + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + protected virtual void Dispose (bool disposing) + { + if (!disposing || CairoDebug.Enabled) + CairoDebug.OnDisposed<Pattern> (handle, disposing); + + if (!disposing|| handle == IntPtr.Zero) + return; - public PatternType PatternType { - get { return NativeMethods.cairo_pattern_get_type (Handle); } + NativeMethods.cairo_pattern_destroy (handle); + handle = IntPtr.Zero; } } } |