Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            this.Navigation = NavigationManager.GetNavigationSources("Main")[0];
            NavigateToHome();
        }
        public void Navigate_To_Last()
        {
            var navigationSource = new NavigationSource();
            var commands         = new NavigationSourceCommands(navigationSource);

            MyNavViewModelA.Reset();
            MyNavViewModelB.Reset();
            MyNavViewModelC.Reset();

            commands.NavigateCommand.Execute(typeof(MyNavViewModelA));
            commands.NavigateCommand.Execute(typeof(MyNavViewModelB));
            commands.NavigateCommand.Execute(typeof(MyNavViewModelC));
            commands.MoveToPreviousCommand.Execute(null);
            commands.MoveToPreviousCommand.Execute(null);

            MyNavViewModelA.Reset();
            MyNavViewModelB.Reset();
            MyNavViewModelC.Reset();

            Assert.AreEqual(false, commands.MoveToFirstCommand.CanExecute(null));
            Assert.AreEqual(false, commands.MoveToPreviousCommand.CanExecute(null));
            Assert.AreEqual(true, commands.MoveToNextCommand.CanExecute(null));
            Assert.AreEqual(true, commands.MoveToLastCommand.CanExecute(null));
            commands.MoveToLastCommand.Execute(null);
            Assert.AreEqual(true, MyNavViewModelA.IsOnNavigatingFromInvoked);
            Assert.AreEqual(true, MyNavViewModelC.IsOnNavigatedToInvoked);
            Assert.AreEqual(true, commands.MoveToFirstCommand.CanExecute(null));
            Assert.AreEqual(true, commands.MoveToPreviousCommand.CanExecute(null));
            Assert.AreEqual(false, commands.MoveToNextCommand.CanExecute(null));
            Assert.AreEqual(false, commands.MoveToLastCommand.CanExecute(null));
        }
Exemplo n.º 3
0
 private void NavigateToExecute(NavigationSource page)
 {
     if (this.CurrentPage != page)
     {
         this.NavigationProvider.Navigate(page);
         this.CurrentPage = page;
     }
 }
Exemplo n.º 4
0
        public ShellViewModel()
        {
            // 1. With <ContentControl Content="{Binding Navigation.Current}" />
            this.Navigation = NavigationManager.GetOrCreateDefaultNavigationSource("Main");

            // 2 ... or with <ContentControl mvvmLib:NavigationManager.SourceName="Main"/>
            //this.Navigation = NavigationManager.GetNavigationSources("Main")[0];

            this.NavigateToHome();
        }
Exemplo n.º 5
0
        public Window3()
        {
            InitializeComponent();

            var from = NavigationManager.GetNavigationSources("MultipleSubscribersSample")[0];

            var to = new NavigationSource();

            to.Sync(from);
            ListView1.ItemsSource  = to.Sources;
            ListView1.SelectedItem = to.Current;
            //var collectionSync = new CollectionSync(from, to);
        }
Exemplo n.º 6
0
        public App(NavigationSource navigationSource = NavigationSource.Normal)
        {
            Current = this;
            InitializeComponent();

            // Create Authentication Service
            AuthenticationService = new AuthenticationService(AuthenticationSettings.Tenant, AuthenticationSettings.ClientID, AuthenticationSettings.AuthorityPolicy);
            // Add Policies to Authentication Service
            AuthenticationService.AddNamedPolicy(nameof(AuthenticationSettings.PolicySignUpSignIn), AuthenticationSettings.PolicySignUpSignIn);
            //AuthenticationService.AddNamedPolicy(nameof(AuthenticationSettings.PolicyEditProfile), AuthenticationSettings.PolicyEditProfile);
            //AuthenticationService.AddNamedPolicy(nameof(AuthenticationSettings.PolicyResetPassword), AuthenticationSettings.PolicyResetPassword);
            // Add scopes
            AuthenticationService.AddNamedScope(nameof(AuthenticationSettings.ReadScope), AuthenticationSettings.ReadScope);
            AuthenticationService.AddNamedScope(nameof(AuthenticationSettings.WriteScope), AuthenticationSettings.WriteScope);


            MainPage = new SplashScreen(navigationSource);
        }
