Пример #1
0
        /// <summary>
        /// The forward.
        /// </summary>
        private void Forward()
        {
            this.IsNavigatingForward = true;
            WizardItem newItem = this.GetItem(this.SelectedModel.Children.First());

            this.SetSelectedItemIfCanNavigate(newItem);
        }
Пример #2
0
        /// <summary>
        /// The back.
        /// </summary>
        private void Back()
        {
            this.IsNavigatingBackward = true;
            WizardItem newItem = this.GetItem(this.SelectedModel.Parent);

            this.SetSelectedItemIfCanNavigate(newItem);
        }
Пример #3
0
 /// <summary>
 /// Sets the selected item if the current instance can navigate to it.
 /// </summary>
 /// <param name="newItem">The new item.</param>
 private void SetSelectedItemIfCanNavigate(WizardItem newItem)
 {
     if (CanNavigate((WizardItem)this.SelectedItem, newItem))
     {
         this.SelectedItem = newItem;
     }
 }
Пример #4
0
        /// <summary>
        /// The on selected item changed.
        /// </summary>
        /// <param name="dependencyObject"> The dependency object. </param>
        /// <param name="e"> The event Arguments. </param>
        private static async void OnSelectedItemChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            Wizard     wizard  = (Wizard)dependencyObject;
            WizardItem oldItem = e.OldValue as WizardItem;
            WizardItem newItem = e.NewValue as WizardItem;

            await wizard.OnSelectedItemChanged(oldItem, newItem);
        }
Пример #5
0
        /// <summary>
        /// The on navigation ended.
        /// </summary>
        /// <param name="oldItem"> The old item. </param>
        /// <param name="newItem"> The new item. </param>
        protected virtual void OnNavigationEnded(WizardItem oldItem, WizardItem newItem)
        {
            if (newItem != null)
            {
                newItem.IsEntering = false;
            }

            this.IsNavigatingBackward     = false;
            this.IsNavigatingForward      = false;
            this.IsNavigatingHorizontally = false;
        }
