예제 #1
0
        List <ITreeViewItem> ITreeViewItem.Childrens()
        {
            List <ITreeViewItem> list      = new List <ITreeViewItem>();
            List <ElementInfo>   Childrens = base.UIAElementInfo.WindowExplorer.GetElementChildren(base.UIAElementInfo);

            foreach (ElementInfo EI in Childrens)
            {
                ITreeViewItem TVI = null;
                if (EI.GetType() == typeof(UIAElementInfo))
                {
                    EI.WindowExplorer = UIAElementInfo.WindowExplorer;
                    PBControlTreeItemBase treeItem = GetMatchingPBTreeItem(EI);
                    treeItem.UIAElementInfo.WindowExplorer = UIAElementInfo.WindowExplorer;

                    double XOffset =
                        double.Parse(((UIAutomationDriverBase)UIAElementInfo.WindowExplorer).mUIAutomationHelper
                                     .GetControlPropertyValue(EI.ElementObject, "XOffset"));
                    double YOffset =
                        double.Parse(((UIAutomationDriverBase)UIAElementInfo.WindowExplorer).mUIAutomationHelper
                                     .GetControlPropertyValue(EI.ElementObject, "YOffset"));
                    treeItem.UIAElementInfo.XCordinate = XOffset - base.UIAElementInfo.XCordinate;
                    treeItem.UIAElementInfo.YCordinate = YOffset - base.UIAElementInfo.YCordinate;

                    TVI = treeItem;
                }
                else
                {
                    TVI = HTMLElementInfoConverter.GetHTMLElementTreeItem(EI);
                }
                list.Add(TVI);
            }
            return(list);
        }
예제 #2
0
        public static PBControlTreeItemBase GetMatchingPBTreeItem(ElementInfo elementInfo)
        {
            if (elementInfo == null || elementInfo.ElementObject == null)
            {
                return(null);
            }

            string elementControlType = ((PBDriver)elementInfo.WindowExplorer).mUIAutomationHelper.GetElementControlType(elementInfo.ElementObject);
            string elmentClass        =
                ((PBDriver)elementInfo.WindowExplorer).mUIAutomationHelper.GetControlPropertyValue(
                    elementInfo.ElementObject, "ClassName");

            PBControlTreeItemBase treeItem;

            if (General.CompareStringsIgnoreCase(elementControlType, "button"))
            {
                treeItem = new PBButtonTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "edit"))
            {
                treeItem = new PBTextBoxTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "title bar"))
            {
                treeItem = new PBTitleBarTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "pane") && General.CompareStringsIgnoreCase(elmentClass, "SysDateTimePick32"))
            {
                treeItem = new PBDatePickerTreeItem();
            }

            //TODO:For grids need to implement generic way, independent of class name.This is breaking other pane controls which are not actually Grids.
            //else if (elementNode.Current.LocalizedControlType == "pane" && elementNode.Current.ClassName == "pbdw126")
            //{
            //    PBDataGridTreeItem DGTI = new PBDataGridTreeItem();
            //    DGTI.AEControl = elementNode;
            //    Childrens.Add(DGTI);
            //}

            else if (General.CompareStringsIgnoreCase(elementControlType, "pane") && General.CompareStringsIgnoreCase(elmentClass, "PBTabControl32_100"))
            {
                treeItem = new PBTabTreeItem();
            }
            //TODO: Find a Better way to distinguish a grid control
            else if (General.CompareStringsIgnoreCase(elementControlType, "pane") && (elmentClass.StartsWith("pbd")))// && (elementNode.Current.Name=="")
            {
                treeItem = new PBDataGridTreeItem();
            }
            else if (elmentClass.Equals("Internet Explorer_Server"))
            {
                treeItem = new PBBrowserTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "text"))
            {
                treeItem = new PBTextTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "scroll bar"))
            {
                treeItem = new PBScrollBarTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "menu bar"))
            {
                treeItem = new PBMenuBarTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "menu item"))
            {
                treeItem = new PBMenuItemTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "check box"))
            {
                treeItem = new PBCheckBoxTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "radio button"))
            {
                treeItem = new PBRadioButtonTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "combo box"))
            {
                treeItem = new PBComboBoxTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "list"))
            {
                treeItem = new PBListBoxTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "list item"))
            {
                treeItem = new PBListItemTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "Dialog"))
            {
                treeItem = new PBDialogBoxTreeItem();
            }
            //TODO: Add special handling for table controls. Don't display table fields as child, instead create similar table on Explorer pages using these values
            else if (General.CompareStringsIgnoreCase(elementControlType, "table"))
            {
                treeItem = new PBTableTreeItem();
            }
            else if (General.CompareStringsIgnoreCase(elementControlType, "document") || (elementControlType == ""))
            {
                treeItem = new PBDocumentTreeItem();
            }
            else
            {
                treeItem = new PBControlTreeItemBase();
            }

            // we need to put all the minimal attr so calc when needed
            UIAElementInfo EI = new UIAElementInfo();

            EI.ElementObject        = elementInfo.ElementObject; // The most important, the rest will be lazy loading
            treeItem.UIAElementInfo = EI;

            return(treeItem);
        }