public static void Bind <Tfirst, Tsecond>(UIProperty <Tfirst> first, UIProperty <Tsecond> second, BindingOptions opts) { if (opts.Mode == BindingMode.OneWay) { second.OnChanged += (e) => { object value = e; if (opts.Converter != null) { value = opts.Converter.ConvertTo(e); } first.SetValue((Tfirst)value); }; } else { //ToDo: fix endless call loop second.OnChanged += (e) => { first.SetValue((Tfirst)e); }; first.OnChanged += (e) => { second.SetValue((Tsecond)e); }; } }
/// <summary> /// This function returns htmlDocument for a given window. /// </summary> /// <param name="hwnd">Handle pointer to the window (main frame).</param> /// <param name="uiPropertyKey">Desired UI property key.</param> /// <param name="uiPropertyValue">Desired UI property value.</param> /// <param name="specialCond">The thread will keep on looping till the desired condition is attained</param> /// <returns>Html document.</returns> public HtmlDocument Get_HtmlDocumentToWindow(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue, object specialCond) { try { this.hwndWizard = hwnd; do { ////Get the window object UIObject objWindow = UIObject.FromHandle(this.hwndWizard); ////Get the Internet Explorer_Server object UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue); Window winIE_Server = new Window(objIE_Server.NativeWindowHandle); //// Get HTML Document this.htmlDocWizzrd = new HtmlDocument(winIE_Server); }while ((bool)specialCond); } catch (Exception e) { throw e; } return(this.htmlDocWizzrd); }
/// <summary> /// This function returns htmlDocument for a given window. /// </summary> /// <param name="hwnd">Handle pointer to the window (main frame).</param> /// <param name="uiPropertyKey">Desired UI property key.</param> /// <param name="uiPropertyValue">Desired UI property value.</param> /// <param name="elementToFind">The thread will keep on looping till the desired element is found in the return html.</param> /// <param name="isSpecific">If the function is for specific code.</param> /// <returns>Html document.</returns> public HtmlDocument Get_HtmlDocumentToWindow(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue, string elementToFind, bool isSpecific) { try { int count = 0; this.hwndWizard = hwnd; do { ////Get the window object UIObject objWindow = UIObject.FromHandle(this.hwndWizard); ////Get the Internet Explorer_Server object UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue); Window winIE_Server = new Window(objIE_Server.NativeWindowHandle); //// Get HTML Document this.htmlDocWizzrd = new HtmlDocument(winIE_Server); count++; }while ((!this.htmlDocWizzrd.RawHtml.ToString().Contains(elementToFind)) && (count < 5)); } catch (Exception e) { throw e; } return(this.htmlDocWizzrd); }
public void SingleTweet(ClientTweet tweet, UIProperty property) { if (OnSingleTweet != null) { Application.Current.Dispatcher.BeginInvoke(OnSingleTweet, new object[] { tweet, property }); } }
public UIObject FindItemByProperty( UIObject uiObject, UIProperty property, object value) { return(ItemContainerProvider.FindItemByProperty(uiObject: uiObject, uiProperty: property, value: value)); }
public UIObject FindItemByProperty( UIObject uiObject, UIProperty uiProperty, object value) { return(this._itemContainPattern.FindItemByProperty(uiObject: uiObject, uiProperty: uiProperty, value: value)); }
public void SetPossibleValues(UIProperty property) { if (property.Value == null) { return; } property.UIType.Descriptor = GetDescriptors(property.Value.GetType()); var entry = GetItem(property.Value.GetType()); if (entry?.Generator == null) { return; } var type = _typeFinder.Find(property.UIType.FullName); if (type == null) { return; } property.UIType.PossibleValues = entry.Generator.Get(type); if (property.UIType.PossibleValues?.Length > 0) { property.UIType.Descriptor |= UIPropertyDescriptors.Literals; } }
public ScrollChangedEventWaiter(IScroll root, ScrollProperty scrollProperty, double expectedValue) : base(new PropertyChangedEventSource(root as UIObject, Scope.Element, UIProperty.Get("Scroll." + scrollProperty.ToString()))) { Log.Comment("ScrollChangedEventWaiter - Constructor for scrollProperty={0} and expectedValue={1}.", scrollProperty.ToString(), expectedValue.ToString()); this.root = root as UIObject; this.scrollProperty = scrollProperty; this.expectedDoubleValue = expectedValue; if (!double.IsNaN(this.expectedDoubleValue)) { switch (this.scrollProperty) { case ScrollProperty.HorizontalScrollPercent: this.AddFilter(new Predicate <WaiterEventArgs>(args => root.HorizontalScrollPercent == expectedValue)); break; case ScrollProperty.HorizontalViewSize: this.AddFilter(new Predicate <WaiterEventArgs>(args => root.HorizontalViewSize == expectedValue)); break; case ScrollProperty.VerticalScrollPercent: this.AddFilter(new Predicate <WaiterEventArgs>(args => root.VerticalScrollPercent == expectedValue)); break; case ScrollProperty.VerticalViewSize: this.AddFilter(new Predicate <WaiterEventArgs>(args => root.VerticalViewSize == expectedValue)); break; } } this.Reset(); }
public void SetPossibleValues(UIReflectionProperty xRef, UIProperty xProp) { if (xRef == null || xProp == null) { return; } xProp.UIType = CreateType(xRef); var entry = GetItem(xProp.Value?.GetType()); if (entry?.Generator == null) { return; } var type = _typeFinder.Find(xProp.UIType.FullName); if (type == null) { return; } xProp.UIType.PossibleValues = entry.Generator.Get(type); if (xProp.UIType.PossibleValues?.Length > 0) { xProp.UIType.Descriptor |= UIPropertyDescriptors.Literals; } }
public HtmlDocument Get_HtmlDocumentToWindow1(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue) { try { this.hwndWizard = hwnd; ////Get the window object(Main window). UIObject objWindow = UIObject.FromHandle(this.hwndWizard); ////Get the specific UI object. UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue); ////Create window to the specific UI object. Window winIE_Server = new Window(objIE_Server.NativeWindowHandle); //// Get HTML Document(Main window). this.htmlDocWizzrd = new HtmlDocument(winIE_Server); } catch (Exception e) { } return(this.htmlDocWizzrd); }
public void TopNavigationHaveCorrectSelectionWhenChangingMenuItems() { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Test" })) { for (int i = 0; i < 3; i++) { Log.Comment("Iteration: " + i); Log.Comment("Invoke ChangeDataSource"); var button = new Button(FindElement.ById("ChangeDataSource")); button.Invoke(); Wait.ForIdle(); Log.Comment("Reset TestResult"); var resetButton = new Button(FindElement.ById("ResetResult")); resetButton.Invoke(); Wait.ForIdle(); ElementCache.Refresh(); UIObject selectedItem = FindElement.ByName("Happy new year Item"); Log.Comment("Verify the item is selected"); Verify.IsTrue(Convert.ToBoolean(selectedItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); } } }
public Window Get_HtmlDocumentToWindow(IntPtr hid, string abc, string xyz) { try { this.hwd = hid; ////Get the window object UIObject objWindow = UIObject.FromHandle(this.hwd); ////Get the Internet Explorer_Server object UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(abc), xyz); winIE_Server = new Window(objIE_Server.NativeWindowHandle); // doc = new HtmlDocument(winIE_Server); } catch (Exception ex) { throw ex; } return(winIE_Server); }
public IActionResult GetModelProperties(string type, XioOperationType operation) { var t = getModelType(type, operation); List <UIProperty> properties = new List <UIProperty>(); foreach (var prop in t.GetProperties()) { var dn = prop.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName; var required = prop.GetCustomAttribute <RequiredAttribute>() != null; var editor = prop.GetCustomAttribute <XioEditorAttribute>()?.Editor ?? prop.PropertyType.Name; var defValue = prop.GetCustomAttribute <DefaultValueAttribute>()?.Value; var hideUnless = prop.GetCustomAttribute <HideUnlessAttribute>()?.Options; var p = new UIProperty { PropertyName = prop.Name, DisplayName = dn ?? prop.Name, Editor = editor, HideUnless = hideUnless, DefaultValue = defValue, IsRequired = required, Validate = false }; properties.Add(p); } return(Json(properties)); }
/// <summary> /// This function returns htmlDocument for a given window, it searches 5 times(project requirement). /// </summary> /// <param name="hwnd">Handle pointer to the window (main frame).</param> /// <param name="uiPropertyKey">Desired UI property key.</param> /// <param name="uiPropertyValue">Desired UI property value.</param> /// <param name="elementToFind">The thread will keep on looping till the desired element is found in the return html.</param> /// <param name="isSpecific">If the function is for specific code.</param> /// <returns>Html document.</returns> public HtmlDocument Get_HtmlDocumentToWindow(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue, string elementToFind, bool isSpecific) { try { int count = 0; this.hwndWizard = hwnd; do { ////Get the window object(Main window). UIObject objWindow = UIObject.FromHandle(this.hwndWizard); ////Get the specific UI object. UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue); ////Create window to the specific UI object. Window winIE_Server = new Window(objIE_Server.NativeWindowHandle); //// Get HTML Document(Main window). this.htmlDocWizzrd = new HtmlDocument(winIE_Server); count++; }while ((!this.htmlDocWizzrd.RawHtml.ToString().Contains(elementToFind)) && (count < 5)); } catch (Exception e) { #if debug throw new MitabaseException(MitaBaseMessages.HtmlDocNotFetch + Environment.NewLine + e.Message + Environment.NewLine + "UIElementWindow."); #endif throw new MitabaseException(MitaBaseMessages.HtmlDocNotFetch); } return(this.htmlDocWizzrd); }
/// <summary> /// This method is used when exact UI property to a control is known. /// </summary> /// <param name="hwnd">Handle pointer to the window (main frame).</param> /// <param name="uiPropertyKey">Desired UI property key.</param> /// <param name="uiPropertyValue">Desired UI property value.</param> /// <returns>Control window.</returns> public Window Get_WindowToSpecificControl(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue) { try { this.hwndWizard = hwnd; ////Get the window object(Main window). UIObject objSignupWindow = UIObject.FromHandle(this.hwndWizard); ////Get the specific UI object. UIObject objIE_Server = objSignupWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue); ////Create window to the specific UI object. this.winControl = new Window(objIE_Server.NativeWindowHandle); } catch (Exception e) { #if debug throw new MitabaseException(MitaBaseMessages.CreateWindowFail + Environment.NewLine + e.Message + Environment.NewLine + "UIElementWindow."); #endif throw new MitabaseException(MitaBaseMessages.CreateWindowFail); } return(this.winControl); }
public void SetPossibleValues(UIReflectionProperty xRef, UIProperty xProp, Enum e) { if (xRef == null || xProp == null) { return; } xProp.UIType = CreateType(xRef); var item = GetItem(xProp.UIType.GetType()); var gen = new EnumGenerator(); var result = gen.Get(e.GetType()); if (item != null) { xProp.UIType.Descriptor = item.Descriptor; } xProp.UIType.PossibleValues = result; xProp.UIType.Descriptor |= UIPropertyDescriptors.Literals; if (e.HasFlags()) { xProp.UIType.Descriptor |= UIPropertyDescriptors.Flags; } }
public RegexFilter(UIProperty property, Regex regularExpression) { Validate.ArgumentNotNull(parameter : property, parameterName : nameof(property)); Validate.ArgumentNotNull(parameter: regularExpression, parameterName: nameof(regularExpression)); this._property = property; this._regularExpression = regularExpression; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { object ret = null; UIProperty uiProperty = null; if (value is ClientTweet) { uiProperty = ((ClientTweet)value).uiProperty; } else if (value is ClientDirectMessage) { uiProperty = ((ClientDirectMessage)value).uiProperty; } if (uiProperty == null) { return(null); } if (uiProperty.isBackOne) { ret = DataInstence.skin.blockOne; } else { ret = DataInstence.skin.blockTwo; } return(ret); }
public bool Validate(StringBuilder errors) { if (UIProperty.Exists(name: this._propertyName)) { return(true); } errors.AppendLine(value: StringResource.Get(id: "PropertyNotFound_1", (object)this._propertyName)); return(false); }
protected void AddRelationContenerByRelatedProperty(UIProperty uiProperty, RelationContener relationContener) { var uiRelatedProperty = uiProperty as UIRelatedProperty; if (!(uiRelatedProperty == null || RelationsContenerByRelatedProperty.ContainsKey(uiRelatedProperty))) { RelationsContenerByRelatedProperty.Add(uiRelatedProperty, relationContener); relationContener.Removed += () => RelationsContenerByRelatedProperty.Remove(uiRelatedProperty); } }
public override void DeleteProperty(UIProperty property) { base.DeleteProperty(property); var navigationProperty = property.BusinessInstance as NavigationProperty; if (navigationProperty != null) { BusinessInstance.NavigationProperties.Remove(navigationProperty); } }
private void btnAddNewUIProperty_Click(object sender, RoutedEventArgs e) { if (this.bdrContainer.DataContext == null) { return; } var uiProperty = new UIProperty("ChangeMe", "ChangeMe"); (this.bdrContainer.DataContext as UIControl).ControlProperties.Add(uiProperty); }
public void MenuItemAutomationSelectionTest() { var testScenarios = RegressionTestScenario.BuildAllRegressionTestScenarios(); foreach (var testScenario in testScenarios) { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName })) { UIObject firstItem = FindElement.ByName("Home"); UIObject secondItem = FindElement.ByName("Apps"); UIObject thirdItem = FindElement.ByName("Games"); Log.Comment("Verify the second item is not already selected"); Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); firstItem.SetFocus(); AutomationElement firstItemAE = AutomationElement.FocusedElement; SelectionItemPattern firstItemSIP = firstItemAE.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; Log.Comment("Move focus to the second item by pressing down(left nav)/right(right nav) arrow once"); var key = Key.Right; if (testScenario.IsLeftNavTest) { key = Key.Down; } KeyboardHelper.PressKey(key); Wait.ForIdle(); Verify.IsTrue(secondItem.HasKeyboardFocus); AutomationElement secondItemAE = AutomationElement.FocusedElement; SelectionItemPattern secondItemSIP = secondItemAE.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; Log.Comment("Select the second item using SelectionItemPattern.Select and verify"); secondItemSIP.Select(); Wait.ForIdle(); Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); Log.Comment("Deselect the second item"); firstItemSIP.Select(); Wait.ForIdle(); Verify.IsTrue(Convert.ToBoolean(firstItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); Log.Comment("Select the second item using SelectionItemPattern.AddToSelection and verify"); secondItemSIP.AddToSelection(); Wait.ForIdle(); Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); ClickClearSelectionButton(); Log.Comment("second item is unselected"); Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); } } }
public static UIProperty Init() { UIProperty property = new UIProperty(); property.WindowStyle = UIWindowStyle.Normal; property.WindowMode = UIWindowMode.DoNothing; property.ColliderType = UIColliderType.None; property.AnimationType = UIAnimationType.Normal; property.UIPath = string.Empty; return(property); }
public static IEnumerable <UIObject> GetTopLevelWindowsModernApp(int processId) { UICollection.Timeout = TimeSpan.Zero; foreach (var uiObject in UIObject.Root.Children.FindMultiple(condition: UICondition.CreateFromClassName(className: "ApplicationFrameWindow"))) { if (uiObject.Children.Contains(uiProperty: UIProperty.Get(name: "ProcessId"), value: processId)) { yield return(uiObject); } } }
public void RequestSingleTweetPacket <TRes>(BasePacket packet, UIProperty property, Action <TRes, UIProperty> callback) { if (OnApiCall != null) { Application.Current.Dispatcher.BeginInvoke(OnApiCall, new object[] { packet.eresponse }); } Task t = Task.Factory.StartNew(new Action((() => TaskRequestPacket <TRes>(packet, property, callback))), token); t.ContinueWith(TaskComplete); listTask.TryAdd(t); }
public ValueChangedEventWaiter(IValue root, string expectedValue = "") : base(new PropertyChangedEventSource(root as UIObject, Scope.Element, UIProperty.Get("Value.Value"))) { this.root = root as UIObject; this.expectedValue = expectedValue; if (expectedValue.Length > 0) { this.AddFilter(new Predicate <WaiterEventArgs>(args => root.Value == expectedValue)); } this.Start(); }
protected override void OnExecute(UIMessageContext ctx) { if (ctx.Request == null) { return; } var req = ctx.Get <GetObjectRequest>(); if (req == null) { return; } var props = GetUIProperties(req.WidgetId, true, req.Path); if (!props.Any()) { return; } var prop = props[0]; if (prop.UIType.Descriptor.HasFlag(UIPropertyDescriptors.Enumerable)) { if (prop.UIType.Descriptor.HasFlag(UIPropertyDescriptors.Enumerable)) { // grab index value; if null, return without creating an ObjectResponse. var index = ReflectionMethods.GetIndexerValue(req.Path[0]); if (index == null) { return; } var item = ReflectionMethods.GetItem(prop.Value, index.Value); prop.Value = GetUIProperties(item); } } prop.Path = req.Path?.Union(prop.Path)?.ToArray(); var cantCast = SetPath(prop.Value, req.Path); ctx.SetResponse <ObjectResponse>(res => { res.UnknownCondition = cantCast; res.Property = prop; res.WidgetId = req.WidgetId; res.ObjectName = UIProperty.GetLastPath(req.Path); }); }
public UIObject FindItemByProperty( UIObject uiObject, UIProperty uiProperty, object value) { Validate.ArgumentNotNull(parameter: uiProperty, parameterName: nameof(uiProperty)); if (value != null && uiProperty == UIProperty.Get(property: AutomationElement.SearchVirtualItemsProperty)) { throw new ArgumentException(message: StringResource.Get(id: "FindItemByProperty_ArgumentException")); } var num = (int)ActionHandler.Invoke(sender: UIObject, actionInfo: ActionEventArgs.GetDefault(action: "WaitForReady")); var element = uiObject == (UIObject)null ? Pattern.FindItemByProperty(element: null, property: uiProperty.Property, value: value) : Pattern.FindItemByProperty(element: uiObject.AutomationElement, property: uiProperty.Property, value: value); return(!(element == null) ? new UIObject(element: element) : null); }
public void VerifyNavigationViewItemIsSelectedWorks() { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Init Test" })) { Log.Comment("Verify the 1st NavItem.IsSelected=true works"); UIObject item1 = FindElement.ByName("Albums"); Verify.IsNotNull(item1); Verify.IsTrue(Convert.ToBoolean(item1.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); Log.Comment("Verify the 2nd NavItem.IsSelected=true is ignored"); UIObject item2 = FindElement.ByName("People"); Verify.IsNotNull(item2); Verify.IsFalse(Convert.ToBoolean(item2.GetProperty(UIProperty.Get("SelectionItem.IsSelected")))); } }
//实例化UI// public UIBase InstantiatedUI(UIProperty pProperty) { GameObject TmpUI = null; foreach(GameObject TmpObject in UIPrefabArray) { if(TmpObject.name == pProperty.name) TmpUI = TmpObject; } if(TmpUI == null) TmpUI = Resources.Load("UI/"+pProperty.name,typeof(GameObject)) as GameObject; if(TmpUI != null) { UIBase Obj = (Instantiate(TmpUI) as GameObject).GetComponent<UIBase>(); Obj.name = pProperty.name; OtherTool.SetLayer(Obj.gameObject,m_pCameraList[pProperty.GetCameraLayer()].gameObject.layer); Obj.transform.parent = m_pUIAnchorMap[m_pCameraList[pProperty.GetCameraLayer()]] as Transform; Obj.transform.localPosition = Vector3.zero; Obj.transform.localScale = Vector3.one; m_pUIMap[m_pCameraList[pProperty.GetCameraLayer()]] = Obj; return Obj; } LogManager.LogError("Cant Find Target UI Prefab " + pProperty.name); return null; }