⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wizardcontrol.cs

📁 Magic Library 1.7,有说明文档
💻 CS
📖 第 1 页 / 共 4 页
字号:
// *****************************************************************************
// 
//  (c) Crownwood Consulting Limited 2002 
//  All rights reserved. The software and associated documentation 
//  supplied hereunder are the proprietary information of Crownwood Consulting 
//	Limited, Haxey, North Lincolnshire, England and are supplied subject to 
//	licence terms.
// 
//  Magic Version 1.7 	www.dotnetmagic.com
// *****************************************************************************

using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.ComponentModel;
using Crownwood.Magic.Common;
using Crownwood.Magic.Controls;
using Crownwood.Magic.Collections;

namespace Crownwood.Magic.Controls
{
    [ToolboxBitmap(typeof(WizardControl))]
    [DefaultProperty("Profile")]
    [Designer(typeof(WizardControlDesigner))]
    public class WizardControl : UserControl
	{
	    // Define enumerations and structures
	    public enum Status
	    {
	        Default,
	        Yes,
	        No
	    }
	    
	    public enum Profiles
	    {
	        Install,
	        Configure,
	        Controller
	    }
	    
	    // Class wide constants
	    protected const int _panelGap = 10;
	    protected const int _buttonGap = 10;
	    protected static Image _standardPicture;
	
	    // Instance fields
        protected Image _picture;
        protected string _title;
        protected Font _fontTitle;
        protected Font _fontSubTitle;
        protected Color _colorTitle;
        protected Color _colorSubTitle;
        protected Profiles _profile;
        protected bool _assignDefault;
        protected WizardPage _selectedPage;
        protected Status _showUpdate, _enableUpdate;
        protected Status _showCancel, _enableCancel;
        protected Status _showBack, _enableBack;
        protected Status _showNext, _enableNext;
        protected Status _showFinish, _enableFinish;
        protected Status _showClose, _enableClose;
        protected Status _showHelp, _enableHelp;
        protected WizardPageCollection _wizardPages;
	    
	    // Instance designer fields
        protected System.Windows.Forms.Panel _panelTop;
        protected System.Windows.Forms.Panel _panelBottom;
        protected System.Windows.Forms.Button _buttonUpdate;
        protected System.Windows.Forms.Button _buttonCancel;
        protected System.Windows.Forms.Button _buttonBack;
        protected System.Windows.Forms.Button _buttonNext;
        protected System.Windows.Forms.Button _buttonFinish;
        protected System.Windows.Forms.Button _buttonClose;
        protected System.Windows.Forms.Button _buttonHelp;
        protected Crownwood.Magic.Controls.TabControl _tabControl;
		protected System.ComponentModel.Container components = null;

        // Delegate definitions
        public delegate void WizardPageHandler(WizardPage wp, WizardControl wc);

        // Instance events
        public event WizardPageHandler WizardPageEnter;
        public event WizardPageHandler WizardPageLeave;
        public event EventHandler WizardCaptionTitleChanged;
        public event EventHandler SelectionChanged;
        public event EventHandler UpdateClick;
        public event EventHandler CancelClick;
        public event EventHandler FinishClick;
        public event EventHandler CloseClick;
        public event EventHandler HelpClick;
        public event CancelEventHandler NextClick;
        public event CancelEventHandler BackClick;

        static WizardControl()
        {
            // Create a strip of images by loading an embedded bitmap resource
            _standardPicture = ResourceHelper.LoadBitmap(Type.GetType("Crownwood.Magic.Controls.WizardControl"),
                                                         "Crownwood.Magic.Resources.WizardPicture.bmp");
        }

