コード例 #1
0
        public static UIObject GetTopLevelUIObject(UIObject topWindow)
        {
            if (topWindow == null)
            {
                throw new ArgumentNullException(paramName: nameof(topWindow));
            }
            Log.Out(msg: "GetTopLevelUIObject: object");
            UIObject element = null;

            if ((ControlType)topWindow.GetProperty(property: UIProperty.Get(name: "ControlType")) != ControlType.Window)
            {
                throw new InvalidOperationException(message: "topWindow didn't find a window (ControlType==Window) after app activation completed.");
            }
            if (topWindow.ClassName.Equals(value: "Windows.UI.Core.CoreWindow", comparisonType: StringComparison.OrdinalIgnoreCase))
            {
                element = topWindow;
            }
            else
            {
                uint num;
                for (num = 0U; num < 10U && !topWindow.Children.TryFind(condition: UICondition.CreateFromClassName(className: "Windows.UI.Core.CoreWindow").AndWith(newCondition: UICondition.CreateFromName(name: topWindow.Name)), element: out element); ++num)
                {
                    Thread.Sleep(millisecondsTimeout: 100);
                }
                if (element == null)
                {
                    throw new UIObjectNotFoundException(message: string.Format(format: "Unable to find {0} in {1}", arg0: "Windows.UI.Core.CoreWindow", arg1: topWindow));
                }
                Log.Out(msg: "Found {0} in {1} tries", (object)"Windows.UI.Core.CoreWindow", (object)num);
            }

            return(element);
        }
コード例 #2
0
        public static UICondition CreateTopLevelWindowCondition()
        {
            var deviceFamily = AnalyticsInfo.VersionInfo.DeviceFamily;

            return(deviceFamily.Equals(value: "Windows.Desktop", comparisonType: StringComparison.OrdinalIgnoreCase) || deviceFamily.Equals(value: "Windows.Server", comparisonType: StringComparison.OrdinalIgnoreCase) || deviceFamily.Equals(value: "Windows.Team", comparisonType: StringComparison.OrdinalIgnoreCase) ? UICondition.CreateFromClassName(className: "ApplicationFrameWindow") : UICondition.CreateFromClassName(className: "Windows.UI.Core.CoreWindow"));
        }