public bool Contains(WizardPageDescriptor descriptor)
		{
			foreach(WizardPageDescriptor pd in base.InnerList)
				if (Type.Equals(pd.Type, descriptor.Type))
					return true;
			return false;
		}
Example #2
0
        /// <summary>
        /// Returns the WizardPageDescriptor from a given location
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public WizardPageDescriptor GetPageDescriptor(WizardNavigationLocation location)
        {
            WizardPageDescriptor descriptor = null;

            // first look in the page cache as we might have already created a descriptor for the type needed
            descriptor = _pagesUsed[location.WizardPageType];

            // ok, it was in the cache
            if (descriptor != null)
            {
                // make sure that an instance was created
                if (!descriptor.IsNull)
                {
                    // if not do it now
                    WizardPageDescriptor.Create(this, descriptor);
                }
            }
            else
            {
                // create a new page descriptor that points to the location's wizard page type
                descriptor = new WizardPageDescriptor(location.WizardPageType);

                // create an instance of the type
                WizardPageDescriptor.Create(this, descriptor);

                // cache the page descript
                _pagesUsed.Add(descriptor);
            }
            return(descriptor);
        }
Example #3
0
 public void Remove(WizardPageDescriptor descriptor)
 {
     if (this.Contains(descriptor))
     {
         base.InnerList.Remove(descriptor);
     }
 }
Example #4
0
 public void Add(WizardPageDescriptor descriptor)
 {
     if (this.Contains(descriptor))
     {
         throw new ArgumentException();
     }
     base.InnerList.Add(descriptor);
 }
Example #5
0
 public bool Contains(WizardPageDescriptor descriptor)
 {
     foreach (WizardPageDescriptor pd in base.InnerList)
     {
         if (Type.Equals(pd.Type, descriptor.Type))
         {
             return(true);
         }
     }
     return(false);
 }
Example #6
0
        /// <summary>
        /// Creates an instance of the descriptor's Type, saves a reference to the instance, and reads the Wizard Pages metadata (Not for external use)
        /// </summary>
        /// <param name="wizardPageHost">The Wizard that is hosting the page</param>
        /// <returns></returns>
        internal static void Create(IWizard wizard, WizardPageDescriptor descriptor)
        {
            // find the default constructor
            ConstructorInfo ci = descriptor.Type.GetConstructor(Type.EmptyTypes);

            // create an instance of the type
            object instance = ci.Invoke(null);

            // cast to a wizard page for ease of usage
            IWizardPage wizardPage = (IWizardPage)instance;

            // set the wizard that will be owning the wizard page
            wizardPage.Wizard = wizard;

            // set the instance created on the descriptor so that it may be referenced later
            descriptor.SetInstance(wizardPage);
        }
		/// <summary>
		/// Creates an instance of the descriptor's Type, saves a reference to the instance, and reads the Wizard Pages metadata (Not for external use)
		/// </summary>
		/// <param name="wizardPageHost">The Wizard that is hosting the page</param>
		/// <returns></returns>
		internal static void Create(IWizard wizard, WizardPageDescriptor descriptor)
		{
			// find the default constructor
			ConstructorInfo ci = descriptor.Type.GetConstructor(Type.EmptyTypes);

			// create an instance of the type
			object instance = ci.Invoke(null);

			// cast to a wizard page for ease of usage
			IWizardPage wizardPage = (IWizardPage)instance;

			// set the wizard that will be owning the wizard page
			wizardPage.Wizard = wizard;

			// set the instance created on the descriptor so that it may be referenced later
			descriptor.SetInstance(wizardPage);															
		}
