public static void CreateElementPosition(Control c, StringBuilder sb, EnumWebElementPositionType positionType) { IWebClientControl wcc = c as IWebClientControl; if (wcc != null) { if (wcc.textAlign != EnumTextAlign.left) { sb.Append(string.Format(CultureInfo.InvariantCulture, "text-align:{0};", wcc.textAlign)); } // string widthStyle, heightStyle; GetElementStyleSize(wcc, out widthStyle, out heightStyle); if (!string.IsNullOrEmpty(widthStyle)) { sb.Append("width:"); sb.Append(widthStyle); } if (!string.IsNullOrEmpty(heightStyle)) { sb.Append("height:"); sb.Append(heightStyle); } // } IWebBox wb = c as IWebBox; if (wb != null) { if (wb.Box.BorderRadius > 0) { sb.Append("border-radius:"); sb.Append(wb.Box.BorderRadius.ToString(CultureInfo.InvariantCulture)); sb.Append("px;"); } if (wb.Box.BoxShadow > 0) { int bs = 1; if (wb.Box.BoxShadow > 2) { bs = wb.Box.BoxShadow / 2; } string cs; if (wb.Box.ShadowColor == Color.Empty) { cs = ObjectCreationCodeGen.GetColorString(Color.DarkGray); } else { cs = ObjectCreationCodeGen.GetColorString(wb.Box.ShadowColor); } sb.Append(string.Format(CultureInfo.InvariantCulture, "box-shadow:{0}px {0}px {1}px {2};", wb.Box.BoxShadow, bs, cs)); } if (wb.Box.GradientEndColor != Color.Empty || wb.Box.GradientStartColor != Color.Empty) { string c1; if (wb.Box.GradientStartColor != Color.Empty) { c1 = ObjectCreationCodeGen.GetColorString(wb.Box.GradientStartColor); } else { c1 = ObjectCreationCodeGen.GetColorString(Color.White); } string c2; if (wb.Box.GradientEndColor != Color.Empty) { c2 = ObjectCreationCodeGen.GetColorString(wb.Box.GradientEndColor); } else { c2 = ObjectCreationCodeGen.GetColorString(Color.White); } sb.Append(string.Format(CultureInfo.InvariantCulture, "background-image:-ms-linear-gradient({0}deg, {1}, {2});", wb.Box.GradientAngle, c1, c2)); sb.Append(string.Format(CultureInfo.InvariantCulture, "background-image:-o-linear-gradient({0}deg, {1}, {2});", wb.Box.GradientAngle, c1, c2)); sb.Append(string.Format(CultureInfo.InvariantCulture, "background-image:-moz-linear-gradient({0}deg, {1}, {2});", wb.Box.GradientAngle, c1, c2)); sb.Append(string.Format(CultureInfo.InvariantCulture, "background-image:-webkit-linear-gradient({0}deg, {1}, {2});", wb.Box.GradientAngle, c1, c2)); } } IScrollableWebControl sw = c as IScrollableWebControl; if (sw != null) { if (sw.Overflow != EnumOverflow.visible) { sb.Append(string.Format(CultureInfo.InvariantCulture, "overflow:{0};", sw.Overflow)); } } if (c.RightToLeft == RightToLeft.Yes) { sb.Append("direction:rtl;"); } if (positionType != EnumWebElementPositionType.Auto) { if (positionType == EnumWebElementPositionType.Absolute) { sb.Append("position: absolute; "); Point pointForm = c.Location; sb.Append("left:"); sb.Append(pointForm.X.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); sb.Append("top:"); sb.Append(pointForm.Y.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); } else if (positionType == EnumWebElementPositionType.Relative) { sb.Append("position: relative; "); sb.Append("left:"); sb.Append(c.Left.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); // sb.Append("top:"); sb.Append(c.Top.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); } else if (positionType == EnumWebElementPositionType.FloatLeft) { sb.Append("float:left; "); } else if (positionType == EnumWebElementPositionType.FloatRight) { sb.Append("float:right; "); } else if (positionType == EnumWebElementPositionType.FloatCenter) { sb.Append("float:center; "); } } IWebClientControl wc = c as IWebClientControl; if (wc != null) { if (wc.Opacity < 100) { sb.Append(string.Format(CultureInfo.InvariantCulture, "opacity:{0};filter:alpha(opacity={1}); ", ((double)wc.Opacity / (double)100).ToString("#.##", CultureInfo.InvariantCulture), wc.Opacity)); } } }
public static void CreateElementPosition(Control c, StringBuilder sb, EnumWebElementPositionType positionType) { IWebClientControl wcc = c as IWebClientControl; if (wcc != null) { if (wcc.textAlign != EnumTextAlign.left) { sb.Append(string.Format(CultureInfo.InvariantCulture, "text-align:{0};", wcc.textAlign)); } } IScrollableWebControl sw = c as IScrollableWebControl; if (sw != null) { if (sw.Overflow != EnumOverflow.visible) { sb.Append(string.Format(CultureInfo.InvariantCulture, "overflow:{0};", sw.Overflow)); } } if (c.RightToLeft == RightToLeft.Yes) { sb.Append("direction:rtl;"); } if (positionType != EnumWebElementPositionType.Auto) { if (positionType == EnumWebElementPositionType.Absolute) { sb.Append("position: absolute; "); //Form f = c.FindForm(); //if (f != null) //{ //Point pointScreen = c.PointToScreen(c.Location); //Point pointForm = f.PointToClient(pointScreen); Point pointForm = c.Location; sb.Append("left:"); sb.Append(pointForm.X.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); // sb.Append("top:"); sb.Append(pointForm.Y.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); //} } else if (positionType == EnumWebElementPositionType.Relative) { sb.Append("position: relative; "); sb.Append("left:"); sb.Append(c.Left.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); // sb.Append("top:"); sb.Append(c.Top.ToString(CultureInfo.InvariantCulture)); sb.Append("px; "); } else if (positionType == EnumWebElementPositionType.FloatLeft) { sb.Append("float:left; "); } else if (positionType == EnumWebElementPositionType.FloatRight) { sb.Append("float:right; "); } else if (positionType == EnumWebElementPositionType.FloatCenter) { sb.Append("float:center; "); } } IWebClientControl wc = c as IWebClientControl; if (wc != null) { if (wc.Opacity < 100) { sb.Append(string.Format(CultureInfo.InvariantCulture, "opacity:{0};filter:alpha(opacity={1}); ", ((double)wc.Opacity / (double)100).ToString("#.##", CultureInfo.InvariantCulture), wc.Opacity)); } } }