Exemplo n.º 1
0
        internal WindowWrapper(Window window)
        {
            Window     = window;
            Dispatcher = new DispatcherWrapper(window.Dispatcher);
            window.CoreWindow.Closed += (s, e) => WindowWrapperManager.Instances.Remove(this);
            window.Closed            += (s, e) => WindowWrapperManager.Instances.Remove(this);
            window.Activate();

            IsMainView = CoreApplication.MainView == CoreApplication.GetCurrentView();

            _DisplayInformation = new Lazy <DisplayInformation>(() =>
            {
                Window.Activate();
                return(Dispatcher.Dispatch(() => DisplayInformation.GetForCurrentView()));
            });
            _ApplicationView = new Lazy <ApplicationView>(() =>
            {
                Window.Activate();
                return(Dispatcher.Dispatch(() => ApplicationView.GetForCurrentView()));
            });
            _UIViewSettings = new Lazy <UIViewSettings>(() =>
            {
                Window.Activate();
                return(Dispatcher.Dispatch(() => UIViewSettings.GetForCurrentView()));
            });
        }
Exemplo n.º 2
0
        public async Task<ViewLifetimeControl> OpenAsync(Type page, object parameter = null, string title = null,
            ViewSizePreference size = ViewSizePreference.UseHalf)
        {
            WriteLine($"Page: {page}, Parameter: {parameter}, Title: {title}, Size: {size}");

            var currentView = ApplicationView.GetForCurrentView();
            title = title ?? currentView.Title;
           
            var newView = CoreApplication.CreateNewView();
            var dispatcher = new DispatcherWrapper(newView.Dispatcher);
            var newControl = await dispatcher.Dispatch(async () =>
            {                
                var control=ViewLifetimeControl.GetForCurrentView();
                var newWindow = Window.Current;
                var newAppView = ApplicationView.GetForCurrentView();
                newAppView.Title = title;                
                var nav = BootStrapper.Current.NavigationServiceFactory(BootStrapper.BackButton.Ignore, BootStrapper.ExistingContent.Exclude);
                control.NavigationService = nav;
                nav.Navigate(page, parameter);
                newWindow.Content = nav.Frame;
                newWindow.Activate();

                await ApplicationViewSwitcher
                    .TryShowAsStandaloneAsync(newAppView.Id, ViewSizePreference.Default, currentView.Id, size);
                return control;
            }).ConfigureAwait(false);
            return newControl;
        }
        public async Task <ViewLifetimeControl> OpenAsync(Type page, object parameter = null, string title = null,
                                                          ViewSizePreference size     = ViewSizePreference.UseHalf)
        {
            WriteLine($"Page: {page}, Parameter: {parameter}, Title: {title}, Size: {size}");

            var currentView = ApplicationView.GetForCurrentView();

            title = title ?? currentView.Title;

            var newView    = CoreApplication.CreateNewView();
            var dispatcher = new DispatcherWrapper(newView.Dispatcher);
            var newControl = await dispatcher.Dispatch(async() =>
            {
                var control               = ViewLifetimeControl.GetForCurrentView();
                var newWindow             = Window.Current;
                var newAppView            = ApplicationView.GetForCurrentView();
                newAppView.Title          = title;
                var nav                   = BootStrapper.Current.NavigationServiceFactory(BootStrapper.BackButton.Ignore, BootStrapper.ExistingContent.Exclude);
                control.NavigationService = nav;
                nav.Navigate(page, parameter);
                newWindow.Content = nav.Frame;
                newWindow.Activate();

                await ApplicationViewSwitcher
                .TryShowAsStandaloneAsync(newAppView.Id, ViewSizePreference.Default, currentView.Id, size);
                return(control);
            }).ConfigureAwait(false);

            return(newControl);
        }
Exemplo n.º 4
0
        public async Task <IViewLifetimeControl> OpenAsync(UIElement content, string title = null,
                                                           ViewSizePreference size         = ViewSizePreference.UseHalf)
        {
            WriteLine($"Frame: {content}, Title: {title}, Size: {size}");

            var currentView = ApplicationView.GetForCurrentView();

            title = title ?? currentView.Title;

            var newView    = CoreApplication.CreateNewView();
            var dispatcher = new DispatcherWrapper(newView.Dispatcher);
            var newControl = await dispatcher.Dispatch(async() =>
            {
                var control      = ViewLifetimeControl.GetForCurrentView();
                var newWindow    = Window.Current;
                var newAppView   = ApplicationView.GetForCurrentView();
                newAppView.Title = title;

                // TODO: (Jerry)
                // control.NavigationService = nav;

                newWindow.Content = content;
                newWindow.Activate();

                await ApplicationViewSwitcher
                .TryShowAsStandaloneAsync(newAppView.Id, ViewSizePreference.Default, currentView.Id, size);
                return(control);
            }).ConfigureAwait(false);

            return(newControl);
        }
Exemplo n.º 5
0
 private void BootStrapper_BackRequested(object sender, HandledEventArgs e)
 {
     e.Handled = Handled;
     foreach (IAction item in Actions)
     {
         _dispatcher.Dispatch(() => item.Execute(sender, null));
     }
 }
Exemplo n.º 6
0
    internal void SomeCode()
    {
        // A UI application would call...
        var dispatcher        = Dispatcher.CurrentDispatcher;
        var dispatcherWrapper = new DispatcherWrapper(action => dispatcher.BeginInvoke(action));

        // A non-UI application would call...
        dispatcherWrapper = new DispatcherWrapper(action => action());
        // The library code would call..
        dispatcherWrapper.Dispatch(() => {
            // This code runs on the UI thread in UI apps and on any thread in non-UI apps.
        });
    }