**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Drawing / System.Drawing.Drawing2D / CustomLineCap.cs
bloba01ee407c70b5d315d4b7a946892ea4b15b8d442
1 //
2 // System.Drawing.Drawing2D.CustomLineCap.cs
3 //
4 // Authors:
5 // Dennis Hayes (dennish@Raytek.com)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 // Ravindra (rkumar@novell.com)
8 //
9 // Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
10 // Copyright (C) 2004 Novell, Inc. http://www.novell.com
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
23 //
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
26 //
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System;
38 namespace System.Drawing.Drawing2D
40 /// <summary>
41 /// Summary description for CustomLineCap.
42 /// </summary>
43 public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
45 private bool disposed;
46 internal IntPtr nativeObject;
48 // Constructors
50 internal CustomLineCap () { }
52 internal CustomLineCap (IntPtr ptr)
54 nativeObject = ptr;
57 public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath) : this (fillPath, strokePath, LineCap.Flat, 0)
61 public CustomLineCap (GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap) : this (fillPath, strokePath, baseCap, 0)
65 public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
67 IntPtr fill = IntPtr.Zero;
68 IntPtr stroke = IntPtr.Zero;
70 if (fillPath != null)
71 fill = fillPath.nativePath;
72 if (strokePath != null)
73 stroke = strokePath.nativePath;
75 Status status = GDIPlus.GdipCreateCustomLineCap (fill, stroke, baseCap, baseInset, out nativeObject);
76 GDIPlus.CheckStatus (status);
79 public LineCap BaseCap {
80 get {
81 LineCap baseCap;
82 Status status = GDIPlus.GdipGetCustomLineCapBaseCap (nativeObject, out baseCap);
83 GDIPlus.CheckStatus (status);
85 return baseCap;
88 set {
89 Status status = GDIPlus.GdipSetCustomLineCapBaseCap (nativeObject, value);
90 GDIPlus.CheckStatus (status);
94 public LineJoin StrokeJoin {
95 get {
96 LineJoin strokeJoin;
97 Status status = GDIPlus.GdipGetCustomLineCapStrokeJoin (nativeObject, out strokeJoin);
98 GDIPlus.CheckStatus (status);
100 return strokeJoin;
103 set {
104 Status status = GDIPlus.GdipSetCustomLineCapStrokeJoin (nativeObject, value);
105 GDIPlus.CheckStatus (status);
109 public float BaseInset {
110 get {
111 float baseInset;
112 Status status = GDIPlus.GdipGetCustomLineCapBaseInset (nativeObject, out baseInset);
113 GDIPlus.CheckStatus (status);
115 return baseInset;
118 set {
119 Status status = GDIPlus.GdipSetCustomLineCapBaseInset (nativeObject, value);
120 GDIPlus.CheckStatus (status);
124 public float WidthScale {
125 get {
126 float widthScale;
127 Status status = GDIPlus.GdipGetCustomLineCapWidthScale (nativeObject, out widthScale);
128 GDIPlus.CheckStatus (status);
130 return widthScale;
133 set {
134 Status status = GDIPlus.GdipSetCustomLineCapWidthScale (nativeObject, value);
135 GDIPlus.CheckStatus (status);
139 // Public Methods
141 public virtual object Clone ()
143 IntPtr clonePtr;
144 Status status = GDIPlus.GdipCloneCustomLineCap (nativeObject, out clonePtr);
145 GDIPlus.CheckStatus (status);
147 return new CustomLineCap (clonePtr);
150 public virtual void Dispose ()
152 Dispose (true);
153 System.GC.SuppressFinalize (this);
156 protected virtual void Dispose (bool disposing)
158 if (! disposed) {
159 Status status = GDIPlus.GdipDeleteCustomLineCap (nativeObject);
160 GDIPlus.CheckStatus (status);
161 disposed = true;
162 nativeObject = IntPtr.Zero;
166 ~CustomLineCap ()
168 Dispose (false);
171 public void GetStrokeCaps (out LineCap startCap, out LineCap endCap)
173 Status status = GDIPlus.GdipGetCustomLineCapStrokeCaps (nativeObject, out startCap, out endCap);
174 GDIPlus.CheckStatus (status);
177 public void SetStrokeCaps(LineCap startCap, LineCap endCap)
179 Status status = GDIPlus.GdipSetCustomLineCapStrokeCaps (nativeObject, startCap, endCap);
180 GDIPlus.CheckStatus (status);