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); }
private void VerifyDockPosition(DockPattern pattern, DockPosition dockPosition) { Assert.AreEqual(dockPosition, pattern.Current.DockPosition, "DockPosition " + dockPosition); Assert.AreEqual(dockPosition, splitter1Element.GetCurrentPropertyValue(DockPattern.DockPositionProperty), "DockPositionProperty " + dockPosition); }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- public DockTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands) : base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Dock, dirResults, testEvents, commands) { m_pattern = (DockPattern)element.GetCurrentPattern(DockPattern.Pattern); if (m_pattern == null) { throw new Exception(Helpers.PatternNotSupported); } }
// </Snippet102> // <Snippet1025> ///-------------------------------------------------------------------- /// <summary> /// Gets the current view identifier from a target. /// </summary> /// <param name="dockPattern"> /// The control pattern of interest. /// </param> /// <returns> /// The current dock position. /// </returns> ///-------------------------------------------------------------------- private DockPosition GetCurrentDockPosition( DockPattern dockPattern) { if (dockPattern == null) { throw new ArgumentNullException( "DockPattern parameter must not be null."); } return(dockPattern.Current.DockPosition); }
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); }
public static bool TryGetDockPattern(this AutomationElement element, out DockPattern result) { if (element.TryGetCurrentPattern(System.Windows.Automation.DockPattern.Pattern, out var pattern)) { result = (DockPattern)pattern; return(true); } result = null; return(false); }
// </Snippet100> // <Snippet101> ///-------------------------------------------------------------------- /// <summary> /// Obtains a DockPattern control pattern from an /// automation element. /// </summary> /// <param name="targetControl"> /// The automation element of interest. /// </param> /// <returns> /// A DockPattern object. /// </returns> ///-------------------------------------------------------------------- private DockPattern GetDockPattern( AutomationElement targetControl) { DockPattern dockPattern = null; try { dockPattern = targetControl.GetCurrentPattern( DockPattern.Pattern) as DockPattern; } // Object doesn't support the DockPattern control pattern catch (InvalidOperationException) { return(null); } return(dockPattern); }
// </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 } }
public void PatternController(AutomationPattern pat, AutomationElement selectedItem, ListView listView2) { if (pat == ScrollPattern.Pattern) { ScrollPattern scrollPattern = selectedItem.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Scroll - not implemented"; lvi.Tag = new PatternInfo(1, 1, selectedItem, scrollPattern); listView2.Items.Add(lvi); } else if (pat == DockPattern.Pattern) { DockPattern dockPattern = selectedItem.GetCurrentPattern(DockPattern.Pattern) as DockPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "SetDockPosition - not implemented"; lvi.Tag = new PatternInfo(2, 1, selectedItem, dockPattern); listView2.Items.Add(lvi); } else if (pat == ExpandCollapsePattern.Pattern) { ExpandCollapsePattern expandCollapsePattern = selectedItem.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern; ListViewItem lvi1 = new ListViewItem(); lvi1.Content = "Expand"; lvi1.Tag = new PatternInfo(3, 1, selectedItem, expandCollapsePattern); listView2.Items.Add(lvi1); ListViewItem lvi2 = new ListViewItem(); lvi2.Content = "Collapse"; lvi2.Tag = new PatternInfo(3, 2, selectedItem, expandCollapsePattern); listView2.Items.Add(lvi2); } else if (pat == GridPattern.Pattern) { GridPattern gridPattern = selectedItem.GetCurrentPattern(GridPattern.Pattern) as GridPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "GetItem - not implemented"; lvi.Tag = new PatternInfo(4, 1, selectedItem, gridPattern); listView2.Items.Add(lvi); } else if (pat == GridItemPattern.Pattern) { } else if (pat == InvokePattern.Pattern) { InvokePattern invokePattern = selectedItem.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Invoke"; lvi.Tag = new PatternInfo(6, 1, selectedItem, invokePattern); listView2.Items.Add(lvi); } else if (pat == ItemContainerPattern.Pattern) { } else if (pat == MultipleViewPattern.Pattern) { } else if (pat == RangeValuePattern.Pattern) { RangeValuePattern rangeValuePattern = selectedItem.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "SetValue - not implemented"; lvi.Tag = new PatternInfo(9, 1, selectedItem, rangeValuePattern); listView2.Items.Add(lvi); } else if (pat == ScrollItemPattern.Pattern) { } else if (pat == SelectionItemPattern.Pattern) { } else if (pat == SelectionPattern.Pattern) { } else if (pat == SynchronizedInputPattern.Pattern) { } else if (pat == TextPattern.Pattern) { } else if (pat == TogglePattern.Pattern) { TogglePattern togglePattern = selectedItem.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Toggle"; lvi.Tag = new PatternInfo(15, 1, selectedItem, togglePattern); listView2.Items.Add(lvi); } else if (pat == TransformPattern.Pattern) { TransformPattern transformPattern = selectedItem.GetCurrentPattern(TransformPattern.Pattern) as TransformPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "Move - not implemented"; lvi.Tag = new PatternInfo(16, 1, selectedItem, transformPattern); listView2.Items.Add(lvi); ListViewItem lvi2 = new ListViewItem(); lvi2.Content = "Resize - not implemented"; lvi2.Tag = new PatternInfo(16, 2, selectedItem, transformPattern); listView2.Items.Add(lvi2); ListViewItem lvi3 = new ListViewItem(); lvi3.Content = "Rotate - not implemented"; lvi3.Tag = new PatternInfo(16, 3, selectedItem, transformPattern); listView2.Items.Add(lvi3); } else if (pat == ValuePattern.Pattern) { ValuePattern valuePattern = selectedItem.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "setValue"; lvi.Tag = new PatternInfo(17, 1, selectedItem, valuePattern); listView2.Items.Add(lvi); } else if (pat == VirtualizedItemPattern.Pattern) { } else if (pat == WindowPattern.Pattern) { WindowPattern windowPattern = selectedItem.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern; ListViewItem lvi = new ListViewItem(); lvi.Content = "SetWindowVisualState - not implemented"; lvi.Tag = new PatternInfo(19, 1, selectedItem, windowPattern); listView2.Items.Add(lvi); } else { listView2.Items.Add("else"); } }
public DockPatternPropertyObject(DockPattern dockPattern) { this._pattern = dockPattern; }
/// <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); }
/// <summary> /// Gets the current DockPosition of the control within a docking container. /// </summary> /// <param name="control">The UI Automation element</param> /// <returns> /// <see cref="DockPosition"/> /// </returns> internal static DockPosition GetDockPosition(AutomationElement control) { DockPattern pat = (DockPattern)CommonUIAPatternHelpers.CheckPatternSupport(DockPattern.Pattern, control); return(pat.Current.DockPosition); }