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 }
public MainWindow() { InitializeComponent(); PushToTalkRelease = new AutoResetEvent(false); Logic = Core.Instance; TranslationManager.Instance.DefaultLanguage = new CultureInfo("en"); TranslationManager.Instance.CurrentLanguage = new CultureInfo(Logic.Configuration.Language ?? "en"); 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 }