Beispiel #1
0
 public Notification(Hardcodet.Wpf.TaskbarNotification.Interop.Point origin, string title, string message)
 {
     InitializeComponent();
     m_Origin       = origin;
     tbTitle.Text   = title;
     tbMessage.Text = message;
 }
Beispiel #2
0
        /// <summary>Determines the current screen resolution in DPI.</summary>
        /// <returns>Point.X is the X DPI, Point.Y is the Y DPI.</returns>
        public static Hardcodet.Wpf.TaskbarNotification.Interop.Point GetSystemDpi()
        {
            Hardcodet.Wpf.TaskbarNotification.Interop.Point result = new Hardcodet.Wpf.TaskbarNotification.Interop.Point();

            IntPtr hDC = GetDC(IntPtr.Zero);

            result.X = GetDeviceCaps(hDC, (int)DeviceCap.LOGPIXELSX);
            result.Y = GetDeviceCaps(hDC, (int)DeviceCap.LOGPIXELSY);

            ReleaseDC(IntPtr.Zero, hDC);

            return(result);
        }
Beispiel #3
0
 public void ShowNotification(string title, string message)
 {
     Current.Dispatcher.BeginInvoke(new Action(() =>
     {
         Logger.Info("Notification: {0}: {1}", title, message);
         Hardcodet.Wpf.TaskbarNotification.Interop.Point origin = TaskbarIcon.GetPopupTrayPosition();
         origin.Y += 9; // spawn it as close to the taskbar as we can
         TaskbarIcon.CustomPopupPosition = () =>
         {
             return(origin);
         };
         Notification notification = new Notification(origin, title, message);
         TaskbarIcon.ShowCustomBalloon(notification, PopupAnimation.Slide, null);
     }));
 }
Beispiel #4
0
        public void ShowSnapPane(bool animate = true)
        {
            if (m_ConnectTask == null)
            {
                return;
            }
            if (m_ConnectTask.Status == TaskStatus.Running || m_ConnectTask.Status == TaskStatus.WaitingForActivation)
            {
                // wait for it to complete...
                Task.Run(async() =>
                {
                    while (m_ConnectTask.Status == TaskStatus.Running || m_ConnectTask.Status == TaskStatus.WaitingForActivation)
                    {
                        await Task.Delay(10);
                    }
                    await Current.Dispatcher.BeginInvoke(new Action <bool>(ShowSnapPane), animate);
                }).ConfigureAwait(false);

                return;
            }

            if (m_SnapcastClient.ServerData == null)
            {
                ShowNotification("Connection error", string.Format("Unable to connect to snapserver at {0}:{1}", SnapSettings.Server, SnapSettings.ControlPort));
                return;
            }

            if (TaskbarIcon.CustomBalloon == null || TaskbarIcon.CustomBalloon.IsOpen == false)
            {
                Hardcodet.Wpf.TaskbarNotification.Interop.Point origin = TaskbarIcon.GetPopupTrayPosition();
                origin.Y += 9; // spawn it as close to the taskbar as we can
                TaskbarIcon.CustomPopupPosition = () =>
                {
                    return(origin);
                };
                SnapControl.SnapControl sc        = new SnapControl.SnapControl(origin, m_SnapcastClient);
                PopupAnimation          animation = animate ? PopupAnimation.Slide : PopupAnimation.None;
                TaskbarIcon.ShowCustomBalloon(sc, animation, null);
            }
            else
            {
                TaskbarIcon.CloseBalloon();
            }
        }
Beispiel #5
0
        public Notification(Hardcodet.Wpf.TaskbarNotification.Interop.Point origin, string title, string message)
        {
            InitializeComponent();
            m_Origin       = origin;
            tbTitle.Text   = title;
            tbMessage.Text = message;

            if (SnapSettings.NotificationBehaviour == SnapSettings.ENotificationBehaviour.AutoDismiss && SnapSettings.NotificationAutoDismissSeconds > 0)
            {
                m_Timer = new Timer(SnapSettings.NotificationAutoDismissSeconds * 1000);
                m_Timer.Start();
                m_Timer.Elapsed += (sender, args) =>
                {
                    Snapcast.TaskbarIcon.CloseBalloon();
                    m_Timer.Stop();
                    m_Timer = null;
                };
            }
        }
Beispiel #6
0
        public SnapControl(Hardcodet.Wpf.TaskbarNotification.Interop.Point origin, SnapDotNet.ControlClient.SnapcastClient client)
        {
            InitializeComponent();

            if (SnapSettings.SnapControlDismissMethod == SnapSettings.ESnapControlDismissMethod.ClickOutside)
            {
                Snapcast.HookEvents.MouseDownExt += global_MouseClick;
            }

            m_Origin         = origin;
            m_SnapcastClient = client;
            spGroups.Children.Clear();
            m_SnapcastClient.OnServerUpdated += () =>
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(_OnServerUpdated));
            };

            _OnServerUpdated();

            SnapSettings.OnThemeChanged += SnapSettings_OnThemeChanged;
        }