コード例 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainWindow()
        {
            _environment = KeyboardApplicationEnvironment.Create(this);
            _host        = _environment.Host;

            InitializeComponent();
        }
コード例 #2
0
        /// <summary>
        /// Create a new instance of the host for the environment.
        /// </summary>
        /// <param name="environment">The environment.</param>
        /// <returns>The new host.</returns>
        public static KeyboardHost Create(IKeyboardApplicationEnvironment environment)
        {
            var host = new KeyboardHost(environment);

            host.SetTextHint(host.TextSlice);

            host.ShiftToggleState.IsChecked   = environment.SystemProvider.IsShiftKeyDown;
            host.ControlToggleState.IsChecked = environment.SystemProvider.IsControlKeyDown;
            host.AltToggleState.IsChecked     = environment.SystemProvider.IsAltKeyDown;

            return(host);
        }
コード例 #3
0
        public MainWindow()
        {
            GeoWatcher.PositionChanged += GeoWatcher_PositionChanged;
            GeoWatcher.Start(false);

            ShowSettings = new RelayCommand(OnShowSettings);

            IKeyboardApplicationEnvironment environment = KeyboardApplicationEnvironment.Create(this);

            _host = environment.Host;

            InitializeComponent();

            EulaWindow.ShowDialogOnFirstRun();
        }
コード例 #4
0
        KeyboardHost(IKeyboardApplicationEnvironment environment)
        {
            _environment = environment;
            _editor      = new TextBoxEditor(_environment.ClipboardProvider);

            SetTrainingPhrase();
            _environment.AppSettings.Keyboard.AttachPropertyChangedAction(nameof(_environment.AppSettings.Keyboard.IsTrainingMode), SetTrainingPhrase);

            _isUpdateAvailable            = _environment.IsUpdateAvailable;
            _environment.UpdateAvailable += (s, e) => IsUpdateAvailable = _environment.IsUpdateAvailable;

            var publicTextToAudio  = _environment.TextToAudioProviderFactory.Create(AppSettings.Instance.PublicNarration);
            var privateTextToAudio = _environment.TextToAudioProviderFactory.Create(AppSettings.Instance.PrivateNarration);

            ActivityDisplayStatus = _environment.ActivityDisplayProvider.Status;
            _environment.ActivityDisplayProvider.StatusChanged += (s, e) => ActivityDisplayStatus = _environment.ActivityDisplayProvider.Status;

            var publicNarrator  = new Narrator(environment.Random, AppSettings.Instance.PublicNarration, _environment.AudioProviderFactory, publicTextToAudio, _environment.ActivityDisplayProvider);
            var privateNarrator = new Narrator(environment.Random, AppSettings.Instance.PrivateNarration, _environment.AudioProviderFactory, privateTextToAudio, NullActivityDisplayProvider.Instance);

            _narrator = new CompoundNarrator(publicNarrator, privateNarrator);

            Speak             = new RelayCommand(SpeakAction);
            SendToSlack       = new RelayCommand(SendToSlackAction, (o) => AppSettings.Instance.General.SlackHostUri != GeneralSettings.UnsetSlackHostUri);
            Clear             = new RelayCommand(ClearAction);
            UpdateApplication = new RelayCommand(UpdateApplicationAction);
            ExitApplication   = new RelayCommand(ExitApplicationAction);
            Calibrate         = new RelayCommand(CalibrateAction);

            for (var index = 0; index < 7; index++)
            {
                suggestionItems.Add(new SuggestionItem(this, index));
            }
            for (var index = 0; index < 6; index++)
            {
                phraseItems.Add(new PhraseItem(this, index));
            }

            ShiftToggleState   = ToggleStates["Shift"];
            ControlToggleState = ToggleStates["Control"];
            AltToggleState     = ToggleStates["Alt"];

            ShiftToggleState.CheckChanged += OnShiftChanged;

            _predictor = PredictionEngineFactory.Create(PredictionEnvironment.Instance);
            _predictor.PredictionChanged += OnPredictionChanged;

            _ambiguousKeys = new List <List <string> >();

            _minuteTick.Tick += OnMinuteTick;
            ScheduleNextMinuteTick();

            ShowActiveListening  = new RelayCommand((o) => AppSettings.Instance.Prediction.PredictionLayout = PredictionLayout.ActiveListening);
            ShowWordPrediction   = new RelayCommand((o) => AppSettings.Instance.Prediction.PredictionLayout = PredictionLayout.WordsAlone);
            ShowPhrasePrediction = new RelayCommand((o) => AppSettings.Instance.Prediction.PredictionLayout = PredictionLayout.PhraseAlone);

            ActiveListeningLaugh       = new RelayCommand((o) => SpeakEffect(AudioGesture.Laugh));
            ActiveListeningHmm         = new RelayCommand((o) => SpeakEffect(AudioGesture.Hmm));
            ActiveListeningSarcasm     = new RelayCommand((o) => SpeakEffect(AudioGesture.Sarcasm));
            ActiveListeningOh          = new RelayCommand((o) => SpeakEffect(AudioGesture.Oh));
            ActiveListeningSharpBreath = new RelayCommand((o) => SpeakEffect(AudioGesture.SharpBreath));
            ActiveListeningArgh        = new RelayCommand((o) => SpeakEffect(AudioGesture.Argh));
            ActiveListeningCough       = new RelayCommand((o) => SpeakEffect(AudioGesture.Cough));
            ActiveListeningUgh         = new RelayCommand((o) => SpeakEffect(AudioGesture.Ugh));
        }