1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Peter Bartok (pbartok@novell.com)
30 using System
.Collections
;
33 namespace System
.Windows
.Forms
{
34 public class DataFormats
{
36 static readonly object lockobj
= new object ();
38 private static Format formats
;
43 public Format (string name
, int ID
)
53 while (f
.next
!= null)
60 #region Public Instance Properties
73 internal Format Next
{
78 #endregion // Public Instance Properties
80 #region Private Methods
81 internal static Format
Add(string name
) {
88 cliphandle
= XplatUI
.ClipboardOpen(false);
89 f
= new Format(name
, XplatUI
.ClipboardGetID(cliphandle
, name
));
90 XplatUI
.ClipboardClose(cliphandle
);
95 internal static Format
Add(int id
) {
100 f
= new Format("Format"+id
.ToString(), id
);
105 internal static Format
Find(int id
) {
109 while ((f
!= null) && (f
.Id
!= id
)) {
115 internal static Format
Find(string name
) {
119 while ((f
!= null) && (!f
.Name
.Equals(name
))) {
125 internal static Format List
{
130 #endregion // Private Methods
134 private DataFormats () {}
136 #region Public Static Fields
137 public static readonly string Bitmap
= "Bitmap";
138 public static readonly string CommaSeparatedValue
= "Csv";
139 public static readonly string Dib
= "DeviceIndependentBitmap";
140 public static readonly string Dif
= "DataInterchangeFormat";
141 public static readonly string EnhancedMetafile
= "EnhancedMetafile";
142 public static readonly string FileDrop
= "FileDrop";
143 public static readonly string Html
= "HTML Format";
144 public static readonly string Locale
= "Locale";
145 public static readonly string MetafilePict
= "MetaFilePict";
146 public static readonly string OemText
= "OEMText";
147 public static readonly string Palette
= "Palette";
148 public static readonly string PenData
= "PenData";
149 public static readonly string Riff
= "RiffAudio";
150 public static readonly string Rtf
= "Rich Text Format";
151 public static readonly string Serializable
= "WindowsForms10PersistentObject";
152 public static readonly string StringFormat
= "System.String";
153 public static readonly string SymbolicLink
= "SymbolicLink";
154 public static readonly string Text
= "Text";
155 public static readonly string Tiff
= "Tiff";
156 public static readonly string UnicodeText
= "UnicodeText";
157 public static readonly string WaveAudio
= "WaveAudio";
158 #endregion // Public Static Fields
160 private static object lock_object
= new object ();
161 private static bool initialized
;
163 public static Format
GetFormat (int ID
)
168 return Format
.Find (ID
);
172 public static Format
GetFormat (string format
)
177 return Format
.Add (format
);
181 // Assumes we are locked on the lock_object when it is called
182 private static void Init ()
186 IntPtr cliphandle
= XplatUI
.ClipboardOpen(false);
188 new Format (Text
, XplatUI
.ClipboardGetID (cliphandle
, Text
));
189 new Format (Bitmap
, XplatUI
.ClipboardGetID (cliphandle
, Bitmap
));
190 new Format (MetafilePict
, XplatUI
.ClipboardGetID (cliphandle
, MetafilePict
));
191 new Format (SymbolicLink
, XplatUI
.ClipboardGetID (cliphandle
, SymbolicLink
));
192 new Format (Dif
, XplatUI
.ClipboardGetID (cliphandle
, Dif
)) ;
193 new Format (Tiff
, XplatUI
.ClipboardGetID (cliphandle
, Tiff
));
194 new Format (OemText
, XplatUI
.ClipboardGetID (cliphandle
, OemText
));
195 new Format (Dib
, XplatUI
.ClipboardGetID (cliphandle
, Dib
));
196 new Format (Palette
, XplatUI
.ClipboardGetID (cliphandle
, Palette
));
197 new Format (PenData
, XplatUI
.ClipboardGetID (cliphandle
, PenData
));
198 new Format (Riff
, XplatUI
.ClipboardGetID (cliphandle
, Riff
));
199 new Format (WaveAudio
, XplatUI
.ClipboardGetID (cliphandle
, WaveAudio
));
200 new Format (UnicodeText
, XplatUI
.ClipboardGetID (cliphandle
, UnicodeText
));
201 new Format (EnhancedMetafile
, XplatUI
.ClipboardGetID (cliphandle
, EnhancedMetafile
));
202 new Format (FileDrop
, XplatUI
.ClipboardGetID (cliphandle
, FileDrop
));
203 new Format (Locale
, XplatUI
.ClipboardGetID (cliphandle
, Locale
));
204 new Format (CommaSeparatedValue
, XplatUI
.ClipboardGetID (cliphandle
, CommaSeparatedValue
));
205 new Format (Html
, XplatUI
.ClipboardGetID (cliphandle
, Html
));
206 new Format (Rtf
, XplatUI
.ClipboardGetID (cliphandle
, Rtf
));
207 new Format (Serializable
, XplatUI
.ClipboardGetID (cliphandle
, Serializable
));
208 new Format (StringFormat
, XplatUI
.ClipboardGetID (cliphandle
, StringFormat
));
210 XplatUI
.ClipboardClose (cliphandle
);