C#图片浏览器综合设计实验.doc_第1页
C#图片浏览器综合设计实验.doc_第2页
C#图片浏览器综合设计实验.doc_第3页
C#图片浏览器综合设计实验.doc_第4页
C#图片浏览器综合设计实验.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

华南农业大学信息学院设计性、综合性实验实验题目图片浏览器起止日期2010-2011学年第2学期课程名称可视化程序设计学生资料学号 200830690208 学生姓名 梁嘉雯 院系 信息学院 专业班级 08软件工程2班 实验内容综合运用Visual C#.NET提供的标准控件,模仿Windows中的图片浏览器功能,自己作一个图片浏览器。评语与成绩项目/分数优良中及格不及格系统分析设计程序设计水平内容完成情况设计报告撰写质量课程设计总结情况附加说明:成绩 (优/良/及格/不及格) 指导教师 刘汉兴 年 月 日实验报告一、 实验目的:1) 熟悉.NET的编程方法,掌握项目的创建于使用及安装;2) 熟悉C#编程语言;3) 熟悉C#图形界面编程;二、 实验内容:1) 参照Windows提供的图片浏览器,设计一个与之类似的程序;2) 基本要求 l 文件操作: 目录打开,指定文件打开; l 图片显示方式: normal,stretch; l 图片旋转操作; l 图片浏览功能:幻灯片演示; l .3)界面美观,操作方便 三、实验过程 1、设计思路1)根据系统功能,设计界面1.1打开文件,选择图片,将图片显示在pictureBox中;1.2添加一个treeView,在目录树中打开图片文件夹,将其显示在ListView中;1.3图片的显示方式,文件操作步骤中显示在pictureBox的图片以stretch方式显示,从ListView中选定显示到pictureBox中的图片以normal方式显示,图片变换功能选择中实现各种拉伸功能与旋转方式,点击还原可恢复normal显示。1.4幻灯片演示,利用timer控件实现幻灯片播放功能1.5可浏览上一张、下一张图片2、实现过程1)图片浏览器界面:界面简洁,功能明了。(如图)图片浏览界面展示1(指定文件打开方式):图片浏览界面展示2(目录树中打开选择图片文件夹):listView中可选择显示方式2)各功能关键代码:2.1指定文件打开,展示图片private void ToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = *.jpg;*.bmp|*.jpg;*.bmp; if (openFile.ShowDialog() = DialogResult.OK) Bitmap srcBitmap = new Bitmap(openFile.FileName); myBitmap = new Bitmap(srcBitmap, this.pictureBox1.Width, this.pictureBox1.Height); this.pictureBox1.Image = myBitmap; /this.pictureBox1.Image = Image.FromFile(openFile.FileName); 2.2双击listView选定项,展示选定图片private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) ListViewItem item = listView1.SelectedItems0; index = item.ImageIndex; pictureBox1.Load(arrPathindex); 2.3图片变换private void buttonLeftToRight_Click(object sender, EventArgs e) if (pictureBox1.Image != null) /左到右拉伸 g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); for (int x = 0; x = width; x+) g.DrawImage(this.pictureBox1.Image, 0, 0, x, height); g.Dispose(); private void buttonUptoDown_Click(object sender, EventArgs e) if (pictureBox1.Image != null) /上到下拉伸 g = this.pictureBox1.CreateGraphics(); /初始为灰色 g.Clear(Color.Gray); for (int y = 0; y = height; y+) g.DrawImage(this.pictureBox1.Image, 0, 0, width, y); g.Dispose(); private void buttonReversal_Click(object sender, EventArgs e) if (pictureBox1.Image != null) /反转 g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); for (int x = -width / 2; x = width / 2; x+) Rectangle DestRect = new Rectangle(0, height / 2 - x, width, 2 * x); Rectangle SrcRect = new Rectangle(0, 0, this.pictureBox1.Image.Width, this.pictureBox1.Image.Height); g.DrawImage(this.pictureBox1.Image, DestRect, SrcRect, GraphicsUnit.Pixel); g.Dispose(); private void buttonMiddletoSide_Click(object sender, EventArgs e) if (pictureBox1.Image != null) /中间向两边拉伸 g = this.pictureBox1.CreateGraphics(); /初始为灰色 g.Clear(Color.Gray); for (int y = 0; y = width / 2; y+) Rectangle DestRect = new Rectangle(width / 2 - y, 0, 2 * y, height); Rectangle SrcRect = new Rectangle(0, 0, this.pictureBox1.Image.Width, this.pictureBox1.Image.Height); g.DrawImage(this.pictureBox1.Image, DestRect, SrcRect, GraphicsUnit.Pixel); g.Dispose(); private void buttonExpand_Click(object sender, EventArgs e) if (pictureBox1.Image != null) /中间向四周扩散 g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); for (int x = 0; x = width / 2; x+) Rectangle DestRect = new Rectangle(width / 2 - x, height / 2 - x, 2 * x, 2 * x); Rectangle SrcRect = new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height); g.DrawImage(this.pictureBox1.Image, DestRect, SrcRect, GraphicsUnit.Pixel); g.Dispose(); private void button5_Click(object sender, EventArgs e)/右旋 if (pictureBox1.Image != null) pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); pictureBox1.Refresh(); private void button7_Click(object sender, EventArgs e)/左旋 if (pictureBox1.Image != null) pictureBox1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone); pictureBox1.Refresh(); 2.4幻灯片播放 private void timer1_Tick(object sender, EventArgs e) /播放时展示下一张 if (index 0) pictureBox1.Load(arrPath-index); else index = arrPath.Length; pictureBox1.Load(arrPath-index); private void button2_Click(object sender, EventArgs e)/查看下一张 if (pictureBox1.Image != null) if (index arrPath.Length - 1) pictureBox1.Load(arrPath+index); else index = 0; pictureBox1.Load(arrPathindex); 四、 实验总结 本次实验设计出了一个简单的图片浏览器,实验初完成时,我是采用多窗口展示方式的,可是作为一个用户来说,我本人是不太喜欢太多个窗口,觉得很麻烦,不够简洁,于是我把图片展示那部分

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论