Exemplo n.º 1
0
 /// <summary>
 ///     Makes the clicked item active, if this is allowed
 /// </summary>
 /// <param name="wizardScreen"></param>
 public void JumpTo(IWizardScreen wizardScreen)
 {
     if (wizardScreen.IsEnabled && wizardScreen.IsVisible && !wizardScreen.IsActive)
     {
         Wizard.CurrentWizardScreen = wizardScreen;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Initialize this with the information in the IWizard
        /// </summary>
        /// <param name="wizard">IWizard</param>
        private void Initialize(IWizard wizard)
        {
            Wizard = wizard;
            if (Wizard.WizardScreens == null)
            {
                throw new ArgumentNullException(nameof(wizard.WizardScreens));
            }

            // Make sure the view is created via the dispatcher
            Application.Current.Dispatcher.Invoke(() =>
            {
                WizardScreensView        = CollectionViewSource.GetDefaultView(wizard.WizardScreens);
                WizardScreensView.Filter = o =>
                {
                    IWizardScreen wizardScreen = o as IWizardScreen;
                    return(wizardScreen?.IsVisible == true);
                };
            });
        }
Exemplo n.º 3
0
        private void AddScreen(IWizardScreen screen)
        {
            _pages.Add(screen);
            StackPanel stackPanel = new StackPanel();

            string[] title = screen.Title;
            foreach (string text in title)
            {
                stackPanel.Children.Add(new TextBlock
                {
                    Text = text,
                    HorizontalAlignment = System.Windows.HorizontalAlignment.Center
                });
            }
            System.Windows.Controls.Button element = new System.Windows.Controls.Button
            {
                Content = stackPanel,
                Style   = (FindResource("WizardStepStyle") as Style)
            };
            Steps.Children.Add(element);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Displays a given screen in the content area of the wizard
        /// </summary>
        /// <param name="screenType">WizardScreenType enum of screen to be displayed</param>
        private void LoadScreen(WizardScreenType screenType)
        {
            // Do not proceed if there was a validation failiure in current screen
            if (!activeWizardScreens[currentScreen].ValidateScreen())
            {
                return;
            }

            // Check if specified screen type is present
            if (!activeWizardScreens.ContainsKey(screenType))
            {
                throw new InvalidOperationException("Specified wizard screen was not found!");
            }

            // Clear existing content
            wizardScreenPanel.Controls.Clear();
            IWizardScreen screenToLoad = activeWizardScreens[screenType];

            wizardScreenPanel.Controls.Add(screenToLoad as UserControl);
            wizardScreenPanel.Controls[0].Dock = DockStyle.Fill;

            // Set the headings
            mainHeader.Text = screenToLoad.MainHeader;
            subHeader.Text  = screenToLoad.SubHeader;

            // If showing the last screen, disable next and activate finish.
            if ((int)screenType == activeWizardScreens.Count - 1)
            {
                navigateNext.Enabled   = false;
                navigateFinish.Enabled = true;
            }
            else
            {
                navigateNext.Enabled   = true;
                navigateFinish.Enabled = false;
            }

            // Enable back button only if its not the first screen being displayed now
            navigatePrevious.Enabled = ((int)screenType != 0);
        }
        public IWizardScreen GetNextScreen(IWizardScreen screenThatClosed)
        {
            var identity   = screenThatClosed.GetType();
            var state      = screenThatClosed.State;
            var transition = screenThatClosed.NextScreenType;

            if (!ContainsKey(identity))
            {
                throw new InvalidOperationException(String.Format("There are no states transitions defined for state {0}", identity));
            }

            if (!this[identity].ContainsKey(transition))
            {
                throw new InvalidOperationException(String.Format("There is no response setup for transition {0} from screen {1}", transition, identity));
            }

            if (this[identity][transition] == null)
            {
                return(null);
            }

            return((IWizardScreen)this[identity][transition].DynamicInvoke(state));
        }