Esempio n. 1
0
        private void CopyPropertyChangesHandler(object sender, ExecutedRoutedEventArgs e)
        {
            if (_currentSelection != null)
            {
                SaveEditedProperties(_currentSelection);
            }

            EditedPropertiesHelper.DumpObjectsWithEditedProperties();
        }
Esempio n. 2
0
 /// <summary>
 /// Loop through the properties in the current PropertyGrid and save away any properties
 /// that have been changed by the user.
 /// </summary>
 /// <param name="owningObject">currently selected object that owns the properties in the grid (before changing selection to the new object)</param>
 private void SaveEditedProperties(VisualTreeItem owningObject)
 {
     foreach (PropertyInformation property in PropertyGrid.PropertyGrid.Properties)
     {
         if (property.IsValueChangedByUser)
         {
             EditedPropertiesHelper.AddEditedProperty(Dispatcher, owningObject, property);
         }
     }
 }
Esempio 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;
            }

            CurrentSelection = null;

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

            EditedPropertiesHelper.DumpObjectsWithEditedProperties();

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

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

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

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

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

            SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
        }
Esempio n. 4
0
 /// <summary>
 /// Event handler for a snooped window closing. This is our chance to spit out
 /// all the properties that changed during the snoop session for that window.
 /// Note: there may be multiple snooped windows (when in multiple dispatcher mode)
 /// and each window is hooked up to it's own instance of SnoopUI and this event.
 /// </summary>
 private void SnoopedWindowClosingHandler(object sender, CancelEventArgs e)
 {
     // changing the selection captures any changes in the selected item at the time of window closing
     CurrentSelection = null;
     EditedPropertiesHelper.DumpObjectsWithEditedProperties();
 }