Exemplo n.º 1
0
        /// <summary>
        /// Called when the WizardPage becomes inactive
        /// </summary>
        public virtual void Deactivate(WizardNavigationReasons reason)
        {
            _active          = false;
            _currentLocation = null;

            Debug.WriteLine(string.Format("The '{0}' is being deactivated because the Wizard is '{1}'.", this.GetType().Name, reason.ToString()));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deactivates a page
 /// </summary>
 /// <param name="wizardPage"></param>
 /// <param name="throwExceptions"></param>
 /// <returns></returns>
 public bool DeactivatePage(IWizardPage wizardPage, WizardNavigationReasons reason, bool throwExceptions)
 {
     if (wizardPage != null)
     {
         try
         {
             wizardPage.Deactivate(reason);
             return(true);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex);
             if (throwExceptions)
             {
                 throw new Exception(ex.Message, ex);
             }
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Called when the WizardPage becomes ready to allow redirection by directly using the Wizard
 /// </summary>
 /// <param name="previousPage"></param>
 /// <param name="currentLocation"></param>
 /// <param name="reason"></param>
 public virtual void ReadyToPerformRedirections(IWizardPage previousPage, WizardNavigationLocation currentLocation, WizardNavigationReasons reason)
 {
 }
Exemplo n.º 4
0
        /// <summary>
        /// Called when the WizardPage becomes active
        /// </summary>
        /// <param name="previousPage">The WizardPage that was the previous active page</param>
        /// <param name="currentLocation">The WizardNavigationLocation that directed the Wizard to this WizardPage</param>
        public virtual void Activate(IWizardPage previousPage, WizardNavigationLocation currentLocation, WizardNavigationReasons reason)
        {
            _active          = true;
            _currentLocation = currentLocation;

            Debug.WriteLine(string.Format("The '{0}' is being activated because the Wizard is '{1}'.", this.GetType().Name, reason.ToString()));
        }
		/// <summary>
		/// Called when the WizardPage becomes inactive
		/// </summary>
		public virtual void Deactivate(WizardNavigationReasons reason)
		{
			_active = false;
			_currentLocation = null;

			Debug.WriteLine(string.Format("The '{0}' is being deactivated because the Wizard is '{1}'.", this.GetType().Name, reason.ToString()));
		}
		/// <summary>
		/// Called when the WizardPage becomes ready to allow redirection by directly using the Wizard
		/// </summary>
		/// <param name="previousPage"></param>
		/// <param name="currentLocation"></param>
		/// <param name="reason"></param>
		public virtual void ReadyToPerformRedirections(IWizardPage previousPage, WizardNavigationLocation currentLocation, WizardNavigationReasons reason)
		{

		}
		/// <summary>
		/// Called when the WizardPage becomes active
		/// </summary>
		/// <param name="previousPage">The WizardPage that was the previous active page</param>
		/// <param name="currentLocation">The WizardNavigationLocation that directed the Wizard to this WizardPage</param>
		public virtual void Activate(IWizardPage previousPage, WizardNavigationLocation currentLocation, WizardNavigationReasons reason)
		{
			_active = true;
			_currentLocation = currentLocation;	
		
			Debug.WriteLine(string.Format("The '{0}' is being activated because the Wizard is '{1}'.", this.GetType().Name, reason.ToString()));
		}
        /// <summary>
        /// Overrides the standard IWizardPage.Activate method so that a default route may be selected from the available paths
        /// </summary>
        /// <param name="previousPage"></param>
        /// <param name="currentLocation"></param>
        /// <param name="reason"></param>
        public override void Activate(IWizardPage previousPage, WizardNavigationLocation currentLocation, WizardNavigationReasons reason)
        {
            // always call to the base class first
            base.Activate(previousPage, currentLocation, reason);

            // assuming the current location isn't null
            if (this.CurrentLocation != null)
            {
                // by default just try and select the "Next" route in the path list
                this.CurrentLocation.Paths.TryAndSelectPath("Next");
            }
        }
Exemplo n.º 9
0
		/// <summary>
		/// Notifies a page that it is ready to and allowed to perform automatic redirection using the wizard directly
		/// </summary>
		/// <param name="wizardPage"></param>
		/// <param name="previousPage"></param>
		/// <param name="location"></param>
		/// <param name="reason"></param>
		/// <param name="throwExceptions"></param>
		/// <returns></returns>
		public bool NotifyPageItIsReadyToPerformRedirections(IWizardPage wizardPage, IWizardPage previousPage, WizardNavigationLocation location, WizardNavigationReasons reason, bool throwExceptions)
		{
			if (wizardPage != null)
			{
				try
				{
					wizardPage.ReadyToPerformRedirections(previousPage, location, reason); 
					return true;
				}
				catch(Exception ex)
				{
					Trace.WriteLine(ex);
					if (throwExceptions)
						throw new Exception(ex.Message, ex);
				}
			}
			return false;
		}
Exemplo n.º 10
0
		/// <summary>
		/// Deactivates a page
		/// </summary>
		/// <param name="wizardPage"></param>
		/// <param name="throwExceptions"></param>
		/// <returns></returns>
		public bool DeactivatePage(IWizardPage wizardPage, WizardNavigationReasons reason, bool throwExceptions)
		{
			if (wizardPage != null)
			{
				try
				{
					wizardPage.Deactivate(reason);
					return true;
				}
				catch(Exception ex)
				{
					Trace.WriteLine(ex);
					if (throwExceptions)
						throw new Exception(ex.Message, ex);
				}
			}
			return false;
		}
Exemplo n.º 11
0
		/// <summary>
		/// Activates a page
		/// </summary>
		/// <param name="wizardPage"></param>
		/// <param name="previousPage"></param>
		/// <param name="location"></param>
		/// <param name="throwExceptions"></param>
		/// <returns></returns>
		public bool ActivatePage(IWizardPage wizardPage, IWizardPage previousPage, WizardNavigationLocation location, WizardNavigationReasons reason, bool throwExceptions)
		{
			if (wizardPage != null)
			{
				try
				{
					wizardPage.Activate(previousPage, location, reason);

					// figure out the names of the possible routes away from this location
					string[] names = location.Paths.GetPathNames();
					string pathNames = string.Join(", ", names);					
					Debug.WriteLine(string.Format("The location represented by the '{0}' WizardPage has '{1}' possible routes.\n\tThey are as follows '{2}' with the page types to which they point.", location.WizardPageType.Name, location.Paths.Count, pathNames));					
					foreach(WizardNavigationPath path in location.Paths)
						Debug.WriteLine(string.Format("\t'{0}' = {1}", path.Name, path.Destination.WizardPageType.Name));

					return true;
				}
				catch(Exception ex)
				{
					Trace.WriteLine(ex);
					if (throwExceptions)
						throw new Exception(ex.Message, ex);
				}
			}
			return false;
		}
Exemplo n.º 12
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;
			}
		}
Exemplo n.º 13
0
 /// <summary>
 /// Notifies a page that it is ready to and allowed to perform automatic redirection using the wizard directly
 /// </summary>
 /// <param name="wizardPage"></param>
 /// <param name="previousPage"></param>
 /// <param name="location"></param>
 /// <param name="reason"></param>
 /// <param name="throwExceptions"></param>
 /// <returns></returns>
 public bool NotifyPageItIsReadyToPerformRedirections(IWizardPage wizardPage, IWizardPage previousPage, WizardNavigationLocation location, WizardNavigationReasons reason, bool throwExceptions)
 {
     if (wizardPage != null)
     {
         try
         {
             wizardPage.ReadyToPerformRedirections(previousPage, location, reason);
             return(true);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex);
             if (throwExceptions)
             {
                 throw new Exception(ex.Message, ex);
             }
         }
     }
     return(false);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Activates a page
        /// </summary>
        /// <param name="wizardPage"></param>
        /// <param name="previousPage"></param>
        /// <param name="location"></param>
        /// <param name="throwExceptions"></param>
        /// <returns></returns>
        public bool ActivatePage(IWizardPage wizardPage, IWizardPage previousPage, WizardNavigationLocation location, WizardNavigationReasons reason, bool throwExceptions)
        {
            if (wizardPage != null)
            {
                try
                {
                    wizardPage.Activate(previousPage, location, reason);

                    // figure out the names of the possible routes away from this location
                    string[] names     = location.Paths.GetPathNames();
                    string   pathNames = string.Join(", ", names);
                    Debug.WriteLine(string.Format("The location represented by the '{0}' WizardPage has '{1}' possible routes.\n\tThey are as follows '{2}' with the page types to which they point.", location.WizardPageType.Name, location.Paths.Count, pathNames));
                    foreach (WizardNavigationPath path in location.Paths)
                    {
                        Debug.WriteLine(string.Format("\t'{0}' = {1}", path.Name, path.Destination.WizardPageType.Name));
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    if (throwExceptions)
                    {
                        throw new Exception(ex.Message, ex);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 15
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);
            }
        }
Exemplo n.º 16
0
		/// <summary>
		/// Overrides the standard IWizardPage.Activate method so that a default route may be selected from the available paths
		/// </summary>
		/// <param name="previousPage"></param>
		/// <param name="currentLocation"></param>
		/// <param name="reason"></param>
		public override void Activate(IWizardPage previousPage, WizardNavigationLocation currentLocation, WizardNavigationReasons reason)
		{
			// always call to the base class first
			base.Activate (previousPage, currentLocation, reason);

			// assuming the current location isn't null			
			if (this.CurrentLocation != null)
				// by default just try and select the "Next" route in the path list
				this.CurrentLocation.Paths.TryAndSelectPath("Next");
		}