如果Infopath设计的模版上有图片框(图片内插),当插入图片并把录入的输入移至其它地方后
如果其它用户想看原图,有几种方法,
1、右键单击, 复制粘贴到,office的软件中查看,最好是粘贴到Fantpange中
2、自己写工具,把数据从Infopath声称的XML数据文件中 导出来,不过要导就全部都导出来了,我不需要看这么多,只想看其中一张图片
3、还有一种方式是,写一个浏览图片的工具,想看那张看那张,哈哈,方便多了
实现方式:
1、在Infopath数据文件中右键单击想要浏览的图片,复制
2、复制的同时,Windows系统会在缓存中生成一个临时文件;
3、从自己的工具中引用这个临时文件,就OK了
4、因为从剪贴板取不到Infopath的图片数据,只能取到一个HTM文件,是关于复制的Infopath图片的信息
如果是复制的其他图片,如从网上或是浏览其中,就很容易的从剪贴板上直接去过来了
如图所示Infopath数据;

粘贴过来的工具显示效果

软件代码
如果其它用户想看原图,有几种方法,
1、右键单击, 复制粘贴到,office的软件中查看,最好是粘贴到Fantpange中
2、自己写工具,把数据从Infopath声称的XML数据文件中 导出来,不过要导就全部都导出来了,我不需要看这么多,只想看其中一张图片
3、还有一种方式是,写一个浏览图片的工具,想看那张看那张,哈哈,方便多了
实现方式:
1、在Infopath数据文件中右键单击想要浏览的图片,复制
2、复制的同时,Windows系统会在缓存中生成一个临时文件;
3、从自己的工具中引用这个临时文件,就OK了
4、因为从剪贴板取不到Infopath的图片数据,只能取到一个HTM文件,是关于复制的Infopath图片的信息
如果是复制的其他图片,如从网上或是浏览其中,就很容易的从剪贴板上直接去过来了
如图所示Infopath数据;

粘贴过来的工具显示效果

软件代码
1
using System;
2
using System.Drawing;
3
using System.Collections;
4
using System.ComponentModel;
5
using System.Windows.Forms;
6
using System.Data;
7
8
namespace RecordSoft
9

