图片管理器

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

兰州商学院陇桥学院
工学系课程设计报告
设计题目:图片管理系统
系别:工学系
专业 (方向):信息管理与信息系统
年级、班: 2011级信息管理与信息系统班学生姓名:潘存利
学生学号: 20110651123 指导教师: 安晓燕
2013年12月26日
目录
一、系统开发背景 (3)
二、系统分析与设计 (3)
(一)系统功能要求 (3)
(二)系统模块结构设计 (3)
三、系统的设计与实现 (4)
(一)系统窗体页面的设计 (4)
(二)具体功能模块的实现 (5)
四、系统测试 (9)
(一)测试窗口界面的实现 (9)
(二)各模块功能的具体测试 (10)
五、总结 (12)
六、附件(代码、部分图表) (13)
图片管理系统
一、系统开发背景
随着科技的进步和发展,当今社会正快速向信息化社会前进,信息自动化的作用越来越大,从而使我们从繁琐的事物中解放出来,提高了我们的工作效率。

图片管理对每个人都至关重要。

图片管理系统充分利用信息技术提高个人的图片管理水平、效率。

该系统实现图片的录入、查询、浏览等功能。

将动态实现对PC机个人图片所在位置的查找、打开等操作,便于个人迅速、准确的定位图片。

本次设计开发的图片管理系统大大减轻了操作人员的工作量,提高工作效率。

二、系统分析与设计
(一)系统功能要求
可以录入本机的图片文件,对图片进行相关的查询、编辑、浏览以及打印功能。

1.添加相应图片文件;
2.对图片相关信息的查询、编辑等;
3.通过幻灯片效果浏览图片等;
(二)系统模块结构设计
通过对系统功能的分析,图片管理系统系统功能如图所示。

图1 图片管理系统功能图
通过上图的功能分析,把整个系统划分为4个模块:
1、文件菜单栏主要实现对具体图片的打开、更改、删除、保存、打印以及设为桌面背景的相关功能;
2、设置菜单栏主要实现对图片相关特效的设置,包括调整图片的大小以及文字的设置等功能;
3、窗口菜单栏主要实现在窗口添加相关快捷菜单;
4、退出图片管理系统。

三、系统的设计与实现
(一)系统窗体页面的设计
分析:通过对系统的具体规划,首先创建窗口页面,然后再窗口内添加相关控件。

流程图如图2所示。

图2 窗口页面功能图
该系统窗体页面设计代码如下所示:
#region窗体加载
private void frmMain_Load(object sender, EventArgs e)
{
tsslDate.Text = DateTime.Now.ToString();
DirectoryInfo DInfo = new DirectoryInfo(TPath());
FileSystemInfo[] FSInfo = DInfo.GetFileSystemInfos();
for (int i = 0; i < FSInfo.Length; i++)
{
try
{
FileInfo FInfo = new FileInfo(TPath() + "\\" +
FSInfo[i].ToString())
;
FInfo.Delete();
}
catch
{ }
}
if (listBox1.Items.Count == 0)
{
ToolStatusUnable();
}
}
private void frmMain_Activated_1(object sender, EventArgs e)
{
if (listBox1.Items.Count != 0)
{
listBox1_SelectedIndexChanged_1(sender,e);
}
}
}
(二)具体功能模块的实现
1、文件菜单栏创建
分析:通过对该模块的分析,具体功能有打开、更改、删除、保存、打印以及设为桌面背景的相关功能。

流程图如图3所示。

图3 文件模块流程图
该模块相关功能代码如下:
#region文件菜单
private void更改目录ToolStripMenuItem_Click(object sender, EventArgs e) {
toolStripButton1_Click(sender, e);
}
private void刷新ToolStripMenuItem1_Click(object sender, EventArgs e)
{
toolStripButton2_Click(sender, e);
}
private void退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void设为桌面背景ToolStripMenuItem1_Click(object sender, EventArgs e) {
设为桌面背景ToolStripMenuItem_Click(sender,e);
}
private void删除ToolStripMenuItem1_Click(object sender, EventArgs e)
{
删除ToolStripMenuItem_Click(sender, e);
}
private void重命名ToolStripMenuItem1_Click(object sender, EventArgs e)
{
重命名ToolStripMenuItem_Click(sender, e);
}
private void打印ToolStripMenuItem1_Click(object sender, EventArgs e)
{
打印ToolStripMenuItem_Click(sender, e);
}
2、设置菜单栏创建
分析:通过对该模块的分析,具体功能有对图片本身以及文字进行调整,然后通过幻灯片显示。

