public void matches_by_key_alone()
        {
            var key = new NavigationKey("something");

            var matcher = new ByName("something");
            matcher.Matches(key).ShouldBeTrue();
        }
        public void negative_test_by_key_alone()
        {
            var key = new NavigationKey("something");

            var matcher = new ByName("else");
            matcher.Matches(key).ShouldBeFalse();
        }
Example #3
0
        public void format_description()
        {
            var key = new NavigationKey("something");

            new AddChild().FormatDescription("parent", key)
            .ShouldEqual("Add '{0}' to menu 'parent'".ToFormat(key.ToLocalizationKey()));
        }
Example #4
0
        public void format_description()
        {
            var key = new NavigationKey("something");

            new AddBefore().FormatDescription("parent", key)
            .ShouldEqual("Insert '{0}' before 'parent'".ToFormat(key.ToLocalizationKey()));
        }
        public void negative_test_by_localization_key()
        {
            var key = new NavigationKey("something");

            var matcher = new ByName("OtherKey:something");

            matcher.Matches(key).ShouldBeFalse();
        }
Example #6
0
        public void matches_by_localizer_key()
        {
            var key = new NavigationKey("something");

            var matcher = new ByName("NavigationKey:something");

            matcher.Matches(key).ShouldBeTrue();
        }
Example #7
0
        public void negative_test_by_localization_key()
        {
            var key = new NavigationKey("something");

            var matcher = new ByName("OtherKey:something");

            matcher.Matches(key).ShouldBeFalse();
        }
Example #8
0
        public void depends_on_negative()
        {
            var token = new NavigationKey("something");

            MockFor <IStringTokenMatcher>().Stub(x => x.Matches(token)).Return(false);

            ClassUnderTest.DependsOn(token).ShouldBeFalse();
        }
Example #9
0
        public void negative_test_by_key_alone()
        {
            var key = new NavigationKey("something");

            var matcher = new ByName("else");

            matcher.Matches(key).ShouldBeFalse();
        }
Example #10
0
        public ModalResult <TResult> ShowModal <TResult>(string navigationKey, object viewModel)
        {
            NavigationKey.EnsuresNavigationKeyHasParent(navigationKey);

            var viewInfo         = NavigateToInternal(navigationKey, viewModel, true, false);
            var modalHostControl = (ModalHostControl)viewInfo.ViewHostInstance.View;

            return(new ModalResult <TResult>(modalHostControl.ResultCompletionSource.Task, viewInfo));
        }
 public void RemoveParameter(NavigationKey navigationKey)
 {
     try
     {
         NavigationData.Remove(navigationKey);
     }
     catch (Exception)
     {
     }
 }
Example #12
0
        protected NavigationItemViewModel(string title, NavigationKey navigationKey)
        {
            Title         = title;
            NavigationKey = navigationKey;
#if (WPF)
            ViewInjectionManager.Default.RegisterNavigatedEventHandler(this, () =>
            {
                ViewInjectionManager.Default.Navigate(Regions.Content, this.NavigationKey);
            });
#endif
        }
 /// <summary>
 /// Retrieves the data that was sent to the view model casted to the required type. If nothing was sent or the type requested is wrong, a default value will be provided
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key"></param>
 /// <returns></returns>
 public T GetParameter <T>(NavigationKey key)
 {
     try
     {
         return((T)NavigationData[key]);
     }
     catch (Exception)
     {
         return(default(T));
     }
 }
Example #14
0
        public void matches_negative()
        {
            var key = new NavigationKey("something");

            new Literal(new NavigationKey("else")).Matches(key).ShouldBeFalse();
        }
Example #15
0
        public void matches_positive()
        {
            var key = new NavigationKey("something");

            new Literal(key).Matches(key).ShouldBeTrue();
        }
 /// <summary>
 /// Sets the navigation data. If you need to communicate with a view model without navigating to it, use IEventAggregator
 /// </summary>
 /// <param name="key">The key which identifies the data</param>
 /// <param name="data">The data to be sent</param>
 public void SetNavigationData(NavigationKey key, object data)
 {
     NavigationData[key] = data;
 }
