Example #1
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()));
        }
Example #2
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()));
        }
Example #3
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 #4
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);
        }
        /// <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");
            }
        }
Example #6
0
 /// <summary>
 /// Navigates the Wizard backwards to the last location
 /// </summary>
 /// <returns></returns>
 public bool GoBack()
 {
     try
     {
         if (this.CanGoBack())
         {
             WizardNavigationLocation location = _pageHistory.Pop() as WizardNavigationLocation;
             if (location != null)
             {
                 return(this.Goto(location, false /*don't keep in history*/, WizardNavigationReasons.NavigatingBackward, true));
             }
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex);
     }
     return(false);
 }
Example #7
0
        /// <summary>
        /// Navigates the Wizard forward to the next selected location
        /// </summary>
        /// <returns></returns>
        public bool GoForward()
        {
            try
            {
                // if we have a page loaded
                if (_currentPage != null)
                {
                    // find it's selected destination location
                    WizardNavigationLocation location = _currentPage.WizardPage.CurrentLocation.Paths.FindSelectedDestination();

                    // the current page may not have selected a location as of yet, so be carefull
                    if (location != null)
                    {
                        // goto the location
                        return(this.Goto(location, true, WizardNavigationReasons.NavigatingForward, true));
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
            return(false);
        }
		/// <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()));
		}
Example #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;
		}
Example #10
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;
		}
Example #11
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;
		}
		/// <summary>
		/// Adds a route from this location to the location defined by the specified path elements
		/// </summary>
		/// <param name="destination">The destination location</param>
		/// <param name="name">A key by which the route will be known</param>
		/// <param name="selected">A flag that indicates whether this route is the selected path</param>
		public void AddRoute(WizardNavigationLocation destination, string name, bool selected)
		{
			// add a new path to describe this route
			_paths.Add(new WizardNavigationPath(destination, name, selected));
		}
		/// <summary>
		/// Initializes a new instance of the WizardNavigationmap class
		/// </summary>
		/// <param name="startingLocation">The starting location for the navigation map</param>
		public WizardNavigationMap(WizardNavigationLocation start)
		{
			_start = start;
		}
		/// <summary>
		/// Initializes a new instance of the WizardNavigationPath class
		/// </summary>
		/// <param name="destination">A destination location to associate with this path</param>
		public WizardNavigationPath(WizardNavigationLocation destination, string name, bool selected)
		{
			_destination = destination;			
			_name = name;
			_selected = selected;
		}
Example #15
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);
 }
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);
            }
        }
		/// <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)
		{

		}
Example #18
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)
 {
 }
		/// <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()));
		}
Example #20
0
 /// <summary>
 /// Initializes a new instance of the WizardNavigationPath class
 /// </summary>
 /// <param name="destination">A destination location to associate with this path</param>
 public WizardNavigationPath(WizardNavigationLocation destination, string name, bool selected)
 {
     _destination = destination;
     _name        = name;
     _selected    = selected;
 }
 /// <summary>
 /// Initializes a new instance of the WizardNavigationmap class
 /// </summary>
 /// <param name="startingLocation">The starting location for the navigation map</param>
 public WizardNavigationMap(WizardNavigationLocation start)
 {
     _start = start;
 }
		/// <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");
		}
Example #23
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;
			}
		}
 /// <summary>
 /// Adds a route from this location to the location defined by the specified path elements
 /// </summary>
 /// <param name="destination">The destination location</param>
 /// <param name="name">A key by which the route will be known</param>
 /// <param name="selected">A flag that indicates whether this route is the selected path</param>
 public void AddRoute(WizardNavigationLocation destination, string name, bool selected)
 {
     // add a new path to describe this route
     _paths.Add(new WizardNavigationPath(destination, name, selected));
 }