private async void MainWindowMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (Interlocked.CompareExchange(ref AudioLocker, 1, 0) == 0)
            {
                await ShowMessage().ConfigureAwait(false);

                AudioLocker = 0;
            }

            async Task ShowMessage()
            {
                Task task = Task.CompletedTask;

                if (Settings.Value.AudioEnable)
                {
                    task = Speech.AnnounceTime(Clock.GetCurrentInstant().InZone(TimeZone));
                }
                string version = Assembly.GetEntryAssembly()?.GetName()?.Version?.ToString() ?? "?";

                new MsgBox(this)
                {
                    MsgBoxIconType = MsgBox.IconType.Information,
                    Background     = Brushes.LightGray,
                    Title          = "ExchangeTime " + version
                }.Show("Zoom: mouse wheel\nQuit: double-click left mouse button");

                await task.ConfigureAwait(false);
            }
        }
Exemple #2
0
        private async void MainWindowMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (Properties.Settings.Default.Audio)
            {
                await Speech.AnnounceTime(Clock.GetSystemZonedDateTime().LocalDateTime);
            }

            new MsgBox(this)
            {
                iconType   = MsgBox.IconType.Information,
                Background = Brushes.LightGray,
                Title      = "ExchangeTime"
            }.Show("Zoom: mouse wheel\nQuit: double-click left mouse button");
        }
        private async Task Notify(Instant instant)
        {
            if (!Properties.Settings.Default.Audio)
            {
                return;
            }

            foreach (var location in Locations.Where(loc => loc.Notifications.Any()))
            {
                var dt = instant.InZone(location.TimeZone).LocalDateTime;

                // don't notify on weekends
                if (dt.IsWeekend(location.Country))
                {
                    continue;
                }

                // don't notify on holidays
                var holiday    = Holidays.TryGetHoliday(location.Country, location.Region, dt.Date);
                var earlyClose = location.EarlyCloses.Where(x => x.DateTime.Date == dt.Date).SingleOrDefault();

                if (holiday != null && earlyClose == null)
                {
                    continue;
                }
                if (earlyClose != null && dt.TimeOfDay > earlyClose.DateTime.TimeOfDay)
                {
                    continue;
                }

                // holiday   earlyClose   Notify
                //  Y          N          No
                //  Y          Y          <= earlyClose
                //  N          Y          <= earlyClose
                //  N          N          Yes

                foreach (var notification in location.Notifications)
                {
                    if (dt.TimeOfDay == notification.Time)
                    {
                        await Speech.AnnounceTime(dt, location.Name, notification.Text).ConfigureAwait(false);
                    }
                }
            }
        }
Exemple #4
0
    private async Task Notify(Instant instant)
    {
        foreach (Location location in Locations.Where(loc => loc.Notifications.Any()))
        {
            LocalDateTime dt = instant.InZone(location.TimeZone).LocalDateTime;

            // don't notify on weekends
            if (dt.IsWeekend(location.Country))
            {
                continue;
            }

            // don't notify on holidays
            EarlyClose earlyClose = location.EarlyCloses.Where(x => x.DateTime.Date == dt.Date).SingleOrDefault(EarlyClose.Undefined);
            if (Holidays.TryGetHoliday(location.Country, location.Region, dt.Date, out Holiday holiday) && !earlyClose.IsValid)
            {
                continue;
            }
            if (earlyClose.IsValid && dt.TimeOfDay > earlyClose.DateTime.TimeOfDay)
            {
                continue;
            }

            // holiday   earlyClose   Notify
            //  Y          N          No
            //  Y          Y          <= earlyClose
            //  N          Y          <= earlyClose
            //  N          N          Yes

            foreach (Notification notification in location.Notifications)
            {
                if (dt.TimeOfDay == notification.Time)
                {
                    await Speech.AnnounceTime(dt, location.Name, notification.Text).ConfigureAwait(false);
                }
            }
        }
    }