矩形绘制,图片浏览工具,五子棋程序 大放送!!!!

上传人:简****9 文档编号:102387101 上传时间:2019-10-02 格式:DOC 页数:15 大小:108.51KB
返回 下载 相关 举报
矩形绘制,图片浏览工具,五子棋程序 大放送!!!!_第1页
第1页 / 共15页
矩形绘制,图片浏览工具,五子棋程序 大放送!!!!_第2页
第2页 / 共15页
矩形绘制,图片浏览工具,五子棋程序 大放送!!!!_第3页
第3页 / 共15页
矩形绘制,图片浏览工具,五子棋程序 大放送!!!!_第4页
第4页 / 共15页
矩形绘制,图片浏览工具,五子棋程序 大放送!!!!_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《矩形绘制,图片浏览工具,五子棋程序 大放送!!!!》由会员分享,可在线阅读,更多相关《矩形绘制,图片浏览工具,五子棋程序 大放送!!!!(15页珍藏版)》请在金锄头文库上搜索。

1、计算机上机实验报告( 20102011学年 第2学期)班级: 软件101 姓名: 罗今 学号: 201000514120 课程名称:面向对象设计C# 指导教师:张慎武实验名称: GDI与图形图像 实验序号: 7 实验日期:2012-5-26 实验成绩: 要求:1. 实验内容部分主要是对本次实习所做工作的理解,即主要实现了什么功能,主要思路。 不要过于简略,也不能罗列程序。2. 源程序请单独提交,不要附在实习报告中。3. 报告要注意简练,但能完整表达自己的意图,不要刻意追求篇幅。一、实验目的及要求(本次上机实践所涉及并要求掌握的知识点)。1 深入理解网络通信的基本技术和方法。2 进一步理解常用网

2、络协议的基本概念。3. 掌握基本的网络通信的程序设计,熟练应用套接字和常用的网络通信类。二、实验环境(本次上机实践所使用的平台和相关软件)。软件:WindowsXP系统+Visual Studio 2010三、实验内容(1) 设计一个根据鼠标来绘制矩形的程序,即当按下鼠标左键并拖动至某个位置后释放鼠标时,可根据按下鼠标时的第1个点和释放鼠标时的第2个点来确定并绘制矩形。(2) 设计一个动态翻看图片的程序,包含两个按钮(“上一张”,”下一张”),图片显示是可以是”上下对接”,“左右拉伸”,“反转”以及“中间想两边拉伸”等动态效果。(3) 设计一个简单的20*20棋盘格的手动移子的五子棋程序。四、

3、实验步骤及结果第一个程序(绘制矩形):(1) 窗口控件设计:(2) 代码设计:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 绘制矩形 public partial class Form1 : Form public Form1() InitializeComponent()

4、; g = this.pictureBox1.CreateGraphics(); Graphics g; int x = 0; int y = 0; bool blDraw = false; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) x = e.X; y = e.Y; blDraw = true; private void pictureBox1_MouseUp(object sender, MouseEventArgs e) if (blDraw) Pen p = new Pen(Color.Blu

5、e, 2); if(x e.X & y e.Y) g.DrawRectangle(p, x, y, System.Math.Abs(e.X - x), System.Math.Abs(e.Y - y); if (x e.Y) g.DrawRectangle(p, x, e.Y, System.Math.Abs(e.X - x), System.Math.Abs(e.Y - y); if (x e.X & y e.X & y e.Y) g.DrawRectangle(p, e.X, e.Y, System.Math.Abs(e.X - x), System.Math.Abs(e.Y - y);

6、blDraw = false; 第二个程序(动态翻看图片):(1) 窗口控件设计:(2) 代码设计:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;namespace 动态翻看图片 public partial class Form1 : Form public

7、Form1() InitializeComponent(); string files; string file; string pfile; string prefile; string nextfile; public string GetDirPath(string filePath) /得到上级目录 string dirPath = ; int i; string str = filePath.Split(); for (i = 0; i str.Length - 1; i+) dirPath += stri + ; return dirPath; private void butto

8、n3_Click(object sender, EventArgs e) OpenFileDialog ofd1 = new OpenFileDialog(); ofd1.Filter = Bitmap文件(*.bmp)|*.bmp|所有适合文件(*.bmp/*.jpg/*.gif)|*.*|Jpeg文件(*.jepg)|*.jpg; ofd1.FilterIndex = 2; ofd1.RestoreDirectory = true; if (DialogResult.OK = ofd1.ShowDialog() Bitmap SourceBitmap = new Bitmap(ofd1.F

9、ileName); Bitmap MyBitmap = new Bitmap(SourceBitmap, this.pictureBox1.Width, this.pictureBox1.Height); try pictureBox1.Image = MyBitmap; catch (Exception) MessageBox.Show(该文件不是图形图像文件,无法显示浏览!, 错误提示); file = ofd1.FileName; pfile = GetDirPath(file);/获取上级目录名 private void button1_Click(object sender, Eve

10、ntArgs e) files = Directory.GetFiles(pfile); for (int i = 0; i files.Length; i+) if (file = filesi) if (i - 1 != -1) prefile = filesi - 1; break; else prefile = filesi; break; try Bitmap SourceBitmap = new Bitmap(prefile); Bitmap MyBitmap = new Bitmap(SourceBitmap, this.pictureBox1.Width, this.pictureBox1.Height); pictureBox1.Image = MyBitmap; catch (Exception)

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号