public static void InitializeAssembly(TestContext testContext) { TestLogUtils.InitializeLog(testContext); // Force LoggingExtensions class initialization. using (LoggingExtensions.Indent()) { } FrameworkElementFormatter.GetInstance().SetTypeFormatter(typeof(DataGridRow), new DataGridRowFormatter()); }
private void UpdateCurrentCell() { using (LoggingExtensions.Indent()) { log.Debug("Updating current cell info"); var cell = GetCurrentCell(); if (!cell.IsUndefined) { CurrentCell = CurrentRowCellEnumerationService.GetCellInfo(currentCellPosition.GetCurrentCellIndex(CurrentRowCellEnumerationService)); } } }
public void UpdateFocus() { if (focusDeferCount > 0) { hasPendingFocus = true; return; } hasPendingFocus = false; if (!TargetElement.IsKeyboardFocusWithin) { log.DebugFormat("Ignoring UpdateFocus() request on {0}, because it does not have keyboard focus.", TargetElement); return; } log.DebugFormat("Begin updating focus on {0}", TargetElement); if (nextFocusUpdateOperation != null) { nextFocusUpdateOperation.Abort(); } IsRestoringFocusOnElement = isRestoringState.IsSet; nextFocusUpdateOperation = TargetElement.Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => { using (new DisposalActionCaller(() => IsRestoringFocusOnElement = false)) { log.DebugFormat("Updating focus on {0}", TargetElement); using (LoggingExtensions.Indent()) { //IElementEditStateService editStateService = null; //if (currentCellService.CurrentItemContainer != null) // editStateService = UIServiceProvider.GetService<IElementEditStateService>(currentCellService.CurrentItemContainer, false); //if (editStateService == null) // editStateService = UIServiceProvider.GetService<IElementEditStateService>(TargetElement); var elementToFocus = currentCellService.CurrentCellContainer; if (elementToFocus == null) { return; } if (elementToFocus.IsFocused) { log.DebugFormat("The cell {0} is already in focus.", elementToFocus); return; } var vte = VisualTreeHelpers.GetVisualTreeEnumerator(elementToFocus, (v) => { return((v is UIElement) && ((UIElement)v).Focusable); }, FocusNavigationDirection.Next); while (vte.MoveNext()) { elementToFocus = vte.Current as FrameworkElement; } log.DebugFormat("Trying to set focus on element {0}", elementToFocus); using (isUpdatingFocus.Set()) { bool isFocused = elementToFocus.Focus(); log.DebugFormat("Focus result: {0}, Focused element is {1}", isFocused, Keyboard.FocusedElement); } isFirstFocus = false; nextFocusUpdateOperation = null; } } })); }