public UwpInteropService(HookService hookService, GeneralSettings settings) { this._hookService = hookService; if (settings.SuspendKeyDetection) { this._suspended = hookService.Suspend(); } settings.SuspendKeyDetection.Subscribe(x => this.HandleSuspendedChanged(x)); }
protected override void OnStartup(StartupEventArgs e) { #if !DEBUG var appInstance = new MetroTrilithon.Desktop.ApplicationInstance().AddTo(this); if (appInstance.IsFirst) #endif { if (VirtualDesktop.IsSupported) { this.ShutdownMode = ShutdownMode.OnExplicitShutdown; this.DispatcherUnhandledException += (sender, args) => { ReportException(sender, args.Exception); args.Handled = true; }; DispatcherHelper.UIDispatcher = this.Dispatcher; LocalSettingsProvider.Instance.LoadAsync().Wait(); LocalSettingsProvider.Instance.AddTo(this); ThemeService.Current.Register(this, Theme.Windows, Accent.Windows); var s = e.Args.Select(x => x.ToLower()).Any(x => x == "-s"); this.ShowNotifyIcon(s); var helper = VdmHelperFactory.CreateInstance().AddTo(this); helper.Init(); this._pinService = new PinService(helper).AddTo(this); this._hookService = new HookService(helper).AddTo(this); this._hookService.PinRequested += (sender, hWnd) => this._pinService.Register(hWnd); this._hookService.UnpinRequested += (sender, hWnd) => this._pinService.Unregister(hWnd); this._interopService = new UwpInteropService(this._hookService, Settings.General).AddTo(this); this._notificationService = new NotificationService().AddTo(this); base.OnStartup(e); } else { MessageBox.Show("This applications is supported only Windows 10 (build 10240).", "Not supported", MessageBoxButton.OK, MessageBoxImage.Stop); this.Shutdown(); } } #if !DEBUG else { appInstance.SendCommandLineArgs(e.Args); this.Shutdown(); } #endif }
public SettingsWindowViewModel(HookService hookService) { this._hookService = hookService; this._startup = new Startup(); this.Cultures = new[] { new DisplayViewModel<string> { Display = "(auto)", } } .Concat(ResourceService.Current.SupportedCultures .Select(x => new DisplayViewModel<string> { Display = x.NativeName, Value = x.Name, }) .OrderBy(x => x.Display)) .ToList(); this.Libraries = ProductInfo.Libraries.Aggregate( new List<BindableTextViewModel>(), (list, lib) => { list.Add(new BindableTextViewModel { Text = list.Count == 0 ? "Build with " : ", ", }); list.Add(new HyperlinkViewModel { Text = lib.Name.Replace(' ', Convert.ToChar(160)), Uri = lib.Url, }); return list; }); this._HasStartupLink = this._startup.IsExists; Settings.General.DesktopBackgroundFolderPath .Subscribe(path => this.Backgrounds = WallpaperService.Instance.GetWallpaperFiles(path)) .AddTo(this); Disposable.Create(() => LocalSettingsProvider.Instance.SaveAsync().Wait()) .AddTo(this); }