资源简介
WinForm批量图片压缩工具源代码,一个非常好的WinForm学习例子。
代码片段和文件信息
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace ImageCompact
{
public partial class MainForm : Form
{
private IList imageList = new List();
private delegate void DelegateWriteResult(string file bool result);
private delegate void DelegateWriteMessage(string message);
public MainForm()
{
InitializeComponent();
lvSourceFolderList.GridLines = true;
lvSourceFolderList.FullRowSelect = true;
lvSourceFolderList.View = View.Details;
lvSourceFolderList.Scrollable = true;
lvSourceFolderList.MultiSelect = false;
lvSourceFolderList.Headerstyle = ColumnHeaderstyle.Nonclickable;
lvSourceFolderList.Columns.Add(“图片文件“ 500 HorizontalAlignment.Left);
lvResultList.GridLines = true;
lvResultList.FullRowSelect = true;
lvResultList.View = View.Details;
lvResultList.Scrollable = true;
lvResultList.MultiSelect = false;
lvResultList.Headerstyle = ColumnHeaderstyle.Nonclickable;
lvResultList.Columns.Add(“压缩文件“ 600 HorizontalAlignment.Left);
lvResultList.Columns.Add(“压缩结果“ 80 HorizontalAlignment.Center);
cbSizeRate.SelectedIndex = 8;
cbQualityRate.SelectedIndex = 8;
RegistryKey folders;
folders = OpenRegistryPath(Registry.CurrentUser @“\software\microsoft\windows\currentversion\explorer\shell folders“);
tbTargetFolderPath.Text = folders.GetValue(“Desktop“).ToString();
}
private void btnSelectSourceFolder_Click(object sender EventArgs e)
{
if (DialogResult.OK == folderBrowserDialog.ShowDialog())
{
this.lvSourceFolderList.Items.Clear();
tbSourceFolderPath.Text = folderBrowserDialog.SelectedPath;
ListFiles(new DirectoryInfo(tbSourceFolderPath.Text));
}
}
private void btnSelectTargetFolder_Click(object sender EventArgs e)
{
if (DialogResult.OK == folderBrowserDialog.ShowDialog())
{
tbTargetFolderPath.Text = folderBrowserDialog.SelectedPath;
}
}
private void btnClose_Click(object sender EventArgs e)
{
Application.Exit();
}
private void btnStart_Click(object sender EventArgs e)
{
if (!Directory.Exists(tbTargetFolderPath.Text))
{
MessageBox.Show(“目标文件夹不存在,请先建立这个文件夹。“ “存储错误“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
}
if
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-08-09 21:25 ImageCompact\
目录 0 2013-08-09 21:27 ImageCompact\ImageCompact\
文件 926 2013-08-09 21:25 ImageCompact\ImageCompact.sln
文件 30208 2013-08-09 22:23 ImageCompact\ImageCompact.v11.suo
目录 0 2013-08-09 21:27 ImageCompact\ImageCompact\bin\
目录 0 2013-08-09 22:00 ImageCompact\ImageCompact\bin\Debug\
文件 18432 2013-08-09 22:13 ImageCompact\ImageCompact\bin\Debug\ImageCompact.exe
文件 34304 2013-08-09 22:13 ImageCompact\ImageCompact\bin\Debug\ImageCompact.pdb
文件 21464 2013-08-09 22:00 ImageCompact\ImageCompact\bin\Debug\ImageCompact.vshost.exe
目录 0 2013-08-09 21:27 ImageCompact\ImageCompact\bin\Release\
文件 3706 2013-08-09 21:27 ImageCompact\ImageCompact\ImageCompact.csproj
文件 11953 2013-08-09 22:03 ImageCompact\ImageCompact\MainForm.cs
文件 14052 2013-08-09 22:02 ImageCompact\ImageCompact\MainForm.Designer.cs
文件 6024 2013-08-09 22:02 ImageCompact\ImageCompact\MainForm.resx
目录 0 2013-08-09 21:25 ImageCompact\ImageCompact\obj\
目录 0 2013-08-09 22:13 ImageCompact\ImageCompact\obj\Debug\
文件 789 2013-08-09 21:25 ImageCompact\ImageCompact\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6849 2013-08-09 21:27 ImageCompact\ImageCompact\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 749 2013-08-09 22:01 ImageCompact\ImageCompact\obj\Debug\ImageCompact.csproj.FileListAbsolute.txt
文件 850 2013-08-09 22:02 ImageCompact\ImageCompact\obj\Debug\ImageCompact.csproj.GenerateResource.Cache
文件 1757 2013-08-09 21:27 ImageCompact\ImageCompact\obj\Debug\ImageCompact.csprojResolveAssemblyReference.cache
文件 18432 2013-08-09 22:13 ImageCompact\ImageCompact\obj\Debug\ImageCompact.exe
文件 180 2013-08-09 22:02 ImageCompact\ImageCompact\obj\Debug\ImageCompact.MainForm.resources
文件 34304 2013-08-09 22:13 ImageCompact\ImageCompact\obj\Debug\ImageCompact.pdb
文件 180 2013-08-09 21:27 ImageCompact\ImageCompact\obj\Debug\ImageCompact.Properties.Resources.resources
目录 0 2013-08-09 21:25 ImageCompact\ImageCompact\obj\Debug\TempPE\
文件 496 2013-08-09 21:27 ImageCompact\ImageCompact\Program.cs
目录 0 2013-08-09 21:25 ImageCompact\ImageCompact\Properties\
文件 1344 2013-08-09 21:25 ImageCompact\ImageCompact\Properties\AssemblyInfo.cs
文件 2876 2013-08-09 21:25 ImageCompact\ImageCompact\Properties\Resources.Designer.cs
文件 5612 2013-08-09 21:25 ImageCompact\ImageCompact\Properties\Resources.resx
............此处省略2个文件信息
- 上一篇:CRUDc#
- 下一篇:C#winform获取外接USB设备信息
评论
共有 条评论