silverlight报告.docx
- 文档编号:14100312
- 上传时间:2023-06-20
- 格式:DOCX
- 页数:19
- 大小:39.90KB
silverlight报告.docx
《silverlight报告.docx》由会员分享,可在线阅读,更多相关《silverlight报告.docx(19页珍藏版)》请在冰点文库上搜索。
silverlight报告
淮安信息职业技术学院
———基于动态网页报告案设计
-------------指导老师:
管曙亮
建设单位:
淮安信息职业技术学院
设计单位:
设计人员:
渠翠红
设计时间:
2012年1月2日
摘要:
Silverlight是微软近年推出的Web前端技术,采用它进行网页开发成为程序员除了FLASH外新的选择。
首先讨论了Silverlight的特点和开发技术与XAML语言。
在此基础上对基于Silverlight技术进行网页动画开发进行了分析。
重点探讨了基于Silverlight对页面元素进行二维和三维应用变换的方法。
关键词:
Silverlight;XAML;动画;变换
一、引言
长期以来,在网页动画和网页游戏技术上占统治地位的是FLASH技术。
然而微软在2007年9月发布Silverlight1.0,随后又分别发布了2.0,3.0和4.0。
并且还发布了用于开发Silverlight应用的工具包ExpressionStudio。
并且在其不断发展中,很多新的特性被加入。
基于Silverlight进行网页动画的开发成为一种新的选择。
二、silverlight的概述
MicrosoftSilverlight是微软所发展的Web前端应用程序开发解决方案,是微软丰富型互联网应用程序(RichInternetApplication)策略的主要应用程序开发平台之一,以浏览器的外挂组件方式,提供Web应用程序中多媒体(含影音流与音效流)与高度交互性前端应用程序的解决方案,同时它也是微软UX(用户经验)策略中的一环,也是微软试图将美术设计和程序开发人员的工作明确切分与协同合作发展应用程序的尝试之一。
Silverlight支持动态和静态语言。
具体来说就是ECMA标准的C#,JavaScript,以及流行的VisualBasic语言。
另外,Silverlight还支持IronPython和IronRuby,其分别是Python和Ruby在.NET框架下的版本。
Silverlight知道,应用程序中最重要的是数据。
对此从Silverlight对查询(query),绑定(bindto)和验证(validate)信息的支持可见一斑。
比如,Silverlight提供了查询数据元的三种内置LINQ选项(LINQ到对象,LINQ到XML,LINQ到JSON)。
把数据和UI绑定时,Silverlight提供了单次(one-time),单程(one-way)和双程(two-way)绑定支持。
Silverlight3还支持UI对UI元素绑定。
绑定之后,你有时会需要用户验证输入的数值。
为此,Silverlight3还添加了一个多功能验证组合,令商业流程的应用程序开发更加简便。
三、silverlight的设计
本次设计的主要目的是实现silverllight的增、删、改、查
主要的控件:
label
Windows窗体Label控件用于显示用户不能编辑的文本或图像。
含义:
用于显示标签
它们用于标识窗体上的对象(例如,描述单击某控件时该控件所进行的操作)或显示相应信息以响应应用程序中的运行时事件或进程。
例如,您可以使用标签向文本框、列表框和组合框等添加描述性标题。
也可以编写代码,使标签显示的文本为了响应运行时事件而作出更改。
例如,如果应用程序需要几分钟时间处理更改,则可以在标签中显示处理状态的消息。
因为Label控件不能接收焦点,所以也可以用来为其他控件创建访问键。
访问键允许用户通过按ALT键和访问键来选择另一个控件。
textbox
Windows窗体文本框用于获取用户输入或显示文本。
TextBox控件通常用于可编辑文本,不过也可使其成为只读控件。
文本框可以显示多个行,对文本换行使其符合控件的大小以及添加基本的格式设置。
TextBox控件仅允许在其中显示或输入的文本采用一种格式。
(1)button
Windows窗体Button控件允许用户通过单击来执行操作。
Button控件既可以显示文本,又可以显示图像。
当该按钮被单击时,它看起来像是被按下,然后被释放。
SilverlightTreeView控件的增删改查
这是一个Silverlight树控件增、删、改、查操作的示例。
除了这个之外它还支持节点的拖放功能。
这篇文章需要你最少对Silverlight和数据绑定有一点基本的了解。
我们最后的输出效果会像这样显示:
数据
首先我们来看一下要绑定到TreeView控件的数据结构
Node是要绑定到每一个TreeViewItem的类
另外注意Add和Delete这两个帮助函数,分别用来添加和删除节点。
四、silverlight程序代码
首先建立数据库,然后把主界面设计出来。
主要步骤为:
在L_35101130.Web选择添加新建项
namespaceSL_35101130.Web
{
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.ComponentModel.DataAnnotations;
usingSystem.Linq;
usingSystem.ServiceModel.DomainServices.Hosting;
usingSystem.ServiceModel.DomainServices.Server;
//TheMetadataTypeAttributeidentifiesstudentInfoMetadataastheclass
//thatcarriesadditionalmetadataforthestudentInfoclass.
[MetadataTypeAttribute(typeof(studentInfo.studentInfoMetadata))]
publicpartialclassstudentInfo
{
//Thisclassallowsyoutoattachcustomattributestoproperties
//ofthestudentInfoclass.
//
//Forexample,thefollowingmarkstheXyzpropertyasa
//requiredpropertyandspecifiestheformatforvalidvalues:
//[Required]
//[RegularExpression("[A-Z][A-Za-z0-9]*")]
//[StringLength(32)]
//publicstringXyz{get;set;}
internalsealedclassstudentInfoMetadata
{
//Metadataclassesarenotmeanttobeinstantiated.
privatestudentInfoMetadata()
{
}
publicstring班级{get;set;}
publicstring姓名{get;set;}
publicstring学号{get;set;}
}
}
}效果图为;
登录界面:
代码为:
登录界面:
Login.xaml.cs
silverlight登录界面中如何实现记住用户和密码以及实现登录功能,数据库为本地数据库35101130:
具体要求是,第一次访问从服务器端获取数据保存到本地35101130数据库,以后每次访问从本地数据库35101130获取用户信息进行验证,点击“用户名和密码”,然后输入用户名与密码,能够完成登录功能.
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Net;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Documents;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Animation;
usingSystem.Windows.Shapes;
namespaceSL_35101130
{
publicpartialclassLogin:
UserControl
{
publicLogin()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,RoutedEventArgse)
{
MyCommon.Request("login.ashx?
username="+tb_username.Text+"&password="+tb_password.Text,wb_DownloadStringCompleted);
}
voidwb_DownloadStringCompleted(objectsender,DownloadStringCompletedEventArgse)
{
if(e.Result=="1")
{
MessageBox.Show("登陆成功!
");
MyClass.mainpage.LayoutRoot.Children.Clear();
MyClass.mainpage.LayoutRoot.Children.Add(newInformaion());
elseMessageBox.Show("登陆失败!
");
}
privatevoidbutton2_Click(objectsender,RoutedEventArgse)
login.ashx.cs
login.ashx中连接数据库通过用户名查询用户时,得到数据报告
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
namespaceSL_35101130.Web
{
///
///login的摘要说明
///
publicclasslogin:
IHttpHandler
{
publicvoidProcessRequest(HttpContextcontext)
{
context.Response.ContentType="text/plain";
//context.Response.Write("HelloWorld");
Stringusername=context.Request["username"];
Stringpassword=context.Request["password"];
if(username=="abc"&&password=="123")
context.Response.Write("1");
else
context.Response.Write("false");
}
publicboolIsReusable
{
get
{
returnfalse;
}
}
}
}Silverlight增删改查代码:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Net;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Documents;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Animation;
usingSystem.Windows.Shapes;
usingSL_35101130.Web;
namespaceSL_35101130
{
publicpartialclassInformaion:
UserControl
{
//intm_action;
CHm_ds=null;
publicInformaion()
{
InitializeComponent();
m_ds=newCH();
m_ds.Load(m_ds.GetStudentInfoQuery());
dataGrid1.ItemsSource=m_ds.studentInfos;
}
privatevoidbutton3_Click(objectsender,RoutedEventArgse)
{
}
privatevoid添加_Click(objectsender,RoutedEventArgse)
{
studentInfor=newstudentInfo();
r.学号=tb_sId.Text;
r.姓名=tb_name.Text;
r.班级=tb_class.Text;;
m_ds.studentInfos.Add(r);
m_ds.SubmitChanges();
}
privatevoid删除_Click(objectsender,RoutedEventArgse)
{
studentInfor=(studentInfo)dataGrid1.SelectedItem;
m_ds.studentInfos.Remove(r);
m_ds.SubmitChanges();
}
privatevoid修改_Click(objectsender,RoutedEventArgse)
{
studentInfor=(studentInfo)dataGrid1.SelectedItem;
r.学号=tb_sId.Text;
r.姓名=tb_name.Text;
r.班级=tb_class.Text;
m_ds.SubmitChanges();
}
publicvoidcleanControl()
{
textBox1.Text="";
textBox2.Text="";
textBox3.Text="";
}
mainpage.xaml
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Net;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Documents;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Animation;
usingSystem.Windows.Shapes;
usingSL_35101130.Web;
namespaceSL_35101130
{
publicpartialclassMainPage:
UserControl
{
publicMainPage()
{
InitializeComponent();
Loginfrm=newLogin();
MyClass.mainpage=this;
MyClass.mainpage.LayoutRoot.Children.Add(frm);
Mycommon
usingSystem;
usingSystem.Net;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Documents;
usingSystem.Windows.Ink;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Animation;
usingSystem.Windows.Shapes;
namespaceSL_35101130
{
publicclassMyCommon
{
//获取SL应用程序*.xap文件的URI位置
publicstaticStringGetHostRoot()
{
Strings=App.Current.Host.Source.AbsoluteUri;
returns.Substring(0,s.IndexOf("ClientBin"));
}
//封装请求和响应
publicstaticvoidRequest(Stringurl,DownloadStringCompletedEventHandlercallback)
{
WebClientwb=newWebClient();
wb.DownloadStringCompleted+=newDownloadStringCompletedEventHandler(callback);
wb.DownloadStringAsync(newUri(MyCommon.GetHostRoot()+url,UriKind.Absolute));
}
}
}
mycalss
usingSystem;
usingSystem.Net;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Documents;
usingSystem.Windows.Ink;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Animation;
usingSystem.Windows.Shapes;
namespacesl_35101130
{
publicclassMyClass
{
publicstaticMainm=null;//静态字段,可以存储数据,共享数据
}
}
app.xaml
singSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Net;
usingSystem.Windows;
usingSystem.Windows.Controls;
usingSystem.Windows.Documents;
usingSystem.Windows.Input;
usingSystem.Windows.Media;
usingSystem.Windows.Media.Animation;
usingSystem.Windows.Shapes;
namespacesl_35101130
{
publicpartialclassApp:
Application
{
publicApp()
{
this.Startup+=this.Application_Startup;
this.Exit+=this.Application_Exit;
this.UnhandledException+=this.Application_UnhandledException;
InitializeComponent();
}
privatevoidApplication_Startup(objectsender,StartupEventArgse)
{
Mainmn=newMain();//产生对象
MyClass.m=mn;
this.RootVisual=mn;
//this.RootVisual=newMainPage();
}
privatevoidApplication_Exit(objectsender,EventArgse)
{
}
privatevoidApplication_UnhandledException(objectsender,ApplicationUnhandledExceptionEventArgse)
{
//如果应用程序是在调试器外运行的,则使用浏览器的
//异常机制报告该异常。
在IE上,将在状态栏中用一个
//黄色警报图标来显示该异常,而Firefox则会显示一个脚本错误。
if(!
System.Diagnostics.Debugger.IsAttached)
{
//注意:
这使应用程序可以在已引发异常但尚未处理该异常的情况下
//继续运行。
//对于生产应用程序,此错误处理应替换为向网站报告错误
//并停止应用程序。
e.Handled=true;
Deployment.Current.Dispatcher.BeginInvoke(delegate{ReportErrorToDOM(e);});
}
}
privatevoidReportErrorToDOM(ApplicationUnhandledExceptionEventArgse)
{
try
{
stringerrorMsg=e.ExceptionObject.Message+e.ExceptionObject.StackTrace;
errorMsg=errorMsg.Replace('"','\'').Replace("\r\n",@"\n");System.Windows.Browser.HtmlPage.Window.Eval("thrownewError(\"UnhandledErrorinSilverlightApplication"+errorMsg+"\");");
}
catch
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- silverlight 报告