Ejemplo n.º 1
0
        /// <summary>
        /// Cleanup when closing the window.
        /// </summary>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            this.CurrentSelection = null;

            InputManager.Current.PreProcessInput -= this.HandlePreProcessInput;
            EventsListener.Stop();

            // persist the window placement details to the user settings.
            WINDOWPLACEMENT wp   = new WINDOWPLACEMENT();
            IntPtr          hwnd = new WindowInteropHelper(this).Handle;

            Win32.GetWindowPlacement(hwnd, out wp);
            Properties.Settings.Default.SnoopUIWindowPlacement = wp;

            // persist whether all properties are shown by default
            Properties.Settings.Default.ShowDefaults = this.PropertyGrid.ShowDefaults;

            // persist whether the previewer is shown by default
            Properties.Settings.Default.ShowPreviewer = this.PreviewArea.IsActive;

            // actually do the persisting
            Properties.Settings.Default.Save();

            SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
        }
Ejemplo n.º 2
0
        public EventsListener(Visual visual)
        {
            current     = this;
            this.visual = visual;

            var type = visual.GetType();

            // Cannot unregister for events once we've registered, so keep the registration simple and only do it once.
            for (var baseType = type; baseType != null; baseType = baseType.BaseType)
            {
                if (!registeredTypes.ContainsKey(baseType))
                {
                    registeredTypes[baseType] = baseType;

                    var routedEvents = EventManager.GetRoutedEventsForOwner(baseType);
                    if (routedEvents != null)
                    {
                        foreach (var routedEvent in routedEvents)
                        {
                            EventManager.RegisterClassHandler(baseType, routedEvent, new RoutedEventHandler(HandleEvent),
                                                              true);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Cleanup when closing the window.
        /// </summary>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            // unsubscribe to owner window closing event
            // replaces previous attempts to hookup to MainWindow.Closing on the wrong dispatcher thread
            // This one should be running on the right dispatcher thread since this SnoopUI instance
            // is wired up to the dispatcher thread/window that it owns
            if (Owner != null)
            {
                Owner.Closing -= SnoopedWindowClosingHandler;
            }

            this.CurrentSelection = null;

            InputManager.Current.PreProcessInput -= this.HandlePreProcessInput;
            EventsListener.Stop();

            EditedPropertiesHelper.DumpObjectsWithEditedProperties();

            // persist the window placement details to the user settings.
            WINDOWPLACEMENT wp   = new WINDOWPLACEMENT();
            IntPtr          hwnd = new WindowInteropHelper(this).Handle;

            Win32.GetWindowPlacement(hwnd, out wp);
            Properties.Settings.Default.SnoopUIWindowPlacement = wp;

            // persist whether all properties are shown by default
            Properties.Settings.Default.ShowDefaults = this.PropertyGrid.ShowDefaults;

            // persist whether the previewer is shown by default
            Properties.Settings.Default.ShowPreviewer = this.PreviewArea.IsActive;

            // actually do the persisting
            Properties.Settings.Default.Save();

            SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
        }
Ejemplo n.º 4
0
        public EventsListener(Visual visual)
        {
            EventsListener.current = this;
            this.visual = visual;

            Type type = visual.GetType();

            // Cannot unregister for events once we've registered, so keep the registration simple and only do it once.
            for (Type baseType = type; baseType != null; baseType = baseType.BaseType)
            {
                if (!registeredTypes.ContainsKey(baseType))
                {
                    registeredTypes[baseType] = baseType;

                    RoutedEvent[] routedEvents = EventManager.GetRoutedEventsForOwner(baseType);
                    if (routedEvents != null)
                    {
                        foreach (RoutedEvent routedEvent in routedEvents)
                            EventManager.RegisterClassHandler(baseType, routedEvent, new RoutedEventHandler(EventsListener.HandleEvent), true);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public static void Stop()
 {
     EventsListener.current = null;
 }
Ejemplo n.º 6
0
 public static void Stop()
 {
     current = null;
 }