コード例 #1
0
ファイル: Program.cs プロジェクト: elipriaulx/Whisper
        static async Task Main(string[] args)
        {
            var application   = new WhisperApplication();
            var subscriptions = new CompositeDisposable
            {
                application.InitialisationProgress.Do(x =>
                {
                    Console.WriteLine($"{x.Stage}: {x.Message}");
                }).Subscribe()
            };

            await application.InitialiseApplication();

            // TODO: Implement Interactive/non-interactive console version.

            Console.ReadLine();
        }
コード例 #2
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            _applicationInstance = new WhisperApplication();

            // Initialise the application instance.
            using (var splash = new SplashWindow(_applicationInstance.InitialisationProgress))
            {
                splash.Show();

                var timer = System.Diagnostics.Stopwatch.StartNew();
                await _applicationInstance.InitialiseApplication();

                timer.Stop();

                var delayDelta = (int)(1000 - timer.ElapsedMilliseconds);

                if (delayDelta > 0)
                {
                    await Task.Delay(delayDelta);
                }


                Locator.CurrentMutable.Register(() => new CreateItemView(), typeof(IViewFor <CreateItemViewModel>));
                Locator.CurrentMutable.Register(() => new HistoryListItemView(), typeof(IViewFor <HistoryListItemViewModel>));
                Locator.CurrentMutable.Register(() => new HistoryListView(), typeof(IViewFor <HistoryListViewModel>));

                Locator.CurrentMutable.Register(() => new SettingsPageAboutView(), typeof(IViewFor <SettingsPageAboutViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageApplicationView(), typeof(IViewFor <SettingsPageApplicationViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageGeneralView(), typeof(IViewFor <SettingsPageGeneralViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageGenerationView(), typeof(IViewFor <SettingsPageGenerationViewModel>));
                Locator.CurrentMutable.Register(() => new SettingsPageGenerationItemView(), typeof(IViewFor <SettingsPageGenerationItemViewModel>));

                Func <SettingsWindow> settingsWindowFactory = () =>
                {
                    var settingsWindow = new SettingsWindow();

                    var settingsVm = new SettingsWindowViewModel(new List <SettingsPageViewModelBase>
                    {
                        new SettingsPageAboutViewModel(_applicationInstance.AppInfoService),
                        new SettingsPageGeneralViewModel(_applicationInstance.ConfigService),
                        //new SettingsPageApplicationViewModel(),
                        new SettingsPageGenerationViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService)
                    });

                    settingsWindow.ViewModel = settingsVm;

                    return(settingsWindow);
                };

                var settingsManager = new SettingsWindowManager(settingsWindowFactory);

                var shellWindowViewModel = new ShellWindowViewModel(_applicationInstance.ConfigService, new CreateItemViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService, _applicationInstance.ClipboardService), new HistoryListViewModel(_applicationInstance.GeneratorService, _applicationInstance.ClipboardService), settingsManager);

                // Fix this bat-shit nonsense.
                Locator.CurrentMutable.UnregisterAll <IPropertyBindingHook>();
                Locator.CurrentMutable.Register <IPropertyBindingHook>(() => new BindingHookFixerer());

                var shell = new ShellWindow
                {
                    ViewModel = shellWindowViewModel
                };

                var trayIcon = new WhisperTrayAgent(shell, settingsManager);
                _applicationDisposables.Add(trayIcon);

                splash.Hide();
                splash.Close();

                shell.Show();
            }

            base.OnStartup(e);
        }