public TomightyApplication()
        {
            var eventHub        = new SynchronousEventHub();
            var timer           = new Tomighty.Timer(eventHub);
            var userPreferences = new UserPreferences();
            var pomodoroEngine  = new PomodoroEngine(timer, userPreferences, eventHub);

            var trayMenu             = new TrayMenu() as ITrayMenu;
            var trayIcon             = CreateTrayIcon(trayMenu);
            var timerWindowPresenter = new TimerWindowPresenter(pomodoroEngine, timer, eventHub);

            new TrayIconController(trayIcon, timerWindowPresenter, eventHub);
            new TrayMenuController(trayMenu, this, pomodoroEngine, eventHub);
            new NotificationsPresenter(pomodoroEngine, userPreferences, eventHub);
            new SoundNotificationPlayer(userPreferences, eventHub);
            new AutoUpdate(userPreferences).Start();

            var aboutWindowPresenter     = new AboutWindowPresenter();
            var userPreferencesPresenter = new UserPreferencesPresenter(userPreferences);

            trayMenu.OnAboutClick((sender, e) => aboutWindowPresenter.Show());
            trayMenu.OnPreferencesClick((sender, e) => userPreferencesPresenter.Show());

            ThreadExit += (sender, e) => trayIcon.Dispose();

            new StartupEvents(eventHub);
        }
示例#2
0
        public static async Task WaitPhaseChange(PomodoroEngine engine, PomodoroPhase phase)
        {
            var timeout = TimeSpan.FromSeconds(5);
            var task    = Task.Run(() =>
            {
                while (true)
                {
                    if (engine.Phase == phase)
                    {
                        break;
                    }

                    Thread.Sleep(50);
                }
            });

            if (await Task.WhenAny(task, Task.Delay(timeout)) != task)
            {
                Assert.Fail($"Timout: Phase didn't change to {phase}, actual phase:{engine.Phase}");
            }
        }