FotoVision学习手记(3)

200100301.JPG

AboutForm十分简单,重写了继承自System.Windows.Forms.Form的OnLoad方法,而不采用AboutForm_Load来响应窗体的Load事件。

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;

namespace PhotoVision
{
    /// <summary>
    /// AboutForm 的摘要说明。
    /// </summary>
    public class AboutForm : System.Windows.Forms.Form
    {
        private class Consts
        {
            public const String CompanyLink = "http://phinecos.cnblogs.com/";//开发者网站
        }
        Windows 窗体设计器生成的代码

        private void buttonOk_Click(object sender, System.EventArgs e)
        {//关闭“关于”窗体
            this.Close();
        }

        protected override void OnLoad(System.EventArgs e)
        {//重写了OnLoad方法

            base.OnLoad(e);//引发基类的Load事件

            //更新版本信息
            string delimStr = ".";
            char [] delimiter = delimStr.ToCharArray();//分割符

            String[] version = Application.ProductVersion.Split(delimiter);//分割版本号信息
            this.labelVersion.Text = String.Format("版本号: {0}.{1}.{2}",version[0],version[1],version[2]);

            //获取此应用程序使用的程序集列表

            AssemblyName[] others = System.Reflection.Assembly.GetExecutingAssembly().GetReferencedAssemblies();
            foreach(AssemblyName aName in others)
            {
                this.listAssemblies.Items.Add(String.Format("{0} ({1})",aName.Name,aName.Version.ToString()));
            }

            //图片的存放位置
            this.textPhotoLocation.Text = Global.DataLocation;

        }

        private void linkCompany_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            try
            {//启动浏览器
                this.linkCompany.LinkVisited = true;
                System.Diagnostics.Process.Start(Consts.CompanyLink);
            }
            catch(System.Exception ex)
            {
                Trace.WriteLine(ex.Message.ToString());
            }
        }
    }
}


其中,在获取图片的存放位置时使用了一个全局信息类Global。这是一个静态的不可继承的类,提供了很多供其他类读取和修改的全局信息,例如进度的执行情况,图片操作的列表和从应用程序配置文件中读取的配置信息等等。这些全局信息通过Global类提供的静态的公有属性和公有函数来进行访问。
 
下面是AboutForm里用到的Global的属性:

    /// <summary>
    /// Global 的摘要说明。
    /// </summary>
    public sealed class Global
    {
        private Global()
        {//构造函数私有使得类成为静态类
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public static  String DataLocation
        {//获取指向由指定枚举标识的系统特殊文件夹的路径,其中"Personal"指定用作文档的公共储存库的目录。
            get
            {
                return System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal),System.Windows.Forms.Application.ProductName);
            }
        }
    }


到这里为止,系统里边缘无关的信息都已经了解清楚了,接下来就要开始探索系统中最吸引人的地方---自定义控件和各种面板组件,最后是事件的反升处理(子控件将事件通知给父控件处理),我们会看到就好比是冒泡一样,层层上传事件,这更是系统的精华所在了,此外,GDI+操作更是不可错过的精彩。



本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2006/10/03/520493.html,如需转载请自行联系原作者
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值