仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 587|回复: 8
打印 上一主题 下一主题

[学习教程] 来一篇关于NET的教你制造一个复杂的WPF图片扫瞄器(1)

[复制链接]
冷月葬花魂 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 14:26:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
无论谁倒了对双方阵营的粉丝们也是有害无益。制造一个复杂的WPF图片扫瞄器
这里将完成以下几个功效:
1.对指定文件夹下一切JPG文件举行预览
2.对选定片举行扭转
3.对选定片举行灰度处置
4.对选定片举行裁切处置
5.无穷制的恢复功效
6.相似到场购物车的功效
以上去看看实在现历程。
1.创建一个ImageFile类,用来读取像文件:
//ImageFile.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Windows.Media.Imaging;
usingSystem.Text;

namespacePhotoDemo
{
publicclassImageFile
{
privateString_path;
publicStringPath{get{return_path;}}

privateUri_uri;
publicUriUri{get{return_uri;}}

privateBitmapFrame_image;
publicBitmapFrameImage{get{return_image;}}

publicImageFile(stringpath)
{
_path=path;
_uri=newUri(_path);
_image=BitmapFrame.Create(_uri);
}

publicoverridestringToString()
{
returnPath;
}
}
}
2.创建一个像列表的类,用于获得指定目次下的一切jpg像文件
//PhotoList.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Collections.ObjectModel;
usingSystem.IO;
usingSystem.Text;

namespacePhotoDemo
{
publicclassPhotoList:ObservableCollection<ImageFile>
{
DirectoryInfo_directory;
publicDirectoryInfoDirectory
{
set
{
_directory=value;
Update();
}
get{return_directory;}
}

publicstringPath
{
set
{
_directory=newDirectoryInfo(value);
Update();
}
get{return_directory.FullName;}
}

publicPhotoList(){}

publicPhotoList(DirectoryInfodirectory)
{
_directory=directory;
Update();
}

publicPhotoList(stringpath):this(newDirectoryInfo(path)){}

privatevoidUpdate()
{
foreach(FileInfofin_directory.GetFiles("*.jpg"))
{
Add(newImageFile(f.FullName));
}
}
}
}
这里有两个大众属性:Directory和Path,用来猎取或设置像目次信息和路径,另有一个Update()公有办法,当文件路径变更时,更新最新的像文件列表数据。
3.创建前期处置的类。
因为前期加工均触及“印”,以是就创建一个名为“印范例”(PrintType)的类:
//PrintType.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;

namespacePhotoDemo
{
publicclassPrintType
{
privatestring_description;
publicstringDescription{get{return_description;}}

privatedouble_cost;
publicdoubleCost{get{return_cost;}}

publicPrintType(stringdescription,doublecost)
{
_description=description;
_cost=cost;
}

publicoverridestringToString()
{
return_description;
}
}
}
这里有两个只读属性:形貌Description和用度Cost,还对ToString()办法举行了重载。
4.PrintTypeList类,是PrintType列表的汇合。</P></strong>//PrintTypeList.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Collections.ObjectModel;
usingSystem.Text;

namespacePhotoDemo
{
publicclassPrintTypeList:ObservableCollection<PrintType>
{
publicPrintTypeList()
{
Add(newPrintType("4x6Print",0.15));
Add(newPrintType("GreetingCard",1.49));
Add(newPrintType("T-Shirt",14.99));
}
}
}
5.创建一个PrintBase的类
//PrintBase.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Windows.Media.Imaging;
usingSystem.Text;

