예제 #1
0
        public static int GetLinkElementIndex(mshtml.IHTMLDocument2 doc, mshtml.IHTMLElement ele, string itemName, string tagStr)
        {
            mshtml.IHTMLElementCollection links;
            int        num       = 0;
            bool       flag      = false;
            ElementTag outerText = ElementTag.outerText;

            if (!string.IsNullOrEmpty(tagStr))
            {
                outerText = (ElementTag)WindowUtil.StringToInt(tagStr);
            }
            if (outerText != ElementTag.src)
            {
                links = doc.links;
                if (links == null)
                {
                    goto Label_00EA;
                }
                foreach (mshtml.IHTMLElement element2 in links)
                {
                    if (IsElementMatch(element2, outerText, itemName, ""))
                    {
                        if (ele == element2)
                        {
                            flag = true;
                            break;
                        }
                        num++;
                    }
                }
            }
            else
            {
                links = doc.images;
                if (links != null)
                {
                    foreach (mshtml.IHTMLElement element in links)
                    {
                        if (IsElementMatch(element, outerText, itemName, ""))
                        {
                            if (ele == element)
                            {
                                flag = true;
                                break;
                            }
                            num++;
                        }
                    }
                    Marshal.ReleaseComObject(links);
                }
                goto Label_00EA;
            }
            Marshal.ReleaseComObject(links);
Label_00EA:
            if (!flag)
            {
                num = 0;
            }
            return(num);
        }
예제 #2
0
        public CompositeGameObjectFromFile Build(Stream stream, IFileParserPlugin parser)
        {
            parser.Parse(stream, this);
            var colors = new Queue <Vector4>();

            colors.Enqueue(V4Colors.Red);
            colors.Enqueue(V4Colors.Blue);
            colors.Enqueue(V4Colors.Green);
            colors.Enqueue(V4Colors.Yellow);

            foreach (var com in components)
            {
                var tag    = new ElementTag("Obj_" + Guid.NewGuid());//DateTime.Now.Ticks
                var entity = manager.CreateEntity(tag);
                var cc     = new List <IGraphicComponent>();
                cc.Add(com);
                cc.Add(EntityBuilders.GetObjGroupsRender());
                cc.Add(EntityBuilders.GetTransformation());
                //var material = new PositionColorsComponent();

                //material.Colors = new Vector4[com.Positions.Length];
                //for (var i =0;i < com.Positions.Length; ++i) {
                //    material.Colors[i] = V4Colors.Red;
                //}

                cc.Add(ColorComponent.CreateDiffuse(V4Colors.Red));
                cc.Add(new ManipulatableComponent());

                entity.AddComponents(cc);
                entity.AddComponents(others);
                gobj.AddEntity(tag);
            }

            return(gobj); //new SingleGameObject(tag, info.File.Name);
        }
예제 #3
0
 CollidedWithEntityByRayComponent(ElementTag with, Vector3 intersectionPositionWorld) : this()
 {
     Tag     = ElementTag.New("CollidedWith");
     With    = with;
     IsValid = true;
     IntersectionPositionWorld = intersectionPositionWorld;
 }
예제 #4
0
 public void RemoveVisualObject(IContextState context, ElementTag tag)
 {
     if (tags.Remove(tag))
     {
         Cleanup(tag, context);
     }
 }
예제 #5
0
        public Result AddElementTag(string text, string author)
        {
            try
            {
                var result = _unitOfWork.ElementTagRepository.FindBy(x => x.Name.Trim().ToLower() == text.Trim().ToLower());
                if (result.Any())
                {
                    return(new Result(ResultStatus.ALREADYEXISTS));
                }

                var model = new ElementTag
                {
                    Author = author,
                    Name   = text
                };

                _unitOfWork.ElementTagRepository.Add(model);
                _unitOfWork.SaveChanges();
                return(new Result(ResultStatus.OK));
            }
            catch (Exception ex)
            {
                return(new Result(ResultStatus.EXCEPTION, ex.Message));
            }
        }
        private static void waitUntilElementReadyStateIsComplete(IHTMLElement element)
        {
            //TODO: See if this method could be dropped, it seems to give
            //      more trouble (uninitialized state of elements)
            //      then benefits (I just introduced this method to be on
            //      the save side)

            if (ElementTag.IsValidElement(element, Image.ElementTags))
            {
                return;
            }

            // Wait if the readystate of an element is BETWEEN
            // Uninitialized and Complete. If it's uninitialized,
            // it's quite probable that it will never reach Complete.
            // Like for elements that could not load an image or ico
            // or some other bits not part of the HTML page.
            SimpleTimer timeoutTimer = new SimpleTimer(30);

            do
            {
                int readyState = ((IHTMLElement2)element).readyStateValue;

                if (readyState == 0 || readyState == 4)
                {
                    return;
                }

                Thread.Sleep(Settings.SleepTime);
            } while (!timeoutTimer.Elapsed);

            throw new WatiNException("Element didn't reach readystate = complete within 30 seconds: " + element.outerText);
        }
