Silverlight 版的电子表

Silverlight 版的电子表,第1张

概述程序执行的效果图: 这个程序改编自:webabcd 的 Silverlight 1.0 同样程序。 http://www.cnblogs.com/webabcd/archive/2007/09/17/895328.html  我这里把 Silverlight 1.0 的程序改成 Silverlight 3.0 的程序了。中间的逻辑,原先是JavaScript写的,现在变成C#写的了。 程序是用VS

程序执行的效果图:

这个程序改编自:webabcd 的 Silverlight 1.0 同样程序。

http://www.cnblogs.com/webabcd/archive/2007/09/17/895328.html 

我这里把 Silverlight 1.0 的程序改成 Silverlight 3.0 的程序了。中间的逻辑,原先是JavaScript写的,现在变成C#写的了。

程序是用VS2010 beta 写的, 使用的是 VS2010 默认创建的 Silverlight 项目来编写的。 对其中改动的部分代码如下:

MainPage.xaml 文件

<UserControl x:Class="ClockSilverlightApp.MainPage"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:d="http://schemas.microsoft.com/Expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    mc:Ignorable="d"    d:DesignHeight="300" d:DesignWIDth="400" Loaded="UserControl_Loaded">    <Canvas	xmlns="http://schemas.microsoft.com/clIEnt/2007"	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"	WIDth="180" Height="150"	Background="#0030628D"	x:name="Page" >        <Rectangle x:name="Frame" WIDth="180" Height="150" stroke="#FF000000" strokeThickness="1" RadiusX="20" RadiusY="15">            <Rectangle.Fill>                <linearGradIEntBrush EndPoint="0.5,1.1" StartPoint="0.5,-0.1">                    <GradIEntStop color="#FF259888" Offset="0"/>                    <GradIEntStop color="#FF259888" Offset="0.981"/>                    <GradIEntStop color="#FFC87947" Offset="0.416"/>                    <GradIEntStop color="#FFC87947" Offset="0.636"/>                    linearGradIEntBrush>                Rectangle.Fill>      Rectangle> <Rectangle x:name="Panel" WIDth="164" Height="134" Fill="#7F91B52C" stroke="#FFA2AEBF" RadiusX="50" RadiusY="15" Canvas.left="8" Canvas.top="8" strokeThickness="2"/> <Path x:name="line1" WIDth="163" Height="1" Fill="#FF100888" Stretch="Fill" stroke="#FF1B510C" Canvas.left="8" Canvas.top="92" Data="M33.50029,83.29705 L161.89657,83.297051"/> <Path x:name="line2" WIDth="1" Height="49" Fill="#FF100888" Stretch="Fill" stroke="#FF1B510C" Canvas.left="56" Canvas.top="92" Data="M81.450752,138.29705 L81.450752,90.29705"/> <Path x:name="line3" WIDth="1" Height="49" Fill="#FF100888" Stretch="Fill" stroke="#FF1B510C" Canvas.left="110" Canvas.top="92" Data="M118.30501,164.29698 L118.30501,116.29699"/> <TextBlock x:name="Month" WIDth="16" Height="19" Canvas.left="30" Canvas.top="92" textwrapPing="Wrap" Foreground="#FF100888" Text="月"/> <TextBlock WIDth="16" Height="19" Canvas.left="78" Canvas.top="92" textwrapPing="Wrap" x:name="Day" Foreground="#FF100888" Text="日"/> <TextBlock WIDth="30" Height="19" Canvas.left="129" Canvas.top="92" textwrapPing="Wrap" x:name="Week" Foreground="#FF100888" Text="星期"/> <TextBlock x:name="txtMonth" WIDth="19" Height="19" Canvas.left="28" Canvas.top="111" textwrapPing="Wrap" Foreground="#FF100888" Text="12"/> <TextBlock x:name="txtDay" WIDth="20.5" Height="19" Canvas.left="77" Canvas.top="111" textwrapPing="Wrap" Foreground="#FF100888" Text="31"/> <TextBlock x:name="txtWeek" WIDth="20" Height="19" Canvas.left="133" Canvas.top="111" textwrapPing="Wrap" Foreground="#FF100888" Text="六"/> <TextBlock x:name="txtHour" WIDth="48" Height="48" Canvas.left="14.5" Canvas.top="38" textwrapPing="Wrap" FontSize="36" Foreground="#FF100888" Text="23"/> <TextBlock x:name="txtMinute" WIDth="48" Height="48" Canvas.left="68.5" Canvas.top="38" textwrapPing="Wrap" FontSize="36" Foreground="#FF100888" Text="59"/> <TextBlock x:name="txtSecond" WIDth="49" Height="48" Canvas.left="122" Canvas.top="38" textwrapPing="Wrap" FontSize="36" Foreground="#FF100888" Text="59"/> <TextBlock x:name="Colon1" WIDth="9.5" Height="27" Canvas.left="62.5" Canvas.top="48" textwrapPing="Wrap" Foreground="#FF100888" Text=":" FontSize="20"/> <TextBlock x:name="Colon2" WIDth="12" Height="27" Canvas.left="116.5" Canvas.top="48" textwrapPing="Wrap" Foreground="#FF100888" Text=":" FontSize="20"/> <TextBlock x:name="copyright" WIDth="88" Height="16" Canvas.left="16" textwrapPing="Wrap" FontSize="12" Canvas.top="22" Foreground="#FF100888" Text="郭红俊 clock" MouseleftbuttonDown="copyright_MouseleftbuttonDown" MouseEnter="TextBlock_MouseEnter" MouseLeave="TextBlock_MouseLeave" /> <TextBlock x:name="FullScreen" WIDth="88" Height="16" Canvas.left="106" textwrapPing="Wrap" FontSize="12" Canvas.top="22" Foreground="#FF100888" Text="FullScreen" MouseEnter="TextBlock_MouseEnter" MouseLeave="TextBlock_MouseLeave" MouseleftbuttonDown="FullScreen_MouseleftbuttonDown" />       Canvas>        UserControl>

