WEB开发网
开发学院软件开发C语言 使用C#创建一个安装向导 阅读

使用C#创建一个安装向导

 2010-09-30 21:05:21 来源:WEB开发网   
核心提示: 接下来,创建一个FormBase类图代码(Form.Disgner.cs中的代码略去)usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawi

接下来,创建一个FormBase

类图

使用C#创建一个安装向导

代码(Form.Disgner.cs中的代码略去)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace B1Plus.InstallWizardBase
{
    public partial class FormBase : Form
    {
        public WizardController controller = null;
        public FormBase()
        {
            InitializeComponent();
        }
 
        private void btnHelp_Click(object sender, EventArgs e)
        {
            this.ShowHelp();
        }
 
        protected virtual void ShowHelp()
        {
            MessageBox.Show("此步骤未包含任何帮助信息!\n请联系郭富[42319036]");
        }
 
        private void btnPre_Click(object sender, EventArgs e)
        {
            this.GoPrev();
        }
 
        private void btnNext_Click(object sender, EventArgs e)
        {
            this.GoNext();
        }
 
        private void btnStart_Click(object sender, EventArgs e)
        {
            StartInstall();
        }
 
        private void btnFinish_Click(object sender, EventArgs e)
        {
            Cancel();
        }
 
        internal void DisableButtons()
        {
            if (this.controller == null)
                return;
            if (this.controller.IsFirstForm)
                this.btnPre.Visible = false;
            else
                this.btnPre.Visible = true;
            if (this.controller.IsLastForm)
            {
                this.btnNext.Visible = false;
                this.btnStart.Visible = true;
            }
            else
            {
                this.btnNext.Visible = true;
                this.btnStart.Visible = false;
            }
            this.lblStep.Text = (this.controller.CurIndex + 1).ToString() +
                "/" + this.controller.FormsCount.ToString();
        }
 
        protected virtual void GoPrev()
        {
            this.controller.GoPrev();
        }
 
        protected virtual void GoNext()
        {
            if (this.controller.IsLastForm)
                controller.FinishWizard();
            else
                this.controller.GoNext();
        }
 
        protected virtual void Cancel()
        {
            this.controller = null;
            Application.Exit();
        }
 
        protected virtual void StartInstall()
        {
            MessageBox.Show("请重写此方法以执行安装!");
        }
 
        protected virtual void SetBannerInfo(string inf)
        {
            if (inf != null)
            {
                if (inf != "")
                {
                    this.lblBanner.Text = inf;
                    return;
                }
            }
            this.lblBanner.Text = "完成此向导共需" +
                this.controller.FormsCount.ToString() +
                " 步。您现在处于第" +
                (this.controller.CurIndex+1).ToString() +
                " 步。";
        }
 
        private void FormBase_FormClosing(object sender, FormClosingEventArgs e)
        {
        }
    }
}

上一页  1 2 3 4  下一页

Tags:使用 创建 一个

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接