public void DockPositionTest() { DockPattern dockPattern = (DockPattern)splitter1Element.GetCurrentPattern(DockPattern.Pattern); VerifyDockPosition(dockPattern, DockPosition.Left); dockPattern.SetDockPosition(DockPosition.Top); Thread.Sleep(200); VerifyDockPosition(dockPattern, DockPosition.Top); dockPattern.SetDockPosition(DockPosition.Right); Thread.Sleep(200); VerifyDockPosition(dockPattern, DockPosition.Right); dockPattern.SetDockPosition(DockPosition.Bottom); Thread.Sleep(200); VerifyDockPosition(dockPattern, DockPosition.Bottom); dockPattern.SetDockPosition(DockPosition.Left); Thread.Sleep(200); VerifyDockPosition(dockPattern, DockPosition.Left); RunCommand("set splitter dock top"); VerifyDockPosition(dockPattern, DockPosition.Top); RunCommand("set splitter dock right"); VerifyDockPosition(dockPattern, DockPosition.Right); RunCommand("set splitter dock bottom"); VerifyDockPosition(dockPattern, DockPosition.Bottom); RunCommand("set splitter dock left"); VerifyDockPosition(dockPattern, DockPosition.Left); }
public void SetDockPosition(DockPosition position, bool log) { if (log) { procedureLogger.Action(string.Format("Dock {0} to {1}.", this.NameAndType, position)); } DockPattern dp = (DockPattern)element.GetCurrentPattern(DockPattern.Pattern); dp.SetDockPosition(position); }
// </Snippet1025> // <Snippet103> ///-------------------------------------------------------------------- /// <summary> /// Sets the dock position of a target. /// </summary> /// <param name="dockControl"> /// The automation element of interest. /// </param> /// <param name="dockPosition"> /// The requested DockPosition. /// </param> ///-------------------------------------------------------------------- private void SetDockPositionOfControl( AutomationElement dockControl, DockPosition dockPosition) { if (dockControl == null) { throw new ArgumentNullException( "AutomationElement parameter must not be null."); } try { DockPattern dockPattern = GetDockPattern(dockControl); if (dockPattern == null) { return; } dockPattern.SetDockPosition(dockPosition); } catch (InvalidOperationException) { // When a control is not able to dock. // TO DO: error handling } }
/// <summary> /// Docks the control within a docking container. /// </summary> /// <param name="control">The UI Automation element</param> /// <param name="dockPosition">The <see cref="DockPosition"/>.</param> internal static void SetDockPosition(AutomationElement control, DockPosition dockPosition) { DockPattern pat = (DockPattern)CommonUIAPatternHelpers.CheckPatternSupport(DockPattern.Pattern, control); pat.SetDockPosition(dockPosition); }