Example #8
0
 /// <summary>
 /// Sets the button style for the specified page
 /// </summary>
 /// <param name="descriptor"></param>
 /// <param name="throwExceptions"></param>
 /// <returns></returns>
 public bool SetButtonStylesForPage(WizardPageDescriptor descriptor, bool throwExceptions)
 {
     if (descriptor != null)
     {
         try
         {
             foreach (WizardButtonStyle style in descriptor.ButtonStyles)
             {
                 this.SetButtonStyle(style);
             }
             return(true);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex);
             if (throwExceptions)
             {
                 throw new Exception(ex.Message, ex);
             }
         }
     }
     return(false);
 }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the Wizard class
        /// </summary>
        public Wizard()
        {
            this.InitializeComponent();

            // default props
            this._title       = "My Wizard";
            this._map         = new WizardNavigationMap();
            this._currentPage = null;
            this._pagesUsed   = new WizardPageDescriptorList();
            this._pageHistory = new Stack();
            this._propertyBag = new Hashtable();

            // the initial layout is cancel only
            this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Help, false, false));
            this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Back, false, false));
            this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Next, false, false));
            this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Cancel, true, true));

            // wire up to the wizard button events
            this._buttonHelp.Click   += new EventHandler(this.OnWizardButtonClicked);
            this._buttonBack.Click   += new EventHandler(this.OnWizardButtonClicked);
            this._buttonNext.Click   += new EventHandler(this.OnWizardButtonClicked);
            this._buttonCancel.Click += new EventHandler(this.OnWizardButtonClicked);
        }
		public void Remove(WizardPageDescriptor descriptor)
		{
			if (this.Contains(descriptor))
				base.InnerList.Remove(descriptor);
		}
		public void Add(WizardPageDescriptor descriptor)
		{
			if (this.Contains(descriptor))
				throw new ArgumentException();
			base.InnerList.Add(descriptor);
		}		
Example #12
0
		/// <summary>
		/// Sets the button style for the specified page
		/// </summary>
		/// <param name="descriptor"></param>
		/// <param name="throwExceptions"></param>
		/// <returns></returns>
		public bool SetButtonStylesForPage(WizardPageDescriptor descriptor, bool throwExceptions)
		{
			if (descriptor != null)
			{
				try
				{				
					foreach(WizardButtonStyle style in descriptor.ButtonStyles)
						this.SetButtonStyle(style);
					return true;
				}
				catch(Exception ex)
				{
					Trace.WriteLine(ex);
					if (throwExceptions)
						throw new Exception(ex.Message, ex);
				}
			}
			return false;
		}
Example #13
0
		/// <summary>
		/// Returns the WizardPageDescriptor from a given location
		/// </summary>
		/// <param name="location"></param>
		/// <returns></returns>
		public WizardPageDescriptor GetPageDescriptor(WizardNavigationLocation location)
		{			
			WizardPageDescriptor descriptor = null;			
			
			// first look in the page cache as we might have already created a descriptor for the type needed
			descriptor = _pagesUsed[location.WizardPageType];
			
			// ok, it was in the cache
			if (descriptor != null)
			{
				// make sure that an instance was created
				if (!descriptor.IsNull)
					// if not do it now
					WizardPageDescriptor.Create(this, descriptor);				
			}
			else
			{
				// create a new page descriptor that points to the location's wizard page type
				descriptor = new WizardPageDescriptor(location.WizardPageType);

				// create an instance of the type
				WizardPageDescriptor.Create(this, descriptor);

				// cache the page descript
				_pagesUsed.Add(descriptor);
			}
			return descriptor;
		}
Example #14
0
		/// <summary>
		/// Navigates the Wizard to the specified location
		/// </summary>
		/// <param name="location">The location to display in the Wizard</param>
		/// <param name="throwExceptions">A flag indicating whether errors will be re-thrown if encountered</param>
		/// <returns></returns>
		public bool Goto(WizardNavigationLocation location, bool keepInHistory, WizardNavigationReasons reason, bool throwExceptions)
		{
			if (this.InvokeRequired)
			{
				return (bool)this.Invoke(new GotoInvoker(this.Goto), new object[] {location, keepInHistory, reason, throwExceptions});	
			}

			lock (_gotoSyncLock)
			{
				try
				{
					// if there is a current page, push it's location into the history
					if (_currentPage != null)
					{
						if (keepInHistory)
							// put the previous page's location in the history
							_pageHistory.Push(_currentPage.WizardPage.CurrentLocation);
						
						// deactivate the page
						this.DeactivatePage(_currentPage.WizardPage, reason, throwExceptions);

						// unsite it
						this.UnSitePage(_currentPage.WizardPage, throwExceptions);
					}
					
					// save the current page descriptor, as it will soon be the previous page descriptor
					WizardPageDescriptor previousPageDescriptor = _currentPage;
									
					// try and find the page descriptor for the destination location
					WizardPageDescriptor descriptor = this.GetPageDescriptor(location);
					if (descriptor != null)
					{
						// attempt to site the new wizard page
						if (this.SitePage(descriptor.WizardPage, throwExceptions))
						{
							// setup the button styles for the page
							this.SetButtonStylesForPage(descriptor, throwExceptions);

							// we can always go back while there are pages in the page history
							bool canGoBack = (_pageHistory.Count > 0);

							// enable the back button to reflect our position 
							this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Back, canGoBack, canGoBack));																	
							
							// activate the page
							this.ActivatePage(descriptor.WizardPage, (previousPageDescriptor != null ? previousPageDescriptor.WizardPage : null), location, reason, throwExceptions);
															
							// save the descriptor to the page
							_currentPage = descriptor;	

							// fire the navigation event
							this.OnWizardNavigatedToPage(this, new WizardPageEventArgs(_currentPage.WizardPage));

							// finally notify the page that it is ready to perform redirection
							this.NotifyPageItIsReadyToPerformRedirections(descriptor.WizardPage, (previousPageDescriptor != null ? previousPageDescriptor.WizardPage : null), location, reason, throwExceptions);

							return true;
						}					
					}
				}
				catch(Exception ex)
				{
					Trace.WriteLine(ex);
					if (throwExceptions)
						throw new Exception(ex.Message, ex);
				}
				return false;
			}
		}
