Пример #1
0
 public static void Main(string[] args)
 {
     Application.Init ();
     MainWindow win = new MainWindow ();
     win.Show ();
     Application.Run ();
 }
Пример #2
0
        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);
        }