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); }
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; }