Пример #1
0
        /// <summary>
        /// Initialises a new instance of the <see cref="WizardView"/> class.
        /// </summary>
        public WizardView()
        {
            InitializeComponent();
            this.wizardItem = new WizardItem()
            {
                Content         = "My View Model Bound Here",
                ContentTemplate = null,
                Background      = (ImageBrush)this.Resources["AbstractImageBrush"],
                Description     = "Managers Description",
                Icon            = new BitmapImage(new Uri(@"\Framework.UI.TestHarness;component\Assets\Background1.jpg", UriKind.RelativeOrAbsolute)),
                Id       = "NewManager",
                ParentId = "Managers",
                Title    = "New Manager"
            };

            this.DataContext = new WizardViewModel();
        }
Пример #2
0
        /// <summary>
        /// Initialises a new instance of the <see cref="WizardView"/> class.
        /// </summary>
        public WizardView()
        {
            InitializeComponent();
            this.wizardItem = new WizardItem()
            {
                Content         = "My View Model Bound Here",
                ContentTemplate = null,
                Background      = (ImageBrush)this.Resources["AbstractImageBrush"],
                Description     = "Managers Description",
                Icon            = this.FindResource("User1Geometry"),
                Id       = "NewManager",
                ParentId = "Managers",
                Title    = "New Manager"
            };

            this.DataContext = new WizardViewModel();
        }
Пример #3
0
        /// <summary>
        /// Initialises a new instance of the <see cref="WizardView"/> class.
        /// </summary>
        public WizardView()
        {
            InitializeComponent();
            this.wizardItem = new WizardItem()
            {
                Content = "My View Model Bound Here",
                ContentTemplate = null,
                Background = (ImageBrush)this.Resources["AbstractImageBrush"],
                Description = "Managers Description",
                Icon = this.FindResource("User1Geometry"),
                Id = "NewManager",
                ParentId = "Managers",
                Title = "New Manager"
            };

            this.DataContext = new WizardViewModel();
        }
Пример #4
0
        /// <summary>
        /// Initialises a new instance of the <see cref="WizardView"/> class.
        /// </summary>
        public WizardView()
        {
            InitializeComponent();
            this.wizardItem = new WizardItem()
            {
                Content = "My View Model Bound Here",
                ContentTemplate = null,
                Background = (ImageBrush)this.Resources["AbstractImageBrush"],
                Description = "Managers Description",
                Icon = new BitmapImage(new Uri(@"\Framework.UI.TestHarness;component\Assets\Background1.jpg", UriKind.RelativeOrAbsolute)),
                Id = "NewManager",
                ParentId = "Managers",
                Title = "New Manager"
            };

            this.DataContext = new WizardViewModel();
        }
Пример #5
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;
        }
Пример #6
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;
        }
Пример #7
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;
        }
Пример #8
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();
            }
        }
Пример #9
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);
                }
            }
        }
Пример #10
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();
            }
        }
Пример #11
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;
     }
 }
Пример #12
0
        private void AddUserWizard(User user)
        {
            var stackpanel   = new StackPanel();
            var itemsControl = new ItemsControl();

            stackpanel.Children.Add(new TextBlock {
                Text = user.userInfo.SurName + " " + user.userInfo.Name, FontSize = 16, FontWeight = FontWeights.SemiBold
            });
            stackpanel.Children.Add(new Separator());

            var itemStackPanel = new StackPanel {
                Orientation = Orientation.Horizontal
            };

            itemStackPanel.Children.Add(new TextBlock {
                Text = "Логин:    ", FontWeight = FontWeights.SemiBold, Width = 100
            });
            itemStackPanel.Children.Add(new TextBlock {
                Name = "Login", Text = user.login
            });
            itemsControl.Items.Add(itemStackPanel);
            itemStackPanel = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            itemStackPanel.Children.Add(new TextBlock {
                Text = "E-mail:    ", FontWeight = FontWeights.SemiBold, Width = 100
            });
            itemStackPanel.Children.Add(new TextBlock {
                Text = user.userInfo.Email
            });
            itemsControl.Items.Add(itemStackPanel);
            itemStackPanel = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            itemStackPanel.Children.Add(new TextBlock {
                Text = "Тип:    ", FontWeight = FontWeights.SemiBold, Width = 100
            });
            itemStackPanel.Children.Add(new TextBlock {
                Text = user.userInfo.UserType
            });
            itemsControl.Items.Add(itemStackPanel);
            itemStackPanel = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            itemStackPanel.Children.Add(new TextBlock {
                Text = "Дата рождения:    ", FontWeight = FontWeights.SemiBold, Width = 100
            });
            itemStackPanel.Children.Add(new TextBlock {
                Text = user.userInfo.Date
            });
            itemsControl.Items.Add(itemStackPanel);
            stackpanel.Children.Add(itemsControl);
            var button = new Button {
                Content = "Удалить", Width = 200, Height = 30, HorizontalAlignment = HorizontalAlignment.Right
            };

            button.Click += DeleteUser;
            stackpanel.Children.Add(button);
            var item = new WizardItem
            {
                Content         = stackpanel,
                ContentTemplate = null,
                Description     = "Дата рождения " + user.userInfo.Date,
                Icon            = this.FindResource("User1Geometry"),
                Id       = user.login,
                ParentId = user.userInfo.UserType,
                Title    = user.userInfo.SurName + " " + user.userInfo.Name
            };

            this.Wizard.Items.Add(item);
        }