/// <summary>
        /// Checks for the start of a meeting and pops up a join dialog if the user has requested one
        /// </summary>
        /// <param name="stateInfo"></param>
        public void CheckForMeetingStart(object stateInfo = null)
        {
            var now = DateTime.Now;

            // since this function can be called from both the timer as well as "manually", for example
            // when a meeting refresh occurs, ensure that it does not pop up a dialog more than once
            // in a given minute (which will happen if the user closes the dialog then a refresh runs
            // and causes it to open again)

            if (_lastMeetingNotificationMinute == now.Minute)
            {
                return;
            }

            if (!Properties.Settings.Default.NotifyOnMeetingStart)
            {
                return;
            }

            if (_meetingMenuItemCache == null)
            {
                return;
            }

            // this is mainly for debugging, prevent multiple queued up ticks
            StopCheckForStartingMeeting();

            _lastMeetingNotificationMinute = -1;

            foreach (var item in _meetingMenuItemCache)
            {
                if (item.StartTime.Day == now.Day &&
                    item.StartTime.Hour == now.Hour &&
                    item.StartTime.Minute == now.Minute &&
                    !ChimeHelper.Chime.IsMeetingAlreadyJoined(item.Subject))
                {
                    _lastMeetingNotificationMinute = now.Minute;

                    App.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        MeetingNotificationWindow.CreateAndShow(item);
                    }));
                    break;
                }
            }

            StartCheckForStartingMeeting();
        }
Пример #2
0
        // Not using "Instance" since this Singleton is more of an action
        public static void CreateAndShow(ChimeMeetingMenuItem meetingStartingNow)
        {
            if (_meetingNotificationWindow == null || _meetingNotificationWindow.IsLoaded == false)
            {
                _meetingNotificationWindow = new MeetingNotificationWindow();
            }

            _meetingNotificationWindow.CurrentMeetings = (ChimeMeetingMenuItems)(App.TrayIcon.DataContext);

            _meetingNotificationWindow.ResetAutoHideTimer();

            _meetingNotificationWindow.DefaultMeeting = meetingStartingNow;

            // refresh DataContext since we just set default meeting
            _meetingNotificationWindow.DataContext = _meetingNotificationWindow;

            WindowPositioner.MoveToMouse(_meetingNotificationWindow);
            _meetingNotificationWindow.Show();
            _meetingNotificationWindow.Topmost = true;
        }