Exemplo n.º 7
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (MemberData != null)
                {
                    MemberData.Dispose();
                    MemberData = null;
                }

                if (CellId != null)
                {
                    CellId.Dispose();
                }

                if (NavigationView != null)
                {
                    var disposable = NavigationView as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                        NavigationView = null;
                    }
                }

                if (NavigationSource != null)
                {
                    NavigationSource.Dispose();
                    NavigationSource = null;
                }

                //TODO: Should this be disposed here??
                foreach (var section in Sections.Values)
                {
                    var disposable = section.DataContext as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }

            base.Dispose(disposing);
        }
        public void Commands_With_Views_To_Last()
        {
            var navigationSourceContainer = new NavigationSourceContainer();
            var n1 = new NavigationSource();
            var n2 = new NavigationSource();

            navigationSourceContainer.Register(n1);
            navigationSourceContainer.Register(n2);
            var commands = new NavigationSourceContainerCommands(navigationSourceContainer);

            MyNavViewA.Reset();
            MyNavViewB.Reset();
            MyNavViewC.Reset();
            MyNavViewModelA.Reset();
            MyNavViewModelB.Reset();
            MyNavViewModelC.Reset();

            Assert.AreEqual(0, n1.Sources.Count);
            Assert.AreEqual(0, n2.Sources.Count);
            Assert.AreEqual(-1, n1.CurrentIndex);
            Assert.AreEqual(-1, n2.CurrentIndex);

            commands.NavigateCommand.Execute(typeof(MyNavViewA)); // navigate
            commands.NavigateCommand.Execute(typeof(MyNavViewB));
            commands.NavigateCommand.Execute(typeof(MyNavViewC));
            commands.MoveToPreviousCommand.Execute(null); // previous
            commands.MoveToPreviousCommand.Execute(null); // previous // A

            MyNavViewA.Reset();
            MyNavViewB.Reset();
            MyNavViewC.Reset();
            MyNavViewModelA.Reset();
            MyNavViewModelB.Reset();
            MyNavViewModelC.Reset();

            commands.MoveToLastCommand.Execute(null); // next
            Assert.AreEqual(true, MyNavViewC.IsCanActivateInvoked);
            Assert.AreEqual(typeof(MyNavViewC), n1.Current.GetType());
            Assert.AreEqual(typeof(MyNavViewC), n2.Current.GetType());
        }
Exemplo n.º 9
0
        /// <inheritdoc/>
        protected override void SetBasicInfo(OpenApiOperation operation)
        {
            // Summary
            operation.Summary = "Invoke " + (EdmOperation.IsAction() ? "action " : "function ") + EdmOperation.Name;

            // OperationId
            if (Context.Settings.EnableOperationId)
            {
                StringBuilder operationId = new StringBuilder(NavigationSource.Name);
                if (HasTypeCast)
                {
                    ODataTypeCastSegment typeCast = Path.Segments.FirstOrDefault(s => s is ODataTypeCastSegment) as ODataTypeCastSegment;
                    operationId.Append(".");
                    operationId.Append(typeCast.EntityType.Name);
                }
                else
                {
                    operationId.Append(".");
                    operationId.Append(NavigationSource.EntityType().Name);
                }

                operationId.Append(".");
                operationId.Append(EdmOperation.Name);
                if (EdmOperation.IsAction())
                {
                    operation.OperationId = operationId.ToString();
                }
                else
                {
                    ODataOperationSegment operationSegment = Path.LastSegment as ODataOperationSegment;
                    string pathItemName = operationSegment.GetPathItemName(Context.Settings);
                    string md5          = pathItemName.GetHashMd5();
                    operation.OperationId = operationId.Append(".").Append(md5.Substring(8)).ToString();
                }
            }

            base.SetBasicInfo(operation);
        }
Exemplo n.º 10
0
        public HomeView()
        {
            InitializeComponent();

            this.Navigation = NavigationManager.GetNavigationSources("Main")[0];
        }
        /// <summary>
        /// Uses states machine to determine how to navigate
        /// </summary>
        /// <param name="currentPageName"></param>
        /// <param name="navigationTrigger"></param>
        /// <param name="navigationSource"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>

        public static async Task Navigate(INavigation navigation, string currentPageOrViewModelName, string navigationTrigger, NavigationSource navigationSource = NavigationSource.Normal, Dictionary <string, string> parameters = null)
        {
            if (navigationSource == NavigationSource.FromNotification)
            {
                // Navigation from a Notification
                await Navigate(navigation, NotificationNavigationStateMachine, currentPageOrViewModelName, navigationTrigger, parameters);
            }
            else
            {
                // Normal in app navigation
                await Navigate(navigation, StandardNavigationStateMachine, currentPageOrViewModelName, navigationTrigger, parameters);
            }
        }
Exemplo n.º 12
0
 public ViewEViewModel()
 {
     this.Navigation = NavigationManager.GetDefaultNavigationSource("HistorySample");
 }
Exemplo n.º 13
0
        public SplashScreen(NavigationSource navigationSource)
        {
            InitializeComponent();

            this.BindingContext = new SplashScreenViewModel(navigationSource);
        }
 public SplashScreenViewModel(NavigationSource navigationSource)
 {
     PageAppearing    = new Command(async() => await OnPageAppearing());
     ButtonClicked    = new Command <string>(async(s) => await OnButtonClicked(s));
     NavigationSource = navigationSource;
 }