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


C# IHTMLElement.setAttribute方法代码示例

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


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

示例1: AcceptHyperlink

        public AcceptHyperlink(HTMLDocument Document, string AcceptUrl, string StoreID)
        {
            _anchor = Document.createElement("a");
            _anchor.setAttribute("href", "javascript:accept_link_click();",0);
            _anchor.setAttribute("id", "accept_link", 0);

            _anchor.style.fontSize = "x-small";
            _anchor.style.fontWeight = "bold";

            _anchor.innerText = "Yes, Log Me In";
        }
开发者ID:grefly,项目名称:Buy4,代码行数:11,代码来源:AcceptHyperlink.cs

示例2: YesLink

        public YesLink(HTMLDocument Document, string AcceptUrl, string StoreID, string ReturnUrl)
        {
            _yes_link = Document.createElement("a");

            AcceptUrl = AcceptUrl
                .Replace("###id###", StoreID)
                .Replace("###return_url###", ReturnUrl);

            _yes_link.setAttribute("href",AcceptUrl,0);
            _yes_link.setAttribute("id", "yes_link",0);
            _yes_link.innerText = "Yes";
        }
开发者ID:grefly,项目名称:Buy4,代码行数:12,代码来源:YesLink.cs

示例3: DeclineHyperlink

        public DeclineHyperlink(HTMLDocument Document)
        {
            _anchor = Document.createElement("a");
            _anchor.setAttribute("href", "javascript:decline_link_click()", 0);

            _anchor.style.fontSize = "x-small";
            _anchor.style.fontWeight = "normal";

            _anchor.innerText = "No, thanks";
        }
开发者ID:grefly,项目名称:Buy4,代码行数:10,代码来源:DeclineHyperlink.cs

示例4: NoticeDiv

        public NoticeDiv(HTMLDocument Document,Buy4Configuration Config, Store Store)
        {
            _div = Document.createElement("div");
            _div.innerHTML = Config.GetContent(Store, Document.url);
            _div.style.cssText = Config.GetStyle();

            _div.setAttribute("id", "buy4_notice", 0);
            ((IHTMLStyle2) _div.style).overflowX = "hidden";
            ((IHTMLStyle2) _div.style).overflowY = "hidden";
            ((IHTMLStyle2) _div.style).position = "relative";
            _div.style.display = "none";
            _div.style.filter = "alpha(opacity=95)";
            _div.style.zIndex = 1000;
        }
开发者ID:grefly,项目名称:Buy4,代码行数:14,代码来源:NoticeDiv.cs

示例5: ExtractFlashCore

        void ExtractFlashCore(IHTMLElement rpElement)
        {
            rpElement.setAttribute("wmode", "direct");
            rpElement.document.createStyleSheet().cssText = @"body {
            margin:0;
            overflow:hidden
        }
        
        #game_frame {
            position:fixed;
            left:50%;
            top:-16px;
            margin-left:-450px;
            z-index:1
        }";

            r_IsExtracted = true;
            FlashExtracted();
        }
开发者ID:XHidamariSketchX,项目名称:ProjectDentan,代码行数:19,代码来源:TridentBrowser.cs

