Exemplo n.º 1
0
 static void OpenInNewWindow(object s, RoutedEventArgs args)
 {
     if (s is FrameworkElement f && f.Tag is InstalledFont fnt)
     {
         _ = FontMapView.CreateNewViewForFontAsync(fnt);
     }
 }
Exemplo n.º 2
0
 static void OpenInNewWindow(object s, RoutedEventArgs args)
 {
     if (s is FrameworkElement f && f.Tag is InstalledFont fnt)
     {
         _ = FontMapView.CreateNewViewForFontAsync(fnt, null, f.DataContext as CharacterRenderingOptions);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="fontMap">The FontMap to print</param>
 public PrintHelper(FontMapView fontMap, PrintViewModel printModel)
 {
     this.fontMap      = fontMap;
     _printModel       = printModel;
     printPreviewPages = new List <PrintPage>();
 }
Exemplo n.º 4
0
        public async Task ActivateAsync(object activationArgs)
        {
            if (IsActivation(activationArgs))
            {
                // Initialize things like registering background task before the app is loaded
                await InitializeAsync();

                // We spawn a separate Window for files.
                if (activationArgs is FileActivatedEventArgs fileArgs)
                {
                    bool mainView = Window.Current.Content == null;
                    void CreateView()
                    {
                        FontMapView map = new FontMapView
                        {
                            IsStandalone = true,
                        };

                        _ = map.ViewModel.LoadFromFileArgsAsync(fileArgs);

                        // You have to activate the window in order to show it later.
                        Window.Current.Content = map;
                        Window.Current.Activate();
                    }

                    var view = await WindowService.CreateViewAsync(CreateView, false);

                    await WindowService.TrySwitchToWindowAsync(view, mainView);

                    return;
                }

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (WindowService.MainWindow == null)
                {
                    void CreateMainView()
                    {
                        // Create a Frame to act as the navigation context and navigate to the first page
                        Window.Current.Content = new Frame();
                        NavigationService.Frame.NavigationFailed += (sender, e) => throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
                        NavigationService.Frame.Navigated        += OnFrameNavigated;

                        if (SystemNavigationManager.GetForCurrentView() != null)
                        {
                            SystemNavigationManager.GetForCurrentView().BackRequested += OnAppViewBackButtonRequested;
                        }
                    }

                    var view = await WindowService.CreateViewAsync(CreateMainView, true);

                    await WindowService.TrySwitchToWindowAsync(view, true);
                }
                else
                {
                    /* Main Window exists, make it show */
                    _ = ApplicationViewSwitcher.TryShowAsStandaloneAsync(WindowService.MainWindow.View.Id);
                    WindowService.MainWindow.CoreView.CoreWindow.Activate();
                }
            }



            try
            {
                var activationHandler = GetActivationHandlers()?.FirstOrDefault(h => h.CanHandle(activationArgs));
                if (activationHandler != null)
                {
                    await activationHandler.HandleAsync(activationArgs);
                }
            }
            catch
            {
            }

            if (IsActivation(activationArgs))
            {
                var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem);
                if (defaultHandler.CanHandle(activationArgs))
                {
                    await defaultHandler.HandleAsync(activationArgs);
                }

                // Ensure the current window is active
                Window.Current.Activate();

                ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;

                // Tasks after activation
                await StartupAsync();
            }
        }