Example #17
0
 public static NavigationItemViewModel Create(string title, NavigationKey navigationKey)
 {
     return(ViewModelSource.Create(() => new NavigationItemViewModel(title, navigationKey)));
 }
 public void format_description()
 {
     var key = new NavigationKey("something");
     new AddChild().FormatDescription("parent", key)
         .ShouldEqual("Add '{0}' to menu 'parent'".ToFormat(key.ToLocalizationKey()));
 }
        public void matches_positive()
        {
            var key = new NavigationKey("something");

            new Literal(key).Matches(key).ShouldBeTrue();
        }
 public void default_key()
 {
     var key = new NavigationKey("something");
     new Literal(key).DefaultKey().ShouldBeTheSameAs(key);
 }
 public void matches_negative()
 {
     var key = new NavigationKey("something");
     new Literal(new NavigationKey("else")).Matches(key).ShouldBeFalse();
 }
Example #22
0
        public void default_key()
        {
            var key = new NavigationKey("something");

            new Literal(key).DefaultKey().ShouldBeTheSameAs(key);
        }
Example #23
0
        private View NavigateToInternal(string navigationKey, object viewModel, bool isModal, bool isMessageBox)
        {
            var performAnimation      = true;
            var navigationKeyInstance = NavigationKey.Parse(navigationKey);
            var parentViewInstanceKey = navigationKeyInstance.ParentViewInstanceKey;
            var viewInstanceKey       = navigationKeyInstance.ViewInstanceKey;
            var viewKey   = navigationKeyInstance.ViewKey;
            var hasParent = navigationKeyInstance.HasParent;
            var oldNode   = _viewGroupCollectionManager.GetActiveNode();

            ViewGroupNode newNode;

            // if the navigation key refers to a parent e.g : "parentView/view"

            if (hasParent)
            {
                if (_viewGroupCollectionManager.TryFindViewNode(viewInstanceKey, out newNode))
                {
                    // activates an existing node
                    EnsuresViewHasParentAndMatch(newNode, parentViewInstanceKey);
                    _viewGroupCollectionManager.ActivateExistingNode(newNode);

                    // if the node already exists and the old and new nodes belong to the same group, do not animate
                    performAnimation = oldNode.List != newNode.List;
                }
                else
                {
                    // activates a new node
                    EnsureParentViewExist(parentViewInstanceKey);
                    EnsureParentViewIsTopMost(parentViewInstanceKey);

                    newNode = CreateNewNodeFrom(viewInstanceKey, viewKey, viewModel, isModal, isMessageBox);

                    var parentNode = _viewGroupCollectionManager.FindViewNode(parentViewInstanceKey);
                    _viewGroupCollectionManager.ActivateNewNode(newNode, parentNode.List);
                }

                // perform asynchronous update of the UI
                if (performAnimation)
                {
                    _taskInvoker.Enqueue(
                        new Func <ViewGroupNode, ViewGroupNode, Task>(_workspaceAdapter.PerformUIActivation), oldNode,
                        newNode);
                }

                return(newNode.Value);
            }

            // if the navigation key has a simple form e.g : "view"

            if (_viewGroupCollectionManager.TryFindViewNode(viewInstanceKey, out newNode))
            {
                // activates an existing node
                newNode = _viewGroupCollectionManager.IsTopMostView(viewInstanceKey) ? newNode : newNode.List.Peek();
                _viewGroupCollectionManager.ActivateExistingNode(newNode);

                // if the node already exists and the old and new nodes belong to the same group, do not animate
                performAnimation = oldNode.List != newNode.List;
            }
            else
            {
                // activates a new node
                newNode = CreateNewNodeFrom(viewInstanceKey, viewKey, viewModel, isModal, isMessageBox);
                _viewGroupCollectionManager.ActivateNewNode(newNode);
            }

            // perform asynchronous update of the UI
            if (performAnimation)
            {
                _taskInvoker.Enqueue(
                    new Func <ViewGroupNode, ViewGroupNode, Task>(_workspaceAdapter.PerformUIActivation), oldNode,
                    newNode);
            }

            return(newNode.Value);
        }
 public void format_description()
 {
     var key = new NavigationKey("something");
     new AddAfter().FormatDescription("parent", key)
         .ShouldEqual("Insert '{0}' after 'parent'".ToFormat(key.ToLocalizationKey()));
 }