示例6: UpdateImageSource

        internal static void UpdateImageSource(ImagePropertiesInfo imgProperties, IHTMLElement imgElement, IBlogPostImageEditingContext editorContext, ImageInsertHandler imageInsertHandler, ImageDecoratorInvocationSource invocationSource)
        {
            ISupportingFile oldImageFile = null;
            try
            {
                oldImageFile = editorContext.SupportingFileService.GetFileByUri(new Uri((string)imgElement.getAttribute("src", 2)));
            }
            catch (UriFormatException) { }
            if (oldImageFile != null) //then this is a known supporting image file
            {
                using (new WaitCursor())
                {
                    BlogPostImageData imageData = BlogPostImageDataList.LookupImageDataByInlineUri(editorContext.ImageList, oldImageFile.FileUri);
                    if (imageData != null)
                    {
                        //Create a new ImageData object based on the image data attached to the current image src file.
                        BlogPostImageData newImageData = (BlogPostImageData)imageData.Clone();

                        //initialize some handlers for creating files based on the image's existing ISupportingFile objects
                        //This is necessary so that the new image files are recognized as being updates to an existing image
                        //which allows the updates to be re-uploaded back to the same location.
                        CreateImageFileHandler inlineFileCreator = new CreateImageFileHandler(editorContext.SupportingFileService,
                                                                                              newImageData.InlineImageFile != null ? newImageData.InlineImageFile.SupportingFile : null);
                        CreateImageFileHandler linkedFileCreator = new CreateImageFileHandler(editorContext.SupportingFileService,
                                                                                              newImageData.LinkedImageFile != null ? newImageData.LinkedImageFile.SupportingFile : null);

                        //re-write the image files on disk using the latest settings
                        imageInsertHandler.WriteImages(imgProperties, true, invocationSource, new CreateFileCallback(inlineFileCreator.CreateFileCallback), new CreateFileCallback(linkedFileCreator.CreateFileCallback), editorContext.EditorOptions);

                        //update the ImageData file references
                        Size imageSizeWithBorder = imgProperties.InlineImageSizeWithBorder;

                        //force a refresh of the image size values in the DOM by setting the new size attributes
                        imgElement.setAttribute("width", imageSizeWithBorder.Width, 0);
                        imgElement.setAttribute("height", imageSizeWithBorder.Height, 0);

                        newImageData.InlineImageFile.SupportingFile = inlineFileCreator.ImageSupportingFile;
                        newImageData.InlineImageFile.Height = imageSizeWithBorder.Height;
                        newImageData.InlineImageFile.Width = imageSizeWithBorder.Width;
                        if (imgProperties.LinkTarget == LinkTargetType.IMAGE)
                        {
                            newImageData.LinkedImageFile = new ImageFileData(linkedFileCreator.ImageSupportingFile, imgProperties.LinkTargetImageSize.Width, imgProperties.LinkTargetImageSize.Height, ImageFileRelationship.Linked);
                        }
                        else
                            newImageData.LinkedImageFile = null;

                        //assign the image decorators applied during WriteImages
                        //Note: this is a clone so the sidebar doesn't affect the decorator values for the newImageData image src file
                        newImageData.ImageDecoratorSettings = (BlogPostSettingsBag)imgProperties.ImageDecorators.SettingsBag.Clone();

                        //update the upload settings
                        newImageData.UploadInfo.ImageServiceId = imgProperties.UploadServiceId;

                        //save the new image data in the image list
                        editorContext.ImageList.AddImage(newImageData);
                    }
                    else
                        Debug.Fail("imageData could not be located");
                }
            }

            if (imgProperties.LinkTarget == LinkTargetType.NONE)
            {
                imgProperties.RemoveLinkTarget();
            }
        }
开发者ID:dbremner,项目名称:OpenLiveWriter,代码行数:66,代码来源:ImageEditingPropertyHandler.cs

