Esempio n. 1
0
        public MarginStyle GetMarginStyleFromHtml(IHTMLElement img)
        {
            IHTMLElement2 img2         = (IHTMLElement2)img;
            int           marginTop    = GetPixels(img2.currentStyle.marginTop as string);
            int           marginRight  = GetPixels(img2.currentStyle.marginRight as string);
            int           marginBottom = GetPixels(img2.currentStyle.marginBottom as string);
            int           marginLeft   = GetPixels(img2.currentStyle.marginLeft as string);
            MarginStyle   margin       = new MarginStyle(marginTop, marginRight, marginBottom, marginLeft, StyleSizeUnit.PX);

            return(margin);
        }
        protected override void LoadEditor()
        {
            base.LoadEditor();
            HtmlMarginSettings = new HtmlMarginDecoratorSettings(Settings, EditorContext.ImgElement);

            comboBoxMargins.CustomMargins = HtmlMarginSettings.HasCustomMargin;
            MarginStyle marginStyle = HtmlMarginSettings.Margin;

            numericMarginTop.Value    = marginStyle.Top;
            numericMarginRight.Value  = marginStyle.Right;
            numericMarginBottom.Value = marginStyle.Bottom;
            numericMarginLeft.Value   = marginStyle.Left;

            marginCommand.Value = new Padding(marginStyle.Left, marginStyle.Top, marginStyle.Right, marginStyle.Bottom);
        }
Esempio n. 3
0
        private static string GetHtmlMarginFromMarginStyle(MarginStyle margin, IHTMLElement element)
        {
            string unitSize    = margin.SizeUnit.ToString().ToLower(CultureInfo.InvariantCulture);
            string marginRight = margin.Right.ToString(CultureInfo.InvariantCulture) + unitSize;
            string marginLeft  = margin.Left.ToString(CultureInfo.InvariantCulture) + unitSize;

            string currentRightMargin = "";

            if (element.style.marginRight != null)
            {
                currentRightMargin = element.style.marginRight.ToString();
            }

            string currentLeftMargin = "";

            if (element.style.marginLeft != null)
            {
                currentLeftMargin = element.style.marginLeft.ToString();
            }


            // This is because margins and centering images can conflict with eachother
            if (margin.Right == 0 && currentRightMargin == "auto" &&
                margin.Left == 0 && currentLeftMargin == "auto")
            {
                marginRight = "auto";
                marginLeft  = "auto";
            }
            else if ((margin.Right != 0 || margin.Left != 0) && currentRightMargin == "auto" && currentLeftMargin == "auto")
            {
                // The user is breaking their centered image by setting a L/R margin
                element.style.display = "inline";
            }


            string marginString = String.Format(CultureInfo.InvariantCulture, "{0}{4} {1} {2}{4} {3}",
                                                margin.Top, marginRight, margin.Bottom, marginLeft, unitSize);

            return(marginString);
        }
 public MarginStyle GetMarginStyleFromHtml(IHTMLElement img)
 {
     IHTMLElement2 img2 = (IHTMLElement2)img;
     int marginTop = GetPixels(img2.currentStyle.marginTop as string);
     int marginRight = GetPixels(img2.currentStyle.marginRight as string);
     int marginBottom = GetPixels(img2.currentStyle.marginBottom as string);
     int marginLeft = GetPixels(img2.currentStyle.marginLeft as string);
     MarginStyle margin = new MarginStyle(marginTop, marginRight, marginBottom, marginLeft, StyleSizeUnit.PX);
     return margin;
 }
        private static string GetHtmlMarginFromMarginStyle(MarginStyle margin, IHTMLElement element)
        {
            string unitSize = margin.SizeUnit.ToString().ToLower(CultureInfo.InvariantCulture);
            string marginRight = margin.Right.ToString(CultureInfo.InvariantCulture) + unitSize;
            string marginLeft = margin.Left.ToString(CultureInfo.InvariantCulture) + unitSize;

            string currentRightMargin = "";
            if (element.style.marginRight != null)
                currentRightMargin = element.style.marginRight.ToString();

            string currentLeftMargin = "";
            if (element.style.marginLeft != null)
                currentLeftMargin = element.style.marginLeft.ToString();

            // This is because margins and centering images can conflict with eachother
            if (margin.Right == 0 && currentRightMargin == "auto" &&
                margin.Left == 0 && currentLeftMargin == "auto")
            {
                marginRight = "auto";
                marginLeft = "auto";
            }
            else if ((margin.Right != 0 || margin.Left != 0) && currentRightMargin == "auto" && currentLeftMargin == "auto")
            {
                // The user is breaking their centered image by setting a L/R margin
                element.style.display = "inline";
            }

            string marginString = String.Format(CultureInfo.InvariantCulture, "{0}{4} {1} {2}{4} {3}",
                margin.Top, marginRight, margin.Bottom, marginLeft, unitSize);
            return marginString;
        }