Ejemplo n.º 1
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            try
            {
                m_Delegate = new runDelegate(Run);
                var       selStr  = Selector.Get(context);
                UiElement element = null;
                element = Common.GetValueOrDefault(context, this.Element, null);
                if (element == null && selStr != null)
                {
                    element = UiElement.FromSelector(selStr);
                }
                else
                {
                    PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope];
                    element = property.GetValue(context.DataContext) as UiElement;
                }

                UiElement relativeEle = element.FindRelativeElement((int)Position, OffSetX.Get(context), OffSetY.Get(context));
                FoundElement.Set(context, relativeEle);
                //relativeEle.DrawHighlight(System.Drawing.Color.Red, TimeSpan.FromSeconds(2), true);

                return(m_Delegate.BeginInvoke(callback, state));
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取偏移相对元素失败", e.Message);
                if (ContinueOnError.Get(context))
                {
                    return(m_Delegate.BeginInvoke(callback, state));
                }
                else
                {
                    throw e;
                }
            }
        }