예제 #7
0
        private static void CreateTags(IDictionary <Element, Tag> tagMap, ICollection <Tag> tagList,
                                       AssemblingContext context, Element element, BeginningTag parent)
        {
            if (element is ConcreteElement)
            {
                ElementTag tag = new ElementTag(tagList.Count, context, parent, (ConcreteElement)element);
                tagMap.Add(element, tag);
                tagList.Add(tag);
            }
            else if (element is CompositeElement)
            {
                CompositeElement compositeElement = (CompositeElement)element;

                BeginningTag beginningTag = new BeginningTag(tagList.Count, context, parent, compositeElement);
                tagMap.Add(element, beginningTag);
                tagList.Add(beginningTag);

                foreach (Element e in compositeElement.GetElements())
                {
                    CreateTags(tagMap, tagList, context, e, beginningTag);
                }

                EndTag endTag = new EndTag(tagList.Count, context, parent, beginningTag);
                tagList.Add(endTag);
            }
        }
예제 #8
0
        public static PolylineGameObject Create(IEntityManager manager, ElementTag tag,
                                                IEnumerable <Vector3> points, Vector4[] color)
        {
            var indeces = new List <int>();

            for (var i = 0; i < points.Count(); i++)
            {
                indeces.AddRange(new[] { i, i });
            }
            var geo = new SimpleGeometryComponent()
            {
                Positions = points.ToImmutableArray(),
                Indices   = indeces.ToImmutableArray(),
                Colors    = color.ToImmutableArray(),
            };
            var tag1 = manager
                       .CreateEntity(tag)
                       .AddComponent(geo)
                       .AddComponent(SDX.Engine.Components.D3DLineVertexRenderComponent.AsLineList())
                       .AddComponent(new TransformComponent())
                       //.AddComponent(new PositionColorsComponent { Colors = color })
                       .Tag;

            return(new PolylineGameObject(tag1));
        }
예제 #9
0
        public static mshtml.IHTMLElement GetInputElement(mshtml.IHTMLDocument2 doc, string itemName, string tagStr, string indexStr)
        {
            mshtml.IHTMLElementCollection o       = (mshtml.IHTMLElementCollection)doc.all.tags("input");
            mshtml.IHTMLElement           element = null;
            ElementTag iD   = ElementTag.ID;
            int        num  = 0;
            int        num2 = 0;

            if (!string.IsNullOrEmpty(indexStr))
            {
                num = WindowUtil.StringToInt(indexStr);
            }
            if ((tagStr != string.Empty) && (tagStr != ""))
            {
                iD = (ElementTag)WindowUtil.StringToInt(tagStr);
            }
            foreach (mshtml.IHTMLElement element2 in o)
            {
                if (IsElementMatch(element2, iD, itemName, ""))
                {
                    if (num2 == num)
                    {
                        element = element2;
                        break;
                    }
                    num2++;
                }
            }
            if (o != null)
            {
                Marshal.ReleaseComObject(o);
            }
            return(element);
        }
예제 #10
0
 ColorComponent(Vector4 color, ColorTypes type) : this()
 {
     IsValid = true;
     Tag     = ElementTag.New();
     Color   = color;
     Type    = type;
 }
예제 #11
0
        /// <inheritdoc />
        public void WaitUntilReady()
        {
            WaitUntilElementAvailable();

            if (ElementTag.IsMatch(ElementFactory.GetElementTags <Image>(), this))
            {
                return;
            }

            // Wait as long as the readystate of an element is BETWEEN
            // Uninitialized and Complete. If it's uninitialized,
            // it's quite probable that it will never reach Complete.
            // Like for elements that could not load an image or icon
            // or some other bits not part of the HTML page.
            var tryFuncUntilTimeOut = new TryFuncUntilTimeOut(TimeSpan.FromSeconds(Settings.WaitForCompleteTimeOut));
            var ihtmlElement2       = AsHtmlElement2;
            var success             = tryFuncUntilTimeOut.Try(() =>
            {
                var readyState = ihtmlElement2.readyStateValue;
                return(readyState == 0 || readyState == 4);
            });

            if (success)
            {
                return;
            }

            throw new WatiNException(String.Format("Element didn't reach readystate = complete within {0} seconds: {1}", Settings.WaitForCompleteTimeOut, AsHtmlElement.outerText));
        }
예제 #12
0
        public static VisualPolylineObject Create(IContextState context, ElementTag tag,
                                                  Vector3[] points, Vector4 color, bool isVisible = true)
        {
            var manager = context.GetEntityManager();

            var indeces = new List <int>();
            var pos     = new List <Vector3>();
            var prev    = points[0];

            for (var i = 0; i < points.Length; i++)
            {
                pos.Add(prev);
                pos.Add(points[i]);
                prev = points[i];
            }
            for (var i = 0; i < pos.Count; i++)
            {
                indeces.AddRange(new[] { i, i });
            }
            var geo = context.GetGeometryPool().AddGeometry(new ImmutableGeometryData(pos, indeces));

            manager
            .CreateEntity(tag)
            .AddComponent(geo)
            .AddComponent(TransformComponent.Identity())
            .AddComponent(ColorComponent.CreateDiffuse(color))
            .AddComponent(isVisible ? RenderableComponent.AsLineList() : RenderableComponent.AsLineList().Disable());

            return(new VisualPolylineObject(tag));
        }
