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


C# IHTMLElement.removeAttribute方法代码示例

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


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

示例1: htmlEditor_SnapRectEvent

        private void htmlEditor_SnapRectEvent(IHTMLElement pIElement, ref RECT prcNEW, _ELEMENT_CORNER elementCorner)
        {
            IHTMLImgElement imgElement = pIElement as IHTMLImgElement;
            if (imgElement != null)
            {
                // see if we are scaling a new image
                if (snapRectImageElement == null || snapRectImageElement.sourceIndex != snapRectImageElement.sourceIndex)
                {
                    // save the image element so that mouseUp handler can regenerate the resized image.
                    snapRectImageElement = pIElement;

                    //save the initial image size so that we can scale the image based on the original size.
                    //Note: this is important to minimize rounding errors that may occurs while the image is snapping
                    //the old logic scaled based on the imgElement height and width attributes, so each snap iteration would
                    //case the image to distort more and more.
                    snapRectInitialImageSize = new Size(imgElement.width, imgElement.height);
                }

                // only preserve constraints if we are sizing a true corner
                if (IsTrueCorner(elementCorner))
                {
                    snapRectPreserveConstraints = true;
                    // get the new width and height
                    int width = prcNEW.right - prcNEW.left;
                    int height = prcNEW.bottom - prcNEW.top;

                    // scale the picture (using its current proportions!) based on the size of the snap rectangle.
                    Size constrainedSize = ImageUtils.GetScaledImageSize(width, height, snapRectInitialImageSize);
                    width = constrainedSize.Width;
                    height = constrainedSize.Height;

                    // adjust the location and size of the image
                    switch (elementCorner)
                    {
                        case _ELEMENT_CORNER.ELEMENT_CORNER_BOTTOMLEFT:
                            prcNEW.left = prcNEW.right - width;
                            prcNEW.bottom = prcNEW.top + height;
                            break;
                        case _ELEMENT_CORNER.ELEMENT_CORNER_BOTTOMRIGHT:
                            prcNEW.right = prcNEW.left + width;
                            prcNEW.bottom = prcNEW.top + height;
                            break;
                        case _ELEMENT_CORNER.ELEMENT_CORNER_TOPLEFT:
                            prcNEW.left = prcNEW.right - width;
                            prcNEW.top = prcNEW.bottom - height;
                            break;
                        case _ELEMENT_CORNER.ELEMENT_CORNER_TOPRIGHT:
                            prcNEW.right = prcNEW.left + width;
                            prcNEW.top = prcNEW.bottom - height;
                            break;
                        default:
                            Trace.Fail("Unexpected element corner: " + elementCorner.ToString());
                            break;
                    }
                }

                //Hack: unset the width and height attributes so that the MSHTMLEditor doesn't set the height/width
                //using the style attribute when it handles the snapRect.  Once its set using style, it can never be unset...
                pIElement.removeAttribute("width", 0);
                pIElement.removeAttribute("height", 0);

            }

            //suppress resizing of the the extended entry splitter
            if (pIElement.id == PostBodyEditingElementBehavior.EXTENDED_ENTRY_ID)
            {
                IHTMLElement2 e2 = (IHTMLElement2)pIElement;
                IHTMLRect rect = e2.getBoundingClientRect();
                prcNEW.top = rect.top;
                prcNEW.bottom = rect.bottom;
                prcNEW.left = rect.left;
                prcNEW.right = rect.right;
            }
        }
开发者ID:braegelno5,项目名称:OpenLiveWriter,代码行数:74,代码来源:BlogPostHtmlEditorControl.cs


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