public void ShowDrop()
{
// Wrong thread?
if (InvokeRequired)
{
Invoke(new MethodInvoker(() => ShowDrop()));
return;
}
// Somehow this can be run even when disposed...
if (IsDisposed)
{
return;
}
// Don't do anything if we're out of the taskbar with auto-hide
if (Taskbar.GetTaskbarState() == Taskbar.TaskbarState.AutoHide && !MouseInTaskbar())
{
Hide();
return;
}
// Now then...
lastNotifyIconPoint = _owner.GetLocation(false);
Hide();
// Point?
_owner.DropRefreshCallback(lastNotifyIconPoint.HasValue);
// Don't bother doing anything if we don't have a value
if (lastNotifyIconPoint.HasValue)
{
Point notifyIconLocation = lastNotifyIconPoint.Value;
// Stuff
Size taskbarSize = Taskbar.GetTaskbarSize();
Point taskbarLocation = Taskbar.GetTaskbarLocation();
// We've got a find, yessiree!
firstFind = true;
// Anyway, the task at hand; where does our drop zone go?
switch (Taskbar.GetTaskbarEdge())
{
case Taskbar.TaskbarEdge.Bottom:
Top = taskbarLocation.Y + 2;
Left = notifyIconLocation.X;
Width = 24;
Height = taskbarSize.Height;
break;
case Taskbar.TaskbarEdge.Top:
Top = -2;
Left = notifyIconLocation.X;
Width = 24;
Height = taskbarSize.Height;
break;
case Taskbar.TaskbarEdge.Left:
Top = notifyIconLocation.Y;
Left = -2;
Width = taskbarSize.Width;
Height = 24;
break;
case Taskbar.TaskbarEdge.Right:
Top = notifyIconLocation.Y;
Left = taskbarLocation.X + 2;
Width = taskbarSize.Width;
Height = 24;
break;
}
// We still want to show again even if we fail to find, but only if we've found it at least once!
if (firstFind)
{
// Post-disposal exception horror fix pt.2
try
{
Show();
TopMost = false;
}
catch { }
}
}
}