Example #1
0
        public void click(OnElement position)
        {
            Size size = Element.Size;
            int  offset = Math.Min(size.Width, size.Height) / 4;
            int  x = 0, y = 0;

            switch (position)
            {
            case OnElement.top:
                x = size.Width / 2;
                y = offset;
                break;

            case OnElement.left:
                x = offset;
                y = size.Height / 2;
                break;

            case OnElement.bottom:
                x = size.Width / 2;
                y = size.Height - offset;
                break;

            case OnElement.right:
                x = size.Width - offset;
                y = size.Height / 2;
                break;
            }
            clickByOffset(x, y);
        }
Example #2
0
        public void Parse()
        {
            try
            {
                reader.MoveToContent();
                while (reader.Read())
                {
                    var arg = new ParseEventArg
                    {
                        NodeType     = reader.NodeType,
                        Depth        = reader.Depth,
                        Name         = reader.Name,
                        EmptyElement = reader.IsEmptyElement
                    };
                    if (reader.HasValue)
                    {
                        arg.Value = reader.Value;
                    }
                    else
                    {
                        arg.Value = null;
                    }
                    if (reader.HasAttributes)
                    {
                        var arr = new Attribute[reader.AttributeCount];
                        for (var i = 0; i < reader.AttributeCount; i++)
                        {
                            reader.MoveToAttribute(i);
                            arr[i] = new Attribute {
                                Name = reader.Name, Value = reader.Value, Index = i
                            };
                        }
                        reader.MoveToElement();
                        arg.Attributes = new ReadOnlyCollection <Attribute>(arr);
                    }
                    else
                    {
                        arg.Attributes = new ReadOnlyCollection <Attribute>(empty);
                    }
                    OnNode?.Invoke(this, arg);
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        OnElement?.Invoke(this, arg);
                        break;

                    case XmlNodeType.CDATA:
                        OnCData?.Invoke(this, arg);
                        break;

                    case XmlNodeType.Comment:
                        OnComment?.Invoke(this, arg);
                        break;

                    case XmlNodeType.DocumentType:
                        OnDocType?.Invoke(this, arg);
                        break;

                    case XmlNodeType.EndElement:
                        OnEndElement?.Invoke(this, arg);
                        break;

                    case XmlNodeType.EntityReference:
                        OnEntityReferenceUnresolved?.Invoke(this, arg);
                        reader.ResolveEntity();
                        reader.Read();
                        arg.Name     = reader.Name;
                        arg.Value    = reader.Value;
                        arg.Depth    = reader.Depth;
                        arg.NodeType = reader.NodeType;
                        OnEntityReference?.Invoke(this, arg);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        OnProcessingInstruction?.Invoke(this, arg);
                        break;

                    case XmlNodeType.Text:
                        OnText?.Invoke(this, arg);
                        break;
                    }
                }
            }
            catch (XmlException e)
            {
                OnException?.Invoke(this, e);
            }
        }