예제 #13
0
        public static SingleGameObject Create(IEntityManager manager, BoundingBox box, Vector4 color)
        {
            var tag = new ElementTag("Physics Object" + Guid.NewGuid());

            //var box = new BoundingBox(new Vector3(-5,10,-5), new Vector3(5,20,5));

            box = box.Transform(Matrix4x4.CreateTranslation(new Vector3(64, 100, 32) - box.GetCenter()));

            var geobox = GeometryBuilder.BuildGeoBox(box);

            manager.CreateEntity(tag)
            .AddComponents(new IGraphicComponent[] {
                new SimpleGeometryComponent {
                    Positions = geobox.Positions.ToImmutableArray(),
                    Indices   = geobox.Indices.ToImmutableArray(),
                    Normals   = geobox.Positions.CalculateNormals(geobox.Indices).ToImmutableArray(),
                    Color     = color
                },
                new D3DTriangleColoredVertexRenderComponent(),
                TransformComponent.Create(Matrix4x4.Identity),
                PhysicalComponentFactory.CreateAABB(),
                // PhysicalComponentFactory.CreateMesh(),
            });

            return(new PhysicsObjectTest(tag));
        }
예제 #14
0
 public HasElementComparer(IEnumerable <string> tagNames, Constraint locator)
 {
     this.tagNames = (from tagName in tagNames
                      from tag in ElementTag.ToElementTags(tagName)
                      select tag).ToList();
     this.locator = locator;
 }
예제 #15
0
 public SpherePointComponent(Vector3 center, float radius) : this()
 {
     Center  = center;
     Radius  = radius;
     IsValid = true;
     Tag     = ElementTag.New();
 }
예제 #16
0
        public BoundingBoxRenderableComponent(IVeldridShaderSpecification shader, DeviceBufferesUpdater deviceBufferes, BoundingBox box)
            : base(shader, deviceBufferes)
        {
            EntityTag = new ElementTag("BoundingBox");
            Box       = box;
            geometry  = new Geometry3D();
            var corners = box.GetCorners();

            var points = new List <Vector3>()
            {
                corners.NearBottomLeft,
                corners.NearBottomRight,
                corners.NearTopLeft,
                corners.NearTopRight,
                corners.FarBottomLeft,
                corners.FarBottomRight,
                corners.FarTopLeft,
                corners.FarTopRight
            };

            geometry.Positions = points;
            var index = 0;

            geometry.Indices = new List <int>(geometry.Positions.Select(x => index++));

            var lb = new Std.Engine.Helpers.LineBuilder();

            geometry = lb.Build(points);
        }
예제 #17
0
        public GameObject DrawPolyline(string key, Vector3[] margin, Vector4 green)
        {
            var line = VisualPolylineObject.Create(Context, ElementTag.New($"{key}_polyline"),
                                                   margin, green, true);

            return(line);
        }
예제 #18
0
        protected virtual void UppdateGeometry(IEntityManager manager, ElementTag tag, GeometryComponent geo)
        {
            var en = manager.GetEntity(tag);

            en.RemoveComponents <GeometryComponent>();
            en.AddComponent(geo);
        }
        public static List <string> GetAllValuesFromDropDown(string element, ElementTag elementTag)
        {
            List <string> valuesList = new List <string>();

            if (elementTag == ElementTag.Id)
            {
                foreach (var item in new SelectElement(Driver._driver.FindElement(By.Id(element))).Options)
                {
                    valuesList.Add(item.Text);
                }

                return(valuesList);
            }

            if (elementTag == ElementTag.Name)
            {
                foreach (var item in new SelectElement(Driver._driver.FindElement(By.Name(element))).Options)
                {
                    valuesList.Add(item.Text);
                }

                return(valuesList);
            }
            if (elementTag == ElementTag.Class)
            {
                foreach (var item in new SelectElement(Driver._driver.FindElement(By.ClassName(element))).Options)
                {
                    valuesList.Add(item.Text);
                }

                return(valuesList);
            }

            return(new List <string>());
        }
예제 #20
0
 PerfomanceComponent(double elapsedMilliseconds, double fPS) : this()
 {
     Tag = ElementTag.New();
     ElapsedMilliseconds = elapsedMilliseconds;
     IsValid             = true;
     FPS = fPS;
 }
