如果Infopath设计的模版上有图片框(图片内插),当插入图片并把录入的输入移至其它地方后
     如果其它用户想看原图,有几种方法,
1、右键单击, 复制粘贴到,office的软件中查看,最好是粘贴到Fantpange中
2、自己写工具,把数据从Infopath声称的XML数据文件中 导出来,不过要导就全部都导出来了,我不需要看这么多,只想看其中一张图片
3、还有一种方式是,写一个浏览图片的工具,想看那张看那张,哈哈,方便多了

实现方式:
1、在Infopath数据文件中右键单击想要浏览的图片,复制
2、复制的同时,Windows系统会在缓存中生成一个临时文件;
3、从自己的工具中引用这个临时文件,就OK了
4、因为从剪贴板取不到Infopath的图片数据,只能取到一个HTM文件,是关于复制的Infopath图片的信息
      如果是复制的其他图片,如从网上或是浏览其中,就很容易的从剪贴板上直接去过来了

如图所示Infopath数据;


粘贴过来的工具显示效果


软件代码
  1using System;
  2using System.Drawing;
  3using System.Collections;
  4using System.ComponentModel;
  5using System.Windows.Forms;
  6using System.Data;
  7
  8namespace 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 窗体设计器生成的代码
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


posted on 2007-02-01 10:50  Dragon-China  阅读(1177)  评论(0编辑  收藏  举报