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 {
35 #region DataFormats.Format Subclass
37 #region Local Variables
41 #endregion Local Variables
43 #region Public Constructors
44 public Format(string name, int ID) {
49 internal Format(string name, int ID, Format after) : this(name, ID) {
52 #endregion // Public Constructors
54 #region Public Instance Properties
66 #endregion // Public Instance Properties
68 #region Private Methods
69 internal static Format Find(Format f, int id) {
70 while ((f != null) && (f.Id != id)) {
76 internal static Format Find(Format f, string name) {
77 while ((f != null) && (!f.Name.Equals(name))) {
82 #endregion // Private Methods
85 #endregion // DataFormats.Format Subclass
87 #region Local Variables
88 private static bool initialized = false;
89 private static Format formats;
90 #endregion // Local Variables
93 private DataFormats() {
95 #endregion // Constructors
97 #region Public Static Fields
98 public static readonly string Bitmap = "Bitmap";
99 public static readonly string CommaSeparatedValue = "Csv";
100 public static readonly string Dib = "DeviceIndependentBitmap";
101 public static readonly string Dif = "DataInterchangeFormat";
102 public static readonly string EnhancedMetafile = "EnhancedMetafile";
103 public static readonly string FileDrop = "FileDrop";
104 public static readonly string Html = "HTML Format";
105 public static readonly string Locale = "Locale";
106 public static readonly string MetafilePict = "MetaFilePict";
107 public static readonly string OemText = "OEMText";
108 public static readonly string Palette = "Palette";
109 public static readonly string PenData = "PenData";
110 public static readonly string Riff = "RiffAudio";
111 public static readonly string Rtf = "Rich Text Format";
112 public static readonly string Serializable = "WindowsForms10PersistentObject";
113 public static readonly string StringFormat = "System.String";
114 public static readonly string SymbolicLink = "SymbolicLink";
115 public static readonly string Text = "Text";
116 public static readonly string Tiff = "Tiff";
117 public static readonly string UnicodeText = "UnicodeText";
118 public static readonly string WaveAudio = "WaveAudio";
119 #endregion // Public Static Fields
121 #region Public Static Methods
122 public static Format GetFormat(int ID) {
127 return Format.Find(formats, ID);
130 public static Format GetFormat(string format) {
135 return Format.Find(formats, format);
137 #endregion // Public Static Methods
139 #region Private Methods
140 private static void Initialize() {
141 lock (typeof(DataFormats.Format)) {
146 cliphandle = XplatUI.ClipboardOpen();
147 formats = new DataFormats.Format(Text, 1);
148 f = new Format(Bitmap, 2, formats);
149 f = new Format(MetafilePict, 3, f);
150 f = new Format(SymbolicLink, 4, f);
151 f = new Format(Dif, 5, f);
152 f = new Format(Tiff, 6, f);
153 f = new Format(OemText, 7, f);
154 f = new Format(Dib, 8, f);
155 f = new Format(Palette, 9, f);
156 f = new Format(PenData, 10, f);
157 f = new Format(Riff, 11, f);
158 f = new Format(WaveAudio, 12, f);
159 f = new Format(UnicodeText, 13, f);
160 f = new Format(EnhancedMetafile, 14, f);
161 f = new Format(FileDrop, 15, f);
162 f = new Format(Locale, 16, f);
164 f = new Format(CommaSeparatedValue, XplatUI.ClipboardGetID(cliphandle, CommaSeparatedValue), f);
165 f = new Format(Html, XplatUI.ClipboardGetID(cliphandle, Html), f);
166 f = new Format(Rtf, XplatUI.ClipboardGetID(cliphandle, Rtf), f);
167 f = new Format(Serializable, XplatUI.ClipboardGetID(cliphandle, Serializable), f);
168 f = new Format(StringFormat, XplatUI.ClipboardGetID(cliphandle, StringFormat), f);
170 XplatUI.ClipboardClose(cliphandle);
176 #endregion // Private Methods