MainPage.xaml.cs 文件

using System;using System.Collections.Generic;using System.linq;using System.Net;using System.windows;using System.windows.Controls;using System.windows.documents;using System.windows.input;using System.windows.Media;using System.windows.Media.Animation;using System.windows.Shapes;using System.windows.Threading;using System.windows.browser;namespace ClockSilverlightApp{    public partial class MainPage : UserControl    {        public MainPage()        {            InitializeComponent();            dicWeek.Add(DayOfWeek.FrIDay,"");            dicWeek.Add(DayOfWeek.Monday,"");            dicWeek.Add(DayOfWeek.Saturday,"六");            dicWeek.Add(DayOfWeek.Sunday,"");            dicWeek.Add(DayOfWeek.Thursday,"");            dicWeek.Add(DayOfWeek.Tuesday,"");            dicWeek.Add(DayOfWeek.Wednesday,"");        }        private static Readonly Dictionary      string> dicWeek =     new Dictionary        string>();    /// /// 定时更新前段显示信息事件 ///     ///     ///     private    voID enableClock(    object sender,EventArgs e) { DateTime dt = DateTime.Now;    this.txtMonth.Text =    string.Format("    {0:00}",dt.Month);    this.txtDay.Text =    string.Format("    {0:00}",dt.Day);    this.txtWeek.Text = dicWeek[dt.DayOfWeek];    this.txtHour.Text =    string.Format("    {0:00}",dt.Hour);    this.txtMinute.Text =    string.Format("    {0:00}",dt.Minute);    this.txtSecond.Text =    string.Format("    {0:00}",dt.Second); } dispatcherTimer timer =    new dispatcherTimer();    private    voID UserControl_Loaded(    object sender,RoutedEventArgs e) { enableClock(    null,null); timer.Interval =    new TimeSpan(0,1); timer.Tick +=    new EventHandler(enableClock); timer.Start(); }    private    voID copyright_MouseleftbuttonDown(    object sender,MousebuttonEventArgs e) { HTMLPage.Window.Navigate(    new Uri("    http://www.csdn.net/"),"    new"); }    private    voID TextBlock_MouseEnter(    object sender,MouseEventArgs e) {    if (sender ==    null)    return; TextBlock tb = sender    as TextBlock;    if (tb ==    null)    return;    // TextBlock.foreground tb.Foreground =    new SolIDcolorBrush(colors.Red);    // TextBlock.textdecorations tb.Textdecorations = Textdecorations.Underline; tb.Cursor = Cursors.Hand; }    private    voID TextBlock_MouseLeave(    object sender,MouseEventArgs e) {    if (sender ==    null)    return; TextBlock tb = sender    as TextBlock;    if (tb ==    null)    return;    // TextBlock.foreground tb.Foreground =    new SolIDcolorBrush(color.FromArgb(255,16,8,136));    // TextBlock.textdecorations tb.Textdecorations =    null; tb.Cursor = Cursors.Arrow; }    private    voID FullScreen_MouseleftbuttonDown(    object sender,MousebuttonEventArgs e) { Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen; } } }   ,>  ,>

其他文件没有变化。

这个程序我觉得挺适合初学者做出第一个有点意思的Silverlight程序。所以就把它改写成Silverlight 3 的程序了。

总结

以上是内存溢出为你收集整理的Silverlight 版的电子表全部内容,希望文章能够帮你解决Silverlight 版的电子表所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1044167.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存