{
10
/**//// <summary>
11
/// Form1 的摘要说明。
12
/// </summary>
13
public class Form1 : System.Windows.Forms.Form
14
{
15
private System.Windows.Forms.ToolBar toolBar1;
16
private System.Windows.Forms.ImageList imageList1;
17
private System.Windows.Forms.Panel panel1;
18
private System.Windows.Forms.PictureBox pictureBox1;
19
private System.Windows.Forms.ToolBarButton tbbPasteImage;
20
private System.Windows.Forms.ToolBarButton tbbImageMoveLeft;
21
private System.Windows.Forms.ToolBarButton tbbImageMoveRight;
22
private System.Windows.Forms.ToolBarButton tbbImageMoveUp;
23
private System.Windows.Forms.ToolBarButton tbbImageMoveDown;
24
private System.Windows.Forms.ToolBarButton tbbImageZoomIn;
25
private System.Windows.Forms.ToolBarButton tbbImageZoomOut;
26
private System.Windows.Forms.ToolBarButton tbbExit;
27
private System.Windows.Forms.ToolBarButton tbbImageSave;
28
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
29
private System.Windows.Forms.ToolBarButton tbbOriginalImage;
30
private System.ComponentModel.IContainer components;
31
32
int height = 0;
33
int width = 0;
34
string html = "";
35
int index1 = 0;
36
private System.Windows.Forms.StatusBar statusBar1;
37
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
38
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
39
private System.Windows.Forms.StatusBarPanel statusBarPanel3;
40
int index2 = 0;
41
42
public Form1()
43
{
44
//
45
// Windows 窗体设计器支持所必需的
46
//
47
InitializeComponent();
48
49
//
50
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
51
//
52
}
53
54
/**//// <summary>
55
/// 清理所有正在使用的资源。
56
/// </summary>
57
protected override void Dispose( bool disposing )
58
{
59
if( disposing )
60
{
61
if (components != null)
62
{
63
components.Dispose();
64
}
65
}
66
base.Dispose( disposing );
67
}
68
69
Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码
70
/**//// <summary>
71
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
72
/// 此方法的内容。
73
/// </summary>
74
private void InitializeComponent()
75
{
76
this.components = new System.ComponentModel.Container();
77
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
78
this.toolBar1 = new System.Windows.Forms.ToolBar();
79
this.tbbImageSave = new System.Windows.Forms.ToolBarButton();
80
this.tbbPasteImage = new System.Windows.Forms.ToolBarButton();
81
this.tbbImageMoveLeft = new System.Windows.Forms.ToolBarButton();
82
this.tbbImageMoveRight = new System.Windows.Forms.ToolBarButton();
83
this.tbbImageMoveUp = new System.Windows.Forms.ToolBarButton();
84
this.tbbImageMoveDown = new System.Windows.Forms.ToolBarButton();
85
this.tbbImageZoomIn = new System.Windows.Forms.ToolBarButton();
86
this.tbbImageZoomOut = new System.Windows.Forms.ToolBarButton();
87
this.tbbOriginalImage = new System.Windows.Forms.ToolBarButton();
88
this.tbbExit = new System.Windows.Forms.ToolBarButton();
89
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
90
this.panel1 = new System.Windows.Forms.Panel();
91
this.pictureBox1 = new System.Windows.Forms.PictureBox();
92
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
93
this.statusBar1 = new System.Windows.Forms.StatusBar();
94
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
95
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
96
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
97
this.panel1.SuspendLayout();
98
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
99
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
100
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
101
this.SuspendLayout();
102
//
103
// toolBar1
104
//
105
this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
106
this.toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
107
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[]
{
108
this.tbbPasteImage,
109
this.tbbImageSave,
110
this.tbbImageMoveLeft,
111
this.tbbImageMoveRight,
112
this.tbbImageMoveUp,
113
this.tbbImageMoveDown,
114
this.tbbImageZoomIn,
115
this.tbbImageZoomOut,
116
this.tbbOriginalImage,
117
this.tbbExit});
118
this.toolBar1.DropDownArrows = true;
119
this.toolBar1.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
120
this.toolBar1.ImageList = this.imageList1;
121
this.toolBar1.Location = new System.Drawing.Point(0, 0);
122
this.toolBar1.Name = "toolBar1";
123
this.toolBar1.ShowToolTips = true;
124
this.toolBar1.Size = new System.Drawing.Size(864, 43);
125
this.toolBar1.TabIndex = 1;
126
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
127
//
128
// tbbImageSave
129
//
130
this.tbbImageSave.ImageIndex = 10;
131
this.tbbImageSave.Text = "保存";
132
this.tbbImageSave.ToolTipText = "保存图片框中的图片";
133
//
134
// tbbPasteImage
135
//
136
this.tbbPasteImage.ImageIndex = 5;
137
this.tbbPasteImage.Text = "粘贴";
138
this.tbbPasteImage.ToolTipText = "粘贴Infopath图片框的复制内容";
139
//
140
// tbbImageMoveLeft
141
//
142
this.tbbImageMoveLeft.ImageIndex = 1;
143
this.tbbImageMoveLeft.Text = "左移";
144
this.tbbImageMoveLeft.ToolTipText = "向左移动图像";
145
//
146
// tbbImageMoveRight
147
//
148
this.tbbImageMoveRight.ImageIndex = 2;
149
this.tbbImageMoveRight.Text = "右移";
150
this.tbbImageMoveRight.ToolTipText = "向右移动图像";
151
//
152
// tbbImageMoveUp
153
//
154
this.tbbImageMoveUp.ImageIndex = 3;
155
this.tbbImageMoveUp.Text = "上移";
156
this.tbbImageMoveUp.ToolTipText = "向上移动图像";
157
//
158
// tbbImageMoveDown
159
//
160
this.tbbImageMoveDown.ImageIndex = 0;
161
this.tbbImageMoveDown.Text = "下移";
162
this.tbbImageMoveDown.ToolTipText = "向下移动图像";
163
//
164
// tbbImageZoomIn
165
//
166
this.tbbImageZoomIn.ImageIndex = 12;
167
this.tbbImageZoomIn.Text = "放大";
168
this.tbbImageZoomIn.ToolTipText = "放大图像";
169
//
170
// tbbImageZoomOut
171
//
172
this.tbbImageZoomOut.ImageIndex = 12;
173
this.tbbImageZoomOut.Text = "缩小";
174
this.tbbImageZoomOut.ToolTipText = "缩小图像";
175
//
176
// tbbOriginalImage
177
//
178
this.tbbOriginalImage.ImageIndex = 9;
179
this.tbbOriginalImage.Text = "原图";
180
this.tbbOriginalImage.ToolTipText = "图像的原始大小";
181
//
182
// tbbExit
183
//
184
this.tbbExit.ImageIndex = 13;
185
this.tbbExit.Text = "退出";
186
this.tbbExit.ToolTipText = "退出工具";
187
//
188
// imageList1
189
//
190
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
191
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
192
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
193
//
194
// panel1
195
//
196
this.panel1.AutoScroll = true;
197
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
198
this.panel1.Controls.Add(this.pictureBox1);
199
this.panel1.Location = new System.Drawing.Point(0, 48);
200
this.panel1.Name = "panel1";
201
this.panel1.Size = new System.Drawing.Size(864, 630);
202
this.panel1.TabIndex = 2;
203
//
204
// pictureBox1
205
//
206
this.pictureBox1.BackColor = System.Drawing.SystemColors.Control;
207
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
208
this.pictureBox1.Name = "pictureBox1";
209
this.pictureBox1.Size = new System.Drawing.Size(856, 624);
210
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
211
this.pictureBox1.TabIndex = 3;
212
this.pictureBox1.TabStop = false;
213
this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
214
//
215
// statusBar1
216
//
217
this.statusBar1.Location = new System.Drawing.Point(0, 678);
218
this.statusBar1.Name = "statusBar1";
219
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[]
{
220
this.statusBarPanel1,
221
this.statusBarPanel2,
222
this.statusBarPanel3});
223
this.statusBar1.ShowPanels = true;
224
this.statusBar1.Size = new System.Drawing.Size(864, 32);
225
this.statusBar1.TabIndex = 3;
226
//
227
// statusBarPanel1
228
//
229
this.statusBarPanel1.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
230
this.statusBarPanel1.Width = 200;
231
//
232
// statusBarPanel2
233
//
234
this.statusBarPanel2.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
235
this.statusBarPanel2.Width = 200;
236
//
237
// statusBarPanel3
238
//
239
this.statusBarPanel3.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
240
this.statusBarPanel3.Width = 200;
241
//
242
// Form1
243
//
244
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
245
this.AutoScroll = true;
246
this.ClientSize = new System.Drawing.Size(864, 710);
247
this.Controls.Add(this.statusBar1);
248
this.Controls.Add(this.panel1);
249
this.Controls.Add(this.toolBar1);
250
this.MaximizeBox = false;
251
this.Name = "Form1";
252
this.Text = "Infopath图片察看工具";
253
this.panel1.ResumeLayout(false);
254
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
255
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
256
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
257
this.ResumeLayout(false);
258
259
}
260
#endregion
261
262
/**//// <summary>
263
/// 应用程序的主入口点。
264
/// </summary>
265
[STAThread]
266
// static void Main()
267
// {
268
// Application.Run(new Form1());
269
// }
270
271
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
272
{
273
274
if(e.Button == this.tbbImageSave) //图像保存
275
{
276
this.saveFileDialog1.Filter ="JPEG文件(*.JPEG,*.JPG)|*.JPG|BMP文件(*.BMP)|*.BMP|GIF文件(*.GIF)|*.GIF";
277
this.saveFileDialog1.Title = "请选择文件保存的路径";
278
this.saveFileDialog1.ShowDialog();
279
this.saveFileDialog1.OverwritePrompt = true; //文件名重复则提示
280
if(this.saveFileDialog1.FileName !="")
281
{
282
if(this.saveFileDialog1.FilterIndex ==1)
283
this.pictureBox1.Image.Save(this.saveFileDialog1.FileName,System.Drawing.Imaging.ImageFormat.Jpeg);
284
else if(this.saveFileDialog1.FilterIndex ==2)
285
this.pictureBox1.Image.Save(this.saveFileDialog1.FileName,System.Drawing.Imaging.ImageFormat.Bmp);
286
else if(this.saveFileDialog1.FilterIndex ==3)
287
this.pictureBox1.Image.Save(this.saveFileDialog1.FileName,System.Drawing.Imaging.ImageFormat.Gif);
288
}
289
}
290
else if(e.Button == this.tbbPasteImage) //图像粘贴
291
{
292
293
if(Clipboard.GetDataObject() != null)
294
{
295
IDataObject data = Clipboard.GetDataObject();
296
297
if(data.GetDataPresent(DataFormats.Bitmap))
298
{
299
try
300
{
301
if(data.GetData(DataFormats.Bitmap) as Bitmap != null)
302
{
303
this.pictureBox1.Image = (Bitmap)data.GetData(DataFormats.Bitmap);
304
}
305
else
306
{
307
//Image image = (Image)data.GetData(DataFormats.Bitmap,true);
308
//this.pictureBox1.Image = (Bitmap)data.GetData("DeviceIndependentBitmap");
309
//System.IO.MemoryStream bb = data.GetData("UntrustedDragDrop") as System.IO.MemoryStream;
310
//Bitmap bit = new Bitmap(bb);
311
html = data.GetData("HTML Format").ToString();
312
index1 = html.IndexOf("src=");
313
index2 = html.IndexOf(".tmp");
314
html = html.Substring(index1+5,index2-index1-1);
315
316
Bitmap mybitmap = new Bitmap(html);
317
this.pictureBox1.Image = mybitmap;
318
}
319
320
height = this.pictureBox1.Image.Height;
321
width = this.pictureBox1.Image.Width;
322
323
this.pictureBox1.Height= height;
324
this.pictureBox1.Width = width;
325
326
this.statusBarPanel1.Text = "欢迎使用本工具";
327
this.statusBarPanel2.Text = "图像宽度:"+width+" 图像高度:"+height;
328
}
329
catch(Exception error)
330
{
331
MessageBox.Show("出错信息:\r\n"+error.Message+"","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
332
}
333
}
334
else
335
{
336
MessageBox.Show("剪贴板中没有可显示的图像格式","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
337
}
338
}
339
else
340
{
341
MessageBox.Show("系统剪贴板为空","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
342
}
343
}
344
else if(e.Button == this.tbbImageMoveLeft) //图像左移
345
{
346
if(this.pictureBox1.Right - this.panel1.Width >= 0 && this.pictureBox1.Width > this.panel1.Width)
347
{
348
this.pictureBox1.Left = this.pictureBox1.Left - 20;
349
}
350
}
351
else if(e.Button == this.tbbImageMoveRight) //图像右移
352
{
353
if(this.pictureBox1.Left < this.panel1.Left )
354
this.pictureBox1.Left = this.pictureBox1.Left + 20;
355
}
356
else if(e.Button == this.tbbImageMoveUp) //图像上移
357
{
358
if(this.pictureBox1.Bottom > this.panel1.Height && this.pictureBox1.Height>this.panel1.Height)
359
this.pictureBox1.Top = this.pictureBox1.Top - 20;
360
}
361
else if(e.Button == this.tbbImageMoveDown) //图像下移
362
{
363
if(this.pictureBox1.Top < this.panel1.Top-56)
364
this.pictureBox1.Top = this.pictureBox1.Top + 20;
365
}
366
else if(e.Button == this.tbbImageZoomIn) //图像放大
367
{
368
this.pictureBox1.Width = Convert.ToInt32(this.pictureBox1.Width*1.1);
369
this.pictureBox1.Height = Convert.ToInt32(this.pictureBox1.Height*1.1);
370
}
371
else if(e.Button == this.tbbImageZoomOut) //图像缩小
372
{
373
this.pictureBox1.Width = Convert.ToInt32(this.pictureBox1.Width*0.9);
374
this.pictureBox1.Height = Convert.ToInt32(this.pictureBox1.Height*0.9);
375
}
376
else if(e.Button == this.tbbOriginalImage) //原始图像
377
{
378
this.pictureBox1.Height = height;
379
this.pictureBox1.Width = width;
380
}
381
else if(e.Button == this.tbbExit) //程序退出
382
{
383
System.Windows.Forms.Application.Exit();
384
}
385
386
}
387
388
private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
389
{
390
this.statusBarPanel3.Text = "光标位置: X="+Cursor.Position.X+" Y="+Cursor.Position.Y;
391
392
}
393
394
395
396
397
}
398
}
399
using System;2
using System.Drawing;3
using System.Collections;4
using System.ComponentModel;5
using System.Windows.Forms;6
using System.Data;7

8
namespace RecordSoft9


{10

/**//// <summary>11
/// Form1 的摘要说明。12
/// </summary>13
public class Form1 : System.Windows.Forms.Form14

{15
private System.Windows.Forms.ToolBar toolBar1;16
private System.Windows.Forms.ImageList imageList1;17
private System.Windows.Forms.Panel panel1;18
private System.Windows.Forms.PictureBox pictureBox1;19
private System.Windows.Forms.ToolBarButton tbbPasteImage;20
private System.Windows.Forms.ToolBarButton tbbImageMoveLeft;21
private System.Windows.Forms.ToolBarButton tbbImageMoveRight;22
private System.Windows.Forms.ToolBarButton tbbImageMoveUp;23
private System.Windows.Forms.ToolBarButton tbbImageMoveDown;24
private System.Windows.Forms.ToolBarButton tbbImageZoomIn;25
private System.Windows.Forms.ToolBarButton tbbImageZoomOut;26
private System.Windows.Forms.ToolBarButton tbbExit;27
private System.Windows.Forms.ToolBarButton tbbImageSave;28
private System.Windows.Forms.SaveFileDialog saveFileDialog1;29
private System.Windows.Forms.ToolBarButton tbbOriginalImage;30
private System.ComponentModel.IContainer components;31

32
int height = 0;33
int width = 0;34
string html = "";35
int index1 = 0;36
private System.Windows.Forms.StatusBar statusBar1;37
private System.Windows.Forms.StatusBarPanel statusBarPanel1;38
private System.Windows.Forms.StatusBarPanel statusBarPanel2;39
private System.Windows.Forms.StatusBarPanel statusBarPanel3;40
int index2 = 0;41

42
public Form1()43

{44
//45
// Windows 窗体设计器支持所必需的46
//47
InitializeComponent();48

49
//50
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码51
//52
}53

54

/**//// <summary>55
/// 清理所有正在使用的资源。56
/// </summary>57
protected override void Dispose( bool disposing )58

{59
if( disposing )60

{61
if (components != null) 62

{63
components.Dispose();64
}65
}66
base.Dispose( disposing );67
}68

69

Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码70

/**//// <summary>71
/// 设计器支持所需的方法 - 不要使用代码编辑器修改72
/// 此方法的内容。73
/// </summary>74
private void InitializeComponent()75

{76
this.components = new System.ComponentModel.Container();77
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));78
this.toolBar1 = new System.Windows.Forms.ToolBar();79
this.tbbImageSave = new System.Windows.Forms.ToolBarButton();80
this.tbbPasteImage = new System.Windows.Forms.ToolBarButton();81
this.tbbImageMoveLeft = new System.Windows.Forms.ToolBarButton();82
this.tbbImageMoveRight = new System.Windows.Forms.ToolBarButton();83
this.tbbImageMoveUp = new System.Windows.Forms.ToolBarButton();84
this.tbbImageMoveDown = new System.Windows.Forms.ToolBarButton();85
this.tbbImageZoomIn = new System.Windows.Forms.ToolBarButton();86
this.tbbImageZoomOut = new System.Windows.Forms.ToolBarButton();87
this.tbbOriginalImage = new System.Windows.Forms.ToolBarButton();88
this.tbbExit = new System.Windows.Forms.ToolBarButton();89
this.imageList1 = new System.Windows.Forms.ImageList(this.components);90
this.panel1 = new System.Windows.Forms.Panel();91
this.pictureBox1 = new System.Windows.Forms.PictureBox();92
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();93
this.statusBar1 = new System.Windows.Forms.StatusBar();94
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();95
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();96
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();97
this.panel1.SuspendLayout();98
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();99
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();100
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();101
this.SuspendLayout();102
// 103
// toolBar1104
// 105
this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;106
this.toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;107

this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[]
{108
this.tbbPasteImage,109
this.tbbImageSave,110
this.tbbImageMoveLeft,111
this.tbbImageMoveRight,112
this.tbbImageMoveUp,113
this.tbbImageMoveDown,114
this.tbbImageZoomIn,115
this.tbbImageZoomOut,116
this.tbbOriginalImage,117
this.tbbExit});118
this.toolBar1.DropDownArrows = true;119
this.toolBar1.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));120
this.toolBar1.ImageList = this.imageList1;121
this.toolBar1.Location = new System.Drawing.Point(0, 0);122
this.toolBar1.Name = "toolBar1";123
this.toolBar1.ShowToolTips = true;124
this.toolBar1.Size = new System.Drawing.Size(864, 43);125
this.toolBar1.TabIndex = 1;126
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);127
// 128
// tbbImageSave129
// 130
this.tbbImageSave.ImageIndex = 10;131
this.tbbImageSave.Text = "保存";132
this.tbbImageSave.ToolTipText = "保存图片框中的图片";133
// 134
// tbbPasteImage135
// 136
this.tbbPasteImage.ImageIndex = 5;137
this.tbbPasteImage.Text = "粘贴";138
this.tbbPasteImage.ToolTipText = "粘贴Infopath图片框的复制内容";139
// 140
// tbbImageMoveLeft141
// 142
this.tbbImageMoveLeft.ImageIndex = 1;143
this.tbbImageMoveLeft.Text = "左移";144
this.tbbImageMoveLeft.ToolTipText = "向左移动图像";145
// 146
// tbbImageMoveRight147
// 148
this.tbbImageMoveRight.ImageIndex = 2;149
this.tbbImageMoveRight.Text = "右移";150
this.tbbImageMoveRight.ToolTipText = "向右移动图像";151
// 152
// tbbImageMoveUp153
// 154
this.tbbImageMoveUp.ImageIndex = 3;155
this.tbbImageMoveUp.Text = "上移";156
this.tbbImageMoveUp.ToolTipText = "向上移动图像";157
// 158
// tbbImageMoveDown159
// 160
this.tbbImageMoveDown.ImageIndex = 0;161
this.tbbImageMoveDown.Text = "下移";162
this.tbbImageMoveDown.ToolTipText = "向下移动图像";163
// 164
// tbbImageZoomIn165
// 166
this.tbbImageZoomIn.ImageIndex = 12;167
this.tbbImageZoomIn.Text = "放大";168
this.tbbImageZoomIn.ToolTipText = "放大图像";169
// 170
// tbbImageZoomOut171
// 172
this.tbbImageZoomOut.ImageIndex = 12;173
this.tbbImageZoomOut.Text = "缩小";174
this.tbbImageZoomOut.ToolTipText = "缩小图像";175
// 176
// tbbOriginalImage177
// 178
this.tbbOriginalImage.ImageIndex = 9;179
this.tbbOriginalImage.Text = "原图";180
this.tbbOriginalImage.ToolTipText = "图像的原始大小";181
// 182
// tbbExit183
// 184
this.tbbExit.ImageIndex = 13;185
this.tbbExit.Text = "退出";186
this.tbbExit.ToolTipText = "退出工具";187
// 188
// imageList1189
// 190
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);191
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));192
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;193
// 194
// panel1195
// 196
this.panel1.AutoScroll = true;197
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;198
this.panel1.Controls.Add(this.pictureBox1);199
this.panel1.Location = new System.Drawing.Point(0, 48);200
this.panel1.Name = "panel1";201
this.panel1.Size = new System.Drawing.Size(864, 630);202
this.panel1.TabIndex = 2;203
// 204
// pictureBox1205
// 206
this.pictureBox1.BackColor = System.Drawing.SystemColors.Control;207
this.pictureBox1.Location = new System.Drawing.Point(0, 0);208
this.pictureBox1.Name = "pictureBox1";209
this.pictureBox1.Size = new System.Drawing.Size(856, 624);210
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;211
this.pictureBox1.TabIndex = 3;212
this.pictureBox1.TabStop = false;213
this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);214
// 215
// statusBar1216
// 217
this.statusBar1.Location = new System.Drawing.Point(0, 678);218
this.statusBar1.Name = "statusBar1";219

