Example #1
0
        protected void Application_Startup(object sender, StartupEventArgs e)
        {
            // ミューテックスの所有権を要求
            if (mutex.WaitOne(0, false) == false)
            {
                // すでに起動していると判断して終了
                MessageBox.Show("既に起動しています。");
                mutex.Close();
                mutex = null;
                this.Shutdown();
            }

            DispatcherHelper.UIDispatcher = Dispatcher;
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(
                    XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            var vm     = new ShellViewModel();
            var window = new ShellWindow();

            window.DataContext = vm;
            window.Show();
        }
Example #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Person person = new Person()
            {
                Name     = "Luke",
                Birthday = new DateTime(2080, 2, 6)
            };

            ShellWindow mainWindow = new ShellWindow();

            mainWindow.DataContext = person;
            mainWindow.Show();
        }
Example #3
0
        private void OnCommand(string option)
        {
            switch (option)
            {
            case "hide":
                _shell.Hide();
                break;

            case "show":
                _shell.Show();
                break;

            case "quit":
                _baloon.Dispatcher.BeginInvoke((Action)Dispose);
                break;

            default:
                _baloon.Append(@"\![" + option + "]");
                break;
            }
        }
Example #4
0
 private void RestoreApplication()
 {
     DismissTray();
     _shellWindow.Show();
 }
 private void openShellWindow(OpenSimulationMessage message)
 {
     ShellWindow shellwindow = new ShellWindow(message);
     shellwindow.Show();
 }
Example #6
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);
        }