1、2.开发与运行环境开发环境:Windows XP、Windows 7开发工具:Microsoft Visual studio2010 C#、SQL2008运行环境:Windows XP/72.系统设计3.1.系统流程3.2.功能模块3.详细设计4.1.登陆界面本系统采用“用户账号数据库”一体模式,做到用户登录以后能够浏览与管理的图片及相册都为私人所有,以确保隐私安全。4.2.主界面菜单栏按钮除了有图标及名称以外,鼠标悬停一秒自动显示提示,主体部分左侧目录列表与缩略图显示区域之间边框位置可调。单击选中列表名称背景自动变蓝,并且在右侧缩略图显示区域显示该目录下的图片缩略图及图片名称,单击选中缩略图
2、会有蓝色边框且支持多选。 新增目录时会有窗口提示填写新目录名称,后在目录列表里生成项,并且在系统文件夹下生成相应文件夹。未选定目录情况下删除目录会提示选择一个目录,选定目录情况下删除目录时会有窗口提示操作不可逆是否确认,点击确认后完成删除操作。未选定目录情况下导入图片下拉列表自动显示首个目录名称,选定目录情况下导入图片下拉列表显示所选定目录名称,也可即时选定。支持bmp,jpg,gif,jpeg,ico格式图片。用户可以选定某图片进行改名,若有图片重名将自动改名。状态栏显示所选图片信息。缩略图按比例缩小并在各框中居中显示。导入图片时下方进度条显示进度鼠标形状为漏斗。4.3.图片浏览界面 本界面
3、与主界面为同一窗口,开始下方工具栏隐藏,双击缩略图进入图片浏览时上方工具栏隐藏显示下方工具栏。鼠标悬停按钮一秒则显示提示。播放幻灯片时可自行选择时间间隔,窗口小于图片大小时可拖动也可选择合适窗口大小显示。5.调试分析主界面打不开出错原因及改正:把lstFolder的SelectedIndexChanged事件的代码没注意写在了lvView的SelectedIndexChanged中了使得删除路径不对导致操作时出现异常将两部分代码交换每次运行时原先保存在lstFolder的文件不显示了错误原因及改正:要使得上次运行时保存在图片目录文件下的文件在下次运行时也直接显示在lstFolder中需要在Ma
4、inForm_Load方法里加上如下代码6.课程设计总结通过这次课程设计,实现了一个简单的图片管理系统,而我也对C#软件开发有了更深一步的认识,不论从开始分析到后来编程再到最后调试,也学到了很多在课堂上没有学到的东西。对于VisualStudio2010和SQL2008的使用也更加熟练。系统中存在的一些不足和系统设计上存在的缺憾,说明自己在这些方面还有很多不足之处有待自己进一步学习、提高。?在本次课程设计中,赵师赵辉和同组同学给了我很大的指导帮助,从他们哪里我学到了很多,在此表示感谢!7.参考文献1邱锦伦 Visual C#.NET程序设计教程 清华大学出版社 2006年4月2刘金岭 数据库系
5、统及应用教程SQL Server2008 清华大学出版社 2013年9月3陈 广 C#程序设计基础教程与实训 北京大学出版社 2013年7月8.附录using System;usingusing System.Linq;namespace 图片管理器 static class Program STAThread static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmLogin(); usin
6、g System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.IO;using System.Collections; public partial class MainForm : Form public MainForm() InitializeComponent(); private string path = Application.StartupPath + 图片目录; private Pen boundPen = new Pen(Color.Gainsbor
7、o); private Pen selPen = new Pen(Color.Blue, 3); private SolidBrush textBrush = new SolidBrush(Color.Black); private SolidBrush bgBrush; private StringFormat format = new StringFormat(); private Bitmap bmpInPb; private Point mousePoint = new Point(); private Point pbPoint = new Point(); private bool
8、 canDrag; private bool isDraging; private int bmpIndex; private void MainForm_Load(object sender, EventArgs e) lvView.Dock = DockStyle.Fill; tscbInterval.SelectedIndex = 1; ShowView(); bgBrush = new SolidBrush(lvView.BackColor); statusStrip1.Items0.Visible = false; format.Alignment = StringAlignment
9、.Center; try if (!Directory.Exists(path) Directory.CreateDirectory(path); catch (Exception ex) MessageBox.Show(ex.Message, 错误, MessageBoxButtons.OK, MessageBoxIcon.Error); return; DirectoryInfo dir = new DirectoryInfo(path); foreach (DirectoryInfo d in dir.GetDirectories() Folder folder = new Folder
10、(Application.StartupPath, d.Name); private void Form1_Load(object sender, EventArgs e)错?a误 foreach (DirectoryInfo d in dir.GetDirectories()/获取dir中D的目录 private void toolStripButton1_Click(object sender, EventArgs e) FrmCreateFolder frmCreateFolder = new FrmCreateFolder(this.lstFolder); frmCreateFolde
11、r.ShowDialog(this); finally frmCreateFolder.Dispose(); private void tsbtnLoad_Click(object sender, EventArgs e) FrmLoadPic frmLoadPic = new FrmLoadPic(this.lstFolder, this.statusStrip1); if (frmLoadPic.ShowDialog(this) = DialogResult.OK) LoadToListView(); frmLoadPic.Dispose();/销毁窗体 private void lvVi
12、ew_DrawItem(object sender, DrawListViewItemEventArgs e) if Graphics g = e.Graphics; Folder folder = (Folder)lstFolder.SelectedItem; Bitmap Rectangle bmpRect = Folder.GetRectFromBounds(bmp, e.Bounds); bmpRect.Offset(0, 1); Rectangle boundRect = Folder.GetRectFromBounds(101, 101, e.Bounds); Rectangle
13、textRect = new Rectangle(e.Bounds.X + 4, g.DrawRectangle(boundPen, boundRect); if (e.State & ListViewItemStates.Selected) != 0) g.DrawImage(bmp, bmpRect); boundRect.Inflate(1, 1); g.DrawRectangle(selPen, boundRect); else g.FillRectangle(bgBrush, textRect); private void LoadToListView() lvView.BeginU
14、pdate();folder.IsLoaded) folder.LoadImage(); foreach (DictionaryEntry de in folder.bmps)string)de.Key); lvView.EndUpdate(); private void lstFolder_SelectedIndexChanged(object sender, EventArgs e) /浏览 private void ShowView() tsMain.Visible = true; lstFolder.Visible = true; splitter1.Visible = true; l
15、vView.Visible = true; pbPic.Visible = false; tsViewPic.Visible = false; private void ShowImage() tsMain.Visible = false; lstFolder.Visible = false; splitter1.Visible = false; lvView.Visible = false; pbPic.Visible = true; tsViewPic.Visible = true; private void lvView_DoubleClick(object sender, EventA
16、rgs e) Point p = Control.MousePosition; p = lvView.PointToClient(p); ListViewHitTestInfo info = lvView.HitTest(p); ShowImage(); private void PaintImageInPb(string bmpName) if (bmpInPb != null) bmpInPb.Dispose(); bmpInPb = folder.GetImage(bmpName); statusStrip1.Items1.Text = 名称:o + bmpName + 尺寸?: +x
17、pbPic.Image = bmpInPb; MatchImage(); private void MatchImage() if (tsbtnNormal.Checked) /正常显示模式 pbPic.Dock = DockStyle.None; pbPic.SizeMode = PictureBoxSizeMode.AutoSize; pbPic.Left = (panel1.Width - pbPic.Width) / 2; pbPic.Top = (panel1.Height - pbPic.Height) / 2; if (pbPic.Width panel1.Width | pbP
18、ic.Height panel1.Height) /图像的长或宽大于显示边框时 canDrag = true; pbPic.Cursor = Cursors.Hand;/改变鼠标指针样式 /图像小于显示边框则不允许拖a动 canDrag = false; pbPic.Cursor = Cursors.Default; if (bmpInPb.Width panel1.Width | bmpInPb.Height pbPic.Dock = DockStyle.Fill; pbPic.SizeMode = PictureBoxSizeMode.Zoom; private void tsbtnMat
19、ch_Click(object sender, EventArgs e) ToolStripButton btn = (ToolStripButton)sender; if (btn.Checked) tsbtnNormal.Checked = false; tsbtnMatch.Checked = false; btn.Checked = true; private void pbPic_MouseDown(object sender, MouseEventArgs e) if (e.Button != MouseButtons.Left) isDraging = true; mousePo
20、int.X = e.X; mousePoint.Y = e.Y; pbPoint.X = pbPic.Left; pbPoint.Y = pbPic.Top; private void pbPic_MouseMove(object sender, MouseEventArgs e)isDraging | !canDrag) int x = pbPic.Left; panel1.Width) x += e.X - mousePoint.X; if (x 0) x = 0; else if (x + pbPic.Width y += e.Y - mousePoint.Y; if (y y = 0;
21、 else if (y + pbPic.Height y = panel1.Height - pbPic.Height; pbPic.Left = x; pbPic.Top = y; private void pbPic_MouseUp(object sender, MouseEventArgs e) isDraging = false; private void tsbtnReturn_Click(object sender, EventArgs e) timer1.Stop(); pbPic.Image = null; private void tsbtnPeriod_Click(obje
22、ct sender, EventArgs e) if (bmpIndex = 0) bmpIndex-; ListViewItem item = lvView.ItemsbmpIndex; PaintImageInPb(item.Text); private void tsbtnNext_Click(object sender, EventArgs e) bmpIndex = 0; bmpIndex+; private void sbtnAntoPlay_Click(object sender, EventArgs e) timer1.Enabled = !timer1.Enabled; ts
23、btnAutoPlay.Checked = timer1.Enabled; private void tscbInterval_SelectedIndexChanged(object sender, EventArgs e) timer1.Interval = (int)(Math.Pow(2, tscbInterval.SelectedIndex) * 1000); private void timer1_Tick(object sender, EventArgs e) tsbtnNext_Click(null, null); private void toolStripButton5_Click(object sender, EventArgs e) Close(); private void tsbtnDelFolder_Click(object
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2