Пример #1
0
 protected override void Execute(CodeActivityContext context)
 {
     try
     {
         Int32     _HighlightTime = GetValueOrDefault(context, HighlightTime, 1);
         Color     _Value         = GetValueOrDefault(context, Value, Color.Red);
         var       selStr         = Selector.Get(context);
         UiElement element        = GetValueOrDefault(context, this.Element, null);
         if (element == null && selStr != null)
         {
             element = UiElement.FromSelector(selStr);
         }
         if (element != null)
         {
             element.DrawHighlight(_Value, TimeSpan.FromSeconds(_HighlightTime), true);
             Thread.Sleep(_HighlightTime * 1);
         }
         else
         {
             UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound"));
         }
     }
     catch (Exception e)
     {
         SharedObject.Instance.Output(SharedObject.enOutputType.Error, "UI元素设置高亮失败", e.Message);
         if (ContinueOnError.Get(context))
         {
         }
         else
         {
             throw;
         }
     }
 }
Пример #2
0
 protected override void Execute(CodeActivityContext context)
 {
     try
     {
         Int32     _HighlightTime = GetValueOrDefault(context, HighlightTime, 1);
         Color     _Value         = GetValueOrDefault(context, Value, Color.Red);
         var       selStr         = Selector.Get(context);
         UiElement element        = GetValueOrDefault(context, this.Element, null);
         if (element == null && selStr != null)
         {
             element = UiElement.FromSelector(selStr);
         }
         if (element != null)
         {
             element.DrawHighlight(_Value, TimeSpan.FromSeconds(_HighlightTime), true);
             Thread.Sleep(_HighlightTime * 1);
         }
         else
         {
             SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", "查找不到元素");
             if (ContinueOnError.Get(context))
             {
                 return;
             }
             else
             {
                 throw new NotImplementedException("查找不到元素");
             }
         }
     }
     catch (Exception e)
     {
         SharedObject.Instance.Output(SharedObject.enOutputType.Error, "UI元素设置高亮失败", e.Message);
         if (ContinueOnError.Get(context))
         {
         }
         else
         {
             throw;
         }
     }
 }