public void Inspect()
{
object root = FindRoot();
if (root == null)
{
if (!SnoopModes.MultipleDispatcherMode)
{
//SnoopModes.MultipleDispatcherMode is always false for all scenarios except for cases where we are running multiple dispatchers.
//If SnoopModes.MultipleDispatcherMode was set to true, then there definitely was a root visual found in another dispatcher, so
//the message below would be wrong.
MessageBox.Show
(
"Can't find a current application or a PresentationSource root visual!",
"Can't Snoop",
MessageBoxButton.OK,
MessageBoxImage.Exclamation
);
}
return;
}
Load(root);
Window ownerWindow = SnoopWindowUtils.FindOwnerWindow();
if (ownerWindow != null)
{
if (ownerWindow.Dispatcher != this.Dispatcher)
{
return;
}
this.Owner = ownerWindow;
}
SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);
this.Dispatcher.UnhandledException += new DispatcherUnhandledExceptionEventHandler(UnhandledExceptionHandler);
Show();
Activate();
}