流程图如图4所示。

图4 设置模块流程图
该模块相关功能代码如下:
private void图片特效ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count != 0)
{
frmSpecialEfficacy special = new frmSpecialEfficacy();
special.ig = pictureBox1.Image;
special.ShowDialog();
}
}
private void图片调节ToolStripMenuItem_Click(object sender, EventArgs e) {
frmPicAdjust picadjust = new frmPicAdjust();
picadjust.ig = pictureBox1.Image;
picadjust.PicOldPath = FPath;
picadjust.ShowDialog();
}
private void图片文字ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (pictureBox1.Image != null)
{
frmWater water = new frmWater();
water.ig = pictureBox1.Image;
water.FPath = FPath;
water.ShowDialog();
}
}
private void幻灯片放映ToolStripMenuItem_Click(object sender, EventArgs e) {
if (folderBrowserDialog2.ShowDialog() == DialogResult.OK)
{
string path = folderBrowserDialog2.SelectedPath;
frmSlide slide = new frmSlide();
slide.Ppath = path;
slide.ShowDialog();
}
}
3、窗口菜单栏创建
分析:通过对该模块的分析,具体功能是在窗口界面添加快捷工具栏。

流程图如图5所示。

图5 窗口模块流程图
该模块相关功能代码如下:
private void状态栏ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (状态栏ToolStripMenuItem.CheckState == CheckState.Checked)
{
状态栏ToolStripMenuItem.CheckState = CheckState.Unchecked;
statusStrip1.Visible = false;
}
else
{
状态栏ToolStripMenuItem.CheckState = CheckState.Checked;
statusStrip1.Visible = true;
}
}
private void工具栏ToolStripMenuItem_Click(object sender, EventArgs e) {
if (工具栏ToolStripMenuItem.CheckState == CheckState.Checked)
{
工具栏ToolStripMenuItem.CheckState = CheckState.Unchecked;
toolStrip1.Visible = false;
}
else
{
工具栏ToolStripMenuItem.CheckState = CheckState.Checked;
toolStrip1.Visible = true;
}
}
private void图片信息ToolStripMenuItem_Click(object sender, EventArgs e) {
if (图片信息ToolStripMenuItem.CheckState == CheckState.Checked)
{
图片信息ToolStripMenuItem.CheckState = CheckState.Unchecked;
button1.Visible = false;
}
else
{
图片信息ToolStripMenuItem.CheckState = CheckState.Checked;
button1.Visible = true;
}
}
四、系统测试
通过以上对系统各个模块的具体分析与设计,其测试结果:
(一)测试窗口界面的实现
测试窗口界面的实现,首先打开C#程序窗口设计界面,然后添加相关控件,最后根据系统设计的要求对界面进行具体设计。

测试结果如图所示。

图6 系统界面
(二)各模块功能的具体测试
测试各功能模块的实现,具体测试结果如下所示。

1.文件菜单栏
图7 文件栏
2.设置菜单栏
图8 设置栏3.窗口菜单栏
图9 窗口栏4.幻灯片的实现
图10 幻灯片
五、总结
这学期的课程设计结束了,在老师和同学的帮助下,我基本完成了系统的设计。

我按照系统工程软件设计的要求,从需求分析,概念设计,总体设计,详细设计,系统测试等各个步骤,分步完成系统的各项任务,实现了系统中的图片管理、浏览等功能。

这次课程设计,由于理论知识的不足,再加上平时没有什么设计经验,系统还有许多不足之处:一是对界面的整体布局有所欠缺,没有很好的对该系统做整体的设计;二是在相关代码的编写过程中,对有些特殊语法没有很好的理解,导致有些功能没有达到预期效果;三是对窗体界面设计的相关控件的具体功能没有很好的认识,致使许多功能没有很好发挥出来。

