/// <summary>
        ///     The on content changed.
        /// </summary>
        public void OnContentChanged()
        {
            Dispatcher.BeginInvoke(
                DispatcherPriority.ApplicationIdle,
                new Action(
                    () =>
            {
                Rectangle workingArea;
                if (FullScreenHelper.ForegroundIsFullScreen() && Screen.AllScreens.Count(x => !x.Primary) >= 1)
                {
                    workingArea = Screen.AllScreens.First(x => !x.Primary).WorkingArea;
                }
                else
                {
                    workingArea = Screen.PrimaryScreen.WorkingArea;
                }

                var presentationSource = PresentationSource.FromVisual(this);
                if (presentationSource?.CompositionTarget == null)
                {
                    return;
                }

                var transform = presentationSource.CompositionTarget.TransformFromDevice;
                var corner    =
                    transform.Transform(new Point(workingArea.Right,
                                                  ApplicationSettings.ToastsAreLocatedAtTop ? workingArea.Top : workingArea.Bottom));

                Left = corner.X - ActualWidth;
                Top  = corner.Y - (ApplicationSettings.ToastsAreLocatedAtTop ? -ActualHeight : ActualHeight);
            }));
        }
Ejemplo n.º 2
0
        private void FullscreenTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            if (cm.CurrentCharacter == null ||
                !ApplicationSettings.AllowAutoBusy ||
                cm.CurrentCharacter.Status == StatusType.Busy)
            {
                return;
            }

            if (cm.CurrentCharacter.Status != StatusType.Online &&
                cm.CurrentCharacter.Status != StatusType.Idle &&
                cm.CurrentCharacter.Status != StatusType.Away)
            {
                return;
            }

            if (!FullScreenHelper.ForegroundIsFullScreen())
            {
                return;
            }

            Log("Setting user status to busy");
            cm.CurrentCharacter.Status = StatusType.Busy;
            events.SendUserCommand("busy", new[] { cm.CurrentCharacter.StatusMessage });
            fullscreenTimer.Stop();
        }