コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: breebchi/OptiKey
        public MainViewModel(
            IAudioService audioService,
            ICalibrationService calibrationService,
            IDictionaryService dictionaryService,
            IKeyStateService keyStateService,
            ISuggestionStateService suggestionService,
            ICapturingStateManager capturingStateManager,
            ILastMouseActionStateManager lastMouseActionStateManager,
            IInputService inputService,
            IKeyboardOutputService keyboardOutputService,
            IMouseOutputService mouseOutputService,
            IWindowManipulationService mainWindowManipulationService,
            List<INotifyErrors> errorNotifyingServices)
        {
            this.audioService = audioService;
            this.calibrationService = calibrationService;
            this.dictionaryService = dictionaryService;
            this.keyStateService = keyStateService;
            this.suggestionService = suggestionService;
            this.capturingStateManager = capturingStateManager;
            this.lastMouseActionStateManager = lastMouseActionStateManager;
            this.inputService = inputService;
            this.keyboardOutputService = keyboardOutputService;
            this.mouseOutputService = mouseOutputService;
            this.mainWindowManipulationService = mainWindowManipulationService;
            this.errorNotifyingServices = errorNotifyingServices;

            calibrateRequest = new InteractionRequest<NotificationWithCalibrationResult>();
            SelectionMode = SelectionModes.Key;

            InitialiseKeyboard(mainWindowManipulationService);
            AttachScratchpadEnabledListener();
            AttachKeyboardSupportsCollapsedDockListener(mainWindowManipulationService);
            AttachKeyboardSupportsSimulateKeyStrokesListener();
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: tqphan/OptiKey
        public MainViewModel(
            IAudioService audioService,
            ICalibrationService calibrationService,
            IDictionaryService dictionaryService,
            IKeyboardService keyboardService,
            ISuggestionStateService suggestionService,
            ICapturingStateManager capturingStateManager,
            ILastMouseActionStateManager lastMouseActionStateManager,
            IInputService inputService,
            IOutputService outputService,
            IWindowManipulationService mainWindowManipulationService,
            List<INotifyErrors> errorNotifyingServices)
        {
            Log.Debug("Ctor called.");

            this.audioService = audioService;
            this.calibrationService = calibrationService;
            this.dictionaryService = dictionaryService;
            this.keyboardService = keyboardService;
            this.suggestionService = suggestionService;
            this.capturingStateManager = capturingStateManager;
            this.lastMouseActionStateManager = lastMouseActionStateManager;
            this.inputService = inputService;
            this.outputService = outputService;
            this.mainWindowManipulationService = mainWindowManipulationService;
            this.errorNotifyingServices = errorNotifyingServices;

            calibrateRequest = new InteractionRequest<NotificationWithCalibrationResult>();

            SelectionMode = SelectionModes.Key;
            Keyboard = new Alpha();

            SelectKeyboardOnKeyboardSetChanges();
            AttachScratchpadEnabledListener();

            HandleFunctionKeySelectionResult(KeyValues.LeftShiftKey); //Set initial shift state to on
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: masonyang/OptiKey
 private void AttachKeyboardSupportsCollapsedDockListener(IWindowManipulationService mainWindowManipulationService)
 {
     Action<bool> resizeDockIfCollapsedDockingNotSupported = collapsedDockingSupported =>
     {
         if (!collapsedDockingSupported
             && Settings.Default.MainWindowState == WindowStates.Docked
             && Settings.Default.MainWindowDockSize == DockSizes.Collapsed)
         {
             Log.Info("Keyboard does not support collapsed dock and main window is docked and collapsed - resizing to full dock");
             mainWindowManipulationService.ResizeDockToFull();
         }
     };
     this.OnPropertyChanges(mvm => mvm.KeyboardSupportsCollapsedDock).Subscribe(resizeDockIfCollapsedDockingNotSupported);
     resizeDockIfCollapsedDockingNotSupported(KeyboardSupportsCollapsedDock);
 }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: masonyang/OptiKey
        private void InitialiseKeyboard(IWindowManipulationService windowManipulationService)
        {
            if (Settings.Default.ConversationOnlyMode)
            {
                Keyboard = new ConversationAlpha(null);
                windowManipulationService.Maximise();
            }
            else
            {
                switch (Settings.Default.StartupKeyboard)
                {
                    case Enums.Keyboards.Alpha:
                        Keyboard = new Alpha();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.ConversationAlpha:
                        Keyboard = new ConversationAlpha(() =>
                        {
                            Keyboard = new Menu(() => Keyboard = new Alpha());
                            mainWindowManipulationService.Restore();
                            mainWindowManipulationService.ResizeDockToFull();
                        });
                        windowManipulationService.Maximise();
                        break;

                    case Enums.Keyboards.ConversationNumericAndSymbols:
                        Keyboard = new ConversationNumericAndSymbols(() =>
                        {
                            Keyboard = new Menu(() => Keyboard = new Alpha());
                            mainWindowManipulationService.Restore();
                            mainWindowManipulationService.ResizeDockToFull();
                        });
                        windowManipulationService.Maximise();
                        break;

                    case Enums.Keyboards.Currencies1:
                        Keyboard = new Currencies1();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.Currencies2:
                        Keyboard = new Currencies2();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.Diacritics1:
                        Keyboard = new Diacritics1();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.Diacritics2:
                        Keyboard = new Diacritics2();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.Diacritics3:
                        Keyboard = new Diacritics3();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.Menu:
                        Keyboard = new Menu(() => Keyboard = new Alpha());
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.Minimised:
                        Keyboard = new Minimised(() =>
                        {
                            Keyboard = new Menu(() => Keyboard = new Alpha());
                            windowManipulationService.Restore();
                            mainWindowManipulationService.ResizeDockToFull();
                        });
                        windowManipulationService.Minimise();
                        break;

                    case Enums.Keyboards.Mouse:
                        Keyboard = new Mouse(() => Keyboard = new Menu(() => Keyboard = new Alpha()));
                        windowManipulationService.Restore();
                        if (Settings.Default.MouseKeyboardDockSize == DockSizes.Full)
                        {
                            mainWindowManipulationService.ResizeDockToFull();
                        }
                        else
                        {
                            mainWindowManipulationService.ResizeDockToCollapsed();
                        }
                        break;

                    case Enums.Keyboards.NumericAndSymbols1:
                        Keyboard = new NumericAndSymbols1();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.NumericAndSymbols2:
                        Keyboard = new NumericAndSymbols2();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.NumericAndSymbols3:
                        Keyboard = new NumericAndSymbols3();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.PhysicalKeys:
                        Keyboard = new PhysicalKeys();
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;

                    case Enums.Keyboards.SizeAndPosition:
                        Keyboard = new SizeAndPosition(() => Keyboard = new Menu(() => Keyboard = new Alpha()));
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                        break;
                }
            }
        }
コード例 #5
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            try
            {
                Log.Info("Boot strapping the services and UI.");

                // We manually close this because automatic closure steals focus from the
                // dynamic splash screen.
                splashScreen.Close(TimeSpan.FromSeconds(0.5f));

                //Apply theme
                applyTheme();

                //Define MainViewModel before services so I can setup a delegate to call into the MainViewModel
                //This is to work around the fact that the MainViewModel is created after the services.
                MainViewModel     mainViewModel         = null;
                Action <KeyValue> fireKeySelectionEvent = kv =>
                {
                    if (mainViewModel != null) //Access to modified closure is a good thing here, for once!
                    {
                        mainViewModel.FireKeySelectionEvent(kv);
                    }
                };

                CleanupAndPrepareCommuniKateInitialState();

                ValidateDynamicKeyboardLocation();

                // Handle plugins. Validate if directory exists and is accessible and pre-load all plugins, building a in-memory list of available ones.
                ValidatePluginsLocation();
                if (Settings.Default.EnablePlugins)
                {
                    PluginEngine.LoadAvailablePlugins();
                }

                var presageInstallationProblem = PresageInstallationProblemsDetected();

                //Create services
                var           errorNotifyingServices = new List <INotifyErrors>();
                IAudioService audioService           = new AudioService();

                IDictionaryService           dictionaryService           = new DictionaryService(Settings.Default.SuggestionMethod);
                IPublishService              publishService              = new PublishService();
                ISuggestionStateService      suggestionService           = new SuggestionStateService();
                ICalibrationService          calibrationService          = CreateCalibrationService();
                ICapturingStateManager       capturingStateManager       = new CapturingStateManager(audioService);
                ILastMouseActionStateManager lastMouseActionStateManager = new LastMouseActionStateManager();
                IKeyStateService             keyStateService             = new KeyStateService(suggestionService, capturingStateManager, lastMouseActionStateManager, calibrationService, fireKeySelectionEvent);
                IInputService inputService = CreateInputService(keyStateService, dictionaryService, audioService,
                                                                calibrationService, capturingStateManager, errorNotifyingServices);
                IKeyboardOutputService keyboardOutputService = new KeyboardOutputService(keyStateService, suggestionService, publishService, dictionaryService, fireKeySelectionEvent);
                IMouseOutputService    mouseOutputService    = new MouseOutputService(publishService);
                errorNotifyingServices.Add(audioService);
                errorNotifyingServices.Add(dictionaryService);
                errorNotifyingServices.Add(publishService);
                errorNotifyingServices.Add(inputService);

                ReleaseKeysOnApplicationExit(keyStateService, publishService);

                //Compose UI
                var mainWindow = new MainWindow(audioService, dictionaryService, inputService, keyStateService);
                IWindowManipulationService mainWindowManipulationService = CreateMainWindowManipulationService(mainWindow);
                errorNotifyingServices.Add(mainWindowManipulationService);
                mainWindow.WindowManipulationService = mainWindowManipulationService;

                //Subscribing to the on closing events.
                mainWindow.Closing += dictionaryService.OnAppClosing;

                mainViewModel = new MainViewModel(
                    audioService, calibrationService, dictionaryService, keyStateService,
                    suggestionService, capturingStateManager, lastMouseActionStateManager,
                    inputService, keyboardOutputService, mouseOutputService, mainWindowManipulationService,
                    errorNotifyingServices);

                mainWindow.SetMainViewModel(mainViewModel);

                //Setup actions to take once main view is loaded (i.e. the view is ready, so hook up the services which kicks everything off)
                Action postMainViewLoaded = () =>
                {
                    mainViewModel.AttachErrorNotifyingServiceHandlers();
                    mainViewModel.AttachInputServiceEventHandlers();
                };

                mainWindow.AddOnMainViewLoadedAction(postMainViewLoaded);

                //Show the main window
                mainWindow.Show();

                if (Settings.Default.LookToScrollShowOverlayWindow)
                {
                    // Create the overlay window, but don't show it yet. It'll make itself visible when the conditions are right.
                    new LookToScrollOverlayWindow(mainViewModel);
                }

                //Display splash screen and check for updates (and display message) after the window has been sized and positioned for the 1st time
                EventHandler sizeAndPositionInitialised = null;
                sizeAndPositionInitialised = async(_, __) =>
                {
                    mainWindowManipulationService.SizeAndPositionInitialised -= sizeAndPositionInitialised; //Ensure this handler only triggers once
                    await ShowSplashScreen(inputService, audioService, mainViewModel, OptiKey.Properties.Resources.OPTIKEY_MOUSE_DESCRIPTION);

                    await mainViewModel.RaiseAnyPendingErrorToastNotifications();
                    await AttemptToStartMaryTTSService(inputService, audioService, mainViewModel);
                    await AlertIfPresageBitnessOrBootstrapOrVersionFailure(presageInstallationProblem, inputService, audioService, mainViewModel);

                    inputService.RequestResume(); //Start the input service

                    await CheckForUpdates(inputService, audioService, mainViewModel);
                };

                if (mainWindowManipulationService.SizeAndPositionIsInitialised)
                {
                    sizeAndPositionInitialised(null, null);
                }
                else
                {
                    mainWindowManipulationService.SizeAndPositionInitialised += sizeAndPositionInitialised;
                }

                Current.Exit += (o, args) =>
                {
                    mainWindowManipulationService.PersistSizeAndPosition();
                    Settings.Default.Save();
                };
            }
            catch (Exception ex)
            {
                Log.Error("Error starting up application", ex);
                throw;
            }
        }
コード例 #6
0
        private void InitialiseKeyboard(IWindowManipulationService windowManipulationService)
        {
            if (Settings.Default.ConversationOnlyMode)
            {
                Keyboard = new ConversationAlpha(null);
                windowManipulationService.Maximise();
            }
            else
            {
                switch (Settings.Default.StartupKeyboard)
                {
                case Enums.Keyboards.Alpha:
                    Keyboard = new Alpha();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.ConversationAlpha:
                    Keyboard = new ConversationAlpha(() =>
                    {
                        Keyboard = new Menu(() => Keyboard = new Alpha());
                        mainWindowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                    });
                    windowManipulationService.Maximise();
                    break;

                case Enums.Keyboards.ConversationNumericAndSymbols:
                    Keyboard = new ConversationNumericAndSymbols(() =>
                    {
                        Keyboard = new Menu(() => Keyboard = new Alpha());
                        mainWindowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                    });
                    windowManipulationService.Maximise();
                    break;

                case Enums.Keyboards.Currencies1:
                    Keyboard = new Currencies1();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.Currencies2:
                    Keyboard = new Currencies2();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.Diacritics1:
                    Keyboard = new Diacritics1();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.Diacritics2:
                    Keyboard = new Diacritics2();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.Diacritics3:
                    Keyboard = new Diacritics3();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.Menu:
                    Keyboard = new Menu(() => Keyboard = new Alpha());
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.Minimised:
                    Keyboard = new Minimised(() =>
                    {
                        Keyboard = new Menu(() => Keyboard = new Alpha());
                        windowManipulationService.Restore();
                        mainWindowManipulationService.ResizeDockToFull();
                    });
                    windowManipulationService.Minimise();
                    break;

                case Enums.Keyboards.Mouse:
                    Keyboard = new Mouse(() => Keyboard = new Menu(() => Keyboard = new Alpha()));
                    windowManipulationService.Restore();
                    if (Settings.Default.MouseKeyboardDockSize == DockSizes.Full)
                    {
                        mainWindowManipulationService.ResizeDockToFull();
                    }
                    else
                    {
                        mainWindowManipulationService.ResizeDockToCollapsed();
                    }
                    break;

                case Enums.Keyboards.NumericAndSymbols1:
                    Keyboard = new NumericAndSymbols1();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.NumericAndSymbols2:
                    Keyboard = new NumericAndSymbols2();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.NumericAndSymbols3:
                    Keyboard = new NumericAndSymbols3();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.PhysicalKeys:
                    Keyboard = new PhysicalKeys();
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;

                case Enums.Keyboards.SizeAndPosition:
                    Keyboard = new SizeAndPosition(() => Keyboard = new Menu(() => Keyboard = new Alpha()));
                    windowManipulationService.Restore();
                    mainWindowManipulationService.ResizeDockToFull();
                    break;
                }
            }
        }
コード例 #7
0
ファイル: App.xaml.cs プロジェクト: rsrobinett/OptiKey
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            try
            {
                Log.Info("Boot strapping the services and UI.");

                //Apply theme
                applyTheme();

                //Define MainViewModel before services so I can setup a delegate to call into the MainViewModel
                //This is to work around the fact that the MainViewModel is created after the services.
                MainViewModel     mainViewModel         = null;
                Action <KeyValue> fireKeySelectionEvent = kv =>
                {
                    if (mainViewModel != null) //Access to modified closure is a good thing here, for once!
                    {
                        mainViewModel.FireKeySelectionEvent(kv);
                    }
                };

                //Create services
                var                          errorNotifyingServices      = new List <INotifyErrors>();
                IAudioService                audioService                = new AudioService();
                IDictionaryService           dictionaryService           = new DictionaryService(Settings.Default.AutoCompleteMethod);
                IPublishService              publishService              = new PublishService();
                ISuggestionStateService      suggestionService           = new SuggestionStateService();
                ICalibrationService          calibrationService          = CreateCalibrationService();
                ICapturingStateManager       capturingStateManager       = new CapturingStateManager(audioService);
                ILastMouseActionStateManager lastMouseActionStateManager = new LastMouseActionStateManager();
                IKeyStateService             keyStateService             = new KeyStateService(suggestionService, capturingStateManager, lastMouseActionStateManager, calibrationService, fireKeySelectionEvent);
                IInputService                inputService                = CreateInputService(keyStateService, dictionaryService, audioService, calibrationService, capturingStateManager, errorNotifyingServices);
                IKeyboardOutputService       keyboardOutputService       = new KeyboardOutputService(keyStateService, suggestionService, publishService, dictionaryService, fireKeySelectionEvent);
                IMouseOutputService          mouseOutputService          = new MouseOutputService(publishService);
                errorNotifyingServices.Add(audioService);
                errorNotifyingServices.Add(dictionaryService);
                errorNotifyingServices.Add(publishService);
                errorNotifyingServices.Add(inputService);

                //Release keys on application exit
                ReleaseKeysOnApplicationExit(keyStateService, publishService);

                //Compose UI
                var mainWindow = new MainWindow(audioService, dictionaryService, inputService, keyStateService);
                IWindowManipulationService mainWindowManipulationService = CreateMainWindowManipulationService(mainWindow);
                errorNotifyingServices.Add(mainWindowManipulationService);
                mainWindow.WindowManipulationService = mainWindowManipulationService;

                mainViewModel = new MainViewModel(
                    audioService, calibrationService, dictionaryService, keyStateService,
                    suggestionService, capturingStateManager, lastMouseActionStateManager,
                    inputService, keyboardOutputService, mouseOutputService, mainWindowManipulationService, errorNotifyingServices);

                mainWindow.MainView.DataContext = mainViewModel;

                //Setup actions to take once main view is loaded (i.e. the view is ready, so hook up the services which kicks everything off)
                Action postMainViewLoaded = mainViewModel.AttachServiceEventHandlers;
                if (mainWindow.MainView.IsLoaded)
                {
                    postMainViewLoaded();
                }
                else
                {
                    RoutedEventHandler loadedHandler = null;
                    loadedHandler = (s, a) =>
                    {
                        postMainViewLoaded();
                        mainWindow.MainView.Loaded -= loadedHandler; //Ensure this handler only triggers once
                    };
                    mainWindow.MainView.Loaded += loadedHandler;
                }

                //Show the main window
                mainWindow.Show();

                //Display splash screen and check for updates (and display message) after the window has been sized and positioned for the 1st time
                EventHandler sizeAndPositionInitialised = null;
                sizeAndPositionInitialised = async(_, __) =>
                {
                    mainWindowManipulationService.SizeAndPositionInitialised -= sizeAndPositionInitialised; //Ensure this handler only triggers once
                    await ShowSplashScreen(inputService, audioService, mainViewModel);

                    inputService.RequestResume(); //Start the input service
                    await CheckForUpdates(inputService, audioService, mainViewModel);
                };
                if (mainWindowManipulationService.SizeAndPositionIsInitialised)
                {
                    sizeAndPositionInitialised(null, null);
                }
                else
                {
                    mainWindowManipulationService.SizeAndPositionInitialised += sizeAndPositionInitialised;
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error starting up application", ex);
                throw;
            }
        }
コード例 #8
0
        private void SetKeyboardFromEnum(Enums.Keyboards keyboardEnum,
                                         IWindowManipulationService windowManipulationService,
                                         Action backAction)
        {
            // Set up the keyboard
            switch (keyboardEnum)
            {
            case Enums.Keyboards.Alpha:
                Keyboard = new Alpha1();
                break;

            case Enums.Keyboards.ConversationAlpha:
                Keyboard = new ConversationAlpha1(backAction);
                break;

            case Enums.Keyboards.ConversationNumericAndSymbols:
                Keyboard = new ConversationNumericAndSymbols(backAction);
                break;

            case Enums.Keyboards.ConversationConfirm:
                Keyboard = new ConversationConfirm(backAction);
                break;

            case Enums.Keyboards.Currencies1:
                Keyboard = new Currencies1();
                break;

            case Enums.Keyboards.Currencies2:
                Keyboard = new Currencies2();
                break;

            case Enums.Keyboards.CustomKeyboardFile:
                Keyboard = new DynamicKeyboard(backAction, mainWindowManipulationService,
                                               keyStateService, inputService, audioService, RaiseToastNotification, Settings.Default.StartupKeyboardFile);
                break;

            case Enums.Keyboards.Diacritics1:
                Keyboard = new Diacritics1();
                break;

            case Enums.Keyboards.Diacritics2:
                Keyboard = new Diacritics2();
                break;

            case Enums.Keyboards.Diacritics3:
                Keyboard = new Diacritics3();
                break;

            case Enums.Keyboards.DynamicKeyboard:
                Keyboard = new DynamicKeyboardSelector(() => { }, 0);
                break;

            case Enums.Keyboards.Menu:
                Keyboard = new Menu(backAction);
                break;

            case Enums.Keyboards.Minimised:
                Keyboard = new Minimised(backAction);
                break;

            case Enums.Keyboards.Mouse:
                Keyboard = new Mouse(backAction);
                break;

            case Enums.Keyboards.NumericAndSymbols1:
                Keyboard = new NumericAndSymbols1();
                break;

            case Enums.Keyboards.NumericAndSymbols2:
                Keyboard = new NumericAndSymbols2();
                break;

            case Enums.Keyboards.NumericAndSymbols3:
                Keyboard = new NumericAndSymbols3();
                break;

            case Enums.Keyboards.PhysicalKeys:
                Keyboard = new PhysicalKeys();
                break;

            case Enums.Keyboards.SizeAndPosition:
                Keyboard = new SizeAndPosition(backAction);
                break;

            case Enums.Keyboards.WebBrowsing:
                Keyboard = new WebBrowsing();
                break;

            default:
                Log.ErrorFormat("Cannot load keyboard: {0}, this is not a valid StartupKeyboard",
                                Settings.Default.StartupKeyboard);
                break;
            }

            // Set the window appropriately according to keyboard
            switch (Settings.Default.StartupKeyboard)
            {
            case Enums.Keyboards.ConversationAlpha:
            case Enums.Keyboards.ConversationConfirm:
            case Enums.Keyboards.ConversationNumericAndSymbols:
                windowManipulationService.Maximise();
                break;

            case Enums.Keyboards.Minimised:
                windowManipulationService.Minimise();
                break;

            case Enums.Keyboards.Mouse:
                windowManipulationService.Restore();
                if (Settings.Default.MouseKeyboardDockSize == DockSizes.Full)
                {
                    windowManipulationService.ResizeDockToFull();
                }
                else
                {
                    windowManipulationService.ResizeDockToCollapsed();
                }
                break;

            default:
                windowManipulationService.Restore();
                windowManipulationService.ResizeDockToFull();
                break;
            }
        }
コード例 #9
0
        private void GenerateContent()
        {
            Log.DebugFormat("GenerateContent called. Keyboard language is '{0}' and Keyboard type is '{1}'",
                            Settings.Default.KeyboardAndDictionaryLanguage, Keyboard != null ? Keyboard.GetType() : null);

            //Clear out point to key map
            PointToKeyValueMap = null;

            mainWindow = mainWindow != null ? mainWindow : VisualAndLogicalTreeHelper.FindVisualParent <MainWindow>(this);

            //Clear any potential main window color overrides
            if (mainWindow != null)
            {
                keyFamily                           = mainWindow.KeyFamily;
                keyValueByGroup                     = mainWindow.KeyValueByGroup;
                overrideTimesByKey                  = mainWindow.OverrideTimesByKey;
                windowManipulationService           = mainWindow.WindowManipulationService;
                mainWindow.BackgroundColourOverride = null;
                mainWindow.BorderBrushOverride      = null;

                //Clear the dictionaries
                keyFamily?.Clear();
                keyValueByGroup?.Clear();
                overrideTimesByKey?.Clear();

                //https://github.com/OptiKey/OptiKey/pull/715
                //Fixing issue where navigating between dynamic and conversation keyboards causing sizing problems:
                //https://github.com/AdamRoden: "I think that because we use a dispatcher to apply the saved size and position,
                //we get in a situation where the main thread maximizes the window before it gets resized by the dispatcher thread.
                //My fix basically says, "don't try restoring the persisted state if we're navigating a maximized keyboard.""
                if (!(Keyboard is ViewModelKeyboards.DynamicKeyboard) &&
                    !(Keyboard is ViewModelKeyboards.ConversationAlpha1) &&
                    !(Keyboard is ViewModelKeyboards.ConversationAlpha2) &&
                    !(Keyboard is ViewModelKeyboards.ConversationConfirm) &&
                    !(Keyboard is ViewModelKeyboards.ConversationNumericAndSymbols))
                {
                    windowManipulationService.RestorePersistedState();
                }
            }

            object newContent = ErrorContent;

            if (Keyboard is ViewModelKeyboards.Alpha1)
            {
                if (Settings.Default.UsingCommuniKateKeyboardLayout)
                {
                    newContent = (object)new CommonViews.CommuniKate {
                        DataContext = Keyboard
                    };
                }
                else
                {
                    switch (Settings.Default.KeyboardAndDictionaryLanguage)
                    {
                    case Languages.CatalanSpain:
                        newContent = new CatalanViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.CroatianCroatia:
                        newContent = new CroatianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.CzechCzechRepublic:
                        newContent = new CzechViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.DanishDenmark:
                        newContent = new DanishViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.DutchBelgium:
                        newContent = new DutchViews.BelgiumAlpha {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.DutchNetherlands:
                        newContent = new DutchViews.NetherlandsAlpha {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.FinnishFinland:
                        newContent = new FinnishViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.FrenchCanada:
                        newContent = new FrenchViews.CanadaAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.FrenchFrance:
                        newContent = new FrenchViews.FranceAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.GeorgianGeorgia:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new GeorgianViews.SimplifiedAlpha1 {
                            DataContext = Keyboard
                        }
                            : new GeorgianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.GermanGermany:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new GermanViews.SimplifiedAlpha1 {
                            DataContext = Keyboard
                        }
                            : Settings.Default.UseAlphabeticalKeyboardLayout
                                ? (object)new GermanViews.AlphabeticalAlpha1 {
                            DataContext = Keyboard
                        }
                                : new GermanViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.GreekGreece:
                        newContent = new GreekViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.HebrewIsrael:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new HebrewViews.SimplifiedAlpha1 {
                            DataContext = Keyboard
                        }
                            : new HebrewViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.HindiIndia:
                        newContent = new HindiViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.HungarianHungary:
                        newContent = new HungarianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.ItalianItaly:
                        newContent = Settings.Default.UseAlphabeticalKeyboardLayout
                            ? (object)new ItalianViews.AlphabeticalAlpha1 {
                            DataContext = Keyboard
                        }
                            : new ItalianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.JapaneseJapan:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new JapaneseViews.SimplifiedAlpha1 {
                            DataContext = Keyboard
                        }
                            : new JapaneseViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.KoreanKorea:
                        newContent = new KoreanViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.PersianIran:
                        newContent = new PersianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.PolishPoland:
                        newContent = new PolishViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.PortuguesePortugal:
                        newContent = new PortugueseViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.RussianRussia:
                        newContent = new RussianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SerbianSerbia:
                        newContent = new SerbianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SlovakSlovakia:
                        newContent = new SlovakViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SlovenianSlovenia:
                        newContent = new SlovenianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SpanishSpain:
                        newContent = new SpanishViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.TurkishTurkey:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new TurkishViews.SimplifiedAlpha1 {
                            DataContext = Keyboard
                        }
                            : new TurkishViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.UkrainianUkraine:
                        newContent = new UkrainianViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.UrduPakistan:
                        newContent = new UrduViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    default:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new EnglishViews.SimplifiedAlpha1 {
                            DataContext = Keyboard
                        }
                            : Settings.Default.UseAlphabeticalKeyboardLayout
                                ? (object)new EnglishViews.AlphabeticalAlpha1 {
                            DataContext = Keyboard
                        }
                                : new EnglishViews.Alpha1 {
                            DataContext = Keyboard
                        };
                        break;
                    }
                }
            }
            else if (Keyboard is ViewModelKeyboards.Alpha2)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.HebrewIsrael:
                    newContent = new HebrewViews.Alpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.HindiIndia:
                    newContent = new HindiViews.Alpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.JapaneseJapan:
                    newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new JapaneseViews.SimplifiedAlpha2 {
                        DataContext = Keyboard
                    }
                            : new JapaneseViews.Alpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.KoreanKorea:
                    newContent = new KoreanViews.Alpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.PersianIran:
                    newContent = new PersianViews.Alpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.UrduPakistan:
                    newContent = new UrduViews.Alpha2 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            //else if (Keyboard is ViewModelKeyboards.Alpha3)
            //{
            //    switch (Settings.Default.KeyboardAndDictionaryLanguage)
            //    {
            //        case Languages.PlaceholderForALanguageWith3AlphaKeyboards:
            //            newContent = new PlaceholderForALanguageWith3AlphaKeyboardsViews.Alpha3 {DataContext = Keyboard};
            //            break;
            //    }
            //}
            else if (Keyboard is ViewModelKeyboards.ConversationAlpha1)
            {
                if (Settings.Default.UsingCommuniKateKeyboardLayout)
                {
                    newContent = (object)new CommonViews.CommuniKate {
                        DataContext = Keyboard
                    };
                }
                else
                {
                    switch (Settings.Default.KeyboardAndDictionaryLanguage)
                    {
                    case Languages.CatalanSpain:
                        newContent = new CatalanViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.CroatianCroatia:
                        newContent = new CroatianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.CzechCzechRepublic:
                        newContent = new CzechViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.DanishDenmark:
                        newContent = new DanishViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.DutchBelgium:
                        newContent = new DutchViews.BelgiumConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.DutchNetherlands:
                        newContent = new DutchViews.NetherlandsConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.FinnishFinland:
                        newContent = new FinnishViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.FrenchCanada:
                        newContent = new FrenchViews.CanadaConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.FrenchFrance:
                        newContent = new FrenchViews.FranceConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.GeorgianGeorgia:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new GeorgianViews.SimplifiedConversationAlpha1 {
                            DataContext = Keyboard
                        }
                            : new GeorgianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.GermanGermany:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new GermanViews.SimplifiedConversationAlpha1 {
                            DataContext = Keyboard
                        }
                            : Settings.Default.UseAlphabeticalKeyboardLayout
                                ? (object)new GermanViews.AlphabeticalConversationAlpha1 {
                            DataContext = Keyboard
                        }
                                : new GermanViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.GreekGreece:
                        newContent = new GreekViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.HebrewIsrael:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new HebrewViews.SimplifiedConversationAlpha1 {
                            DataContext = Keyboard
                        }
                            : new HebrewViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.HindiIndia:
                        newContent = new HindiViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.HungarianHungary:
                        newContent = new HungarianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.ItalianItaly:
                        newContent = Settings.Default.UseAlphabeticalKeyboardLayout
                            ? (object)new ItalianViews.AlphabeticalConversationAlpha1 {
                            DataContext = Keyboard
                        }
                            : new ItalianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.JapaneseJapan:
                        newContent = new JapaneseViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.KoreanKorea:
                        newContent = new KoreanViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.PersianIran:
                        newContent = new PersianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.PolishPoland:
                        newContent = new PolishViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.PortuguesePortugal:
                        newContent = new PortugueseViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.RussianRussia:
                        newContent = new RussianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SerbianSerbia:
                        newContent = new SerbianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SlovakSlovakia:
                        newContent = new SlovakViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SlovenianSlovenia:
                        newContent = new SlovenianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.SpanishSpain:
                        newContent = new SpanishViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.TurkishTurkey:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new TurkishViews.SimplifiedConversationAlpha1 {
                            DataContext = Keyboard
                        }
                            : new TurkishViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.UkrainianUkraine:
                        newContent = new UkrainianViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    case Languages.UrduPakistan:
                        newContent = new UrduViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;

                    default:
                        newContent = Settings.Default.UseSimplifiedKeyboardLayout
                            ? (object)new EnglishViews.SimplifiedConversationAlpha1 {
                            DataContext = Keyboard
                        }
                            : Settings.Default.UseAlphabeticalKeyboardLayout
                                ? (object)new EnglishViews.AlphabeticalConversationAlpha1 {
                            DataContext = Keyboard
                        }
                                : new EnglishViews.ConversationAlpha1 {
                            DataContext = Keyboard
                        };
                        break;
                    }
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationAlpha2)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.HindiIndia:
                    newContent = new HindiViews.ConversationAlpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.JapaneseJapan:
                    newContent = new JapaneseViews.ConversationAlpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.KoreanKorea:
                    newContent = new KoreanViews.ConversationAlpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.PersianIran:
                    newContent = new PersianViews.ConversationAlpha2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.UrduPakistan:
                    newContent = new UrduViews.ConversationAlpha2 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            //else if (Keyboard is ViewModelKeyboards.ConversationAlpha3)
            //{
            //    switch (Settings.Default.KeyboardAndDictionaryLanguage)
            //    {
            //        case Languages.PlaceholderForALanguageWith3AlphaKeyboards:
            //            newContent = new PlaceholderForALanguageWith3AlphaKeyboardsViews.ConversationAlpha3 { DataContext = Keyboard };
            //            break;
            //    }
            //}
            else if (Keyboard is ViewModelKeyboards.ConversationConfirm)
            {
                newContent = new CommonViews.ConversationConfirm {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.ConversationNumericAndSymbols)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.HindiIndia:
                    newContent = new HindiViews.ConversationNumericAndSymbols {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.PersianIran:
                    newContent = new PersianViews.ConversationNumericAndSymbols {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.UrduPakistan:
                    newContent = new UrduViews.ConversationNumericAndSymbols {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new CommonViews.ConversationNumericAndSymbols {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Currencies1)
            {
                newContent = new CommonViews.Currencies1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies2)
            {
                newContent = new CommonViews.Currencies2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics1)
            {
                newContent = new CommonViews.Diacritics1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics2)
            {
                newContent = new CommonViews.Diacritics2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics3)
            {
                newContent = new CommonViews.Diacritics3 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Language)
            {
                newContent = new CommonViews.Language {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Voice)
            {
                var voice = Keyboard as ViewModelKeyboards.Voice;

                // Since the Voice keyboard's view-model is in charge of creating the keys instead of the
                // view, we need to make sure any localized text is up-to-date with the current UI language.
                voice.LocalizeKeys();

                newContent = new CommonViews.Voice {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Menu)
            {
                newContent = new CommonViews.Menu {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Minimised)
            {
                newContent = new CommonViews.Minimised {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Mouse)
            {
                newContent = new CommonViews.Mouse {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols1)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.HindiIndia:
                    newContent = new HindiViews.NumericAndSymbols1 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.PersianIran:
                    newContent = new PersianViews.NumericAndSymbols1 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.UrduPakistan:
                    newContent = new UrduViews.NumericAndSymbols1 {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new CommonViews.NumericAndSymbols1 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols2)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.HindiIndia:
                    newContent = new HindiViews.NumericAndSymbols2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.PersianIran:
                    newContent = new PersianViews.NumericAndSymbols2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.UrduPakistan:
                    newContent = new UrduViews.NumericAndSymbols2 {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new CommonViews.NumericAndSymbols2 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols3)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.HindiIndia:
                    newContent = new HindiViews.NumericAndSymbols3 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.PersianIran:
                    newContent = new PersianViews.NumericAndSymbols3 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.UrduPakistan:
                    newContent = new UrduViews.NumericAndSymbols3 {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new CommonViews.NumericAndSymbols3 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.PhysicalKeys)
            {
                newContent = new CommonViews.PhysicalKeys {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.SizeAndPosition)
            {
                newContent = new CommonViews.SizeAndPosition {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.WebBrowsing)
            {
                newContent = new CommonViews.WebBrowsing {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.YesNoQuestion)
            {
                newContent = new CommonViews.YesNoQuestion {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.DynamicKeyboard)
            {
                var kb = Keyboard as ViewModelKeyboards.DynamicKeyboard;
                newContent = new CommonViews.DynamicKeyboard(mainWindow, kb.Link, keyFamily, keyValueByGroup, overrideTimesByKey, windowManipulationService)
                {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.DynamicKeyboardSelector)
            {
                var kb = Keyboard as ViewModelKeyboards.DynamicKeyboardSelector;
                newContent = new CommonViews.DynamicKeyboardSelector(kb.PageIndex)
                {
                    DataContext = Keyboard
                };
            }
            Content = newContent;
        }
コード例 #10
0
 public VisualsViewModel(IWindowManipulationService windowManipulationService)
 {
     this.windowManipulationService = windowManipulationService;
     Load();
 }
コード例 #11
0
ファイル: MainViewModel.cs プロジェクト: xyfangnudt/OptiKey
        private void SetKeyboardFromEnum(Enums.Keyboards keyboardEnum,
                                         IWindowManipulationService windowManipulationService,
                                         Action backAction)
        {
            // Set up the keyboard
            switch (keyboardEnum)
            {
            case Enums.Keyboards.Alpha:
                Keyboard = new Alpha();
                break;

            case Enums.Keyboards.ConversationAlpha:
                Keyboard = new ConversationAlpha(backAction);
                break;

            case Enums.Keyboards.ConversationNumericAndSymbols:
                Keyboard = new ConversationNumericAndSymbols(backAction);
                break;

            case Enums.Keyboards.ConversationConfirm:
                Keyboard = new ConversationConfirm(backAction);
                break;

            case Enums.Keyboards.Currencies1:
                Keyboard = new Currencies1();
                break;

            case Enums.Keyboards.Currencies2:
                Keyboard = new Currencies2();
                break;

            case Enums.Keyboards.CustomKeyboardFile:
                Keyboard = new DynamicKeyboard(backAction, (d) => { }, Settings.Default.StartupKeyboardFile);
                break;

            case Enums.Keyboards.Diacritics1:
                Keyboard = new Diacritics1();
                break;

            case Enums.Keyboards.Diacritics2:
                Keyboard = new Diacritics2();
                break;

            case Enums.Keyboards.Diacritics3:
                Keyboard = new Diacritics3();
                break;

            case Enums.Keyboards.Menu:
                Keyboard = new Menu(backAction);
                break;

            case Enums.Keyboards.Minimised:
                Keyboard = new Minimised(backAction);
                break;

            case Enums.Keyboards.Mouse:
                Keyboard = new Mouse(backAction);
                break;

            case Enums.Keyboards.NumericAndSymbols1:
                Keyboard = new NumericAndSymbols1();
                break;

            case Enums.Keyboards.NumericAndSymbols2:
                Keyboard = new NumericAndSymbols2();
                break;

            case Enums.Keyboards.NumericAndSymbols3:
                Keyboard = new NumericAndSymbols3();
                break;

            case Enums.Keyboards.PhysicalKeys:
                Keyboard = new PhysicalKeys();
                break;

            case Enums.Keyboards.SizeAndPosition:
                Keyboard = new SizeAndPosition(backAction);
                break;

            case Enums.Keyboards.WebBrowsing:
                Keyboard = new WebBrowsing();
                break;
            }

            // Set the window appropriately according to keyboard
            switch (Settings.Default.StartupKeyboard)
            {
            case Enums.Keyboards.ConversationAlpha:
            case Enums.Keyboards.ConversationConfirm:
            case Enums.Keyboards.ConversationNumericAndSymbols:
                windowManipulationService.Maximise();
                break;

            case Enums.Keyboards.Minimised:
                windowManipulationService.Minimise();
                break;

            case Enums.Keyboards.Mouse:
                windowManipulationService.Restore();
                if (Settings.Default.MouseKeyboardDockSize == DockSizes.Full)
                {
                    windowManipulationService.ResizeDockToFull();
                }
                else
                {
                    windowManipulationService.ResizeDockToCollapsed();
                }
                break;

            default:
                windowManipulationService.Restore();
                windowManipulationService.ResizeDockToFull();
                break;
            }
        }