Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 internal static void SetFocus(ManagedContent m, Func <IInputElement> activeChildFunc, bool forceSetFocus = false)
 {
     m.Dispatcher.BeginInvoke(
         DispatcherPriority.Background,
         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);
         }
     }));
 }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
 internal void WriteState(TextWriter output)
 {
     output.WriteLine("AvalonDock: ActiveContent = " + WpfWorkbench.GetElementName(dockingManager.ActiveContent));
     output.WriteLine("AvalonDock: ActiveDocument = " + WpfWorkbench.GetElementName(dockingManager.ActiveDocument));
 }