namespacePhotoDemo
{
publicclassPrintBase:INotifyPropertyChanged
{
#regionpublicproperty
privateBitmapSource_photo;
publicBitmapSourcePhoto
{
set{_photo=value;OnPropertyChanged("Photo");}
get{return_photo;}
}

privatePrintType_PrintType;
publicPrintTypePrintType
{
set{_PrintType=value;OnPropertyChanged("PrintType");}
get{return_PrintType;}
}

privateint_quantity;
publicintQuantity
{
set{_quantity=value;OnPropertyChanged("Quantity");}
get{return_quantity;}
}
#endregionpublicproperty

publicPrintBase(BitmapSourcephoto,PrintTypeprinttype,intquantity)
{
Photo=photo;
PrintType=printtype;
Quantity=quantity;
}

publicPrintBase(BitmapSourcephoto,stringdescription,doublecost)
{
Photo=photo;
PrintType=newPrintType(description,cost);
Quantity=0;
}

publiceventPropertyChangedEventHandlerPropertyChanged;
privatevoidOnPropertyChanged(Stringinfo)
{
if(PropertyChanged!=null)
PropertyChanged(this,newPropertyChangedEventArgs(info));
}

publicoverridestringToString()
{
returnPrintType.ToString();
}
}
}
这里有三个可读写属性:Photo,PrintType和Quantity(暗示片的数目),还设置了一个PropertyChanged托付,用于当属性变动时做响应的事务处置。
6.承继自PrintBase的三个类:Print,GreetingCard,TShirt,分离用来打印,制成贺卡及制造T恤衫。
//Print.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Windows.Media.Imaging;
usingSystem.Text;

namespacePhotoDemo
{
publicclassPrint:PrintBase
{
publicPrint(BitmapSourcephoto):base(photo,"4x6Print",0.15){}
}
}

//TShirt.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Windows.Media.Imaging;
usingSystem.Text;

namespacePhotoDemo
{
publicclassTShirt:PrintBase
{
publicTShirt(BitmapSourcephoto):base(photo,"T-Shirt",14.99){}
}
}

//GreetingCard.cs
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Windows.Media.Imaging;
usingSystem.Text;

namespacePhotoDemo
{
publicclassGreetingCard:PrintBase
{
publicGreetingCard(BitmapSourcephoto):base(photo,"GreetingCard",1.49){}
}
}
7."印"的汇合:PrintList
//PrintList.cs
usingSystem;
usingSystem.Collections.ObjectModel;

namespacePhotoDemo
{
publicclassPrintList:ObservableCollection<PrintBase>{}
}
你可以先看看这篇文章(软微学院生涯-三朝元老经验谈),打不开再跟我说。(我的意思是想让她自己先稍微了解一下到底现在各个方向学的工具以及以后要做的工具大概是什么,因为喜欢做什么样的事其实自己最清楚的)
飘飘悠悠 该用户已被删除
沙发
发表于 2015-1-18 14:41:34 | 只看该作者
这也就是最近几年来随着各种新的后台技术的诞生,CGI应用在Internet上越来越少的原因。CGI方式不适合大访问量的应用。
因胸联盟 该用户已被删除
板凳
发表于 2015-1-25 05:55:34 | 只看该作者
现在的ASP.net分为两个版本:1.1和2.0Asp.net1.1用VS2003(visualstudio2003)编程。Asp.net2.0用VS2005(visualstudio2005)编程。现在一般开发用的是VS2003。
爱飞 该用户已被删除
地板
发表于 2015-2-2 17:29:43 | 只看该作者
HTML:当然这是网页最基本的语言,每一个服务器语言都需要它的支持,要学习,这个肯定是开始,不说了.
精灵巫婆 该用户已被删除
5#
发表于 2015-2-8 03:09:52 | 只看该作者
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码。
老尸 该用户已被删除
6#
发表于 2015-2-24 05:48:07 | 只看该作者
弱类型造成潜在的出错可能:尽管弱数据类型的编程语言使用起来回方便一些,但相对于它所造成的出错几率是远远得不偿失的。
深爱那片海 该用户已被删除
7#
发表于 2015-3-7 11:30:50 | 只看该作者
网页从开始简单的hmtl到复杂的服务语言,走过了10多个年头,各种技术层出不穷,单个的主流技术也在不断翻新的版本,现在分析下各种语言的区别、优势、劣势、开发注意事项!
灵魂腐蚀 该用户已被删除
8#
发表于 2015-3-15 04:42:44 | 只看该作者
业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高,你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。
若天明 该用户已被删除
9#
发表于 2015-3-21 19:40:08 | 只看该作者
提供基于组件、事件驱动的可编程网络表单,大大简化了编程。还可以用ASP.NET建立网络服务。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-6-6 18:44

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表