Example #15
0
		/// <summary>
		/// Initializes a new instance of the Wizard class
		/// </summary>
		public Wizard()
		{
			this.InitializeComponent();
			
			// default props
			this._title = "My Wizard";
			this._map = new WizardNavigationMap();
			this._currentPage = null;
			this._pagesUsed = new WizardPageDescriptorList();
			this._pageHistory = new Stack();
			this._propertyBag = new Hashtable();

			// the initial layout is cancel only
			this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Help, false, false));
			this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Back, false, false));
			this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Next, false, false));
			this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Cancel, true, true));
			
			// wire up to the wizard button events
			this._buttonHelp.Click += new EventHandler(this.OnWizardButtonClicked);
			this._buttonBack.Click += new EventHandler(this.OnWizardButtonClicked);
			this._buttonNext.Click += new EventHandler(this.OnWizardButtonClicked);
			this._buttonCancel.Click += new EventHandler(this.OnWizardButtonClicked);
		}
Example #16
0
        /// <summary>
        /// Navigates the Wizard to the specified location
        /// </summary>
        /// <param name="location">The location to display in the Wizard</param>
        /// <param name="throwExceptions">A flag indicating whether errors will be re-thrown if encountered</param>
        /// <returns></returns>
        public bool Goto(WizardNavigationLocation location, bool keepInHistory, WizardNavigationReasons reason, bool throwExceptions)
        {
            if (this.InvokeRequired)
            {
                return((bool)this.Invoke(new GotoInvoker(this.Goto), new object[] { location, keepInHistory, reason, throwExceptions }));
            }

            lock (_gotoSyncLock)
            {
                try
                {
                    // if there is a current page, push it's location into the history
                    if (_currentPage != null)
                    {
                        if (keepInHistory)
                        {
                            // put the previous page's location in the history
                            _pageHistory.Push(_currentPage.WizardPage.CurrentLocation);
                        }

                        // deactivate the page
                        this.DeactivatePage(_currentPage.WizardPage, reason, throwExceptions);

                        // unsite it
                        this.UnSitePage(_currentPage.WizardPage, throwExceptions);
                    }

                    // save the current page descriptor, as it will soon be the previous page descriptor
                    WizardPageDescriptor previousPageDescriptor = _currentPage;

                    // try and find the page descriptor for the destination location
                    WizardPageDescriptor descriptor = this.GetPageDescriptor(location);
                    if (descriptor != null)
                    {
                        // attempt to site the new wizard page
                        if (this.SitePage(descriptor.WizardPage, throwExceptions))
                        {
                            // setup the button styles for the page
                            this.SetButtonStylesForPage(descriptor, throwExceptions);

                            // we can always go back while there are pages in the page history
                            bool canGoBack = (_pageHistory.Count > 0);

                            // enable the back button to reflect our position
                            this.SetButtonStyle(new WizardButtonStyle(WizardButtons.Back, canGoBack, canGoBack));

                            // activate the page
                            this.ActivatePage(descriptor.WizardPage, (previousPageDescriptor != null ? previousPageDescriptor.WizardPage : null), location, reason, throwExceptions);

                            // save the descriptor to the page
                            _currentPage = descriptor;

                            // fire the navigation event
                            this.OnWizardNavigatedToPage(this, new WizardPageEventArgs(_currentPage.WizardPage));

                            // finally notify the page that it is ready to perform redirection
                            this.NotifyPageItIsReadyToPerformRedirections(descriptor.WizardPage, (previousPageDescriptor != null ? previousPageDescriptor.WizardPage : null), location, reason, throwExceptions);

                            return(true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    if (throwExceptions)
                    {
                        throw new Exception(ex.Message, ex);
                    }
                }
                return(false);
            }
        }