/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component, string value) { if (!string.IsNullOrEmpty(value)) { component.Scope.SendKeysWithLogging(value); } }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component) { var scopeElement = component.Scope; component.Owner.Driver.Perform( x => x.MoveToElement(scopeElement, OffsetX, OffsetY, OffsetKind)); }
/// <summary> /// Sets the insets of a component from its anchor points. A positive number insets the /// component away from the edge, whereas a negative number out-sets the component /// across the edge. /// /// All components default to no insets. /// /// Any reference to a component's edge using other constraints always refers to its /// edge <b>before</b> insets are applied. /// </summary> /// <param name="item">The component to adjust.</param> /// <param name="insets">The insets to apply. If null, the insets will be set to zero.</param> /// <returns>This object, for call chaining.</returns> public PRelativePanel SetMargin(IUIComponent item, RectOffset insets) { if (item != null) { GetOrThrow(item).Insets = insets; } return(this); }
public override string Execute <TOwner>(IUIComponent <TOwner> component) { return(Source.HasValue ? ContentExtractor.Get(component, Source.Value) : !string.IsNullOrWhiteSpace(AttributeName) ? component.Attributes[AttributeName] : throw new InvalidOperationException($"Cannot execute as none of {Source} or {AttributeName} properties is set.")); }
public static string UIComponentToString(this IUIComponent component) { return($@" Properties {component.Properties}. Color : {component.Color} Html : {component.Html} "); }
/// <summary> /// Overrides the preferred size of a component. If set, instead of looking at layout /// sizes of the component, the specified size will be used instead. /// </summary> /// <param name="item">The component to adjust.</param> /// <param name="size">The size to apply. Only dimensions greater than zero will be used.</param> /// <returns>This object, for call chaining.</returns> public PRelativePanel OverrideSize(IUIComponent item, Vector2 size) { if (item != null) { GetOrThrow(item).OverrideSize = size; } return(this); }
/// <summary> /// Adds a child to this panel. /// </summary> /// <param name="child">The child to add.</param> /// <returns>This panel for call chaining.</returns> public PPanel AddChild(IUIComponent child) { if (child == null) { throw new ArgumentNullException("child"); } children.Add(child); return(this); }
private static IUIComponent CheckGroup(IUIComponent check, IUIComponent rest) { return(new PRelativePanel("Align") { FlexSize = Vector2.right }.AddChild(check).AddChild(rest).AnchorYAxis(check, 0.5f).AnchorYAxis(rest, 0.5f). SetLeftEdge(check, fraction: 0.0f).SetLeftEdge(rest, toRight: check). SetRightEdge(rest, fraction: 1.0f).SetMargin(check, new RectOffset(0, 5, 0, 0))); }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component) { var scopeElement = component.Scope; component.Owner.Driver.Perform(x => x .KeyDown(scopeElement, Keys.Control) .SendKeys("a") .KeyUp(Keys.Control) .SendKeys(Keys.Delete)); }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component) { try { component.Scope.ClearWithLogging(); } catch (InvalidElementStateException) { component.Script.SetValueAndDispatchChangeEvent(string.Empty); } }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component) { var scopeElement = component.Scope; component.Owner.Driver.Perform(x => x .SendKeys(scopeElement, Keys.Home) .KeyDown(Keys.Shift) .SendKeys(Keys.End) .KeyUp(Keys.Shift) .SendKeys(Keys.Delete)); }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component, string value) { var scopeElement = component.Scope; scopeElement.ClearWithLogging(); if (!string.IsNullOrEmpty(value)) { scopeElement.SendKeysWithLogging(value); } }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component) { var cellControl = component.Find <Control <TOwner> >( new ControlDefinitionAttribute("td") { ComponentTypeName = "cell" }, new FindByIndexAttribute(Index)); cellControl.Click(); }
/// <summary> /// Switches to frame represented by <paramref name="component"/> parameter. /// </summary> /// <param name="component">The component representing frame element.</param> /// <returns>The instance of this page object.</returns> public TOwner SwitchToFrame(IUIComponent <TOwner> component) { string message = component is Frame <TOwner> ?$"Switch to {component.ComponentFullName}" : $"Switch to frame of {component.ComponentFullName}"; Log.ExecuteSection( new LogSection(message, LogLevel.Trace), (Action)(() => SwitchToFrame(component.Scope))); return((TOwner)this); }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component, string value) { if (!string.IsNullOrEmpty(value)) { component.Context.UIComponentAccessChainScopeCache.ExecuteWithin(() => { component.ExecuteBehavior <FocusBehaviorAttribute>(x => x.Execute(component)); base.Execute(component, value); }); } }
public static Control <TOwner> GetChildControl <TOwner>(IUIComponent <TOwner> parent, string controlName) where TOwner : PageObject <TOwner> { PropertyInfo property = typeof(TOwner).GetPropertyWithThrowOnError(controlName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty); if (!property.PropertyType.IsSubclassOfRawGeneric(typeof(Control <>))) { throw new InvalidOperationException($"Incorrect type of \"{controlName}\" property."); } return((Control <TOwner>)property.GetValue(parent)); }
/// <summary> /// Retrieves the constraints for a component, or throws an exception if the component /// has not yet been added. /// </summary> /// <param name="item">The unrealized component to look up.</param> /// <returns>The constraints for that component.</returns> /// <exception cref="ArgumentException">If the component has not yet been added to the panel.</exception> private RelativeConfig GetOrThrow(IUIComponent item) { if (item == null) { throw new ArgumentNullException("item"); } if (!constraints.TryGetValue(item, out RelativeConfig value)) { throw new ArgumentException("Components must be added to the panel before using them in a constraint"); } return(value); }
/// <summary> /// Adds a child to this panel. Children must be added to the panel before they are /// referenced in a constraint. /// </summary> /// <param name="child">The child to add.</param> /// <returns>This panel for call chaining.</returns> public PRelativePanel AddChild(IUIComponent child) { if (child == null) { throw new ArgumentNullException("child"); } if (!constraints.ContainsKey(child)) { constraints.Add(child, new RelativeConfig()); } return(this); }
/// <summary> /// Adds a child to this panel. /// </summary> /// <param name="child">The child to add.</param> /// <param name="spec">The location where the child will be placed.</param> /// <returns>This panel for call chaining.</returns> public PGridPanel AddChild(IUIComponent child, GridComponentSpec spec) { if (child == null) { throw new ArgumentNullException("child"); } if (spec == null) { throw new ArgumentNullException("spec"); } children.Add(new GridComponent <IUIComponent>(spec, child)); return(this); }
/// <summary> /// Sets the top edge of a game object. If the fraction is supplied, the component /// will be laid out with the top edge anchored to that fraction of the parent's /// height. If a component is specified and no fraction is specified, the component /// will be anchored with its top edge above the bottom edge of that component. /// If neither is specified, all top edge constraints will be removed. /// /// Any other existing top edge constraint will be overwritten. /// /// Remember that +Y is in the upwards direction. /// </summary> /// <param name="item">The component to adjust.</param> /// <param name="fraction">The fraction to which to align the top edge, with 0.0f /// being the bottom and 1.0f being the top.</param> /// <param name="below">The game object which this component must be below.</param> /// <returns>This object, for call chaining.</returns> public PRelativePanel SetTopEdge(IUIComponent item, float fraction = -1.0f, IUIComponent below = null) { if (item != null) { if (below == item) { throw new ArgumentException("Component cannot refer directly to itself"); } SetEdge(GetOrThrow(item).TopEdge, fraction, below); } return(this); }
/// <summary> /// Sets the right edge of a game object. If the fraction is supplied, the component /// will be laid out with the right edge anchored to that fraction of the parent's /// width. If a component is specified and no fraction is specified, the component /// will be anchored with its right edge to the left of that component. /// If neither is specified, all right edge constraints will be removed. /// /// Any other existing right edge constraint will be overwritten. /// </summary> /// <param name="item">The component to adjust.</param> /// <param name="fraction">The fraction to which to align the right edge, with 0.0f /// being the left and 1.0f being the right.</param> /// <param name="toLeft">The game object which this component must be to the left of.</param> /// <returns>This object, for call chaining.</returns> public PRelativePanel SetRightEdge(IUIComponent item, float fraction = -1.0f, IUIComponent toLeft = null) { if (item != null) { if (toLeft == item) { throw new ArgumentException("Component cannot refer directly to itself"); } SetEdge(GetOrThrow(item).RightEdge, fraction, toLeft); } return(this); }
/// <summary> /// Sets the bottom edge of a game object. If the fraction is supplied, the component /// will be laid out with the bottom edge anchored to that fraction of the parent's /// height. If a component is specified and no fraction is specified, the component /// will be anchored with its bottom edge above the top edge of that component. /// If neither is specified, all bottom edge constraints will be removed. /// /// Any other existing bottom edge constraint will be overwritten. /// /// Remember that +Y is in the upwards direction. /// </summary> /// <param name="item">The component to adjust.</param> /// <param name="fraction">The fraction to which to align the bottom edge, with 0.0f /// being the bottom and 1.0f being the top.</param> /// <param name="above">The game object which this component must be above.</param> /// <returns>This object, for call chaining.</returns> public PRelativePanel SetBottomEdge(IUIComponent item, float fraction = -1.0f, IUIComponent above = null) { if (item != null) { if (above == item) { throw new ArgumentException("Component cannot refer directly to itself"); } SetEdge(GetOrThrow(item).BottomEdge, fraction, above); } return(this); }
internal static TOwner WaitForCssTransitionEnd <TOwner>(this IUIComponent <TOwner> component, string transitionName, RetryOptions waitingOptions, SearchOptions searchOptions = null) where TOwner : PageObject <TOwner> { if (waitingOptions?.Timeout > TimeSpan.Zero) { AtataContext.Current.Log.Start($"Wait for {component.ComponentFullName} \"{transitionName}\" CSS transition completion", LogLevel.Trace); IWebElement element = searchOptions == null ? component.Scope : component.GetScope(searchOptions); element?.Try().Until(HasNoCssTransition, waitingOptions); AtataContext.Current.Log.EndSection(); } return(component.Owner); }
public override void Execute <TOwner>(IUIComponent <TOwner> component, string value) { var scopeElement = component.Scope; scopeElement.ClickWithLogging(); if (!string.IsNullOrEmpty(value)) { foreach (char character in value) { component.Owner.Wait(TypingIntervalInSeconds); scopeElement.SendKeysWithLogging(character.ToString()); } } }
internal static void AddRow(this PGridPanel panel, string rowTitle, IUIComponent text) { int row = panel.Rows; panel.AddRow(new GridRowSpec()).AddChild(new PLabel() { Text = rowTitle, Margin = ROW_MARGIN }, new GridComponentSpec(row, 0) { Alignment = TextAnchor.MiddleRight, Margin = new RectOffset(0, 5, 0, 0) }).AddChild(text, new GridComponentSpec(row, 1) { Alignment = TextAnchor.UpperLeft, Margin = ROW_MARGIN }); }
/// <summary> /// Creates a default UI entry. This entry will have the title and tool tip in the /// first column, and the provided UI component in the second column. Only one row is /// added by this method. /// </summary> /// <param name="entry">The options entry to be presented.</param> /// <param name="parent">The parent where the components will be added.</param> /// <param name="row">The row index where the components will be added.</param> /// <param name="presenter">The presenter that can display this option's value.</param> public static void CreateDefaultUIEntry(IOptionsEntry entry, PGridPanel parent, int row, IUIComponent presenter) { parent.AddChild(new PLabel("Label") { Text = LookInStrings(entry.Title), ToolTip = LookInStrings(entry.Tooltip), TextStyle = PUITuning.Fonts.TextLightStyle }, new GridComponentSpec(row, 0) { Margin = LABEL_MARGIN, Alignment = TextAnchor.MiddleLeft }); parent.AddChild(presenter, new GridComponentSpec(row, 1) { Alignment = TextAnchor.MiddleRight, Margin = CONTROL_MARGIN }); }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component, string value) { if (!string.IsNullOrEmpty(value)) { var scopeElement = component.Scope; for (int i = 0; i < value.Length; i++) { if (i > 0 && TypingIntervalInSeconds > 0) { component.Owner.Wait(TypingIntervalInSeconds); } scopeElement.SendKeysWithLogging(value[i].ToString()); } } }
/// <summary> /// Sets a component's edge constraint. /// </summary> /// <param name="edge">The edge to set.</param> /// <param name="fraction">The fraction of the parent to anchor.</param> /// <param name="child">The other component to anchor.</param> private void SetEdge(RelativeConfig.EdgeStatus edge, float fraction, IUIComponent child) { if (fraction >= 0.0f && fraction <= 1.0f) { edge.Constraint = RelativeConstraintType.ToAnchor; edge.FromAnchor = fraction; edge.FromComponent = null; } else if (child != null) { edge.Constraint = RelativeConstraintType.ToComponent; edge.FromComponent = child; } else { edge.Constraint = RelativeConstraintType.Unconstrained; edge.FromComponent = null; } }
/// <inheritdoc/> public override void Execute <TOwner>(IUIComponent <TOwner> component, string value) { void DoExecute() { component.ExecuteBehavior <ValueClearBehaviorAttribute>(x => x.Execute(component)); if (!string.IsNullOrEmpty(value)) { component.ExecuteBehavior <TextTypeBehaviorAttribute>(x => x.Execute(component, value)); } } if (_useUIComponentScopeCache) { component.Context.UIComponentAccessChainScopeCache.ExecuteWithin(DoExecute); } else { DoExecute(); } }
/// <summary> /// Gets the content of the component using <see cref="ContentSource"/> value. /// </summary> /// <typeparam name="TOwner">The type of the owner page object.</typeparam> /// <param name="component">The component.</param> /// <param name="contentSource">The content source.</param> /// <returns>The content.</returns> public static string Get <TOwner>(IUIComponent <TOwner> component, ContentSource contentSource) where TOwner : PageObject <TOwner>, IPageObject <TOwner> { component.CheckNotNull(nameof(component)); switch (contentSource) { case ContentSource.Text: return(component.Scope.Text); case ContentSource.TextContent: return(component.Attributes.TextContent); case ContentSource.InnerHtml: return(component.Attributes.InnerHtml); case ContentSource.Value: return(component.Attributes.Value); case ContentSource.ChildTextNodes: return(component.Script.ExecuteAgainst <string>(GetTextContentOfChildTextNodesScript)); case ContentSource.ChildTextNodesTrimmed: return(component.Script.ExecuteAgainst <string>(GetTextContentOfChildTextNodesTrimmedScript)); case ContentSource.ChildTextNodesTrimmedAndSpaceJoined: return(component.Script.ExecuteAgainst <string>(GetTextContentOfChildTextNodesTrimmedAndSpaceJoinedScript)); case ContentSource.FirstChildTextNode: return(component.Script.ExecuteAgainst <string>(GetTextContentOfFirstChildTextNodeScript)); case ContentSource.LastChildTextNode: return(component.Script.ExecuteAgainst <string>(GetTextContentOfLastChildTextNodeScript)); default: throw ExceptionFactory.CreateForUnsupportedEnumValue(contentSource, nameof(contentSource)); } }