		public WizardControl()
		{
			InitializeComponent();
			
			// No page currently selected
			_selectedPage = null;
			
	        // Hook into tab control events
	        _tabControl.SelectionChanged += new EventHandler(OnTabSelectionChanged);

            // Create our collection of wizard pages
            _wizardPages = new WizardPageCollection();
            
            // Hook into collection events
            _wizardPages.Cleared += new Collections.CollectionClear(OnWizardCleared);
            _wizardPages.Inserted += new Collections.CollectionChange(OnWizardInserted);
            _wizardPages.Removed += new Collections.CollectionChange(OnWizardRemoved);

            // Hook into drawing events
            _panelTop.Resize += new EventHandler(OnRepaintPanels);
            _panelTop.Paint += new PaintEventHandler(OnPaintTopPanel);
            _panelBottom.Resize += new EventHandler(OnRepaintPanels);
            _panelBottom.Paint += new PaintEventHandler(OnPaintBottomPanel);

            // Initialize state
            _showUpdate = _enableUpdate = Status.Default;
            _showCancel = _enableUpdate = Status.Default;
            _showBack = _enableBack = Status.Default;
            _showNext = _enableNext = Status.Default;
            _showFinish = _enableFinish = Status.Default;
            _showClose = _enableClose = Status.Default;
            _showHelp = _enableHelp = Status.Default;
            
            // Default properties
            ResetProfile();
            ResetTitle();
            ResetTitleFont();
            ResetTitleColor();
            ResetSubTitleFont();
            ResetSubTitleColor();
            ResetPicture();
            ResetAssignDefaultButton();
            
            // Position and enable/disable control button state
            UpdateControlButtons();
   		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this._tabControl = new Crownwood.Magic.Controls.TabControl();
            this._panelTop = new System.Windows.Forms.Panel();
            this._panelBottom = new System.Windows.Forms.Panel();
            this._buttonUpdate = new System.Windows.Forms.Button();
            this._buttonBack = new System.Windows.Forms.Button();
            this._buttonNext = new System.Windows.Forms.Button();
            this._buttonCancel = new System.Windows.Forms.Button();
            this._buttonFinish = new System.Windows.Forms.Button();
            this._buttonClose = new System.Windows.Forms.Button();
            this._buttonHelp = new System.Windows.Forms.Button();
            this._panelBottom.SuspendLayout();
            this.SuspendLayout();
            // 
            // _tabControl
            // 
            this._tabControl.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
                | System.Windows.Forms.AnchorStyles.Left) 
                | System.Windows.Forms.AnchorStyles.Right);
            this._tabControl.Appearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument;
            this._tabControl.IDEPixelBorder = false;
            this._tabControl.Location = new System.Drawing.Point(0, 80);
            this._tabControl.Multiline = true;
            this._tabControl.MultilineFullWidth = true;
            this._tabControl.Name = "_tabControl";
            this._tabControl.ShowArrows = false;
            this._tabControl.ShowClose = false;
            this._tabControl.Size = new System.Drawing.Size(424, 264);
            this._tabControl.TabIndex = 0;
            // 
            // _panelTop
            // 
            this._panelTop.BackColor = System.Drawing.SystemColors.Window;
            this._panelTop.Dock = System.Windows.Forms.DockStyle.Top;
            this._panelTop.Name = "_panelTop";
            this._panelTop.Size = new System.Drawing.Size(424, 80);
            this._panelTop.TabIndex = 1;
            // 
            // _panelBottom
            // 
            this._panelBottom.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                       this._buttonUpdate,
                                                                                       this._buttonBack,
                                                                                       this._buttonNext,
                                                                                       this._buttonCancel,
                                                                                       this._buttonFinish,
                                                                                       this._buttonClose,
                                                                                       this._buttonHelp});
            this._panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
            this._panelBottom.Location = new System.Drawing.Point(0, 344);
            this._panelBottom.Name = "_panelBottom";
            this._panelBottom.Size = new System.Drawing.Size(424, 48);
            this._panelBottom.TabIndex = 2;
            // 
            // _buttonUpdate
            // 
            this._buttonUpdate.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
            this._buttonUpdate.Location = new System.Drawing.Point(8, 14);
            this._buttonUpdate.Name = "_buttonUpdate";
            this._buttonUpdate.TabIndex = 4;
            this._buttonUpdate.Text = "Update";
            this._buttonUpdate.Click += new System.EventHandler(this.OnButtonUpdate);
            // 
            // _buttonBack
            // 
            this._buttonBack.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
            this._buttonBack.Location = new System.Drawing.Point(56, 14);
            this._buttonBack.Name = "_buttonBack";
            this._buttonBack.TabIndex = 3;
            this._buttonBack.Text = "< Back";
            this._buttonBack.Click += new System.EventHandler(this.OnButtonBack);
            // 
            // _buttonNext
            // 
            this._buttonNext.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
            this._buttonNext.Location = new System.Drawing.Point(120, 14);
            this._buttonNext.Name = "_buttonNext";
            this._buttonNext.TabIndex = 2;
            this._buttonNext.Text = "Next >";
            this._buttonNext.Click += new System.EventHandler(this.OnButtonNext);
            // 
            // _buttonCancel
            // 
            this._buttonCancel.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
            this._buttonCancel.Location = new System.Drawing.Point(184, 14);
            this._buttonCancel.Name = "_buttonCancel";
            this._buttonCancel.TabIndex = 1;
            this._buttonCancel.Text = "Cancel";
            this._buttonCancel.Click += new System.EventHandler(this.OnButtonCancel);
            // 
            // _buttonFinish
            // 
            this._buttonFinish.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
            this._buttonFinish.Location = new System.Drawing.Point(248, 14);
            this._buttonFinish.Name = "_buttonFinish";
            this._buttonFinish.TabIndex = 0;
            this._buttonFinish.Text = "Finish";
            this._buttonFinish.Click += new System.EventHandler(this.OnButtonFinish);
            // 
            // _buttonClose
            // 
            this._buttonClose.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
            this._buttonClose.Location = new System.Drawing.Point(304, 14);
            this._buttonClose.Name = "_buttonClose";
            this._buttonClose.TabIndex = 0;
            this._buttonClose.Text = "Close";
            this._buttonClose.Click += new System.EventHandler(this.OnButtonClose);
            // 
            // _buttonHelp
            // 
            this._buttonHelp.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
            this._buttonHelp.Location = new System.Drawing.Point(360, 14);
            this._buttonHelp.Name = "_buttonHelp";
            this._buttonHelp.TabIndex = 0;
            this._buttonHelp.Text = "Help";
            this._buttonHelp.Click += new System.EventHandler(this.OnButtonHelp);
            // 
            // WizardControl
            // 
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this._tabControl,
                                                                          this._panelTop,
                                                                          this._panelBottom});
            this.Name = "WizardControl";
            this.Size = new System.Drawing.Size(424, 392);
            this._panelBottom.ResumeLayout(false);
            this.ResumeLayout(false);

        }
		#endregion
		
        [Category("Wizard")]
        [Description("Access to underlying TabControl instance")]
        public Controls.TabControl TabControl
        {
            get { return _tabControl; }
        }

        [Category("Wizard")]
        [Description("Access to underlying header panel")]
        public Panel HeaderPanel
        {
            get { return _panelTop; }
        }

        [Category("Wizard")]
        [Description("Access to underlying trailer panel")]
        public Panel TrailerPanel
        {
            get { return _panelBottom; }
        }

        [Category("Wizard")]
        [Description("Collection of wizard pages")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public WizardPageCollection WizardPages
		{
		    get { return _wizardPages; }
		}
		
        [Category("Wizard")]
        [Description("Determine default operation of buttons")]
        [DefaultValue(typeof(Profiles), "Configure")]
        public Profiles Profile
        {
            get { return _profile; }
		    
            set 
            {
                if (_profile != value)
                {
                    _profile = value;
		            
                    switch(_profile)
                    {
                        case Profiles.Install:
                        case Profiles.Configure:
                            // Current page selection determines if full page is needed
                            if (_tabControl.SelectedIndex != -1)
                            {
                                // Get the selected wizard page
                                WizardPage wp = _wizardPages[_tabControl.SelectedIndex];
                
                                // Should we be presented in full page?
                                if (wp.FullPage)
                                    EnterFullPage();
                                else
                                {
                                    // Controller profile is not allowed to be outside of FullMode
                                    if (_profile != Profiles.Controller)
                                        LeaveFullPage();
                                }
                            }
                            else
                                LeaveFullPage();
                            
                            _tabControl.HideTabsMode = Magic.Controls.TabControl.HideTabsModes.HideAlways; 
                            break;
                        case Profiles.Controller:
                            // Controller is always full page
                            EnterFullPage();
                                
                            _tabControl.HideTabsMode = Magic.Controls.TabControl.HideTabsModes.ShowAlways;
                            break;
                    }
		            
                    // Position and enable/disable control button state
                    UpdateControlButtons();
                }
            }
        }

        public void ResetProfile()
        {
            Profile = Profiles.Configure;
        }
        
        [Category("Wizard")]
        [Description("Main title text")]
        public Image Picture
        {
            get { return _picture; }
            
            set
            {
                _picture = value;
                _panelTop.Invalidate();
            }
        }

        protected bool ShouldSerializePicture()
        {
            return _picture.Equals(_standardPicture);
        }
        
        public void ResetPicture()
        {
            Picture = _standardPicture;
        }
        
        [Category("Wizard")]
		[Description("Main title text")]
		[Localizable(true)]
		public string Title
		{
		    get { return _title; }
		    
		    set
		    {
		        _title = value;
		        _panelTop.Invalidate();
		    }
		}
		
        public void ResetTitle()
        {
            Title = "Welcome to the Wizard Control";
        }

        protected bool ShouldSerializeTitle()
        {
            return !_title.Equals("Welcome to the Wizard Control");
        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -