图片的放大和缩小

点击放大,图片变大,点击缩小,图片缩小

 

代码

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Text;
 7 using System.Linq;
 8 using System.Threading.Tasks;
 9 using System.Windows.Forms;
10 using DevExpress.XtraEditors;
11 using Com.HuaQin.DBHelper;
12 using System.Drawing;
13 using System.Drawing.Imaging;
14 using System.Reflection;
15 
16 namespace Com.HuaQin.WKStationPlugin
17 {
18     public partial class xFrmQueryChild : DevExpress.XtraEditors.XtraForm
19     {
20         private Image myBitmap;
21         Point op, np;
22         Picture pic;
23         myPoint mousePoint = new myPoint();
24         Boolean flag = true;
25         Boolean mouseDown;
26         Shift sft = new Shift();
27         int scale =1;
28         public xFrmQueryChild(Image bit)
29         {
30             InitializeComponent();
31             pictureEdit1.Image = bit;
32             //pictureBox1.Image = bit;
33             
34             //this.pictureBox1.Image = myBitmap;
35             //pic = new Picture(bit, pictureBox1);
36             //pictureEdit1.ContextMenu = GetMenu(pictureEdit1);
37         }
38 
39         private void toolStripButton2_Click(object sender, EventArgs e)
40         {
41             //InvokeMenuMethod(GetMenu(pictureEdit1) ,"zoomTo");
42             //
43         }
44 
45         private DevExpress.XtraEditors.Controls.PictureMenu GetMenu(DevExpress.XtraEditors.PictureEdit edit)
46         {
47             PropertyInfo pi = typeof(DevExpress.XtraEditors.PictureEdit).GetProperty("Menu", BindingFlags.NonPublic | BindingFlags.Instance);
48             if (pi != null)
49                 return pi.GetValue(edit, null) as DevExpress.XtraEditors.Controls.PictureMenu;
50             return null;
51         }
52         private void InvokeMenuMethod(DevExpress.XtraEditors.Controls.PictureMenu menu, string name)
53         {
54             MethodInfo mi = typeof(DevExpress.XtraEditors.Controls.PictureMenu).GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance);
55             if (mi != null && menu != null)
56                 mi.Invoke(menu, new object[] { menu, new EventArgs() });
57         }
58 
59         private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
60         {
61             var menu = GetMenu(pictureEdit1);
62             InvokeMenuMethod(menu, "OnZoomIn");
63             //"OnZoomOut"
64         }
65 
66         private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
67         {
68             var menu = GetMenu(pictureEdit1);
69             InvokeMenuMethod(menu, "OnZoomOut");
70         }
71        
72     }
73 }
View Code

 

posted on 2016-03-09 14:51  江湖霸王  阅读(246)  评论(0编辑  收藏  举报

导航