static void InitializeWorkbench(WpfWorkbench workbench, IWorkbenchLayout layout) { SD.Services.AddService(typeof(IWorkbench), workbench); UILanguageService.ValidateLanguage(); TaskService.Initialize(); Project.CustomToolsService.Initialize(); workbench.Initialize(); workbench.SetMemento(SD.PropertyService.NestedProperties(workbenchMemento)); workbench.WorkbenchLayout = layout; // HACK: eagerly load output pad because pad services cannnot be instanciated from background threads SD.Services.AddService(typeof(IOutputPad), CompilerMessageView.Instance); var dlgMsgService = SD.MessageService as IDialogMessageService; if (dlgMsgService != null) { dlgMsgService.DialogSynchronizeInvoke = SD.MainThread.SynchronizingObject; dlgMsgService.DialogOwner = workbench.MainWin32Window; } var applicationStateInfoService = SD.GetService <ApplicationStateInfoService>(); if (applicationStateInfoService != null) { applicationStateInfoService.RegisterStateGetter(activeContentState, delegate { return(SD.Workbench.ActiveContent); }); } WorkbenchSingleton.OnWorkbenchCreated(); // initialize workbench-dependent services: NavigationService.InitializeService(); workbench.ActiveContentChanged += delegate { Debug.WriteLine("ActiveContentChanged to " + workbench.ActiveContent); LoggingService.Debug("ActiveContentChanged to " + workbench.ActiveContent); }; workbench.ActiveViewContentChanged += delegate { Debug.WriteLine("ActiveViewContentChanged to " + workbench.ActiveViewContent); LoggingService.Debug("ActiveViewContentChanged to " + workbench.ActiveViewContent); }; workbench.ActiveWorkbenchWindowChanged += delegate { Debug.WriteLine("ActiveWorkbenchWindowChanged to " + workbench.ActiveWorkbenchWindow); LoggingService.Debug("ActiveWorkbenchWindowChanged to " + workbench.ActiveWorkbenchWindow); }; }
protected override void FocusContent() { WpfWorkbench.FocusDebug("{0}.FocusContent() IsActiveContent={1} IsKeyboardFocusWithin={2} Keyboard.FocusedElement={3}", Title, IsActiveContent, IsKeyboardFocusWithin, Keyboard.FocusedElement); if (!(IsActiveContent && !IsKeyboardFocusWithin)) { return; } IInputElement activeChild = CustomFocusManager.GetFocusedChild(this); WpfWorkbench.FocusDebug("{0}.FocusContent() - Will move focus (activeChild={1})", this.Title, activeChild); // use lambda for fetching the active child - this is necessary because the ActiveViewContent might change until the background // action is called AvalonWorkbenchWindow.SetFocus(this, () => activeChild ?? (ActiveViewContent != null ? ActiveViewContent.InitiallyFocusedControl as IInputElement : null)); }
void dockingManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "ActiveContent") { WpfWorkbench.FocusDebug("AvalonDock: ActiveContent changed to {0}", WpfWorkbench.GetElementName(dockingManager.ActiveContent)); if (ActiveContentChanged != null) { ActiveContentChanged(this, e); } CommandManager.InvalidateRequerySuggested(); } else if (e.PropertyName == "ActiveDocument") { WpfWorkbench.FocusDebug("AvalonDock: ActiveDocument changed to {0}", WpfWorkbench.GetElementName(dockingManager.ActiveDocument)); if (ActiveWorkbenchWindowChanged != null) { ActiveWorkbenchWindowChanged(this, e); } CommandManager.InvalidateRequerySuggested(); } }
public void Attach(IWorkbench workbench) { if (this.workbench != null) { throw new InvalidOperationException("Can attach only once!"); } this.workbench = (WpfWorkbench)workbench; this.workbench.mainContent.Content = dockingManager; CommandManager.AddCanExecuteHandler(this.workbench, OnCanExecuteRoutedCommand); CommandManager.AddExecutedHandler(this.workbench, OnExecuteRoutedCommand); Busy = true; try { foreach (PadDescriptor pd in workbench.PadContentCollection) { ShowPad(pd); } } finally { Busy = false; } LoadConfiguration(); EnsureFloatingWindowsLocations(); }
internal static void SetFocus(ManagedContent m, Func <IInputElement> activeChildFunc, bool forceSetFocus = false) { m.Dispatcher.BeginInvoke( DispatcherPriority.Loaded, new Action( delegate { // ensure that condition for FocusContent() is still fulfilled // (necessary to avoid focus switching loops when changing layouts) if (!forceSetFocus && !(m.IsActiveContent && !m.IsKeyboardFocusWithin)) { WpfWorkbench.FocusDebug("{0} - not moving focus (IsActiveContent={1}, IsKeyboardFocusWithin={2})", m.Title, m.IsActiveContent, m.IsKeyboardFocusWithin); return; } IInputElement activeChild = activeChildFunc(); WpfWorkbench.FocusDebug("{0} - moving focus to: {1}", m.Title, activeChild != null ? activeChild.ToString() : "<null>"); if (activeChild != null) { Keyboard.Focus(activeChild); } })); }
internal void WriteState(TextWriter output) { output.WriteLine("AvalonDock: ActiveContent = " + WpfWorkbench.GetElementName(dockingManager.ActiveContent)); output.WriteLine("AvalonDock: ActiveDocument = " + WpfWorkbench.GetElementName(dockingManager.ActiveDocument)); }