示例7: ResetPath

        private static void ResetPath(string attributeName, IHTMLElement element, string baseUrl)
        {
            // For this element, try to find the attribute containing a relative path
            string relativePath = null;

            Object pathObject = element.getAttribute(attributeName, HTMLAttributeFlags.DoNotEscapePaths);
            if (pathObject != DBNull.Value)
            {
                if (pathObject is String)
                    relativePath = (string)pathObject;
            }

            // If a relative path was discovered and its not an internal anchor, reset it
            if (relativePath != null && !relativePath.StartsWith("#", StringComparison.OrdinalIgnoreCase) && !UrlHelper.IsUrl(relativePath))
            {
                // Reset the value of the attribute to the escaped Path
                element.setAttribute(attributeName,
                UrlHelper.EscapeRelativeURL(baseUrl, relativePath),
                HTMLAttributeFlags.CaseInSensitive);
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:21,代码来源:HTMLDocumentHelper.cs

示例8: Test3

        private static void Test3()
        {
            //var settings = VMLSettings.Default;

            var container = "div".AttachToDocument();

            container.style.border = "1px solid red";
            container.style.width = "400px";
            container.style.height = "300px";
            container.style.overflow = IStyle.OverflowEnum.hidden;

            container.style.position = IStyle.PositionEnum.relative;

            var layer = new IVMLGroup().AttachTo(container);

            layer.setAttribute("coordsize", "400,300");

            layer.style.width = "400px";
            layer.style.height = "300px";

            var rect = new IHTMLElement("v:rect").AttachTo(layer);

            // http://midiwebconcept.free.fr/

            rect.setAttribute("fillcolor", "red");
            rect.style.left = "10";
            rect.style.top = "10";
            rect.style.width = "400px";
            rect.style.height = "300px";

            var fill = new IHTMLElement("v:fill").AttachTo(rect);

            fill.setAttribute("color2", "blue");
            fill.setAttribute("type", "gradient");

            {
                var image = new IVMLImage
                {
                    src = "assets/VectorExample/TILE1436.png"
                };
				
				
				image.AttachTo(layer);

				image.style.top = "100px";
				image.style.left = "100px";
                image.style.width = "200px";
                image.style.height = "200px";
				var r = 0;

				image.rotation = r;

				(1000 / 20).AtInterval(
					delegate
					{
						r++;
						image.rotation = r;
					}
				);
				
            }

	

            container.onmousemove +=
                ev =>
                {
                    if (ev.ctrlKey)
                    {
                        if (ev.Element == container)
                        {
                            var image = new IVMLImage()
                                {
                                    src = "assets/VectorExample/TILE1436.png"
                                }.AttachTo(layer);

                            image.style.left = ev.OffsetX + "px";
                            image.style.top = ev.OffsetY + "px";
                            image.style.width = "200px";
                            image.style.height = "200px";
                        }
                    }
                };


            var polyline = new IVMLPolyline();

            polyline.points = "10,8 100,100 55,77";

            polyline.AttachTo(layer);




        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:95,代码来源:VectorExample.cs

示例9: Application

        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public Application(IApp page)
        {
            // X:\jsc.svn\examples\javascript\async\test\TestScopeWithDelegate\TestScopeWithDelegate\Application.cs

            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201406/20140629
            // can we get support for any level1 scope progress elements?
            // after that we may want to allow Tasks being sent back to the worker.
            // what about sharing static bools too. we already share strings..
            // what about synchronizing scope objects once worker is running?
            // a Thread Signal or Task Yield may request the sync to take place.
            // this would allow data sharing during computation?
            // then we may also want to get delegate sharing..


            //0:6113ms Task scope { MemberName = progress, IsString = false, IsNumber = false, TypeIndex = type$Iuc7fw31uTShD4lFrT9xIg }
            //0:6161ms Task scope { MemberName = CS___9__CachedAnonymousMethodDelegate6, IsString = false, IsNumber = false, TypeIndex = type$P_aMwuiDRzTKOqkDQd7BGAw }

            // X:\jsc.svn\core\ScriptCoreLib\JavaScript\BCLImplementation\System\Threading\Tasks\Task\Task.ctor.cs
            IProgress<string> progress = new Progress<string>(
                x =>
                {
                    new IHTMLPre {
                        new { x, Thread.CurrentThread.ManagedThreadId }
                    }.AttachToDocument();
                }
            );

            // http://www.w3schools.com/tags/tag_progress.asp
            //new IHTMLInput(ScriptCoreLib.Shared.HTMLInputTypeEnum.pro
            var p = new IHTMLElement("progress").AttachToDocument();

            p.setAttribute("value", 20);
            p.setAttribute("max", 100);

            IProgress<int> set_progress = new Progress<int>(
                x =>
                    {
                        p.setAttribute("value", x);
                    }
            );


            Native.css.style.transition = "background-color 300ms linear";

            // future jsc will allow a background thread to directly talk to the DOM, while creating a callsite in the background
            IProgress<string> set_backgroundColor = new Progress<string>(
                x =>
                {
                    Native.css.style.backgroundColor = x;
                }
            );


            var foo = "foo";

            new IHTMLButton { "invoke" }.AttachToDocument().onclick +=
                async e =>
                {
                    progress.Report("UI " + new { foo, Thread.CurrentThread.ManagedThreadId });

                    await Task.Run(async delegate
                    {
                        Console.WriteLine("inside worker " + new { foo, Thread.CurrentThread.ManagedThreadId });

                        // we could also support direct delegates?
                        progress.Report("inside worker " + new { foo, Thread.CurrentThread.ManagedThreadId });

                        set_backgroundColor.Report("yellow");

                        // this will confuse task to be Task<?> ?
                        for (int i = 20; i <= 100; i += 2)
                        {
                            set_progress.Report(i);
                            await Task.Delay(100);
                        }

                        set_backgroundColor.Report("cyan");

                        Console.WriteLine("exit worker " + new { foo, Thread.CurrentThread.ManagedThreadId });

                        // we could also support direct delegates?
                        progress.Report("exit worker " + new { foo, Thread.CurrentThread.ManagedThreadId });
                    });
                };

        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:90,代码来源:Application.cs

示例10: MoveCssPropertiesToHtmlAttributes

        /// <summary>
        /// Moves a few CSS properties (text-align, width and height) to their respective HTML attributes (when
        /// applicable) to provide better compatibility with MSHTML's editing commands.
        /// </summary>
        /// <param name="sourceElement">The element from which the CSS property originated.</param>
        /// <param name="destinationElement">The element that will receive the HTML attributes.</param>
        private void MoveCssPropertiesToHtmlAttributes(IHTMLElement sourceElement, IHTMLElement destinationElement)
        {
            IHTMLStyle inlineStyle = destinationElement.style;

            if (!String.IsNullOrEmpty(inlineStyle.textAlign))
            {
                if (SupportsAlignmentAttribute(destinationElement))
                {
                    // The CSS text-align and HTML align attribute have a 1-to-1 mapping, so no conversion needed.
                    destinationElement.setAttribute("align", inlineStyle.textAlign, 0);
                    inlineStyle.textAlign = null;
                }
            }

            string width = inlineStyle.width as string;
            if (!String.IsNullOrEmpty(width) && String.Compare(width, "auto", StringComparison.OrdinalIgnoreCase) != 0)
            {
                if (IsPercentage(width) && SupportsPercentageWidthAttribute(destinationElement))
                {
                    destinationElement.setAttribute("width", width, 0);
                    inlineStyle.width = string.Empty;
                }
                else if (SupportsPixelWidthAttribute(destinationElement))
                {
                    // Make sure we convert any relative units (e.g. em, percentages, etc) to pixels because that is
                    // what the HTML width attribute is expecting. We calculate this off the source element to ensure
                    // it is correct.
                    int widthInPixels = (int)HTMLElementHelper.CSSUnitStringToPixelSize(HTMLElementHelper.CSSUnitStringWidth, sourceElement, null, false);

                    destinationElement.setAttribute("width", widthInPixels.ToString(CultureInfo.InvariantCulture), 0);
                    inlineStyle.width = string.Empty;
                }
            }

            string height = inlineStyle.height as string;
            if (!String.IsNullOrEmpty(height) && String.Compare(height, "auto", StringComparison.OrdinalIgnoreCase) != 0)
            {
                if (IsPercentage(height) && SupportsPercentageHeightAttribute(destinationElement))
                {
                    destinationElement.setAttribute("height", height, 0);
                    inlineStyle.height = string.Empty;
                }
                else if (SupportsPixelHeightAttribute(destinationElement))
                {
                    // Make sure we convert any relative units (e.g. em, percentages, etc) to pixels because that is
                    // what the HTML height attribute is expecting. We calculate this off the source element to ensure
                    // it is correct.
                    int heightInPixels = (int)HTMLElementHelper.CSSUnitStringToPixelSize(HTMLElementHelper.CSSUnitStringHeight, sourceElement, null, true);

                    destinationElement.setAttribute("height", heightInPixels.ToString(CultureInfo.InvariantCulture), 0);
                    inlineStyle.height = string.Empty;
                }
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:60,代码来源:KeepSourceFormatting.cs

示例11: Application


//.........这里部分代码省略.........
                //new XAttribute().Changed

                // http://msdn.microsoft.com/en-us/library/bb387098(v=vs.110).aspx
                // http://msdn.microsoft.com/en-us/library/system.xml.linq.xobject.changed(v=vs.110).aspx
                e.AsXElement().Changed +=
                    (sender, args) =>
                    {
                        // MutationObserver

                        // server side events too?
                    };

                var s = e.createShadowRoot();

                //var i = new IHTMLIFrame { src = "http://example.com" };
                var i = new IHTMLIFrame
                {
                    // prevent cyclic reload
                    src = "about:blank"

                    //src = "http://example.com"
                };

                s.appendChild(
                    i
                );




                e.attributes.WithEach(
                    a =>
                    {
                        //i.src = a.value;

                        new IHTMLPre { "attribute " + new { a.name, a.value } }.AttachToDocument();

                        if (a.name == "foo")
                        {
                            // are we observing that too?
                            i.src = a.value;
                        }
                    }
                );

                // does it mean we are nowready to get events for XLinq?
                // is it suppsoed to work?
                new MutationObserver(

                    new MutationCallback(
                    (mutations, o) =>
                {
                    foreach (var item in mutations)
                    {
                        var value = e.getAttributeNode(item.attributeName).value;

                        //i.src = ;

                        new IHTMLPre { "MutationObserver " + new { item.attributeName, value, item.type, item.target } }.AttachToDocument();


                        if (item.attributeName == "foo")
                        {
                            // are we observing that too?
                            i.src = value;
                        }
                    }
                }

                        )
                ).observe(e, new { attributes = true });

            },


                // http://www.w3.org/TR/2014/WD-dom-20140710/
                // https://code.google.com/p/mutation-summary/wiki/DOMMutationObservers
                // http://stackoverflow.com/questions/5416822/dom-mutation-events-replacement
                attributeChangedCallback:
                    (attributeName, e) =>
                    {
                        // css conditionals


                        new IHTMLPre { new { attributeName
                            }
                        }.AttachToDocument();
                    }
            );

            var z = new IHTMLElement("example-com")
            {
                //$foo = "bar"
                //new XAttribute("foo", "bar")
            }.AttachToDocument();

            z.setAttribute("foo", "http://example.com");


        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:Application.cs

示例12: ImportStyleSheet

        static IHTMLElement ImportStyleSheet(string url)
        {
            Console.WriteLine("importing css at " + url);

            var s = new IHTMLElement(IHTMLElement.HTMLElementEnum.link);

            s.setAttribute("rel", "stylesheet");
            s.setAttribute("type", "text/css");
            s.setAttribute("href", url);

            s.AttachToDocument();

            return s;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:14,代码来源:DemoControl.cs


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