Beispiel #1
0
        public Point?GetLocation(int accuracy, bool tryReturnIfHidden)
        {
            // Try using APIs first
            Rectangle rect = NotifyIconHelpers.GetNotifyIconRectangle(NotifyIcon, tryReturnIfHidden);

            if (!rect.IsEmpty)
            {
                return(rect.Location);
            }

            // Don't fallback if the icon isn't visible
            if (!tryReturnIfHidden)
            {
                Rectangle rect2 = NotifyIconHelpers.GetNotifyIconRectangle(NotifyIcon, true);
                if (rect2.IsEmpty)
                {
                    return(null);
                }
            }

            // Ugly fallback time :(
            var   finder = new Zhwang.SuperNotifyIcon.Finder.NotifyIconColorFinder(NotifyIcon);
            Point?point  = finder.GetLocation(accuracy);

            if (point.HasValue)
            {
                return(point);
            }

            return(null);
        }
Beispiel #2
0
        public Point? GetLocation(int accuracy, bool tryReturnIfHidden)
        {
            // Try using APIs first
            Rectangle rect = NotifyIconHelpers.GetNotifyIconRectangle(NotifyIcon, tryReturnIfHidden);
            if (!rect.IsEmpty)
                return rect.Location;

            // Don't fallback if the icon isn't visible
            if (!tryReturnIfHidden)
            {
                Rectangle rect2 = NotifyIconHelpers.GetNotifyIconRectangle(NotifyIcon, true);
                if (rect2.IsEmpty)
                    return null;
            }

            // Ugly fallback time :(
            var finder = new Zhwang.SuperNotifyIcon.Finder.NotifyIconColorFinder(NotifyIcon);
            Point? point = finder.GetLocation(accuracy);
            if (point.HasValue)
                return point;

            return null;
        }