private static DependencyObject FindChild(DependencyObject parent, string childName) { if (parent == null) { return(null); } int childrenCount = VisualTreeHelper.GetChildrenCount(parent); for (int i = 0; i < childrenCount; i++) { DependencyObject child = VisualTreeHelper.GetChild(parent, i); FrameworkElement frameworkElement = child as FrameworkElement; if (frameworkElement != null && frameworkElement.Name == childName) { return(frameworkElement); } child = StatusBarInjector.FindChild(child, childName); if (child != null) { return(child); } } return(null); }
private CommandHandler(DTE2 dte, Options options) { _options = options; _dte = dte; _control = new StatusbarControl(options, _dte); _events = _dte.Events.CommandEvents; _events.AfterExecute += AfterExecute; _events.BeforeExecute += BeforeExecute; var injector = new StatusBarInjector(Application.Current.MainWindow); injector.InjectControl(_control); _timer = new Timer(); _timer.Elapsed += (s, e) => { _timer.Stop(); _control.SetVisibility(Visibility.Collapsed); }; _options.Saved += (s, e) => { SetTimeout(); if (!_options.LogToStatusBar) _control.SetVisibility(Visibility.Collapsed); if (!_options.LogToOutputWindow) Logger.DeletePane(); }; SetTimeout(); }
private CommandHandler(DTE2 dte, Options options) { ThreadHelper.ThrowIfNotOnUIThread(); _options = options; _dte = dte; _control = new StatusbarControl(options, _dte); _events = _dte.Events.CommandEvents; _events.AfterExecute += AfterExecute; _events.BeforeExecute += BeforeExecute; StatusBarInjector injector = new StatusBarInjector(Application.Current.MainWindow); injector.InjectControlAsync(_control).ConfigureAwait(false); _timer = new Timer(); _timer.Elapsed += (s, e) => { _timer.Stop(); _control.SetVisibilityAsync(Visibility.Collapsed).ConfigureAwait(false); }; _options.Saved += (s, e) => { SetTimeout(); if (!_options.LogToStatusBar) { _control.SetVisibilityAsync(Visibility.Collapsed).ConfigureAwait(false); } if (!_options.LogToOutputWindow) { Logger.DeletePaneAsync().ConfigureAwait(false); } }; SetTimeout(); }
private void FindStatusBar() { _statusBar = StatusBarInjector.FindChild(_window, "StatusBarContainer") as FrameworkElement; _panel = _statusBar.Parent as DockPanel; }
private void FindStatusBar() { this.statusBar = StatusBarInjector.FindChild(this.window, "StatusBarContainer") as FrameworkElement; this.panel = this.statusBar.Parent as DockPanel; }