Пример #1
0
        private static void HandleShowBindingErrors(object sender, ExecutedRoutedEventArgs eventArgs)
        {
            PropertyInformation propertyInformation = (PropertyInformation)eventArgs.Parameter;
            Window window = new Window
            {
                Content = new TextBox
                {
                    IsReadOnly   = true,
                    Text         = propertyInformation.BindingError,
                    TextWrapping = TextWrapping.Wrap
                },
                Width  = 400,
                Height = 300,
                Title  = "Binding Errors for " + propertyInformation.DisplayName
            };

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(window);
            window.Closing +=
                (s, e) =>
            {
                Window w = (Window)s;
                SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(w);
            };
            window.Show();
        }
Пример #2
0
        private void HandleShowBindingErrors(object sender, ExecutedRoutedEventArgs eventArgs)
        {
            var propertyInformation = (PropertyInformation)eventArgs.Parameter;

            if (string.IsNullOrEmpty(propertyInformation.BindingError))
            {
                propertyInformation.UpdateBindingError();
            }

            var textBox = new TextBox
            {
                IsReadOnly             = true,
                IsReadOnlyCaretVisible = true,
                AcceptsReturn          = true,
                TextWrapping           = TextWrapping.Wrap
            };

            textBox.SetBinding(TextBox.TextProperty, new Binding(nameof(propertyInformation.BindingError))
            {
                Source = propertyInformation, Mode = BindingMode.OneWay
            });

            var window = new Window
            {
                Content = textBox,
                Width   = 400,
                Height  = 300,
                Title   = "Binding Errors for " + propertyInformation.DisplayName
            };

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(window);
            window.Show();
        }
Пример #3
0
        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);

            this.Owner = SnoopWindowUtils.FindOwnerWindow(this);

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);
            this.Dispatcher.UnhandledException += new DispatcherUnhandledExceptionEventHandler(UnhandledExceptionHandler);

            Show();
            Activate();
        }
Пример #4
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);
        }
Пример #5
0
        public SnoopBaseWindow()
        {
            this.InheritanceBehavior = InheritanceBehavior.SkipToThemeNext;
            this.SnapsToDevicePixels = true;
            this.Icon = new BitmapImage(new Uri("pack://application:,,,/Snoop.Core;component/Snoop.ico"));

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);
        }
Пример #6
0
        public void Magnify(object root)
        {
            this.Target = root;

            this.Owner = SnoopWindowUtils.FindOwnerWindow(this);

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);

            this.Show();
            this.Activate();
        }
Пример #7
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            this.Viewbox.Child = null;

            // persist the window placement details to the user settings.
            SnoopWindowUtils.SaveWindowPlacement(this, wp => Properties.Settings.Default.ZoomerWindowPlacement = wp);

            SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
        }
Пример #8
0
        public void Inspect(object rootToInspect)
        {
            this.Dispatcher.UnhandledException += this.UnhandledExceptionHandler;

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);

            this.Load(rootToInspect);

            this.Owner = SnoopWindowUtils.FindOwnerWindow(this);

            this.Show();
            this.Activate();
        }
Пример #9
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            this.Viewbox.Child = null;

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

            Win32.GetWindowPlacement(hwnd, out wp);

            SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
        }
Пример #10
0
        public void Inspect(object root, Window ownerWindow)
        {
            this.Dispatcher.UnhandledException += new DispatcherUnhandledExceptionEventHandler(UnhandledExceptionHandler);

            Load(root);

            if (ownerWindow != null)
            {
                this.Owner = ownerWindow;
            }

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);

            Show();
            Activate();
        }
Пример #11
0
        public void Magnify(object root)
        {
            Target = root;

            var ownerWindow = SnoopWindowUtils.FindOwnerWindow();

            if (ownerWindow != null)
            {
                Owner = ownerWindow;
            }

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);

            Show();
            Activate();
        }
Пример #12
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            Viewbox.Child = null;

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

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

            SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
        }
        private void SetFiltersWindow_Closed(object sender, EventArgs e)
        {
            if (_setFilterClicked || !this.ViewModel.IsDirty)
            {
                return;
            }

            var saveChanges = MessageBox.Show("Save changes?", "Changes", MessageBoxButton.YesNo) == MessageBoxResult.Yes;

            if (saveChanges)
            {
                this.ViewModel.SetIsSet();
                SaveFiltersToSettings();
                return;
            }

            SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
        }
Пример #14
0
        private void HandleShowBindingErrors(object sender, ExecutedRoutedEventArgs eventArgs)
        {
            var propertyInformation = (PropertyInformation)eventArgs.Parameter;
            var window  = new Window();
            var textbox = new TextBox
            {
                IsReadOnly   = true,
                Text         = propertyInformation.BindingError,
                TextWrapping = TextWrapping.Wrap
            };

            window.Content = textbox;
            window.Width   = 400;
            window.Height  = 300;
            window.Title   = "Binding Errors for " + propertyInformation.DisplayName;
            SnoopPartsRegistry.AddSnoopVisualTreeRoot(window);
            window.Show();
        }
Пример #15
0
        public void Inspect()
        {
            object localRoot = FindRoot();

            if (localRoot == 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(localRoot);

            Window ownerWindow = SnoopWindowUtils.FindOwnerWindow();

            if (ownerWindow != null)
            {
                if (ownerWindow.Dispatcher != Dispatcher)
                {
                    return;
                }
                Owner = ownerWindow;

                // watch for window closing so we can spit out the changed properties
                ownerWindow.Closing += SnoopedWindowClosingHandler;
            }

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);
            Dispatcher.UnhandledException += UnhandledExceptionHandler;

            Show();
            Activate();
        }
Пример #16
0
        public void Inspect(object root, Window ownerWindow)
        {
            this.Dispatcher.UnhandledException += new DispatcherUnhandledExceptionEventHandler(UnhandledExceptionHandler);

            Load(root);

            if (ownerWindow != null)
            {
                this.Owner = ownerWindow;

                // watch for window closing so we can spit out the changed properties
                ownerWindow.Closing += SnoopedWindowClosingHandler;
            }

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);

            Show();
            Activate();
        }
Пример #17
0
        private void HandleShowBindingErrors(object sender, ExecutedRoutedEventArgs eventArgs)
        {
            PropertyInformation propertyInformation = (PropertyInformation)eventArgs.Parameter;
            Window  window  = new Window();
            TextBox textbox = new TextBox();

            textbox.IsReadOnly   = true;
            textbox.Text         = propertyInformation.BindingError;
            textbox.TextWrapping = TextWrapping.Wrap;
            window.Content       = textbox;
            window.Width         = 400;
            window.Height        = 300;
            window.Title         = "Binding Errors for " + propertyInformation.DisplayName;
            SnoopPartsRegistry.AddSnoopVisualTreeRoot(window);
            window.Closing +=
                (s, e) =>
            {
                Window w = (Window)s;
                SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(w);
            };
            window.Show();
        }
Пример #18
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);
        }
Пример #19
0
        private void ErrorDialog_Loaded(object sender, RoutedEventArgs e)
        {
            TextBlockException.Text = GetExceptionMessage();

            SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);
        }
Пример #20
0
 private void ErrorDialog_Closed(object sender, EventArgs e)
 {
     SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(this);
 }
 private void SetFiltersWindow_Loaded(object sender, RoutedEventArgs e)
 {
     SnoopPartsRegistry.AddSnoopVisualTreeRoot(this);
 }