コード例 #1
0
        private async void OpenFont()
        {
            var picker = new FileOpenPicker();

            foreach (var format in FontFinder.SupportedFormats)
            {
                picker.FileTypeFilter.Add(format);
            }

            picker.CommitButtonText = Localization.Get("OpenFontPickerConfirm");
            var file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                try
                {
                    ViewModel.IsLoadingFonts = true;

                    if (await FontFinder.LoadFromFileAsync(file) is InstalledFont font)
                    {
                        await FontMapView.CreateNewViewForFontAsync(font);
                    }
                }
                finally
                {
                    ViewModel.IsLoadingFonts = false;
                }
            }
        }
コード例 #2
0
 private void OpenInWindowFlyoutItem_Click(object sender, RoutedEventArgs e)
 {
     if (sender is MenuFlyoutItem item &&
         item.DataContext is InstalledFont font)
     {
         _ = FontMapView.CreateNewViewForFontAsync(font);
     }
 }
コード例 #3
0
        private void LayoutRoot_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            var ctrlState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control);

            if ((ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down)
            {
                // Check to see if any basic modals are open first
                if ((SettingsView != null && SettingsView.IsOpen) ||
                    (PrintPresenter != null && PrintPresenter.Child != null))
                {
                    return;
                }

                switch (e.Key)
                {
                case VirtualKey.C:
                    FontMap.TryCopy();
                    break;

                case VirtualKey.S:
                    if (FontMap.ViewModel.SelectedVariant is FontVariant v && FontMap.ViewModel.SelectedVariantAnalysis is CanvasTextLayoutAnalysis a)
                    {
                        ExportManager.RequestExportFontFile(v, a);
                    }
                    break;

                case VirtualKey.N:
                    if (ViewModel.SelectedFont is InstalledFont fnt)
                    {
                        _ = FontMapView.CreateNewViewForFontAsync(fnt);
                    }
                    break;

                case VirtualKey.P:
                    Messenger.Default.Send(new PrintRequestedMessage());
                    break;

                case VirtualKey.Delete:
                    if (ViewModel.SelectedFont is InstalledFont font && font.HasImportedFiles)
                    {
                        FlyoutHelper.RequestDelete(font);
                    }
                    break;
                }
            }
        }
コード例 #4
0
        private void LayoutRoot_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.F11)
            {
                Utils.ToggleFullScreenMode();
            }

            var ctrlState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control);

            if ((ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down)
            {
                // Check to see if any basic modals are open first
                if (AreModalsOpen())
                {
                    return;
                }

                if (!FontMap.HandleInput(e))
                {
                    switch (e.Key)
                    {
                    case VirtualKey.N:
                        if (ViewModel.SelectedFont is InstalledFont fnt)
                        {
                            _ = FontMapView.CreateNewViewForFontAsync(fnt);
                        }
                        break;

                    case VirtualKey.Delete:
                        if (ViewModel.SelectedFont is InstalledFont font && font.HasImportedFiles)
                        {
                            FlyoutHelper.RequestDelete(font);
                        }
                        break;

                    case VirtualKey.L:
                        TogglePane_Click(null, null);
                        break;
                    }
                }
            }
        }
コード例 #5
0
        private void LayoutRoot_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.F11)
            {
                Utils.ToggleFullScreenMode();
            }

            var ctrlState = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Control);

            if ((ctrlState & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down)
            {
                // Check to see if any basic modals are open first
                if ((SettingsView != null && SettingsView.IsOpen) ||
                    (PrintPresenter != null && PrintPresenter.Child != null))
                {
                    return;
                }

                switch (e.Key)
                {
                case VirtualKey.C:
                    FontMap.TryCopy();
                    break;

                case VirtualKey.S:
                    if (FontMap.ViewModel.SelectedVariant is FontVariant v)
                    {
                        ExportManager.RequestExportFontFile(v);
                    }
                    break;

                case VirtualKey.N:
                    if (ViewModel.SelectedFont is InstalledFont fnt)
                    {
                        _ = FontMapView.CreateNewViewForFontAsync(fnt);
                    }
                    break;

                case VirtualKey.P:
                    Messenger.Send(new PrintRequestedMessage());
                    break;

                case VirtualKey.Delete:
                    if (ViewModel.SelectedFont is InstalledFont font && font.HasImportedFiles)
                    {
                        FlyoutHelper.RequestDelete(font);
                    }
                    break;

                case VirtualKey.Add:
                case (VirtualKey)187:
                    FontMap.ViewModel.IncreaseCharacterSize();
                    break;

                case VirtualKey.Subtract:
                case (VirtualKey)189:
                    FontMap.ViewModel.DecreaseCharacterSize();
                    break;

                case VirtualKey.L:
                    TogglePane_Click(null, null);
                    break;

                case VirtualKey.R:
                    ViewModel.Settings.EnablePreviewPane = !ViewModel.Settings.EnablePreviewPane;
                    break;

                case VirtualKey.B:
                    ViewModel.Settings.EnableCopyPane = !ViewModel.Settings.EnableCopyPane;
                    break;

                case VirtualKey.T:
                    FontMap.ViewModel.ChangeDisplayMode();
                    break;

                case VirtualKey.Q:
                    _ = QuickCompareView.CreateNewWindowAsync();
                    break;
                }
            }
        }