c#图片自动播放程序
来源:互联网 发布:阿里巴巴 淘宝便宜 编辑:程序博客网 时间:2024/06/08 18:39
filp_v2系统,是练习c#控件的很好Demo案例。它包含了菜单、多窗口、图片框、复选框、容器等控件。
功能如下:
1:通过定时器完成自动翻转
2:设置毫秒值保存到xml数据中
3:文件夹对话框
4:文件对话框
5:自定义输入文件或目录
功能如下:
1:通过定时器完成自动翻转
2:设置毫秒值保存到xml数据中
3:文件夹对话框
4:文件对话框
5:自定义输入文件或目录
6:多个form之间数据共享
由于代码比较多,下面贴出核心代码
|---获取所有可执行文件、初始化xml保存数据。
using System;using System.IO;using System.Collections;using System.Collections.Generic;using System.Xml;namespace flip_v2{/** 图片+Xml工具类*/public class ImgTool{/** * * 传递一个完整路径,返回一个ilst集合,0为路径(不含文件名)1:播放的文件名(不包含路径) * 如C:\Users\Public\Pictures\Sample Pictures\八仙花.jpg * 0:C:\Users\Public\Pictures\Sample Pictures * 1:八仙花.jpg */public static string[] pathToList(string path){string[] array = new string[2];int last = path.LastIndexOf("\\");if(last!=-1){array[0]=(path.Substring(0,last));array[1]=(path.Substring(last+1));}return array;}/**把所有文件封装到map中 key为uint64 value=string*/public static Dictionary<UInt64,string> pathToMap(string path){Dictionary<UInt64,string> dict = new Dictionary<UInt64,string>();DirectoryInfo info = new DirectoryInfo(path);FileSystemInfo[] fileSystem = info.GetFileSystemInfos();UInt64 count = 1;//获取所有子文件(不包含子文件夹),foreach(FileSystemInfo f in fileSystem){FileInfo file = f as FileInfo;if(file!=null && fileterEndName(file.Name))dict.Add(count++,f.FullName);}return dict;}//文件过滤器:png,jpg,gifpublic static bool fileterEndName(string endName){endName = endName.ToLower();bool b = false;string tag = ".png|.jpg|.gif";int last = endName.LastIndexOf(".");if(last!=-1){endName = endName.Substring(last);if(tag.Contains(endName))b= true;}return b;}/**操作xml:默认保存到c:\\property.xml*/public static void createXml(string path){//xml样式 XmlWriterSettings settings = new XmlWriterSettings();settings.Indent = true;settings.NewLineOnAttributes = false;//本地创建一个新的xmlXmlWriter write = XmlWriter.Create(path,settings);write.WriteStartDocument();write.WriteStartElement("property");write.WriteStartElement("time");write.WriteAttributeString("id","setTime");write.WriteValue("3000");write.WriteEndElement();write.WriteStartElement("localhostPath");write.WriteAttributeString("id","setInputBoxPath");write.WriteValue("");write.WriteEndElement();write.WriteEndElement();write.WriteEndDocument();//刷新缓冲区,并释放资源write.Flush();write.Close();}}}|----目录图片的核心代码
<pre code_snippet_id="237877" snippet_file_name="blog_20140315_2_3804652" name="code" class="csharp">/*执行的事件*/ public void theout(object source, EventArgs e) { Boolean b = checkTag.Checked;if(!b){ myTimer.Stop(); //停止定时器 }else{ //执行获取图片 string pageStr = showImg.Text;UInt64 pageNum = UInt64.Parse(pageStr);pageNum = pageNum+1;try{showPage(pageNum);}catch(Exception){//循环showPage(1);//MessageBox.Show("已是未尾");}} }/**后退*/void BackOffClick(object sender, EventArgs e){string pageStr = showImg.Text;UInt64 pageNum = UInt64.Parse(pageStr);pageNum = pageNum-1;try{showPage(pageNum);}catch(Exception){MessageBox.Show("已是顶页");}}/**前进*/void ForwardClick(object sender, EventArgs e){string pageStr = showImg.Text;UInt64 pageNum = UInt64.Parse(pageStr);pageNum = pageNum+1;try{showPage(pageNum);}catch(Exception){MessageBox.Show("已是未尾");}}public bool showPage(UInt64 pageNum){if(dict==null || dict.Count==0){MessageBox.Show("抱歉,没有找到可执行文件!");stopImg.ForeColor=Color.Red;startImg.ForeColor=Color.LimeGreen;/*还原*/Reduction();return false;}string showImgPath = dict[pageNum];showImg.Image = Image.FromFile(showImgPath);//回显信息string[] str = ImgTool.pathToList(showImgPath);Many.Text = "来自:"+str[0];Single.Text = "正在浏览【"+str[1]+"】";//回显页码showImg.Text = Convert.ToString(pageNum);return true;}
</pre>
下面贴出程序执行图片
2 0
- c#图片自动播放程序
- 自动播放图片代码
- 自动播放图片代码
- 自动循环播放图片
- AdapterViewFlipper自动播放图片
- android 图片的自动播放
- Slideshow:图片自动播放控件
- javascript 设置图片自动播放
- javascript图片自动播放代码
- android 自动播放图片
- js图片自动循环播放
- Flex 图片自动播放与图片拉伸
- 写入简谱(flash钢琴谱)自动播放简谱琴声程序 c#
- C#播放音乐,调用程序
- 一个自动动态播放图片的类
- 自动播放图片,可以调整速度。
- HTML自动播放的图片,点击更换
- UIScrollView 的图片循环+自动播放
- Java面试宝典2013版(11版块1000题)
- java面试心得
- 产品经理 深入浅出(2)
- 1021. Deepest Root【待修正】
- 3322,花生壳,nat123,dnspod综合分析对比了解各发布网站访问内网平台
- c#图片自动播放程序
- ★51单片机学习笔记(一)_总记
- 2014ACM集训13级PK赛4-A Stack or A Queue?
- linux进程同步机制
- Cordova实现activity与html之间相互跳转
- 依赖注入详解
- 25岁要做的事情
- 基于mini2440的SD卡MP3播放器的设计
- hdu 4389 X mod f(x) (数位DP)