this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[]
{220
this.statusBarPanel1,221
this.statusBarPanel2,222
this.statusBarPanel3});223
this.statusBar1.ShowPanels = true;224
this.statusBar1.Size = new System.Drawing.Size(864, 32);225
this.statusBar1.TabIndex = 3;226
// 227
// statusBarPanel1228
// 229
this.statusBarPanel1.Alignment = System.Windows.Forms.HorizontalAlignment.Center;230
this.statusBarPanel1.Width = 200;231
// 232
// statusBarPanel2233
// 234
this.statusBarPanel2.Alignment = System.Windows.Forms.HorizontalAlignment.Center;235
this.statusBarPanel2.Width = 200;236
// 237
// statusBarPanel3238
// 239
this.statusBarPanel3.Alignment = System.Windows.Forms.HorizontalAlignment.Center;240
this.statusBarPanel3.Width = 200;241
// 242
// Form1243
// 244
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);245
this.AutoScroll = true;246
this.ClientSize = new System.Drawing.Size(864, 710);247
this.Controls.Add(this.statusBar1);248
this.Controls.Add(this.panel1);249
this.Controls.Add(this.toolBar1);250
this.MaximizeBox = false;251
this.Name = "Form1";252
this.Text = "Infopath图片察看工具";253
this.panel1.ResumeLayout(false);254
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();255
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();256
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();257
this.ResumeLayout(false);258

