C# 调用画图工具打开图片
来源:互联网 发布:网络教学和函授 编辑:程序博客网 时间:2024/05/18 01:22
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Diagnostics;
namespace WinFormBrowserImage
{
public partial class FormImage : Form
{
#region
private DataTable table;
private PictureBox picture;
private Splitter split;
private OpenFileDialog openFile;
#endregion
public FormImage()
{
#region
InitializeComponent();
openFile = new OpenFileDialog();
openFile.Filter = "图像格式(*.BMP;*.GIF;*.JPG;*.PNG)|*.bmp;*.gif;*.jpg;*.png";
this.AllowDrop = true;
this.HelpButton = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.BackgroundImageLayout = ImageLayout.Zoom;
this.StartPosition = FormStartPosition.WindowsDefaultBounds;
this.Text = "单击标题栏里的帮助按钮可加载图片";
#endregion
}
protected override void OnDragEnter(DragEventArgs e)
{
base.OnDragEnter(e);
this.Activate();
DataObject data = e.Data as DataObject;
if (data.ContainsFileDropList())
{
FileInfo info = new FileInfo(data.GetFileDropList()[0]);
if (Regex.IsMatch(info.Extension, @".(bmp|gif|jpg|png)", RegexOptions.IgnoreCase)) // 指定不区分大小写的匹配。
{
this.Text = info.Name;
this.BackgroundImage = Image.FromFile(info.FullName);
Environment.CurrentDirectory = info.DirectoryName;
openFile.FileName = info.FullName;
}
}
}
protected override void OnHelpButtonClicked(CancelEventArgs e)
{
base.OnHelpButtonClicked(e);
e.Cancel = true;
if (openFile.ShowDialog(this) == DialogResult.OK)
{
this.Text = openFile.SafeFileName;
this.BackgroundImage = Image.FromFile(openFile.FileName);
}
}
protected override void OnDoubleClick(EventArgs e)
{
base.OnDoubleClick(e);
if (File.Exists(this.Text))
{
Process.Start("mspaint.exe", this.Text);
//using (Process psi = new Process())
//{
// ProcessStartInfo info = psi.StartInfo;
// info.FileName = "mspaint.exe"; // 画图工具。
// info.Arguments = this.Text;
// info.WorkingDirectory = Environment.CurrentDirectory; // 当前工作目录。
// info.WindowStyle = ProcessWindowStyle.Maximized; // 窗口最大化。
// psi.Start();
//}
}
}
}
}
- C# 调用画图工具打开图片
- C#调用Windows图片和传真查看器打开图片
- C#调用Windows图片和传真查看器打开图片
- C#调用电脑的默认图片浏览器软件打开图片
- C#仿windows画图工具
- 通过Process.Start调用window自带画图工具打开文件报错无法打开Program.png
- C#中打开图片
- C#调用win32API画图函数示例
- Qt调用OpenCV打开图片
- C# 关闭/打开显示器工具
- C# 调用系统图片
- c#打开图片,用picturebox打开
- c# 中释放打开图片和 子窗体调用父窗体函数
- 调用系统图片查看器,打开图片
- 画图工具
- 画图工具
- 画图工具
- 画图工具
- SQL 存储过程中使用游标的样例
- 基于 Cairngorm MVC 框架的 Flex 程序设计与开发
- C# 更改大小写
- C# MD5 加密
- 应用程序基础,andriod框架主题知识
- C# 调用画图工具打开图片
- andriod用户界面UI
- C# 检索IE缓存图片
- C#向前台页面中输出JS代码
- C# 阴历,阳历互转
- python 线程,GIL 和 ctypes
- PrintToExcel
- MyEclipse8.5插件安装 即性能优化 补充myeclipse6.5的
- Extension Method