在这次课程设计中我收获如下:
1、巩固和加深了对C#的理解,提高综合运用本课程所学知识的能力。

2、培养了我选用参考书,查阅手册及文献资料的能力。

培养独立思考,深入研究,分析问题、解决问题的能力。

3、通过实际编译系统的分析设计、编程调试,掌握应用软件的分析方法和工程设计方法。

根据我在课程设计中遇到的问题,我将在以后的学习当中注意以下几点:
1、认真上好专业实验课,多在实践中锻炼自己。

2、写程序的过程中要考虑周到,严密。

3、在做设计的时候要有信心,有耐心,切勿浮躁。

4、认真的学习课本知识,掌握课本中的知识点,并在此基础上学会灵活运用。

5、在课余时间里多写程序,熟练掌握在调试程序的过程中所遇到的常见错误,以便能节省调试程序的时间。

六、附件(代码、部分图表)
using System.Windows.Forms;
using System.IO;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
namespace PictureManage
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
#region自定义方法
public int Pindex;
public string TPath()
{
string TemporaryPath;
TemporaryPath = Application.StartupPath.ToString(); TemporaryPath = TemporaryPath.Substring(0, stIndexOf("\\"));
TemporaryPath = TemporaryPath.Substring(0, stIndexOf("\\"));
TemporaryPath += @"\TemporaryFolder";
return TemporaryPath;
}
public void ToolStatusUnable()
{
contextMenuStrip1.Enabled = false;
设为桌面背景ToolStripMenuItem1.Enabled = false;
转换为ToolStripMenuItem.Enabled = false;
删除ToolStripMenuItem1.Enabled = false;
重命名ToolStripMenuItem1.Enabled = false;
另存为ToolStripMenuItem1.Enabled = false;
toolStripButton2.Enabled = false;
toolStripButton3.Enabled = false;
toolStripButton4.Enabled = false;
打印ToolStripMenuItem1.Enabled = false;
图片特效ToolStripMenuItem.Enabled = false;
图片调节ToolStripMenuItem.Enabled = false;
toolStripButton5.Enabled = false;
toolStripButton6.Enabled = false;
图片文字ToolStripMenuItem.Enabled = false;
toolStripButton7.Enabled = false;
}
public void ToolStatusEnable()
{
contextMenuStrip1.Enabled = true;
设为桌面背景ToolStripMenuItem1.Enabled = true;
转换为ToolStripMenuItem.Enabled = true;
删除ToolStripMenuItem1.Enabled = true;
重命名ToolStripMenuItem1.Enabled = true;
另存为ToolStripMenuItem1.Enabled = true;
toolStripButton2.Enabled = true;
toolStripButton3.Enabled = true;
toolStripButton4.Enabled = true;
打印ToolStripMenuItem1.Enabled = true;
图片特效ToolStripMenuItem.Enabled = true;
图片调节ToolStripMenuItem.Enabled = true;
toolStripButton5.Enabled = true;
toolStripButton6.Enabled = true;
图片文字ToolStripMenuItem.Enabled = true;
toolStripButton7.Enabled = true;
}
#endregion
#region调用
[DllImport("user32.dll", EntryPoint = "SystemParametersInfoA")] static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, string lpvparam, Int32 fuwinIni);
private const int SPI_SETDESKWALLPAPER = 20;
#endregion
#region窗体加载
private void frmMain_Load(object sender, EventArgs e)
{
tsslDate.Text = DateTime.Now.ToString();
DirectoryInfo DInfo = new DirectoryInfo(TPath());
FileSystemInfo[] FSInfo = DInfo.GetFileSystemInfos();
for (int i = 0; i < FSInfo.Length; i++)
{
try
{
FileInfo FInfo = new FileInfo(TPath() + "\\" +
FSInfo[i].ToString());
FInfo.Delete();
}
catch
{ }
}
if (listBox1.Items.Count == 0)
{
ToolStatusUnable();
}
}
private void frmMain_Activated_1(object sender, EventArgs e)
{
if (listBox1.Items.Count != 0)
{
listBox1_SelectedIndexChanged_1(sender, e);
}
}
#endregion
#region工具栏
string PPath;
public string sum;
private void toolStripButton1_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
listBox1.Items.Clear();
PPath = folderBrowserDialog1.SelectedPath;
DirectoryInfo DInfo = new DirectoryInfo(PPath);
FileSystemInfo[] FSInfo = DInfo.GetFileSystemInfos();
for (int i = 0; i < FSInfo.Length; i++)
{
string FileType =
FSInfo[i].ToString().Substring(FSInfo[i].ToString().LastIndexOf(".") + 1, (FSInfo[i].ToString().Length - FSInfo[i].ToString().LastIndexOf(".") - 1));
FileType = FileType.ToLower();
if(FileType == "jpg"|| FileType == "png"|| FileType == "bmp" || FileType == "gif" || FileType == "jpeg")
{
listBox1.Items.Add(FSInfo[i].ToString());
}
}
sum = listBox1.Items.Count.ToString();
}
}
private void toolStripButton2_Click(object sender, EventArgs e)//刷新按钮
{
if (listBox1.Items.Count == 0)
{
toolStripButton2.Enabled = false;
}
else
{
toolStripButton2.Enabled = true;
listBox1.Items.Clear();
pictureBox1.Image = null;
DirectoryInfo DInfo = new DirectoryInfo(PPath);
FileSystemInfo[] FSInfo = DInfo.GetFileSystemInfos();
for (int i = 0; i < FSInfo.Length; i++)
{
string FileType =
FSInfo[i].ToString().Substring(FSInfo[i].ToString().LastIndexOf(".") + 1, (FSInfo[i].ToString().Length - FSInfo[i].ToString().LastIndexOf(".") - 1));
FileType = FileType.ToLower();
if(FileType == "jpg"|| FileType == "png"|| FileType == "bmp" || FileType == "gif" || FileType == "jpeg")
{
listBox1.Items.Add(FSInfo[i].ToString());
}
}
ToolStatusUnable();
}
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
打印ToolStripMenuItem_Click(sender, e);
}
private void状态栏ToolStripMenuItem_Click(object sender, EventArgs e) {
if (状态栏ToolStripMenuItem.CheckState == CheckState.Checked)
{
状态栏ToolStripMenuItem.CheckState = CheckState.Unchecked;
statusStrip1.Visible = false;
}
else
{
状态栏ToolStripMenuItem.CheckState = CheckState.Checked;
statusStrip1.Visible = true;
}
}
private void工具栏ToolStripMenuItem_Click(object sender, EventArgs e) {
if (工具栏ToolStripMenuItem.CheckState == CheckState.Checked)
{
工具栏ToolStripMenuItem.CheckState = CheckState.Unchecked;
toolStrip1.Visible = false;
}
else
{
工具栏ToolStripMenuItem.CheckState = CheckState.Checked;
toolStrip1.Visible = true;
}
}
private void图片信息ToolStripMenuItem_Click(object sender, EventArgs e) {
if (图片信息ToolStripMenuItem.CheckState == CheckState.Checked)
{
图片信息ToolStripMenuItem.CheckState = CheckState.Unchecked;
button1.Visible = false;
}
else
{
图片信息ToolStripMenuItem.CheckState = CheckState.Checked;
button1.Visible = true;
}
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
删除ToolStripMenuItem_Click(sender, e);
}
private void toolStripButton5_Click(object sender, EventArgs e)//工具栏向上
{
try
{
if (listBox1.SelectedIndex != 0)
{
listBox1.SetSelected(listBox1.SelectedIndex - 1, true);
}
}
catch
{ }
}
private void toolStripButton6_Click(object sender, EventArgs e)//工具栏向下
{
try
{
if (listBox1.SelectedIndex < listBox1.Items.Count - 1)
{
listBox1.SetSelected(listBox1.SelectedIndex + 1, true);
}
}
catch
{ }
}
private void图片特效ToolStripMenuItem_Click(object sender, EventArgs e) {
if (listBox1.Items.Count != 0)
{
frmSpecialEfficacy special = new frmSpecialEfficacy();
special.ig = pictureBox1.Image;
special.ShowDialog();
}
}
private void toolStripButton7_Click(object sender, EventArgs e)//旋转
{
Image myImage = pictureBox1.Image;
myImage.RotateFlip(RotateFlipType.Rotate90FlipXY);
pictureBox1.Image = myImage;
}
#endregion
#region常用事件t
private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
int printWidth = printDocument1.DefaultPageSettings.PaperSize.Width;
int printHeight =
printDocument1.DefaultPageSettings.PaperSize.Height;
if (Convert.ToInt32(PictureWidth) <= printWidth)
{
float x = (printWidth - Convert.ToInt32(PictureWidth)) / 2;
float y = (printHeight - Convert.ToInt32(Pictureheight)) / 2; e.Graphics.DrawImage(Image.FromFile(FPath), x, y,
Convert.ToInt32(PictureWidth), Convert.ToInt32(Pictureheight));
}
else
{
if (Convert.ToInt32(PictureWidth) >
Convert.ToInt32(Pictureheight))
{
Bitmap bitmap = (Bitmap)Bitmap.FromFile(FPath);
bitmap.RotateFlip(RotateFlipType.Rotate90FlipXY);
PictureBox pb = new PictureBox();
pb.Image = bitmap;
Single a = printWidth / Convert.ToSingle(Pictureheight);
e.Graphics.DrawImage(pb.Image, 0, 0,
Convert.ToSingle(Pictureheight) * a, Convert.ToSingle(PictureWidth) * a);
}
else
{
Single a = printWidth / Convert.ToSingle(PictureWidth);
e.Graphics.DrawImage(Image.FromFile(FPath), 0, 0,
Convert.ToSingle(PictureWidth) * a, Convert.ToSingle(Pictureheight) * a);
}
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if (pictureBox1.Image != null)
{
frmPictureMax pictureMax = new frmPictureMax();
pictureMax.FPath = FPath;
pictureMax.PictureWidth = PictureWidth;
pictureMax.Pictureheight = Pictureheight;
pictureMax.SelectFileSize = SelectFileSize;
pictureMax.ShowDialog();
}
}
public Bitmap image1;
public string FPath;
public string PictureWidth;
public string Pictureheight;
public double SelectFileSize;
private void listBox1_SelectedIndexChanged_1(object sender, EventArgs e) {
try
{
if (listBox1.Items.Count != 0)
{
ToolStatusEnable();
}
pictureBox1.BackColor = Color.Black;
string FName = listBox1.SelectedItem.ToString();
if (PPath.Length == 4)
{
FPath = PPath + FName;
}
else
{
FPath = PPath + "\\" + FName;
}
DirectoryInfo DInfo = new DirectoryInfo(TPath());
FileSystemInfo[] FSInfo = DInfo.GetFileSystemInfos();
for (int i = 0; i < FSInfo.Length; i++)
{
try
{
FileInfo FInfo = new FileInfo(TPath() + "\\" +
FSInfo[i].ToString());
FInfo.Delete();
}
catch
{ }
}
string newFilePath;
string SFileType = FPath.Substring(stIndexOf(".") + 1, (FPath.Length - stIndexOf(".") - 1));
FileInfo finfos = new FileInfo(TPath() + "\\" + FName);
if (finfos.Exists)
{
newFilePath = TPath() + "\\" + FName;
}
else
{
File.Copy(FPath, TPath() + "\\" + FName, true);
newFilePath = TPath() + "\\" + FName;
}
pictureBox1.Image = Image.FromFile(newFilePath);
image1 = new Bitmap(newFilePath);
PictureWidth = image1.Width.ToString();
Pictureheight = image1.Height.ToString();
FileInfo finfo = new FileInfo(newFilePath);
string FileSize = finfo.Length.ToString();
SelectFileSize = Convert.ToDouble(FileSize) / 1024 / 1024;
button1.Text = "图片大小" + SelectFileSize.ToString("F") + "M" + "分辨率" + PictureWidth + "×" + Pictureheight;
image1.Dispose();
toolStripStatusLabel3.Text = sum;
toolStripStatusLabel1.Text =
Convert.ToString(listBox1.SelectedIndex + 1);
toolStripStatusLabel2.Visible = true;
//contextMenuStrip1.Enabled = true;
ToolStatusEnable();
Pindex = listBox1.SelectedIndex;//当前选项索引值
}
catch
{ }
}
private void timer1_Tick(object sender, EventArgs e)
{
tsslDate.Text = DateTime.Now.ToString();
}
#endregion
#region文件菜单
private void更改目录ToolStripMenuItem_Click(object sender, EventArgs e) {
toolStripButton1_Click(sender, e);
}
private void刷新ToolStripMenuItem1_Click(object sender, EventArgs e) {
toolStripButton2_Click(sender, e);
}
private void退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void设为桌面背景¡ãToolStripMenuItem1_Click(object sender, EventArgs e)
{
设为桌面背景ToolStripMenuItem_Click(sender, e);
}
private void删除ToolStripMenuItem1_Click(object sender, EventArgs e) {
删除ToolStripMenuItem_Click(sender, e);
}
private void重命名ToolStripMenuItem1_Click(object sender, EventArgs e) {
重命名ToolStripMenuItem_Click(sender, e);
}
private void打印ToolStripMenuItem1_Click(object sender, EventArgs e) {
打印ToolStripMenuItem_Click(sender, e);
}
private void bMPToolStripMenuItem_Click(object sender, EventArgs e) {
string fName = FPath.Substring(stIndexOf("\\") + 1, (stIndexOf(".") - stIndexOf("\\") - 1));
string Opath = FPath.Remove(stIndexOf("\\"));
string Npath;
if (Opath.Length == 4)
{
Npath = Opath;
}
else
{
Npath = Opath + "\\";
}
Bitmap bt = new Bitmap(pictureBox1.Image);
bt.Save(Npath + fName + ".bmp", ImageFormat.Bmp);
FileInfo fi = new FileInfo(FPath);
fi.Delete();
toolStripButton2_Click(sender, e);
}
private void gIFToolStripMenuItem_Click(object sender, EventArgs e) {
string fName = FPath.Substring(stIndexOf("\\") + 1, (stIndexOf(".") - stIndexOf("\\") - 1));
string Opath = FPath.Remove(stIndexOf("\\"));
string Npath;
if (Opath.Length == 4)
{
Npath = Opath;
}
else
{
Npath = Opath + "\\";
}
Bitmap bt = new Bitmap(pictureBox1.Image);
bt.Save(Npath + fName + ".gif", ImageFormat.Gif);
FileInfo fi = new FileInfo(FPath);
fi.Delete();
toolStripButton2_Click(sender, e);
}
private void jPGToolStripMenuItem_Click(object sender, EventArgs e) {
string fName = FPath.Substring(stIndexOf("\\") + 1, (stIndexOf(".") - stIndexOf("\\") - 1));
string Opath = FPath.Remove(stIndexOf("\\"));
string Npath;
if (Opath.Length == 4)
{
Npath = Opath;
}
else
{
Npath = Opath + "\\";
}
Bitmap bt = new Bitmap(pictureBox1.Image);
bt.Save(Npath + fName + ".Jpeg", ImageFormat.Jpeg);
FileInfo fi = new FileInfo(FPath);
fi.Delete();
toolStripButton2_Click(sender, e);
}
private void pNGToolStripMenuItem_Click(object sender, EventArgs e) {
string fName = FPath.Substring(stIndexOf("\\") + 1, (stIndexOf(".") - stIndexOf("\\") - 1));
string Opath = FPath.Remove(stIndexOf("\\"));
string Npath;
if (Opath.Length == 4)
{
Npath = Opath;
}
else
{
Npath = Opath + "\\";
}
Bitmap bt = new Bitmap(pictureBox1.Image);
bt.Save(Npath + fName + ".Png", ImageFormat.Png);
FileInfo fi = new FileInfo(FPath);
fi.Delete();
toolStripButton2_Click(sender, e);
}
private void图片调节ToolStripMenuItem_Click(object sender, EventArgs e) {
frmPicAdjust picadjust = new frmPicAdjust();
picadjust.ig = pictureBox1.Image;
picadjust.PicOldPath = FPath;
picadjust.ShowDialog();
}
private void退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("退出系统", "提示", MessageBoxButtons.OKCancel, rmation) == DialogResult.OK)
{
Application.Exit();
}
}
private void幻灯片放映ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (folderBrowserDialog2.ShowDialog() == DialogResult.OK)
{
string path = folderBrowserDialog2.SelectedPath;
frmSlide slide = new frmSlide();
slide.Ppath = path;
slide.ShowDialog();
}
}
#endregion
#region右键菜单
private void复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
string path = FPath.Remove(2, 1);
System.Collections.Specialized.StringCollection files = new System.Collections.Specialized.StringCollection();
files.Add(path);
Clipboard.SetFileDropList(files);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, rmation);
}
}
private void删除ToolStripMenuItem_Click(object sender, EventArgs e) {
try
{
File.Delete(FPath);
toolStripButton2_Click(sender, e);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, rmation);
}
}
private void刷新ToolStripMenuItem_Click(object sender, EventArgs e) {
toolStripButton2_Click(sender, e);
}
private void重命名ToolStripMenuItem_Click(object sender, EventArgs e) {
string fName = FPath.Substring(stIndexOf("\\") + 1, (stIndexOf(".") - stIndexOf("\\") - 1));
string fType = FPath.Substring(stIndexOf(".") + 1, (FPath.Length - stIndexOf(".") - 1));
frmRename rename = new frmRename();
rename.filename = fName;
rename.filepath = FPath;
rename.filetype = fType;
rename.ShowDialog();
}
private void打印ToolStripMenuItem_Click(object sender, EventArgs e) {
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
private void设为桌面背景ToolStripMenuItem_Click(object sender, EventArgs e)
{
//获取指定图片的扩展名
string SFileType = FPath.Substring(stIndexOf(".") + 1, (FPath.Length - stIndexOf(".") - 1));
//将扩展名转换成小写
SFileType = SFileType.ToLower();
//获取文件名
string SFileName = FPath.Substring(stIndexOf("\\") + 1, (stIndexOf(".") - stIndexOf("\\") - 1));
if (SFileType == "bmp")
{
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, FPath, 1);
}
else
{
string SystemPath = Environment.SystemDirectory;//获取系统路径
string path = SystemPath + "\\" + SFileName + ".bmp";
FileInfo fi = new FileInfo(path);
if (fi.Exists)
{
fi.Delete();
PictureBox pb = new PictureBox();
pb.Image = Image.FromFile(FPath);
pb.Image.Save(SystemPath + "\\" + SFileName + ".bmp", ImageFormat.Bmp);
}
else
{
PictureBox pb = new PictureBox();
pb.Image = Image.FromFile(FPath);
pb.Image.Save(SystemPath + "\\" + SFileName + ".bmp", ImageFormat.Bmp);
}
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path, 1);
}
}
private void另存为ToolStripMenuItem_Click(object sender, EventArgs e) {
try
{
saveFileDialog1.Filter =
"BMP|*.bmp|JPEG|*.jpeg|GIF|*.gif|PNG|*.png";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string picPath = saveFileDialog1.FileName;
string picType = picPath.Substring(stIndexOf(".") + 1, (picPath.Length - stIndexOf(".") - 1));
switch (picType)
{
case"bmp":
Bitmap bt = new Bitmap(FPath);
bt.Save(picPath, ImageFormat.Bmp); break;
case"jpeg":
Bitmap bt1 = new Bitmap(FPath);
bt1.Save(picPath, ImageFormat.Jpeg); break;
case"gif":
Bitmap bt2 = new Bitmap(FPath);
bt2.Save(picPath, ImageFormat.Gif); break;
case"png":
Bitmap bt3 = new Bitmap(FPath);
bt3.Save(picPath, ImageFormat.Png); break;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, rmation);
}
}
private void另存为ToolStripMenuItem1_Click(object sender, EventArgs e) {
另存为ToolStripMenuItem_Click(sender, e);
}
#endregion
private void图片文字ToolStripMenuItem_Click(object sender, EventArgs e) {
if (pictureBox1.Image != null)
{
frmWater water = new frmWater();
water.ig = pictureBox1.Image;
water.FPath = FPath;
water.ShowDialog();
}
}
}
}。

相关文档
最新文档