259
}260
#endregion261

262

/**//// <summary>263
/// 应用程序的主入口点。264
/// </summary>265
[STAThread]266
// static void Main() 267
// {268
// Application.Run(new Form1());269
// }270

271
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)272

{273
274
if(e.Button == this.tbbImageSave) //图像保存275

{ 276
this.saveFileDialog1.Filter ="JPEG文件(*.JPEG,*.JPG)|*.JPG|BMP文件(*.BMP)|*.BMP|GIF文件(*.GIF)|*.GIF";277
this.saveFileDialog1.Title = "请选择文件保存的路径";278
this.saveFileDialog1.ShowDialog(); 279
this.saveFileDialog1.OverwritePrompt = true; //文件名重复则提示280
if(this.saveFileDialog1.FileName !="")281

{282
if(this.saveFileDialog1.FilterIndex ==1)283
this.pictureBox1.Image.Save(this.saveFileDialog1.FileName,System.Drawing.Imaging.ImageFormat.Jpeg);284
else if(this.saveFileDialog1.FilterIndex ==2)285
this.pictureBox1.Image.Save(this.saveFileDialog1.FileName,System.Drawing.Imaging.ImageFormat.Bmp);286
else if(this.saveFileDialog1.FilterIndex ==3)287
this.pictureBox1.Image.Save(this.saveFileDialog1.FileName,System.Drawing.Imaging.ImageFormat.Gif);288
}289
}290
else if(e.Button == this.tbbPasteImage) //图像粘贴291

{292
293
if(Clipboard.GetDataObject() != null)294

{295
IDataObject data = Clipboard.GetDataObject();296

297
if(data.GetDataPresent(DataFormats.Bitmap))298

{299
try300

{ 301
if(data.GetData(DataFormats.Bitmap) as Bitmap != null)302

{303
this.pictureBox1.Image = (Bitmap)data.GetData(DataFormats.Bitmap);304
}305
else306

{307
//Image image = (Image)data.GetData(DataFormats.Bitmap,true);308
//this.pictureBox1.Image = (Bitmap)data.GetData("DeviceIndependentBitmap"); 309
//System.IO.MemoryStream bb = data.GetData("UntrustedDragDrop") as System.IO.MemoryStream;310
//Bitmap bit = new Bitmap(bb);311
html = data.GetData("HTML Format").ToString();312
index1 = html.IndexOf("src=");313
index2 = html.IndexOf(".tmp");314
html = html.Substring(index1+5,index2-index1-1); 315

316
Bitmap mybitmap = new Bitmap(html);317
this.pictureBox1.Image = mybitmap;318
}319

320
height = this.pictureBox1.Image.Height;321
width = this.pictureBox1.Image.Width;322

323
this.pictureBox1.Height= height;324
this.pictureBox1.Width = width;325

326
this.statusBarPanel1.Text = "欢迎使用本工具";327
this.statusBarPanel2.Text = "图像宽度:"+width+" 图像高度:"+height;328
}329
catch(Exception error)330

{331
MessageBox.Show("出错信息:\r\n"+error.Message+"","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information); 332
}333
}334
else335

{ 336
MessageBox.Show("剪贴板中没有可显示的图像格式","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);337
}338
}339
else340

{ 341
MessageBox.Show("系统剪贴板为空","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);342
}343
}344
else if(e.Button == this.tbbImageMoveLeft) //图像左移345

{346
if(this.pictureBox1.Right - this.panel1.Width >= 0 && this.pictureBox1.Width > this.panel1.Width)347

{348
this.pictureBox1.Left = this.pictureBox1.Left - 20; 349
}350
}351
else if(e.Button == this.tbbImageMoveRight) //图像右移352

{353
if(this.pictureBox1.Left < this.panel1.Left )354
this.pictureBox1.Left = this.pictureBox1.Left + 20; 355
}356
else if(e.Button == this.tbbImageMoveUp) //图像上移357

{358
if(this.pictureBox1.Bottom > this.panel1.Height && this.pictureBox1.Height>this.panel1.Height)359
this.pictureBox1.Top = this.pictureBox1.Top - 20;360
}361
else if(e.Button == this.tbbImageMoveDown) //图像下移362

{363
if(this.pictureBox1.Top < this.panel1.Top-56)364
this.pictureBox1.Top = this.pictureBox1.Top + 20;365
}366
else if(e.Button == this.tbbImageZoomIn) //图像放大367

{368
this.pictureBox1.Width = Convert.ToInt32(this.pictureBox1.Width*1.1);369
this.pictureBox1.Height = Convert.ToInt32(this.pictureBox1.Height*1.1);370
}371
else if(e.Button == this.tbbImageZoomOut) //图像缩小372

{373
this.pictureBox1.Width = Convert.ToInt32(this.pictureBox1.Width*0.9);374
this.pictureBox1.Height = Convert.ToInt32(this.pictureBox1.Height*0.9);375
}376
else if(e.Button == this.tbbOriginalImage) //原始图像377

{ 378
this.pictureBox1.Height = height;379
this.pictureBox1.Width = width;380
}381
else if(e.Button == this.tbbExit) //程序退出382

{383
System.Windows.Forms.Application.Exit();384
}385
386
}387

388
private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)389

{390
this.statusBarPanel3.Text = "光标位置: X="+Cursor.Position.X+" Y="+Cursor.Position.Y;391
392
}393
394

395

396
397
}398
}399

