当前位置: 首页>>代码示例>>C#>>正文


C# IUiElement.GetCached方法代码示例

本文整理汇总了C#中IUiElement.GetCached方法的典型用法代码示例。如果您正苦于以下问题:C# IUiElement.GetCached方法的具体用法?C# IUiElement.GetCached怎么用?C# IUiElement.GetCached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUiElement的用法示例。


在下文中一共展示了IUiElement.GetCached方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessAutomationElement

        private List<IUiElement> ProcessAutomationElement(
            IUiElement element,
            string name,
            string automationId,
            string className,
            string[] controlType,
            bool caseSensitive,
            bool onlyOneResult,
            bool onlyTopLevel)
        {
            var resultCollection = new List<IUiElement>();
            
			name = name ?? string.Empty;
			automationId = automationId ?? string.Empty;
			className = className ?? string.Empty;
            
            if ((controlType != null && 
                controlType.Length > 0 && 
                ElementOfPossibleControlType(
                    controlType,
                    // 20140312
                    // element.Current.ControlType.ProgrammaticName)) ||
                    element.GetCurrent().ControlType.ProgrammaticName)) ||
                (controlType == null) ||
                (controlType.Length == 0)) {

                WildcardOptions options;
                if (caseSensitive) {
                    options =
                        WildcardOptions.Compiled;
                } else {
                    options =
                        WildcardOptions.IgnoreCase |
                        WildcardOptions.Compiled;
                }
                
                if (0 == name.Length && 0 == automationId.Length && 0 == className.Length) {
                    name = "*";
                }
                
                var wildcardName = 
                    new WildcardPattern(name,options);
                
                var wildcardAutomationId = 
                    new WildcardPattern(automationId,options);
                
                var wildcardClass = 
                    new WildcardPattern(className,options);
                
                // 20130125
                // there's a bug 20130125
                bool matched = false;
                
                if (FromCache && CurrentData.CacheRequest != null) {
                    // 20140312
                    // if (name.Length > 0 && wildcardName.IsMatch(element.Cached.Name)) {
                    // if (name.Length > 0 && wildcardName.IsMatch((element as ISupportsCached).Cached.Name)) {
                    if (name.Length > 0 && wildcardName.IsMatch(element.GetCached().Name)) {
                        matched = true;
                    } else if (automationId.Length > 0 &&
                        // 20140312
					                          // wildcardAutomationId.IsMatch(element.Cached.AutomationId)) {
                        // wildcardAutomationId.IsMatch((element as ISupportsCached).Cached.AutomationId)) {
                        wildcardAutomationId.IsMatch(element.GetCached().AutomationId)) {
						matched = true;
					} else
                        // 20140312
						// matched |= className.Length > 0 && wildcardClass.IsMatch(element.Cached.ClassName);
                        // matched |= className.Length > 0 && wildcardClass.IsMatch((element as ISupportsCached).Cached.ClassName);
                        matched |= className.Length > 0 && wildcardClass.IsMatch(element.GetCached().ClassName);
                } else {
                    // 20140312
                    // if (name.Length > 0 && wildcardName.IsMatch(element.Current.Name)) {
                    if (name.Length > 0 && wildcardName.IsMatch(element.GetCurrent().Name)) {
                        matched = true;
                    } else if (automationId.Length > 0 &&
                        // 20140312
					                          // wildcardAutomationId.IsMatch(element.Current.AutomationId)) {
                        wildcardAutomationId.IsMatch(element.GetCurrent().AutomationId)) {
						matched = true;
					} else
                        // 20140312
						// matched |= className.Length > 0 && wildcardClass.IsMatch(element.Current.ClassName);
                        matched |= className.Length > 0 && wildcardClass.IsMatch(element.GetCurrent().ClassName);
                }
                
                if (matched) {
                    
                    resultCollection.Add(element);
                    
                    if (onlyOneResult) {

                        throw (new Exception("wrong code here!"));

                    } else {
                        
                        return resultCollection;
                    }
                }
                
//.........这里部分代码省略.........
开发者ID:universsky,项目名称:STUPS,代码行数:101,代码来源:GetControlCollectionCmdletBase.cs

示例2: guiWritingAutomationElementToPropertyGridControl


//.........这里部分代码省略.........
        
        // 20131109
        //private void writingAvailablePatterns(AutomationElement element)
        //        private void writingAvailablePatterns(IUiElement element)
        //        {
        //            try {
        //                this.richPatterns.Text = "available patterns";
        //                this.richPatterns.Text += "\r\n";
//
        //                // 20120618 UiaCOMWrapper
        //                // 20131209
        //                // AutomationPattern[] supportedPatterns =
        //                //     element.GetSupportedPatterns();
        //                IBasePattern[] supportedPatterns =
        //                    element.GetSupportedPatterns();
        //                //UiaCOM::System.Windows.Automation.AutomationPattern[] supportedPatterns =
        //                //    element.GetSupportedPatterns();
//
        //                if (supportedPatterns == null || supportedPatterns.Length <= 0) return;
        //                for (int i = 0; i < supportedPatterns.Length; i++) {
        //                    if (i > 0) {
        //                        this.richPatterns.Text += "\r\n";
        //                    }
        //                    this.richPatterns.Text +=
        //                        // 20131209
        //                        // supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                        // 20131210
        //                        // (supportedPatterns[i] as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                        // (supportedPatterns[i].SourcePattern as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                        (supportedPatterns[i].SourcePattern as AutomationPattern).ProgrammaticName.Replace("Identifiers.Pattern", string.Empty);
        //                }
//
        //                /*
        //                if (supportedPatterns != null &&
        //                    supportedPatterns.Length > 0) {
        //                    for (int i = 0; i < supportedPatterns.Length; i++) {
        //                        if (i > 0) {
        //                            this.richPatterns.Text += "\r\n";
        //                        }
        //                        this.richPatterns.Text +=
        //                            supportedPatterns[i].ProgrammaticName.Replace("Identifiers.Pattern", "");
        //                    }
        //                }
        //                */
        //            }
        //            catch {}
        //        }
        
        // 20131109
        //privaIUiElementperWrapperperWrapper getElementFromPoint()
        // 20131114
        //private IUiElement getElementFromPoint()
        //        private IUiElement getElementFromPoint(System.Drawing.Point mousePoint)
        //        {
        //            // 20131109
        //            //AutomatIUiElement element = null;
        //            IUiElement element = null;
//
        //            // use Windows forms mouse code instead of WPF
        //            // 20131114
        //            //System.Drawing.Point mouse = System.Windows.Forms.Cursor.Position;
//
        //            // commented 20120618 to switch to UiaCOMWrapper
        //            element =
        //                // 20131109
        //                //System.Windows.Automation.AutomationElement.FromPoint(
        //                UiElement.FromPoint(
        //                    // 20131114
        //                    //new System.Windows.Point(mouse.X, mouse.Y));
        //                    new System.Windows.Point(mousePoint.X, mousePoint.Y));
        //            //element =
        //            //    //(UiaNET::System.Windows.Automation.AutomationElement)
        //            //    UiaCOM3.UiaCOMHelper.GetAutomationElementFromPoint();
//
        //            return element;
        //        }
        
        // 20131109
        //private void writingAutomationElementToPropertyGridControl(AutomationElement element)
        private void guiWritingAutomationElementToPropertyGridControl(IUiElement element)
        {
            try {
                pGridElement.SelectedObject =
                    // 20140312
                    // element.Current;
                    element.GetCurrent();
            }
            catch {
                try {
                    pGridElement.SelectedObject =
                        // 20140312
                        // element.Cached;
                        // (element as ISupportsCached).Cached;
                        element.GetCached();
                }
                catch {
                    
                }
            }
        }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:101,代码来源:SpyForm.cs


注:本文中的IUiElement.GetCached方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。