public static void GoBabyGo() { tempWindow = new MainWindow(); tempWindow.Show(); Application.Current.MainWindow.AddHandler(UIElement.PreviewMouseDownEvent, new MouseButtonEventHandler((o, e) => { FrameworkElement element = e.OriginalSource as FrameworkElement; if (element != null) { //Label l = new Label() { Content = PathToString(GenerateTypePath(GetNearestLogicalParent(element))) }; Label l = new Label() { Content = PathToString(GenerateTypePath(element)) }; DockPanel.SetDock(l, Dock.Top); tempWindow.MainStackPanel.Children.Add(l); } }), true); Application.Current.MainWindow.AddHandler(UIElement.PreviewMouseMoveEvent, new MouseEventHandler((o, e) => { FrameworkElement element = e.OriginalSource as FrameworkElement; if (element != null) { //element = GetNearestLogicalParent(element); if (element != adornedElement) { if (adornedElement != null) { AdornerLayer oldElementLayer = AdornerLayer.GetAdornerLayer(adornedElement); if (oldElementLayer != null) { Adorner[] toRemoveArray = oldElementLayer.GetAdorners(adornedElement); if (toRemoveArray != null) { foreach (Adorner a in toRemoveArray) { if (a is BorderAdorner) { oldElementLayer.Remove(a); } } } } } AdornerLayer layer = AdornerLayer.GetAdornerLayer(element); if (layer != null) { BorderAdorner ba = new BorderAdorner(element); ba.IsHitTestVisible = false; layer.Add(ba); } adornedElement = element; } } }), true); }
public static void GoBabyGo() { tempWindow = new MainWindow(); tempWindow.Show(); Application.Current.MainWindow.AddHandler(UIElement.PreviewMouseDownEvent, new MouseButtonEventHandler((o, e) => { FrameworkElement element = e.OriginalSource as FrameworkElement; if (element != null) { //Label l = new Label() { Content = PathToString(GenerateTypePath(GetNearestLogicalParent(element))) }; Label l = new Label() { Content = PathToString(GenerateTypePath(element)) }; DockPanel.SetDock(l, Dock.Top); tempWindow.MainStackPanel.Children.Add(l); } }), true); Application.Current.MainWindow.AddHandler(UIElement.PreviewMouseMoveEvent, new MouseEventHandler((o, e) => { FrameworkElement element = e.OriginalSource as FrameworkElement; if (element != null) { //element = GetNearestLogicalParent(element); if (element != adornedElement) { if (adornedElement != null) { AdornerLayer oldElementLayer = AdornerLayer.GetAdornerLayer(adornedElement); if (oldElementLayer != null) { Adorner[] toRemoveArray = oldElementLayer.GetAdorners(adornedElement); if (toRemoveArray != null) { foreach (Adorner a in toRemoveArray) { if (a is BorderAdorner) oldElementLayer.Remove(a); } } } } AdornerLayer layer = AdornerLayer.GetAdornerLayer(element); if (layer != null) { BorderAdorner ba = new BorderAdorner(element); ba.IsHitTestVisible = false; layer.Add(ba); } adornedElement = element; } } }), true); }