public MainWindow() { InitializeComponent(); PushToTalkRelease = new AutoResetEvent(false); Logic = new Core(); TranslationManager.Instance.CurrentLanguage = new CultureInfo(Logic.Configuration.Language ?? "en"); ni = new System.Windows.Forms.NotifyIcon(); ni.Icon = Properties.Resources.Main; ni.Visible = true; ni.Text = "Articulate"; ni.DoubleClick += (sender, args) => { this.Show(); this.WindowState = WindowState.Normal; }; Logic.Keybinder.KeysPressed += OnKeysPressed; Logic.Keybinder.KeysReleased += OnKeysReleased; #region Rx Event Handlers var ConfidenceEvent = Observable.FromEventPattern<RoutedPropertyChangedEventArgs<double>>(ConfidenceMargin, "ValueChanged"); RxSubscriptions.Push(ConfidenceEvent.Skip(1).Distinct().Sample(TimeSpan.FromMilliseconds(500)).Subscribe(args => { Logic.Configuration.ConfidenceMargin = (int)args.EventArgs.NewValue; if (Logic != null) Logic.Recognizer.ConfidenceMargin = (int)args.EventArgs.NewValue; })); RxSubscriptions.Push(ConfidenceEvent.Skip(1).Distinct().Sample(TimeSpan.FromMilliseconds(50)).ObserveOnDispatcher().Subscribe(args => { ConfidenceMarginNumber.Content = Math.Floor(args.EventArgs.NewValue).ToString(); })); RxSubscriptions.Push(SettingsFlyout.ToObservable<bool>(Flyout.IsOpenProperty).Skip(1).Distinct().ObserveOn(ThreadPoolScheduler.Instance).Subscribe(args => { if (!args) Logic.Configuration.Save(); })); RxSubscriptions.Push(LanguagesFlyout.ToObservable<bool>(Flyout.IsOpenProperty).Skip(1).Distinct().ObserveOn(ThreadPoolScheduler.Instance).Subscribe(args => { if (!args) Logic.Configuration.Save(); })); #endregion }
private Core() { // Necessary to fix Core.Instance initialization loop when loading grammar _Instance = this; Configuration = Settings.Load(); Keybinder = new KeyMonitor(Configuration); Recognizer = new VoiceRecognizer(); SoundPlayer = new SoundEffectsPlayer(Configuration); Recognizer.CommandAccepted += SoundPlayer.CommandAccepted; Recognizer.CommandRejected += SoundPlayer.CommandRejected; Recognizer.StartedListening += SoundPlayer.StartedListening; Recognizer.StoppedListening += SoundPlayer.StoppedListening; }
public AdvancedSettings(Core logic) { Logic = logic; InitializeComponent(); }