예제 #21
0
        public void Render(BillboardTextComponent text)
        {
            var color         = new SolidColorBrush(ToMediaColor(text.TextColor));
            var formattedText = new FormattedText(text.Text, CultureInfo.InvariantCulture,
                                                  FlowDirection.LeftToRight, typeface, text.FontSize, color);

            formattedText.SetFontSize(100, 0, text.Text.Length);

            formattedText.PixelsPerDip = 50;

            var renderTargetBitmapWidth  = (int)(formattedText.Width / 2);
            var renderTargetBitmapHeight = (int)(formattedText.Height / 2);

            var visual = new DrawingVisual();

            using (DrawingContext drawingContext = visual.RenderOpen()) {
                drawingContext.DrawText(formattedText, new System.Windows.Point(0, 0));
            }
            var source = new RenderTargetBitmap(renderTargetBitmapWidth, renderTargetBitmapHeight, 50, 50, PixelFormats.Pbgra32);

            source.Clear();
            source.Render(visual);
            source.Freeze();

            var bitmap = new Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            var data   = bitmap.LockBits(new Rectangle(System.Drawing.Point.Empty, bitmap.Size), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
            bitmap.UnlockBits(data);

            RenderedBitmapText = bitmap;

            renderedTextCompTag = text.Tag;
            Scale = (float)text.FontSize / 100f;
        }
예제 #22
0
        static void _Create(IContextState context, IEnumerable <IFileGeometry3D> meshes,
                            FileInfo texture, string name, LoadedVisualObject visual)
        {
            List <ElementTag> t    = new List <ElementTag>();
            var            details = new LoadedObjectDetails();
            var            baseTag = ElementTag.New();
            var            index   = 0;
            AxisAlignedBox fullBox = AxisAlignedBox.Zero;

            foreach (var geo in meshes)
            {
                var tag = Create(context, baseTag.WithPrefix(geo.Name ?? index.ToString()),
                                 new GeometryStructures <IFileGeometry3D>(geo), texture, out var box);
                t.Add(tag);
                fullBox                = fullBox.Merge(box.Bounds);
                details.VertexCount   += geo.Positions.Count;
                details.TriangleCount += (geo.Indices.Count / 3);
                index++;
            }

            visual.tags.AddRange(t);
            visual.Details = details;

            var size = fullBox.Size();

            visual.worldX = VisualPolylineObject.Create(context, baseTag.WithPrefix("WorldX"),
                                                        new[] { Vector3.Zero + Vector3.UnitX * size.X * -2f, Vector3.Zero + Vector3.UnitX * size.X * 2f }, V4Colors.Red, false);
            visual.worldX.IsVisible = false;
            visual.worldY           = VisualPolylineObject.Create(context, baseTag.WithPrefix("WorldY"),
                                                                  new[] { Vector3.Zero + Vector3.UnitY * size.Y * -2f, Vector3.Zero + Vector3.UnitY * size.Y * 2f }, V4Colors.Green, false);
            visual.worldY.IsVisible = false;
            visual.worldZ           = VisualPolylineObject.Create(context, baseTag.WithPrefix("WorldZ"),
                                                                  new[] { Vector3.Zero + Vector3.UnitZ * size.Z * -2f, Vector3.Zero + Vector3.UnitZ * size.Z * 2f }, V4Colors.Blue, false);
            visual.worldZ.IsVisible = false;
        }
예제 #23
0
        public static int GetButtonElementIndex(IHTMLDocument2 doc, IHTMLElement ele, string itemName, string tagStr)
        {
            int  num  = 0;
            bool flag = false;

            if (ele != null)
            {
                ElementTag iD = ElementTag.ID;
                if ((tagStr != string.Empty) && (tagStr != ""))
                {
                    iD = (ElementTag)WindowUtil.StringToInt(tagStr);
                }
                if (iD != ElementTag.ID)
                {
                    IHTMLElementCollection o = (IHTMLElementCollection)doc.all.tags("input");
                    foreach (IHTMLElement element in o)
                    {
                        if ((IsElementMatchType(element, "submit") || IsElementMatchType(element, "button")) && IsElementMatch(element, iD, itemName, ""))
                        {
                            if (ele == element)
                            {
                                flag = true;
                                break;
                            }
                            num++;
                        }
                    }
                    if (o != null)
                    {
                        Marshal.ReleaseComObject(o);
                    }
                    if (!flag)
                    {
                        o = (IHTMLElementCollection)doc.all.tags("button");
                        foreach (IHTMLElement element2 in o)
                        {
                            if (IsElementMatch(element2, iD, itemName, ""))
                            {
                                if (ele == element2)
                                {
                                    flag = true;
                                    break;
                                }
                                num++;
                            }
                        }
                        if (o != null)
                        {
                            Marshal.ReleaseComObject(o);
                        }
                    }
                }
            }
            if (!flag)
            {
                num = 0;
            }
            return(num);
        }
예제 #24
0
        protected void MoveTo(IEntityManager manager, ElementTag targetEntity)
        {
            var com = new MoveCameraToTargetComponent {
                Target = targetEntity
            };

            manager.GetEntity(targetEntity).AddComponent(com);
        }
예제 #25
0
        public GameObject DrawCylinder(string key, CylinderDetails cyl)
        {
            var geo = GeometryBuilder.BuildCylinder(cyl.Start, cyl.Axis, cyl.Radius, cyl.Length);

            var en = EntityBuilders.BuildColored(Context, ElementTag.New(key), geo, cyl.Color, SharpDX.Direct3D11.CullMode.None);

            return(new SingleVisualObject(en.Tag, key));
        }
예제 #26
0
 public GameObject DrawPoint(string key, Vector3 center, Vector4 color)
 {
     return(VisualSphereObject.Create(Context, ElementTag.New($"{key}_Point"), new VisualSphereObject.Data {
         Center = center,
         Color = color,
         Radius = .1f
     }));
 }
예제 #27
0
            public void AddObserver(ElementTag observer)
            {
                if (Observers == null)
                {
                    Observers = new List <ElementTag>();
                }

                Observers.Add(observer);
            }
예제 #28
0
 public static RenderableComponent AsTriangleColoredList(CullMode mode)
 => new RenderableComponent(mode, PrimitiveTopology.TriangleList, RenderTechniques.TriangleColored)
 {
     Tag           = ElementTag.New(),
     IsValid       = true,
     HasBlendState = true,
     RasterizerStateDescription = D3DRasterizerStateDescriptions.Default(mode),
     BlendStateDescription      = D3DBlendStateDescriptions.BlendStateEnabled,
 };
예제 #29
0
 LightComponent(float intensity, int index, Vector3 position, Vector3 direction, LightTypes type) : this()
 {
     Tag       = ElementTag.New();
     IsValid   = true;
     Intensity = intensity;
     Index     = index;
     Position  = position;
     Direction = direction;
     Type      = type;
 }
예제 #30
0
        public RenderableComponent SwitchCullModeTo(CullMode mode)
        {
            Tag          = ElementTag.New();
            IsRenderable = true;
            var rast = RasterizerStateDescription;

            rast.CullMode = mode;
            RasterizerStateDescription = rast;
            return(this);
        }
예제 #31
0
		private static void AssertLowerCaseUpperCase(Mock<INativeElement> elementMock) 
		{
			// LowerCase
			elementMock.Expect(element => element.TagName).Returns("input");
            elementMock.Expect(element => element.GetAttributeValue("type")).Returns("image");

			// UpperCase
			var elementTag = new ElementTag("INPUT", "IMAGE");
			Assert.IsTrue(elementTag.IsMatch(elementMock.Object), "Compare should compare using CultureInvariant");

            elementMock.VerifyAll();
		}
예제 #32
0
        public void Should_be_equal_when_comparing_lower_with_uppercase_tagname()
        {
            // GIVEN
            var tagLowerCase = new ElementTag("frame");
            var tagUpperCase = new ElementTag("FRAME");

            // WHEN
            var isEqual = tagLowerCase.Equals(tagUpperCase);

            // THEN
            Assert.IsTrue(isEqual, "Casing should not be relavent");

        }
예제 #33
0
	    private static bool FinishedAddingChildrenThatMetTheConstraints(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IHTMLElement element, ref ArrayList children)
	    {            
	        waitUntilElementReadyStateIsComplete(element);

	        attributeBag.IHTMLElement = element;

	        bool validElementType = true;
            if (elementTag.IsInputElement)
            {
                validElementType = elementTag.CompareInputTypes(new IEElement(element));
            }

	        if (validElementType && constraint.Compare(attributeBag))
	        {
	            children.Add(element);
	            if (returnAfterFirstMatch)
	            {
	                return true;
	            }
	        }
	        return false;
	    }
예제 #34
0
        private static ArrayList FindElementById(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IElementCollection elementCollection)
	    {
            ArrayList children = new ArrayList();

	        IHTMLElement element = elementTag.GetElementById(elementCollection.Elements, ((AttributeConstraint)constraint).Value);

	        if (element != null)
	        {
	            FinishedAddingChildrenThatMetTheConstraints(constraint, elementTag, attributeBag, returnAfterFirstMatch, element, ref children);
	        }
	        return children;
	    }
예제 #35
0
	    public static ArrayList FindElements(BaseConstraint constraint, ElementTag elementTag, ElementAttributeBag attributeBag, bool returnAfterFirstMatch, IElementCollection elementCollection)
	    {
	        IHTMLElementCollection elements = elementTag.GetElementCollection(elementCollection.Elements);
            ArrayList children = new ArrayList();

	        if (elements != null)
	        {
	            // Loop through each element and evaluate
	            int length = elements.length;
	            for (int index = 0; index < length; index++ )
                {
                    IHTMLElement element = (IHTMLElement)elements.item(index, null);
                    if (FinishedAddingChildrenThatMetTheConstraints(constraint, elementTag, attributeBag, returnAfterFirstMatch, element, ref children))
                    {
                        return children;
                    }
                }
	        }

	        return children;
	    }
예제 #36
0
        private bool GetMEClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, string wangwangName, string tagStr)
        {
            bool flag = false;
            if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
            {
                IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
                int clientWidth = 0;
                int clientHeight = 0;
                int scrollWidth = 0;
                int scrollHeight = 0;
                mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
                mshtml.IHTMLElementCollection links = doc2.links;
                ArrayList list = new ArrayList();

                ElementTag iD = ElementTag.ID;
                if ((tagStr != string.Empty) && (tagStr != ""))
                {
                    iD = (ElementTag) WindowUtil.StringToInt(tagStr);
                }

                foreach (mshtml.IHTMLElement element2 in links)
                {
                    if ((((element2.getAttribute("href", 0) != null) && (element2.getAttribute("target", 0) != null)) && element2.getAttribute("target", 0).ToString().ToLower().Equals("_blank")) &&
                        HtmlUtil.IsElementMatch(element2, iD, wangwangName, "")
                        )
                    {
                        Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
                        if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
                        {
                            list.Add(element2);
                        }
                    }
                }
                if (list.Count == 1)
                {
                    mshtml.IHTMLElement ele = list[0] as mshtml.IHTMLElement;
                    try
                    {
                        mshtml.IHTMLElement itemBoxEle = ele.parentElement.parentElement.parentElement;
                        IHTMLElementCollection children = itemBoxEle.children as mshtml.IHTMLElementCollection;
                        foreach (IHTMLElement div in children)
                        {
                            if (div.className == "summary")
                            {
                                IHTMLElementCollection children2 = div.children as mshtml.IHTMLElementCollection;
                                foreach (IHTMLElement ele2 in children2)
                                {
                                    if (ele2.tagName.ToLower().Trim() == "a")
                                    {
                                        ele = ele2;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        //
                        return false;
                    }

                    if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
                    {
                        this._randomClickLink = ele.outerText;
                        this._randomClickLinkTag = ElementTag.outerText;
                    }
                    else
                    {
                        this._randomClickLinkTag = ElementTag.href;
                        this._randomClickLink = ele.getAttribute("href", 0).ToString();
                    }
                    this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
                    this._status = IEStatus.IEStatus_MoveToDest;
                    this._beforeWaitTime = this._now;
                    list = null;
                    flag = true;
                    return flag;
                }
                if (doc2 != null)
                {
                    this.MoveMouseToBottom(windowHwnd, doc2);
                    if (this.MoveTimeOut() && this.WaitTimeOut())
                    {
                        parent.ShowTip2("不存在标签 :" + tagStr + " 的店铺:" + wangwangName);
                        this._loop = false;
                        flag = true;
                    }
                }
                return flag;
            }
            if (this.WaitTimeOut())
            {
                flag = true;
            }
            return flag;
        }
예제 #37
0
 public static bool IsElementMatch(mshtml.IHTMLElement ele, ElementTag tag, string itemName, string keyword = "")
 {
     itemName = itemName.Trim();
     if (tag == ElementTag.ID)
     {
         return (!string.IsNullOrEmpty(ele.id) && ele.id.Trim().Equals(itemName));
     }
     if (tag == ElementTag.name)
     {
         return ((ele.getAttribute("name", 0) != null) && ele.getAttribute("name", 0).ToString().Trim().Equals(itemName));
     }
     if (tag == ElementTag.outerText)
     {
         return (!string.IsNullOrEmpty(ele.outerText) && (ele.outerText.Trim().IndexOf(itemName) != -1));
     }
     if (tag == ElementTag.className)
     {
         return (!string.IsNullOrEmpty(ele.className) && ele.className.Trim().Equals(itemName));
     }
     if (tag == ElementTag.outerHTML)
     {
         return (!string.IsNullOrEmpty(ele.outerHTML) && ele.outerHTML.Trim().Equals(itemName));
     }
     if (tag == ElementTag.value)
     {
         return ((ele.getAttribute("value", 0) != null) && ele.getAttribute("value", 0).ToString().Trim().Equals(itemName));
     }
     if (tag == ElementTag.href)
     {
         return ((ele.getAttribute("href", 0) != null) && ele.getAttribute("href", 0).ToString().Trim().Equals(itemName));
     }
     if (tag != ElementTag.src)
     {
         return false;
     }
     if (ele.getAttribute("src", 0) == null)
     {
         return false;
     }
     return (ele.getAttribute("src", 0).ToString().Trim().Equals(itemName) || (!string.IsNullOrEmpty(keyword) && (ele.getAttribute("src", 0).ToString().Trim().IndexOf(keyword) != -1)));
 }
예제 #38
0
        public IEnumerable<INativeElement> GetElementsWithQuerySelector(ICssSelector selector, DomContainer domContainer)
        {
            var container = "document";
            if (_element != null)
            {
                var elementTag = new ElementTag(_element.TagName);
                if (elementTag.Equals(new ElementTag("frame")) || elementTag.Equals(new ElementTag("iframe")))
                {
                    var frameHierarchy = _element.GetAttributeValue("data-watinFrameHierarchy");
                    container = frameHierarchy + ".document";
                }
                else
                {
                    var document = _element.AsHtmlElement.document;
                    var result = new Expando(document).GetValue<string>("___WATINFRAMEHIERARCHY");

                    container = "";
                    if (result != null)
                        container = result;

                    if (!string.IsNullOrEmpty(container))
                        container += ".";

                    container += _element.GetJavaScriptElementReference();
                }
            }
            else
            {
                //container = CreateArray();
            }

            domContainer.RunScript(new ScriptLoader().GetSizzleInstallScript());

            var code = string.Format("document.___WATINRESULT = Sizzle('{0}', {1});", selector.Selector(true), container);
            domContainer.RunScript(code);

            return new JScriptElementArrayEnumerator((IEDocument) domContainer.NativeDocument, "___WATINRESULT");
        }
예제 #39
0
 private bool GetDeepClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, string keyword)
 {
     bool flag = false;
     if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
     {
         IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
         int clientWidth = 0;
         int clientHeight = 0;
         int scrollWidth = 0;
         int scrollHeight = 0;
         mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
         mshtml.IHTMLElementCollection links = doc2.links;
         ArrayList list = new ArrayList();
         if (string.IsNullOrEmpty(keyword))
         {
             keyword = "";
         }
         Regex regex = new Regex(keyword + @"(\w)?");
         foreach (mshtml.IHTMLElement element2 in links)
         {
             if ((((element2.getAttribute("href", 0) != null) && (element2.getAttribute("target", 0) != null)) && element2.getAttribute("target", 0).ToString().ToLower().Equals("_blank")) && (string.IsNullOrEmpty(keyword) || regex.IsMatch(element2.getAttribute("href", 0).ToString())))
             {
                 Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
                 if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
                 {
                     list.Add(element2);
                 }
             }
         }
         if (list.Count > 0)
         {
             Random random = new Random();
             int num5 = random.Next(list.Count);
             random = null;
             mshtml.IHTMLElement ele = list[num5] as mshtml.IHTMLElement;
             if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
             {
                 this._randomClickLink = ele.outerText;
                 this._randomClickLinkTag = ElementTag.outerText;
             }
             else
             {
                 this._randomClickLinkTag = ElementTag.href;
                 this._randomClickLink = ele.getAttribute("href", 0).ToString();
             }
             this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
             this._status = IEStatus.IEStatus_MoveToDest;
             this._beforeWaitTime = this._now;
             list = null;
             random = null;
             return flag;
         }
         if (doc2 != null)
         {
             this.MoveMouseToBottom(windowHwnd, doc2);
             if (this.MoveTimeOut() && this.FindTimeOut())
             {
                 parent.ShowTip2("不存在 " + keyword);
                 this._loop = false;
                 flag = true;
             }
         }
         return flag;
     }
     if (this.FindTimeOut())
     {
         flag = true;
     }
     return flag;
 }
예제 #40
0
        //private bool GetPageClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, string linkName, string tagStr)
        //{
        //    bool flag = false;
        //    if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
        //    {
        //        IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
        //        int clientWidth = 0;
        //        int clientHeight = 0;
        //        int scrollWidth = 0;
        //        int scrollHeight = 0;
        //        mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
        //        mshtml.IHTMLElementCollection links = doc2.links;
        //        ArrayList list = new ArrayList();
        //        ElementTag iD = ElementTag.ID;
        //        if ((tagStr != string.Empty) && (tagStr != ""))
        //        {
        //            iD = (ElementTag)WindowUtil.StringToInt(tagStr);
        //        }
        //        foreach (mshtml.IHTMLElement element2 in links)
        //        {
        //            if ((((element2.getAttribute("href", 0) != null) && (element2.getAttribute("target", 0) != null)) && element2.getAttribute("target", 0).ToString().ToLower().Equals("_blank")) &&
        //                HtmlUtil.IsElementMatch(element2, iD, wangwangName, "")
        //                )
        //            {
        //                Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
        //                if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
        //                {
        //                    list.Add(element2);
        //                }
        //            }
        //        }
        //        if (list.Count == 1)
        //        {
        //            mshtml.IHTMLElement ele = list[0] as mshtml.IHTMLElement;
        //            try
        //            {
        //                mshtml.IHTMLElement itemBoxEle = ele.parentElement.parentElement.parentElement;
        //                IHTMLElementCollection children = itemBoxEle.children as mshtml.IHTMLElementCollection;
        //                foreach (IHTMLElement div in children)
        //                {
        //                    if (div.className == "summary")
        //                    {
        //                        IHTMLElementCollection children2 = div.children as mshtml.IHTMLElementCollection;
        //                        foreach (IHTMLElement ele2 in children2)
        //                        {
        //                            if (ele2.tagName == "a")
        //                            {
        //                                ele = ele2;
        //                                break;
        //                            }
        //                        }
        //                        break;
        //                    }
        //                }
        //            }
        //            catch (System.Exception ex)
        //            {
        //                //
        //                return false;
        //            }
        //            if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
        //            {
        //                this._randomClickLink = ele.outerText;
        //                this._randomClickLinkTag = ElementTag.outerText;
        //            }
        //            else
        //            {
        //                this._randomClickLinkTag = ElementTag.href;
        //                this._randomClickLink = ele.getAttribute("href", 0).ToString();
        //            }
        //            this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
        //            this._status = IEStatus.IEStatus_MoveToDest;
        //            this._beforeWaitTime = this._now;
        //            list = null;
        //            flag = true;
        //            return flag;
        //        }
        //        if (doc2 != null)
        //        {
        //            this.MoveMouseToBottom(windowHwnd, doc2);
        //            if (this.MoveTimeOut() && this.WaitTimeOut())
        //            {
        //                parent.ShowTip2("不存在标签 :" + tagStr + " 的店铺:" + wangwangName);
        //                this._loop = false;
        //                flag = true;
        //            }
        //        }
        //        return flag;
        //    }
        //    if (this.WaitTimeOut())
        //    {
        //        flag = true;
        //    }
        //    return flag;
        //}
        private bool GetPageClickLinkInfo(TenDayBrowser parent, mshtml.IHTMLDocument2 doc2, int index)
        {
            bool flag = false;
            if (((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null)) && (doc2 != null))
            {
                IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
                int clientWidth = 0;
                int clientHeight = 0;
                int scrollWidth = 0;
                int scrollHeight = 0;
                mshtml.IHTMLElement2 element = HtmlUtil.GetWindowWidthAndHeight(windowHwnd, doc2, ref clientWidth, ref clientHeight, ref scrollWidth, ref scrollHeight);
                mshtml.IHTMLElementCollection links = doc2.links;
                ArrayList list = new ArrayList();

                string outText = clickLinkItem[index];

                foreach (mshtml.IHTMLElement element2 in links)
                {
                    if (element2.innerText != null && element2.innerText.ToLower().Trim().Contains(outText))
                    {
                        Rectangle elementRect = HtmlUtil.GetElementRect(doc2.body, element2);
                        if ((((elementRect.Height > 0) && (elementRect.Width > 0)) && (((elementRect.X + element.scrollLeft) > 0) && ((elementRect.X + element.scrollLeft) < scrollWidth))) && (((elementRect.Y + element.scrollTop) > 0) && ((elementRect.Y + element.scrollTop) < scrollHeight)))
                        {
                            list.Add(element2);
                        }
                    }
                }
                if (list.Count == 1)
                {
                    mshtml.IHTMLElement ele = list[0] as mshtml.IHTMLElement;
                    if (!string.IsNullOrEmpty(ele.outerText) && !string.IsNullOrEmpty(ele.outerText.Trim()))
                    {
                        this._randomClickLink = ele.outerText;
                        this._randomClickLinkTag = ElementTag.outerText;
                    }
                    else
                    {
                        this._randomClickLinkTag = ElementTag.href;
                        this._randomClickLink = outText;
                    }
                    this._randomClickLinkIndex = HtmlUtil.GetLinkElementIndex(doc2, ele, this._randomClickLink, ((int)this._randomClickLinkTag).ToString());
                    this._status = IEStatus.IEStatus_MoveToDest;
                    this._beforeWaitTime = this._now;
                    list = null;
                    flag = true;
                    return flag;
                }
                if (doc2 != null)
                {
                    this.MoveMouseToBottom(windowHwnd, doc2);
                    if (this.MoveTimeOut() && this.WaitTimeOut())
                    {
                        parent.ShowTip2("不存在标签 :" + outText);
                        this._loop = false;
                        flag = true;
                    }
                }
                return flag;
            }
            if (this.WaitTimeOut())
            {
                flag = true;
            }
            return flag;
        }
예제 #41
0
		private ArrayList findElementsByAttribute(ElementTag elementTag, BaseConstraint constraint, bool returnAfterFirstMatch)
		{
			// Get elements with the tagname from the page
		    constraint.Reset();
            ElementAttributeBag attributeBag = new ElementAttributeBag(_domContainer);

            if (FindByExactMatchOnIdPossible(constraint))
            {
                return FindElementById(constraint, elementTag, attributeBag, returnAfterFirstMatch, _elementCollection);
            }
            return FindElements(constraint, elementTag, attributeBag, returnAfterFirstMatch, _elementCollection);
		}
 public void ToStringShouldBeEmptyIfTagNameIsNull()
 {
     var elementTag = new ElementTag((string) null);
     Assert.That(elementTag.ToString(), Is.EqualTo(""));
 }
예제 #43
0
		public void IsMatchNullShouldThrow()
		{
			var elementTag = new ElementTag("tagname");
			elementTag.IsMatch(null);
		}
예제 #44
0
		public void ToStringShouldBeEmptyIfTagNameIsNull()
		{
			var elementTag = new ElementTag((string) null);
			Assert.That(elementTag.ToString(), NUnit.Framework.SyntaxHelpers.Is.EqualTo(""));
		}