Пример #6
0
        /// <summary>
        /// The on navigation started.
        /// </summary>
        /// <param name="oldItem"> The old item. </param>
        /// <param name="newItem"> The new item. </param>
        protected virtual void OnNavigationStarted(WizardItem oldItem, WizardItem newItem)
        {
            this.CrossfadeBackground(oldItem, newItem);

            if (oldItem != null)
            {
                oldItem.IsLeaving = true;
                if (oldItem.LeavingCommand != null)
                {
                    oldItem.LeavingCommand.Execute(oldItem.LeavingCommandParameter);
                }

                if ((oldItem.LeavingBranchCommand != null) &&
                    oldItem.Model.Children.All(x => !string.Equals(x.Id, newItem.Id, StringComparison.Ordinal)) &&
                    oldItem.Model.Children.SelectMany(x => x.Children).All(x => !string.Equals(x.Id, newItem.Id, StringComparison.Ordinal)))
                {
                    oldItem.LeavingBranchCommand.Execute(oldItem.LeavingBranchCommandParameter);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Called when the selected item is changed.
        /// </summary>
        /// <param name="oldItem">The old wizard item.</param>
        /// <param name="newItem">The new wizard item.</param>
        /// <returns>A task representing the operation.</returns>
        protected virtual async Task OnSelectedItemChanged(WizardItem oldItem, WizardItem newItem)
        {
            this.IsNavigating = true;

            this.OnNavigationStarted(oldItem, newItem);

            // Skip the exiting transition if there was no old item.
            if (oldItem != null)
            {
                await Task.Delay(this.TransitionDuration.TimeSpan);
            }

            this.OnNavigating(oldItem, newItem);

            await Task.Delay(this.TransitionDuration.TimeSpan);

            this.OnNavigationEnded(oldItem, newItem);

            this.IsNavigating = false;
        }
Пример #8
0
        /// <summary>
        /// Determines whether this instance can navigate the specified new item from the old item.
        /// </summary>
        /// <param name="oldItem">The old item.</param>
        /// <param name="newItem">The new item.</param>
        /// <returns><c>true</c> if the wizard can navigate to the new item. Otherwise <c>false</c>.</returns>
        private static bool CanNavigate(WizardItem oldItem, WizardItem newItem)
        {
            bool canNavigate = true;

            var children = oldItem.Model.Children.SelectMany(x => x.Children);
            var d        = children.All(x => !string.Equals(x.Id, newItem.Id));

            if ((oldItem != null) &&
                (oldItem.LeavingCommand != null) &&
                !oldItem.LeavingCommand.CanExecute(oldItem.LeavingCommandParameter))
            {
                canNavigate = false;
            }
            else if ((oldItem != null) &&
                     (oldItem.LeavingBranchCommand != null) &&
                     oldItem.Model.Children.All(x => !string.Equals(x.Id, newItem.Id, StringComparison.Ordinal)) &&
                     oldItem.Model.Children.SelectMany(x => x.Children).All(x => !string.Equals(x.Id, newItem.Id, StringComparison.Ordinal)) &&
                     !oldItem.LeavingBranchCommand.CanExecute(oldItem.LeavingBranchCommandParameter))
            {
                canNavigate = false;
            }
            else if ((newItem != null) &&
                     !newItem.IsVisited &&
                     (newItem.EnteringFirstTimeCommand != null) &&
                     !newItem.EnteringFirstTimeCommand.CanExecute(newItem.EnteringFirstTimeCommandParameter))
            {
                canNavigate = false;
            }
            else if ((newItem != null) &&
                     (newItem.EnteringCommand != null) &&
                     !newItem.EnteringCommand.CanExecute(newItem.EnteringCommandParameter))
            {
                canNavigate = false;
            }

            return(canNavigate);
        }
Пример #9
0
        /// <summary>
        /// The on wizard item parent changed.
        /// </summary>
        /// <param name="sender"> The sender. </param>
        /// <param name="e"> The event Arguments. </param>
        protected virtual void OnWizardItemParentChanged(object sender, RoutedEventArgs e)
        {
            WizardItem           wizardItem = (WizardItem)sender;
            WizardItemCollection items      = new WizardItemCollection(this.Items.OfType <WizardItem>());

            WizardItemModel model     = wizardItem.Model;
            WizardItemModel oldParent = wizardItem.Model.Parent;

            // Disconnect from old parent.
            if (oldParent != null)
            {
                oldParent.Children.Remove(model);
                model.Parent = null;
            }

            // Connect to new parent.
            if ((wizardItem.ParentId != null) && items.Contains(wizardItem.ParentId))
            {
                WizardItemModel newParent = items[wizardItem.ParentId].Model;

                newParent.Children.Add(model);
                model.Parent = newParent;
            }
        }
Пример #10
0
        /// <summary>
        /// The on navigating.
        /// </summary>
        /// <param name="oldItem"> The old item. </param>
        /// <param name="newItem"> The new item. </param>
        protected virtual void OnNavigating(WizardItem oldItem, WizardItem newItem)
        {
            if (oldItem != null)
            {
                oldItem.IsLeaving  = false;
                oldItem.IsSelected = false;
            }

            if (newItem != null)
            {
                newItem.IsEntering = true;

                if (!newItem.IsVisited && (newItem.EnteringFirstTimeCommand != null))
                {
                    newItem.EnteringFirstTimeCommand.Execute(newItem.EnteringFirstTimeCommandParameter);
                }

                if (newItem.EnteringCommand != null)
                {
                    newItem.EnteringCommand.Execute(newItem.EnteringCommandParameter);
                }

                newItem.IsSelected = true;

                this.DisplayItem = newItem;

                this.UpdateBreadcrumb();

                this.IsBackAllowed    = this.CanBackAllowed();
                this.IsForwardAllowed = this.CanForwardAllowed();

                this.BackCommand.RaiseCanExecuteChanged();
                this.ForwardCommand.RaiseCanExecuteChanged();
                this.SelectCommand.RaiseCanExecuteChanged();
            }
        }
Пример #11
0
        /// <summary>
        /// Gets a <see cref="WizardItemModel"/> from the specified object which can be a <see cref="WizardItemModel"/>, <see cref="WizardItem"/> or wizard item ID.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        /// <returns>The <see cref="WizardItemModel"/>.</returns>
        private WizardItemModel GetModel(object parameter)
        {
            WizardItemModel model = parameter as WizardItemModel;

            if (model == null)
            {
                WizardItem wizardItem = parameter as WizardItem;
                if (wizardItem != null)
                {
                    model = wizardItem.Model;
                }
            }

            if (model == null)
            {
                string wizardItemId = parameter as string;
                if (wizardItemId != null)
                {
                    model = this.models.FirstOrDefault(x => string.Equals(x.Id, wizardItemId, StringComparison.Ordinal));
                }
            }

            return(model);
        }
Пример #12
0
        /// <summary>
        /// The initial collection animation.
        /// </summary>
        /// <param name="itemsControl"> The items control. </param>
        private static void InitCollectionAnimation(ItemsControl itemsControl)
        {
            Wizard     wizard     = itemsControl.FindVisualParent <Wizard>();
            WizardItem wizardItem = itemsControl.FindVisualParent <WizardItem>();

            if ((wizard != null) && (wizardItem != null))
            {
                WizardCollectionAnimation animation = (WizardCollectionAnimation)Enum.Parse(
                    typeof(WizardCollectionAnimation),
                    GetCollectionAnimation(itemsControl).ToString());

                BehaviorCollection            behaviors = Interaction.GetBehaviors(itemsControl);
                AnimatingItemsControlBehavior behavior  = behaviors.OfType <AnimatingItemsControlBehavior>().FirstOrDefault();

                if (behavior == null)
                {
                    behavior = new AnimatingItemsControlBehavior()
                    {
                        Duration = wizard.TransitionDuration.TimeSpan,
                        IsRandom = animation == WizardCollectionAnimation.Random
                    };
                    behaviors.Add(behavior);
                }

                wizardItem.Entering +=
                    (sender, e2) =>
                {
                    behavior.AnimateIn();
                };
                wizardItem.Leaving +=
                    (sender, e2) =>
                {
                    behavior.AnimateOut();
                };
            }
        }
Пример #13
0
        /// <summary>
        /// The select.
        /// </summary>
        /// <param name="parameter"> The parameter. </param>
        private void Select(object parameter)
        {
            WizardItemModel model = this.GetModel(parameter);

            if (model != null)
            {
                if (this.DisplayItem != null)
                {
                    WizardItemModel displayModel = this.DisplayItem.Model;
                    if (displayModel != null)
                    {
                        if (this.Breadcrumb.Contains(model))
                        {
                            // Going back through the breadcrumb.
                            this.IsNavigatingBackward = true;
                        }
                        else if (this.Breadcrumb
                                 .Traverse(x => x.Children)
                                 .Where(x => x != this.Breadcrumb.Last() && !this.Breadcrumb.Last().Children.Traverse(y => y.Children).Contains(x))
                                 .Any(x => x.Equals(model)))
                        {
                            // Going sideways through the breadcrumb.
                            this.IsNavigatingHorizontally = true;
                        }
                        else
                        {
                            // Go forward with the breadcrumb.
                            this.IsNavigatingForward = true;
                        }
                    }
                }

                WizardItem newItem = this.GetItem(model);
                this.SetSelectedItemIfCanNavigate(newItem);
            }
        }
Пример #14
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ModeComboBox = ((System.Windows.Controls.ComboBox)(target));
                return;

            case 2:

            #line 93 "..\..\..\Views\WizardView.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnSkipManagersWizardItemClick);

            #line default
            #line hidden
                return;

            case 3:

            #line 99 "..\..\..\Views\WizardView.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnUnskipManagersWizardItemClick);

            #line default
            #line hidden
                return;

            case 4:

            #line 106 "..\..\..\Views\WizardView.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnAddWizardItemClick);

            #line default
            #line hidden
                return;

            case 5:

            #line 112 "..\..\..\Views\WizardView.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnRemoveWizardItemClick);

            #line default
            #line hidden
                return;

            case 6:

            #line 119 "..\..\..\Views\WizardView.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnCollapseWizardItemClick);

            #line default
            #line hidden
                return;

            case 7:

            #line 125 "..\..\..\Views\WizardView.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnUnCollapseWizardItemClick);

            #line default
            #line hidden
                return;

            case 8:
                this.Wizard = ((Framework.UI.Controls.Wizard)(target));
                return;

            case 9:
                this.ManagersWizardItem = ((Framework.UI.Controls.WizardItem)(target));
                return;

            case 10:
                this.SimonSmithWizardItem = ((Framework.UI.Controls.WizardItem)(target));
                return;
            }
            this._contentLoaded = true;
        }
Пример #15
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.ModeComboBox = ((System.Windows.Controls.ComboBox)(target));
     return;
     case 2:
     
     #line 93 "..\..\..\Views\WizardView.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnSkipManagersWizardItemClick);
     
     #line default
     #line hidden
     return;
     case 3:
     
     #line 99 "..\..\..\Views\WizardView.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnUnskipManagersWizardItemClick);
     
     #line default
     #line hidden
     return;
     case 4:
     
     #line 106 "..\..\..\Views\WizardView.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnAddWizardItemClick);
     
     #line default
     #line hidden
     return;
     case 5:
     
     #line 112 "..\..\..\Views\WizardView.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnRemoveWizardItemClick);
     
     #line default
     #line hidden
     return;
     case 6:
     
     #line 119 "..\..\..\Views\WizardView.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnCollapseWizardItemClick);
     
     #line default
     #line hidden
     return;
     case 7:
     
     #line 125 "..\..\..\Views\WizardView.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.OnUnCollapseWizardItemClick);
     
     #line default
     #line hidden
     return;
     case 8:
     this.Wizard = ((Framework.UI.Controls.Wizard)(target));
     return;
     case 9:
     this.ManagersWizardItem = ((Framework.UI.Controls.WizardItem)(target));
     return;
     case 10:
     this.SimonSmithWizardItem = ((Framework.UI.Controls.WizardItem)(target));
     return;
     }
     this._contentLoaded = true;
 }
