|
1 | 1 | using System; |
| 2 | +using System.Collections.Generic; |
2 | 3 | using System.Diagnostics; |
3 | 4 | using System.Drawing; |
4 | 5 | using System.Drawing.Imaging; |
@@ -193,48 +194,48 @@ private void updateContents() { |
193 | 194 |
|
194 | 195 | Type saveAs = TypeMethods.FromExtension(comExt.Text); |
195 | 196 |
|
196 | | - if (clipData.HasDataThatCanBeSaveAs(saveAs)) { |
197 | | - if (saveAs == Type.IMAGE && clipData.Image != null) { |
198 | | - imgContent.BackgroundImage = clipData.Image; |
199 | | - imgContent.Show(); |
200 | | - box.Text = string.Format(Resources.str_preview_image, clipData.Image.Width, clipData.Image.Height); |
201 | | - } |
202 | | - else if (saveAs == Type.HTML && clipData.Html != null) { |
203 | | - htmlContent.DocumentText = clipData.Html; |
204 | | - htmlContent.Show(); |
205 | | - box.Text = Resources.str_preview_html; |
206 | | - } |
207 | | - else if (saveAs == Type.URL && clipData.TextUrl != null) { |
208 | | - txtContent.Text = clipData.TextUrl; |
209 | | - txtContent.Show(); |
210 | | - box.Text = Resources.str_preview_url; |
211 | | - } |
212 | | - else if (saveAs == Type.CSV && clipData.Csv != null) { |
213 | | - txtContent.Text = clipData.Csv; |
214 | | - txtContent.Show(); |
215 | | - box.Text = Resources.str_preview_csv; |
216 | | - } |
217 | | - else if (saveAs == Type.SYLK && clipData.Sylk != null) { |
218 | | - txtContent.Text = clipData.Sylk; |
219 | | - txtContent.Show(); |
220 | | - box.Text = Resources.str_preview_sylk; |
221 | | - } |
222 | | - else if (saveAs == Type.RTF && clipData.Rtf != null) { |
223 | | - txtContent.Rtf = clipData.Rtf; |
224 | | - txtContent.Show(); |
225 | | - box.Text = Resources.str_preview_rtf; |
226 | | - } |
227 | | - else if (saveAs.IsLikeText()) { |
228 | | - txtContent.Text = clipData.Text; |
| 197 | + if (saveAs == Type.IMAGE && clipData.Image != null) { |
| 198 | + imgContent.BackgroundImage = clipData.Image; |
| 199 | + imgContent.Show(); |
| 200 | + box.Text = string.Format(Resources.str_preview_image, clipData.Image.Width, clipData.Image.Height); |
| 201 | + return; |
| 202 | + } |
| 203 | + |
| 204 | + if (saveAs == Type.HTML && clipData.Html != null) { |
| 205 | + htmlContent.DocumentText = clipData.Html; |
| 206 | + htmlContent.Show(); |
| 207 | + box.Text = Resources.str_preview_html; |
| 208 | + return; |
| 209 | + } |
| 210 | + |
| 211 | + // text like formats which are show in txtContent preview |
| 212 | + foreach (var t in new Dictionary<Type, string> { |
| 213 | + { Type.URL, Resources.str_preview_url }, |
| 214 | + { Type.CSV, Resources.str_preview_csv }, |
| 215 | + { Type.SYLK, Resources.str_preview_sylk }, |
| 216 | + { Type.DIF, Resources.str_preview_dif }, |
| 217 | + { Type.RTF, Resources.str_preview_rtf }, |
| 218 | + }) |
| 219 | + { |
| 220 | + if (saveAs == t.Key && clipData[t.Key] is string) { |
| 221 | + txtContent.Text = clipData[t.Key] as string; |
229 | 222 | txtContent.Show(); |
230 | | - box.Text = string.Format(Resources.str_preview_text, clipData.Text.Length, clipData.Text.Split('\n').Length); |
| 223 | + box.Text = t.Value; |
| 224 | + return; |
231 | 225 | } |
232 | | - |
233 | 226 | } |
234 | | - else { |
235 | | - box.Text = Resources.str_error_cliboard_format_missmatch; |
| 227 | + |
| 228 | + if (saveAs.IsLikeText() && clipData.Text != null) { |
| 229 | + txtContent.Text = clipData.Text; |
| 230 | + txtContent.Show(); |
| 231 | + box.Text = string.Format(Resources.str_preview_text, clipData.Text.Length, |
| 232 | + clipData.Text.Split('\n').Length); |
| 233 | + return; |
236 | 234 | } |
237 | 235 |
|
| 236 | + // no matching data found |
| 237 | + box.Text = Resources.str_error_cliboard_format_missmatch; |
| 238 | + |
238 | 239 | } |
239 | 240 | private void updateSavebutton() |
240 | 241 | { |
@@ -321,6 +322,9 @@ string save() |
321 | 322 | else if (saveAs == Type.SYLK && clipData.Sylk != null) { |
322 | 323 | File.WriteAllText(file, clipData.Sylk, Encoding.ASCII); |
323 | 324 | } |
| 325 | + else if (saveAs == Type.DIF && clipData.Dif != null) { |
| 326 | + File.WriteAllText(file, clipData.Dif, Encoding.ASCII); |
| 327 | + } |
324 | 328 | else if (saveAs == Type.RTF && clipData.Rtf != null) { |
325 | 329 | File.WriteAllText(file, clipData.Rtf, Encoding.ASCII); |
326 | 330 | } |
|
0 commit comments