Пример #16
0
        /// <summary>
        /// The cross fade background.
        /// </summary>
        /// <param name="previousItem"> The previous item. </param>
        /// <param name="currentItem"> The current item. </param>
        private void CrossfadeBackground(WizardItem previousItem, WizardItem currentItem)
        {
            if ((this.previousItemBorder != null) &&
                (previousItem != currentItem))
            {
                if (this.backgroundStoryboard != null)
                {
                    this.backgroundStoryboard.Stop();
                }

                if (previousItem != null)
                {
                    this.previousItemBorder.Background      = previousItem.Background;
                    this.previousItemBorder.BorderBrush     = previousItem.BorderBrush;
                    this.previousItemBorder.BorderThickness = previousItem.BorderThickness;
                }
                else
                {
                    this.previousItemBorder.Background      = null;
                    this.previousItemBorder.BorderBrush     = null;
                    this.previousItemBorder.BorderThickness = new Thickness();
                }

                if (currentItem != null)
                {
                    this.currentItemBorder.Background      = currentItem.Background;
                    this.currentItemBorder.BorderBrush     = currentItem.BorderBrush;
                    this.currentItemBorder.BorderThickness = currentItem.BorderThickness;
                }
                else
                {
                    this.currentItemBorder.Background      = null;
                    this.currentItemBorder.BorderBrush     = null;
                    this.currentItemBorder.BorderThickness = new Thickness();
                }

                if (this.backgroundStoryboard == null)
                {
                    this.backgroundStoryboard = new Storyboard()
                    {
                        Duration = this.TransitionDuration + this.TransitionDuration
                    };

                    DoubleAnimation previousDoubleAnimation = new DoubleAnimation()
                    {
                        From = 1,
                        To   = 0
                    };
                    Storyboard.SetTarget(previousDoubleAnimation, this.previousItemBorder);
                    Storyboard.SetTargetProperty(previousDoubleAnimation, new PropertyPath("Opacity"));
                    this.backgroundStoryboard.Children.Add(previousDoubleAnimation);

                    DoubleAnimation currentDoubleAnimation = new DoubleAnimation()
                    {
                        From = 0,
                        To   = 1
                    };
                    Storyboard.SetTarget(currentDoubleAnimation, this.currentItemBorder);
                    Storyboard.SetTargetProperty(currentDoubleAnimation, new PropertyPath("Opacity"));
                    this.backgroundStoryboard.Children.Add(currentDoubleAnimation);
                }

                this.backgroundStoryboard.Begin();
            }
        }
Пример #17
0
        /// <summary>
        /// The initial animation.
        /// </summary>
        /// <param name="frameworkElement"> The framework element. </param>
        private static void InitAnimation(FrameworkElement frameworkElement)
        {
            Wizard     wizard     = frameworkElement.FindVisualParent <Wizard>();
            WizardItem wizardItem = frameworkElement.FindVisualParent <WizardItem>();

            if ((wizard != null) && (wizardItem != null))
            {
                WizardAnimation animation = (WizardAnimation)Enum.Parse(
                    typeof(WizardAnimation),
                    GetAnimation(frameworkElement).ToString());

                BehaviorCollection behaviors = Interaction.GetBehaviors(frameworkElement);

                FadeBehavior fadeBehavior = null;
                if ((animation == WizardAnimation.Fade) || (animation == WizardAnimation.FadeAndSlide))
                {
                    fadeBehavior = behaviors.OfType <FadeBehavior>().FirstOrDefault();
                    if (fadeBehavior == null)
                    {
                        fadeBehavior = new FadeBehavior()
                        {
                            Duration = wizard.TransitionDuration.TimeSpan,
                        };
                        behaviors.Add(fadeBehavior);
                    }
                }

                SlideBehavior slideBehavior = null;
                if ((animation == WizardAnimation.Slide) || (animation == WizardAnimation.FadeAndSlide))
                {
                    slideBehavior = behaviors.OfType <SlideBehavior>().FirstOrDefault();
                    if (slideBehavior == null)
                    {
                        slideBehavior = new SlideBehavior()
                        {
                            Duration = wizard.TransitionDuration.TimeSpan,
                        };
                        behaviors.Add(slideBehavior);
                    }
                }

                wizardItem.Entering +=
                    (sender, e2) =>
                {
                    if (fadeBehavior != null)
                    {
                        fadeBehavior.FadeIn();
                    }

                    if (slideBehavior != null)
                    {
                        slideBehavior.SlideIn();
                    }
                };
                wizardItem.Leaving +=
                    (sender, e2) =>
                {
                    if (fadeBehavior != null)
                    {
                        fadeBehavior.FadeOut();
                    }

                    if (slideBehavior != null)
                    {
                        slideBehavior.SlideOut();
                    }
                };
            }
        }