Ejemplo n.º 1
0
        private void RenderSliderHeader(HtmlTextWriter output)
        {
            output.AddAttribute(
                _direction == DirectionLift.Vertical ? HtmlTextWriterAttribute.Height : HtmlTextWriterAttribute.Width,
                Size.ToString());

            output.AddAttribute("onselectstart", "return false;");
            output.AddAttribute("ondragstart", "return false;");
            output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            output.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            if (CssClass == string.Empty)
            {
                output.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Utils.Color2Hex(BackColor));
                if (BorderStyle != BorderStyle.None && BorderStyle != BorderStyle.NotSet)
                {
                    output.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, BorderStyle.ToString());
                    output.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, Utils.Color2Hex(BorderColor));
                    output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, BorderWidth.ToString());
                }

                output.AddStyleAttribute("cursor", "default");
            }
            else
            {
                output.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            }
        }
Ejemplo n.º 2
0
//-------------------------------------------------------------------------------------------
        protected override void Render(HtmlTextWriter writer)
        {
            if (!Visible)
            {
                return;
            }
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, BorderStyle.ToString());
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, BorderWidth.ToString());
            writer.AddAttribute(HtmlTextWriterAttribute.Width, Width.ToString());
            writer.AddAttribute(HtmlTextWriterAttribute.Href, Height.ToString());
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.RenderBeginTag("table");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "groupboxtitle");
            writer.RenderBeginTag("tr");
            writer.AddAttribute(HtmlTextWriterAttribute.Background, "images/group-box-bar.gif");
            writer.RenderBeginTag("td");
            writer.Write(Text);
            writer.RenderEndTag();
            writer.RenderEndTag();
            for (int i = 0; i < Items.Count; i++)
            {
                RenderItemRow(writer, Items[i]);
            }
            writer.RenderEndTag();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the HTML CSS.
        /// </summary>
        /// <param name="clientID">The client ID.</param>
        /// <param name="Name">The name.</param>
        /// <returns></returns>
        public string CreateHtmlCss(string clientID, string Name)
        {
            string style = string.Empty;

            style += string.Format(".AME_{0}{1}\n", clientID, Name);
            style += "{\n";
            if (BackColor != Color.Empty)
            {
                style += string.Format("background-color: {0};\n", Utils.Color2Hex(BackColor));
            }
            if (BorderStyle != BorderStyle.NotSet)
            {
                style += string.Format("border-style : {0};\n", BorderStyle.ToString());
                style += string.Format("border-width : {0};\n", BorderWidth);
                style += string.Format("border-color : {0};\n", Utils.Color2Hex(BorderColor));
            }

            if (ForeColor != Color.Empty)
            {
                style += string.Format("color : {0};\n", Utils.Color2Hex(ForeColor));
            }

            style += "margin : 0px;\n";

            style += "}\n\n";

            return(style);
        }
Ejemplo n.º 4
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var list = new TagBuilder("ul", "flex-list", IsInGrid);

            MergeAttributes(list, context);
            if (AlignItems != AlignItems.Default)
            {
                list.AddCssClass("align-" + AlignItems.ToString().ToLowerInvariant());
            }
            if (JustifyItems != JustifyItems.Default)
            {
                list.AddCssClass("justify-" + JustifyItems.ToString().ToKebabCase());
            }
            list.AddCssClass(Orientation.ToString().ToLowerInvariant());
            if (BorderStyle != BorderStyle.None)
            {
                list.AddCssClass($"border-{BorderStyle.ToString().ToKebabCase()}");
            }
            if (MinWidth != null)
            {
                list.MergeStyleUnit("min-width", MinWidth.Value);
            }
            list.RenderStart(context);
            RenderChildren(context);
            list.RenderEnd(context);
        }
        /// <summary>
        /// Adds HTML attributes and styles that need to be rendered to the specified System.Web.UI.HtmlTextWriter.
        /// </summary>
        /// <param name="writer">A System.Web.UI.HtmlTextWriter that represents the output stream to render HTML content on the client.</param>
        public void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (_cssClass != null && _cssClass != string.Empty)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, _cssClass);
            }

            if (_foreColor != Color.Empty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Color, Utils.Color2Hex(_foreColor));
            }
            if (_backColor != Color.Empty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Utils.Color2Hex(_backColor));
            }

            if (_borderColor != Color.Empty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, Utils.Color2Hex(_borderColor));
            }
            if (_borderWidth != Unit.Empty)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, _borderWidth.ToString());
                if (_borderStyle != BorderStyle.NotSet)
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, _borderStyle.ToString());
                }
                else
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");
                }
            }
        }
Ejemplo n.º 6
0
        public override String ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"{DocumentIdentifier},");
            sb.Append($"{FileOrder},");
            sb.Append($"{X},");
            sb.Append($"{Y},");
            sb.Append($"{Width},");
            sb.Append($"{Height},");
            sb.Append($"{MarkupType},");
            sb.Append($"{(FillA == null ? "null" : FillA.ToString())},");
            sb.Append($"{(FillR == null ? "null" : FillR.ToString())},");
            sb.Append($"{(FillG == null ? "null" : FillG.ToString())},");
            sb.Append($"{(FillB == null ? "null" : FillB.ToString())},");
            sb.Append($"{(BorderSize == null ? "null" : BorderSize.ToString())},");
            sb.Append($"{(BorderA == null ? "null" : BorderA.ToString())},");
            sb.Append($"{(BorderR == null ? "null" : BorderR.ToString())},");
            sb.Append($"{(BorderG == null ? "null" : BorderG.ToString())},");
            sb.Append($"{(BorderB == null ? "null" : BorderB.ToString())},");
            sb.Append($"{(BorderStyle == null ? "null" : BorderStyle.ToString())},");
            sb.Append($"{FontName},");
            sb.Append($"{(FontA == null ? "null" : FontA.ToString())},");
            sb.Append($"{(FontR == null ? "null" : FontR.ToString())},");
            sb.Append($"{(FontG == null ? "null" : FontG.ToString())},");
            sb.Append($"{(FontB == null ? "null" : FontB.ToString())},");
            sb.Append($"{(FontSize == null ? "null" : FontSize.ToString())},");
            sb.Append($"{(FontStyle == null ? "null" : FontStyle.ToString())},");
            sb.Append($"{Text},");
            sb.Append($"{ZOrder},");
            String drawCrossLinesValue = DrawCrossLines ? "1" : "0";

            sb.Append($"{drawCrossLinesValue},");
            sb.Append($"{MarkupSubType},");
            sb.Append($"{(Xd == null ? "null" : Xd.ToString())},");
            sb.Append($"{(Yd == null ? "null" : Yd.ToString())},");
            sb.Append($"{(WidthD == null ? "null" : WidthD.ToString())},");
            sb.Append($"{(HeightD == null ? "null" : HeightD.ToString())}");

            String retVal = sb.ToString();

            return(retVal);
        }
        public String ToStringRedactionData()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"{nameof(FileOrder)}: {FileOrder}, ");
            sb.Append($"{nameof(X)}: {X}, ");
            sb.Append($"{nameof(Y)}: {Y}, ");
            sb.Append($"{nameof(Width)}: {Width}, ");
            sb.Append($"{nameof(Height)}: {Height}, ");
            sb.Append($"{nameof(MarkupType)}: {MarkupType}, ");
            sb.Append($"{nameof(FillA)}: {(FillA == null ? "null" : FillA.ToString())}, ");
            sb.Append($"{nameof(FillR)}: {(FillR == null ? "null" : FillR.ToString())}, ");
            sb.Append($"{nameof(FillG)}: {(FillG == null ? "null" : FillG.ToString())}, ");
            sb.Append($"{nameof(FillB)}: {(FillB == null ? "null" : FillB.ToString())}, ");
            sb.Append($"{nameof(BorderSize)}: {(BorderSize == null ? "null" : BorderSize.ToString())}, ");
            sb.Append($"{nameof(BorderA)}: {(BorderA == null ? "null" : BorderA.ToString())}, ");
            sb.Append($"{nameof(BorderR)}: {(BorderR == null ? "null" : BorderR.ToString())}, ");
            sb.Append($"{nameof(BorderG)}: {(BorderG == null ? "null" : BorderG.ToString())}, ");
            sb.Append($"{nameof(BorderB)}: {(BorderB == null ? "null" : BorderB.ToString())}, ");
            sb.Append($"{nameof(BorderStyle)}: {(BorderStyle == null ? "null" : BorderStyle.ToString())}, ");
            sb.Append($"{nameof(FontName)}: {FontName}, ");
            sb.Append($"{nameof(FontA)}: {(FontA == null ? "null" : FontA.ToString())}, ");
            sb.Append($"{nameof(FontR)}: {(FontR == null ? "null" : FontR.ToString())}, ");
            sb.Append($"{nameof(FontG)}: {(FontG == null ? "null" : FontG.ToString())}, ");
            sb.Append($"{nameof(FontB)}: {(FontB == null ? "null" : FontB.ToString())}, ");
            sb.Append($"{nameof(FontSize)}: {(FontSize == null ? "null" : FontSize.ToString())}, ");
            sb.Append($"{nameof(FontStyle)}: {(FontStyle == null ? "null" : FontStyle.ToString())}, ");
            sb.Append($"{nameof(Text)}: {Text}, ");
            sb.Append($"{nameof(ZOrder)}: {ZOrder}, ");
            sb.Append($"{nameof(DrawCrossLines)}: {DrawCrossLines}, ");
            sb.Append($"{nameof(MarkupSubType)}: {MarkupSubType}, ");
            sb.Append($"{nameof(Xd)}: {Xd}, ");
            sb.Append($"{nameof(Yd)}: {Yd}, ");
            sb.Append($"{nameof(WidthD)}: {WidthD}, ");
            sb.Append($"{nameof(HeightD)}: {HeightD}");

            String retVal = sb.ToString();

            return(retVal);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Renders the toolbars container.
        /// </summary>
        /// <param name="output">The output.</param>
        protected void RenderToolbarsContainer(HtmlTextWriter output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            AddAttributesGroup(output, Hidden, string.Empty, $"{UniqueID}_toolbars", $"{UniqueID}_toolbars");

            if (BackColor != Color.Empty)
            {
                AddAttributesGroup(output, Hidden, Utils.Color2Hex(BackColor), $"{UniqueID}_backColor", $"{UniqueID}_backColor");
            }

            if (BackColorDock != Color.Empty)
            {
                AddAttributesGroup(output, Hidden, Utils.Color2Hex(BackColorDock), $"{UniqueID}_backColorDock", $"{UniqueID}_backColorDock");
            }

            output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "1px");
            output.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");
            output.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, "black");

            var top        = string.Empty;
            var left       = string.Empty;
            var enumerator = Style.Keys.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Current != null && string.Equals(enumerator.Current.ToString(), Left, StringComparison.OrdinalIgnoreCase))
                {
                    left = Style[(string)enumerator.Current];
                }

                if (enumerator.Current != null && string.Equals(enumerator.Current.ToString(), Top, StringComparison.OrdinalIgnoreCase))
                {
                    top = Style[(string)enumerator.Current];
                }
            }

            if (left != string.Empty && Width != Unit.Empty)
            {
                output.AddStyleAttribute(LeftSmall, left);
            }
            else
            {
                output.AddStyleAttribute(LeftSmall, ZeroPx);
            }

            output.AddStyleAttribute(TopSmall, top != string.Empty ? top : ZeroPx);

            output.AddStyleAttribute(HtmlTextWriterStyle.Width, Width != Unit.Empty ? Width.ToString() : HundredPercent);

            if (Height != Unit.Empty)
            {
                output.AddStyleAttribute(HtmlTextWriterStyle.Height, Height.ToString());
            }

            output.AddStyleAttribute(PositionString, Position.ToString());
            output.AddAttribute(HtmlTextWriterAttribute.Id, UniqueID);
            output.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
            output.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, Utils.Color2Hex(BorderColor));
            if (BorderStyle != BorderStyle.NotSet)
            {
                output.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, BorderStyle.ToString());
            }

            output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, BorderWidth != Unit.Empty ? BorderWidth.ToString() : ZeroPx);

            output.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Utils.Color2Hex(BackColor));

            output.AddAttribute(OnSelectStart, ReturnFalse);
            if (BackImage != string.Empty)
            {
                output.AddStyleAttribute(BackgroundImage, $"url({ImagesDirectory}{BackImage})");
            }

            RenderToolbarsPosition(output);
        }
Ejemplo n.º 9
0
        internal void CreateStyle(Page Page, string RootCSS)
        {
            if (Page == null)
            {
                throw (new InvalidOperationException("Cannot access the page class"));
            }
            else if (Page.Header == null)
            {
                throw (new InvalidOperationException("Cannot access the page header. Set runat attribute of head tag to server."));
            }


            CustomStyle ul = new CustomStyle();

            ul.Style["margin"]          = "0";
            ul.Style["padding-bottom"]  = RealHeight.ToString();
            ul.Style["padding-left"]    = "0px";
            ul.Style["height"]          = "auto !important";
            ul.Style["list-style-type"] = "none";

            if (BorderStyle != System.Web.UI.WebControls.BorderStyle.NotSet && BorderStyle != System.Web.UI.WebControls.BorderStyle.None)
            {
                ul.Style["border-top"]    = "0 !important";
                ul.Style["border-left"]   = "0 !important";
                ul.Style["border-right"]  = "0 !important";
                ul.Style["border-bottom"] = BorderStyle.ToString().ToLower() + " " + BorderWidth.ToString() + " " + System.Drawing.ColorTranslator.ToHtml(BorderColor);
            }
            Page.Header.StyleSheet.CreateStyleRule(ul, null, RootCSS);

            CustomStyle li = new CustomStyle();

            li.Style["list-style-type"] = "none";
            li.Style["margin"]          = "0";
            li.Style["padding"]         = "0";
            li.Style["display"]         = "inline";
            Page.Header.StyleSheet.CreateStyleRule(li, null, RootCSS + " li");

            CustomStyle liA = new CustomStyle();

            liA.Style["float"]           = "left";
            liA.Style["line-height"]     = "14px";
            liA.Style["padding"]         = "2px 10px 2px 10px;";
            liA.Style["text-decoration"] = "none";
            liA.Style["margin-top"]      = "2px";
            if (TabSeparator.IsEmpty)
            {
                liA.Style["margin-right"] = "2px";
            }
            else
            {
                liA.Style["margin-right"] = TabSeparator.ToString();
            }

            if (!ForeColor.IsEmpty)
            {
                liA.Style["color"] = ForeColor.ToString();
            }
            Page.Header.StyleSheet.CreateStyleRule(liA, null, RootCSS + " a:link, " + RootCSS + " a:visited, " + RootCSS + " span");
            if (!_TabStyle.IsEmpty)
            {
                Page.Header.StyleSheet.CreateStyleRule(_TabStyle, null, RootCSS + " a:link, " + RootCSS + " a:visited, " + RootCSS + " span");
            }


            CustomStyle liAselected = new CustomStyle();

            liAselected.Style["padding"]    = "4px 10px 2px 10px;";
            liAselected.Style["margin-top"] = "0px";

            if (_SelectedTabStyle.BorderStyle == System.Web.UI.WebControls.BorderStyle.NotSet || _SelectedTabStyle.BorderStyle == System.Web.UI.WebControls.BorderStyle.None)
            {
                if (!SelectedTabBackColor.IsEmpty)
                {
                    liAselected.Style["border-bottom"] = "solid 1px " + System.Drawing.ColorTranslator.ToHtml(SelectedTabBackColor);
                }
                else
                {
                    liAselected.Style["border-bottom"] = "solid 1px white";
                }

                /*
                 * .Style("border-bottom") = _SelectedTabStyle.BorderStyle.ToString().ToLower() & " " & _SelectedTabStyle.BorderWidth.ToString() & " " & Drawing.ColorTranslator.ToHtml(_SelectedTabStyle.BorderColor)
                 */
            }
            Page.Header.StyleSheet.CreateStyleRule(liAselected, null, RootCSS + " li.selected a:link, " + RootCSS + " li.selected a:visited, " + RootCSS + " li.selected span");
            if (!_SelectedTabStyle.IsEmpty)
            {
                Page.Header.StyleSheet.CreateStyleRule(_SelectedTabStyle, null, RootCSS + " li.selected a:link, " + RootCSS + " li.selected a:visited, " + RootCSS + " li.selected span");
            }
        }
Ejemplo n.º 10
0
        public async override Task RenderAsync(TextWriter writer)
        {
            var tagBuilder = new TagBuilder("input")
            {
                TagRenderMode = TagRenderMode.SelfClosing
            };

            tagBuilder.Attributes.Add("name", Name);
            tagBuilder.Attributes.Add("type", "submit");
            tagBuilder.Attributes.Add("value", Text);

            if (!Visible)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "display", Value = "none"
                });
            }

            if (BorderWidth > 0)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "border-width", Value = $"{BorderWidth}px"
                });
            }

            if (BorderStyle > BorderStyle.None)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "border-style",
                    Value     = BorderStyle.ToString().ToLower()
                });
            }

            if (!string.IsNullOrEmpty(BorderColor))
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "border-color", Value = BorderColor
                });
            }

            if (!string.IsNullOrEmpty(BackColor))
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "background-color", Value = BackColor
                });
            }

            if (!string.IsNullOrEmpty(ForeColor))
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "color", Value = ForeColor
                });
            }

            if (!string.IsNullOrEmpty(CssClass))
            {
                tagBuilder.AddCssClass(CssClass);
            }

            if (!Enabled)
            {
                tagBuilder.Attributes.Add("disabled", "disabled");
            }

            if (Height > 0)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "hidth", Value = $"{Height}px"
                });
            }

            if (Width > 0)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "width", Value = $"{Width}px"
                });
            }

            if (!string.IsNullOrEmpty(ToolTip))
            {
                tagBuilder.Attributes.Add("title", ToolTip);
            }

            if (Font != null)
            {
                if (!string.IsNullOrEmpty(Font.Name))
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-family", Value = Font.Name
                    });
                }

                if (Font.Size > 0)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-size", Value = $"{Font.Size}px"
                    });
                }

                if (Font.Bold)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-weight", Value = "bold"
                    });
                }

                if (Font.Italic)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-style", Value = "italic"
                    });
                }

                if (Font.Underline)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "text-decoration", Value = "underline"
                    });
                }

                if (Font.Stirkeout)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "text-decoration", Value = "line-throug"
                    });
                }
            }

            if (!string.IsNullOrEmpty(CommandName))
            {
                tagBuilder.Attributes.Add("data-commandName", CommandName);
            }

            if (!string.IsNullOrEmpty(CommandArgument))
            {
                tagBuilder.Attributes.Add("data-commandArgument", CommandArgument);
            }

            tagBuilder.WriteTo(writer, HtmlEncoder.Default);

            await Task.CompletedTask;
        }
Ejemplo n.º 11
0
        private string GenerateCssStyle()
        {
            StringBuilder cssStyle = new StringBuilder();
            string        color;

            cssStyle.Append(" style='");

            if (BorderWidth.ToString().Length > 0)
            {
                cssStyle.Append("border-width:");
                cssStyle.Append(BorderWidth.ToString());
                cssStyle.Append(";");
            }

            if (BorderStyle != BorderStyle.NotSet)
            {
                cssStyle.Append("border-style:");
                cssStyle.Append(BorderStyle.ToString());
                cssStyle.Append(";");
            }

            color = this.GetHtmlColor(BorderColor);
            if (color.Length > 0)
            {
                cssStyle.Append("border-color:");
                cssStyle.Append(color);
                cssStyle.Append(";");
            }

            color = this.GetHtmlColor(BackColor);
            if (color.Length > 0)
            {
                cssStyle.Append("background-color:" + color + ";");
            }

            color = this.GetHtmlColor(ForeColor);
            if (color.Length > 0)
            {
                cssStyle.Append("color:" + color + ";");
            }

            if (this.Font.Bold == true)
            {
                cssStyle.Append("font-weight:bold;");
            }

            if (Font.Italic == true)
            {
                cssStyle.Append("font-style:italic;");
            }

            if (Font.Underline == true)
            {
                cssStyle.Append("text-decoration:underline;");
            }

            if (Font.Strikeout == true)
            {
                cssStyle.Append("text-decoration:line-through;");
            }

            if (Font.Overline == true)
            {
                cssStyle.Append("text-decoration:overline;");
            }

            if (Font.Size.ToString().Length > 0)
            {
                cssStyle.Append("font-size:" + Font.Size.ToString() + ";");
            }

            if (Font.Names.Length > 0)
            {
                cssStyle.Append("font-family:");
                foreach (string fontFamily in Font.Names)
                {
                    cssStyle.Append(fontFamily);
                    cssStyle.Append(",");
                }

                cssStyle.Length = cssStyle.Length - 1;
                cssStyle.Append(";");
            }

            if (string.IsNullOrEmpty(Height.ToString()) == false)
            {
                cssStyle.Append("height:" + Height.ToString() + ";");
            }

            if (string.IsNullOrEmpty(Width.ToString()) == false)
            {
                cssStyle.Append("width:" + Width.ToString() + ";");
            }

            cssStyle.Append("'");

            if (cssStyle.ToString() == " style=''")
            {
                return(string.Empty);
            }
            else
            {
                return(cssStyle.ToString());
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Returns the border style enum as a script property name.
 /// </summary>
 /// <param name="style">The style enum value.</param>
 /// <returns>Returns a script-ready name for the property.</returns>
 public static string CssPropertyName(this BorderStyle style)
 {
     return(style.ToString().CamelCase());
 }
Ejemplo n.º 13
0
 /// <include file='doc\Panel.uex' path='docs/doc[@for="Panel.StringFromBorderStyle"]/*' />
 /// <devdoc>
 /// </devdoc>
 /// <internalonly/>
 private static string StringFromBorderStyle(BorderStyle value) {      
     Type borderStyleType = typeof(BorderStyle);
     return (ClientUtils.IsEnumValid(value, (int)value, (int)BorderStyle.None, (int)BorderStyle.Fixed3D)) ? (borderStyleType.ToString() + "." + value.ToString()) : "[Invalid BorderStyle]";
 }
Ejemplo n.º 14
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var ul = new TagBuilder("a2-list", null, IsInGrid);

            onRender?.Invoke(ul);
            var isBind = GetBinding(nameof(ItemsSource));

            ul.AddCssClassBool(Striped, "striped");
            ul.AddCssClassBool(Border, "border");
            ul.AddCssClassBool(Flush, "flush");
            ul.AddCssClassBool(Compact, "compact");
            ul.MergeAttribute("group-by", GroupBy);
            if (BorderStyle != BorderStyle.None)
            {
                ul.AddCssClass($"border-{BorderStyle.ToString().ToKebabCase()}");
            }
            if (MarkerStyle != RowMarkerStyle.None)
            {
                ul.MergeAttribute("mark-style", MarkerStyle.ToString().ToKebabCase());
            }
            if (Select != null)
            {
                ul.MergeAttribute(":selectable", Select.Value.ToString().ToLowerInvariant());
            }
            ul.AddCssClass(Style.ToString().ToKebabCase());
            //ul.MergeAttribute(":command", "()=> $navigate()");

            if (Background != BackgroundStyle.Default)
            {
                ul.AddCssClass("background-" + Background.ToString().ToKebabCase());
            }

            var mbind = GetBinding(nameof(Mark));

            if (mbind != null)
            {
                ul.MergeAttribute("mark", mbind.Path /*without scope, property name*/);
            }
            else if (Mark != null)
            {
                throw new XamlException("The Mark property must be a binding");
            }

            if (isBind != null)
            {
                ul.MergeAttribute(":items-source", isBind.GetPath(context));
                ul.MergeAttribute("v-lazy", isBind.GetPath(context));
            }
            MergeAttributes(ul, context);
            if (Height != null)
            {
                ul.MergeStyle("height", Height.Value);
            }
            if (MaxHeight != null)
            {
                ul.MergeStyle("max-height", MaxHeight.Value);
            }
            if (AutoSelect != AutoSelectMode.None)
            {
                ul.MergeAttribute("auto-select", AutoSelect.ToString().ToKebabCase());
            }
            ul.RenderStart(context);
            RenderBody(context, isBind != null);
            RenderEmptyPanel(context);
            ul.RenderEnd(context);
        }
    protected string GetRenderStyleValue(string name, BorderStyle value)
    {
        if (value != BorderStyle.NotSet)
        {
            return name + ":" + value.ToString().ToLowerInvariant() + ";";
        }

        // Do not render the value
        return "";
    }
Ejemplo n.º 16
0
        private string RenderPanelHeader(HtmlTextWriter output)
        {
            output.AddAttribute(HtmlTextWriterAttribute.Type, "Hidden");
            output.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
            output.AddAttribute(HtmlTextWriterAttribute.Value, DateTime.Now.Ticks.ToString());
            output.RenderBeginTag(HtmlTextWriterTag.Input);
            output.RenderEndTag();

            output.Write($"<div id=\"{ClientID}_Panel\" onselectstart=\"return false;\" ondragstart=\"return false\">");

            output.AddAttribute(HtmlTextWriterAttribute.Id, ClientID + "_State");
            output.AddAttribute(HtmlTextWriterAttribute.Name, ClientID + "_State");
            output.AddAttribute(HtmlTextWriterAttribute.Type, "hidden");
            output.AddAttribute(HtmlTextWriterAttribute.Value, State.ToString());
            output.RenderBeginTag(HtmlTextWriterTag.Input);
            output.RenderEndTag();

            var style = new StringBuilder();

            if (Width.Value > 0)
            {
                style.Append($"width:{Width};");
            }

            if (Height.Value > 0)
            {
                style.Append($"height:{Height};");
            }

            if (BackColor != Color.Empty)
            {
                style.Append($"background-color:{Utils.Color2Hex(BackColor)};");
            }

            if (BorderStyle != BorderStyle.NotSet && BorderStyle != BorderStyle.None)
            {
                style.Append($"border-color:{Utils.Color2Hex(BorderColor)};");
                style.Append($"border-style:{BorderStyle.ToString()};");
                style.Append($"border-width:{BorderWidth};");
            }

            output.Write(
                $"<table{(style.ToString() != string.Empty ? $" style=\"{style}\"" : string.Empty)} cellpadding={CellPadding} cellspacing={CellSpacing}>");                 // OPEN TABLE 1

            style.Length   = 0;
            style.Capacity = 0;

            if (TitleHeight.Value > 0)
            {
                style.Append($"height:{TitleHeight};");
            }

            if (State == PanelState.Collapsed)
            {
                if (TitleBackColorCollapsed != Color.Empty)
                {
                    style.Append($"background-color:{Utils.Color2Hex(TitleBackColorCollapsed)};");
                }
            }
            else
            {
                if (TitleBackColorExpanded != Color.Empty)
                {
                    style.Append($"background-color:{Utils.Color2Hex(TitleBackColorExpanded)};");
                }
            }

            return(style.ToString());
        }
Ejemplo n.º 17
0
        /// <summary>
        /// returns css "style=" tag for this control
        /// based on standard control visual properties
        /// </summary>
        private string CssStyle()
        {
            var sb = new System.Text.StringBuilder();

            sb.Append(" style='");

            if (!BorderWidth.IsEmpty)
            {
                sb.Append("border-width:");
                sb.Append(BorderWidth.ToString());
                sb.Append(";");
            }
            if (BorderStyle != System.Web.UI.WebControls.BorderStyle.NotSet)
            {
                sb.Append("border-style:");
                sb.Append(BorderStyle.ToString());
                sb.Append(";");
            }
            if (!BorderColor.IsEmpty)
            {
                sb.Append("border-color:");
                sb.Append(HtmlColor(BorderColor));
                sb.Append(";");
            }

            if (!BackColor.IsEmpty)
            {
                sb.Append("background-color:" + HtmlColor(BackColor) + ";");
            }

            if (!ForeColor.IsEmpty)
            {
                sb.Append("color:" + HtmlColor(ForeColor) + ";");
            }

            if (Font.Bold)
            {
                sb.Append("font-weight:bold;");
            }

            if (Font.Italic)
            {
                sb.Append("font-style:italic;");
            }

            if (Font.Underline)
            {
                sb.Append("text-decoration:underline;");
            }

            if (Font.Strikeout)
            {
                sb.Append("text-decoration:line-through;");
            }

            if (Font.Overline)
            {
                sb.Append("text-decoration:overline;");
            }

            if (!Font.Size.IsEmpty)
            {
                sb.Append("font-size:" + Font.Size + ";");
            }

            if (Font.Names.Length > 0)
            {
                sb.Append("font-family:");
                foreach (var fontFamily in Font.Names)
                {
                    sb.Append(fontFamily);
                    sb.Append(",");
                }
                sb.Length = sb.Length - 1;
                sb.Append(";");
            }

            if (!string.IsNullOrEmpty(Height.ToString()))
            {
                sb.Append("height:" + Height + ";");
            }
            if (!string.IsNullOrEmpty(Width.ToString()))
            {
                sb.Append("width:" + Width + ";");
            }

            sb.Append("'");
            return(sb.ToString());
        }
Ejemplo n.º 18
0
        /// <include file='doc\Panel.uex' path='docs/doc[@for="Panel.StringFromBorderStyle"]/*' />
        /// <devdoc>
        /// </devdoc>
        /// <internalonly/>
        private static string StringFromBorderStyle(BorderStyle value)
        {
            Type borderStyleType = typeof(BorderStyle);

            return((ClientUtils.IsEnumValid(value, (int)value, (int)BorderStyle.None, (int)BorderStyle.Fixed3D)) ? (borderStyleType.ToString() + "." + value.ToString()) : "[Invalid BorderStyle]");
        }
Ejemplo n.º 19
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (null == MyGadget)
            {
                return;
            }

            if (MyGadget is RootElementMaster)
            {
                SetupGadgetForInlineRender((RootElementMaster)MyGadget);
            }
            string bordStyle = "";

            if (BorderWidth.Value > 0)
            {
                string color = BorderColor.IsEmpty ? "" : BorderColor.ToKnownColor().ToString();
                bordStyle = string.Format("border:{0} {1} {2};", BorderWidth.ToString(), BorderStyle.ToString(), color);
            }

            writer.Write("<div");
            if (!string.IsNullOrEmpty(CssClass))
            {
                writer.Write(" class=\"" + CssClass + "\" ");
            }
            if (!string.IsNullOrEmpty(bordStyle) ||
                !Width.IsEmpty ||
                !Height.IsEmpty)
            {
                writer.Write(" style=\"");
                writer.Write(bordStyle);
                if (!Width.IsEmpty)
                {
                    writer.Write(String.Format("width:{0};", Width));
                }
                if (!Height.IsEmpty)
                {
                    writer.Write(String.Format("height:{0};", Height));
                }

                writer.Write("\"");
            }
            writer.WriteLine(">");

            if (MyGadget.HasErrors())
            {
                writer.WriteLine("<pre style='font-weight:bold;color:red;'>");
                writer.WriteLine(MyGadget.Errors.ParseErrors[0].Message);
                if (MyGadget.Errors.ParseErrors[0] is XmlException)
                {
                    string err = MyGadget.Errors.GetParseExceptionContent((XmlException)MyGadget.Errors.ParseErrors[0]);
                    if (!string.IsNullOrEmpty(err))
                    {
                        writer.WriteLine(err.Replace("<", "&lt;").Replace(">", "&gt;"));
                    }
                }
                writer.WriteLine("</pre>");
            }
            else
            {
                MyGadget.Render(writer);
            }
            writer.WriteLine("</div>");
        }
Ejemplo n.º 20
0
        public async override Task RenderAsync(TextWriter writer)
        {
            var tagName = "input";

            if (TextMode == TextBoxMode.MultiLine)
            {
                tagName = "textarea";
            }

            var tagBuilder = new TagBuilder(tagName)
            {
                TagRenderMode = TagRenderMode.SelfClosing
            };

            tagBuilder.Attributes.Add("name", Name);
            switch (TextMode)
            {
            case TextBoxMode.SingleLine:
                tagBuilder.Attributes.Add("type", "text");
                break;

            case TextBoxMode.MultiLine:
                if (Columns > 0)
                {
                    tagBuilder.Attributes.Add("cols", Columns.ToString());
                }
                if (Rows > 0)
                {
                    tagBuilder.Attributes.Add("rows", Rows.ToString());
                }
                break;

            case TextBoxMode.Password:
                tagBuilder.Attributes.Add("type", "password");
                break;
            }

            tagBuilder.Attributes.Add("value", Text);

            if (!Visible)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "display", Value = "none"
                });
            }

            if (BorderWidth > 0)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "border-width", Value = $"{BorderWidth}px"
                });
            }

            if (BorderStyle > BorderStyle.None)
            {
                tagBuilder.AddStyle(
                    new Style
                {
                    Attribute = "border-style",
                    Value     = BorderStyle.ToString().ToLower()
                });
            }

            if (!string.IsNullOrEmpty(BorderColor))
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "border-color", Value = BorderColor
                });
            }

            if (!string.IsNullOrEmpty(BackColor))
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "background-color", Value = BackColor
                });
            }

            if (!string.IsNullOrEmpty(ForeColor))
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "color", Value = ForeColor
                });
            }

            if (!string.IsNullOrEmpty(CssClass))
            {
                tagBuilder.AddCssClass(CssClass);
            }

            if (!Enabled)
            {
                tagBuilder.Attributes.Add("disabled", "disabled");
            }

            if (Height > 0)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "hidth", Value = $"{Height}px"
                });
            }

            if (Width > 0)
            {
                tagBuilder.AddStyle(
                    new Style {
                    Attribute = "width", Value = $"{Width}px"
                });
            }

            if (!string.IsNullOrEmpty(ToolTip))
            {
                tagBuilder.Attributes.Add("title", ToolTip);
            }

            if (Font != null)
            {
                if (!string.IsNullOrEmpty(Font.Name))
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-family", Value = Font.Name
                    });
                }

                if (Font.Size > 0)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-size", Value = $"{Font.Size}px"
                    });
                }

                if (Font.Bold)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-weight", Value = "bold"
                    });
                }

                if (Font.Italic)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "font-style", Value = "italic"
                    });
                }

                if (Font.Underline)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "text-decoration", Value = "underline"
                    });
                }

                if (Font.Stirkeout)
                {
                    tagBuilder.AddStyle(
                        new Style {
                        Attribute = "text-decoration", Value = "line-throug"
                    });
                }
            }

            if (ReadOnly)
            {
                tagBuilder.Attributes.Add("readonly", "readonly");
            }

            if (AutoPostBack)
            {
                tagBuilder.Attributes.Add("onchange", "this.form.submit()");
            }

            tagBuilder.WriteTo(writer, HtmlEncoder.Default);

            await Task.CompletedTask;
        }
Ejemplo n.º 21
0
 public override string ToString()
 {
     return("Type:" + BorderStyle.ToString() + " Width:" + BorderWidth);
 }
Ejemplo n.º 22
0
        /// <summary>
        ///     ''' returns css "style=" tag for this control
        ///     ''' based on standard control visual properties
        ///     ''' </summary>
        private string CssStyle()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            string strColor;

            {
                var withBlock = sb;
                withBlock.Append(" style='");

                if (BorderWidth.ToString().Length > 0)
                {
                    withBlock.Append("border-width:");
                    withBlock.Append(BorderWidth.ToString());
                    withBlock.Append(";");
                }
                if (BorderStyle != System.Web.UI.WebControls.BorderStyle.NotSet)
                {
                    withBlock.Append("border-style:");
                    withBlock.Append(BorderStyle.ToString());
                    withBlock.Append(";");
                }
                strColor = HtmlColor(BorderColor);
                if (strColor.Length > 0)
                {
                    withBlock.Append("border-color:");
                    withBlock.Append(strColor);
                    withBlock.Append(";");
                }

                strColor = HtmlColor(BackColor);
                if (strColor.Length > 0)
                {
                    withBlock.Append("background-color:" + strColor + ";");
                }

                strColor = HtmlColor(ForeColor);
                if (strColor.Length > 0)
                {
                    withBlock.Append("color:" + strColor + ";");
                }

                if (Font.Bold)
                {
                    withBlock.Append("font-weight:bold;");
                }

                if (Font.Italic)
                {
                    withBlock.Append("font-style:italic;");
                }

                if (Font.Underline)
                {
                    withBlock.Append("text-decoration:underline;");
                }

                if (Font.Strikeout)
                {
                    withBlock.Append("text-decoration:line-through;");
                }

                if (Font.Overline)
                {
                    withBlock.Append("text-decoration:overline;");
                }

                if (Font.Size.ToString().Length > 0)
                {
                    withBlock.Append("font-size:" + Font.Size.ToString() + ";");
                }

                if (Font.Names.Length > 0)
                {
                    withBlock.Append("font-family:");
                    foreach (var strFontFamily in Font.Names)
                    {
                        withBlock.Append(strFontFamily);
                        withBlock.Append(",");
                    }
                    withBlock.Length = withBlock.Length - 1;
                    withBlock.Append(";");
                }

                if (Height.ToString() != "")
                {
                    withBlock.Append("height:" + Height.ToString() + ";");
                }
                if (Width.ToString() != "")
                {
                    withBlock.Append("width:" + Width.ToString() + ";");
                }

                withBlock.Append("'");
            }
            if (sb.ToString() == " style=''")
            {
                return("");
            }
            else
            {
                return(sb.ToString());
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Creates the HTML CSS.
        /// </summary>
        /// <param name="clientID">The client ID.</param>
        /// <param name="Name">The name.</param>
        /// <returns></returns>
        public string CreateHtmlCss(string clientID, string Name)
        {
            string style = string.Empty;

            style += string.Format(".AME_{0}{1}\n", clientID, Name);
            style += "{\n";
            if (BackColor != Color.Empty)
            {
                style += string.Format("background-color: {0};\n", Utils.Color2Hex(BackColor));
            }
            if (BorderStyle != BorderStyle.NotSet)
            {
                style += string.Format("border-style : {0};\n", BorderStyle.ToString());
                style += string.Format("border-width : {0};\n", BorderWidth);
                style += string.Format("border-color : {0};\n", Utils.Color2Hex(BorderColor));
            }

            if (ForeColor != Color.Empty)
            {
                style += string.Format("color : {0};\n", Utils.Color2Hex(ForeColor));
            }

            if (AllowRollOver && BorderStyleOver != BorderStyle.NotSet && BorderWidthOver.Value > 0)
            {
                int margin = 0;
                if (BorderWidth.Value > BorderWidthOver.Value)
                {
                    margin = 0;
                }
                else if (BorderWidth.Value < BorderWidthOver.Value)
                {
                    margin = (int)(BorderWidthOver.Value - BorderWidth.Value);
                }
                else
                {
                    margin = 0;
                }

                margin += (int)Margin.Value;

                style += string.Format("margin : {0}px;\n", margin);
            }
            else
            {
                style += string.Format("margin : {0}px;\n", (int)Margin.Value);
            }

            style += "}\n\n";

            if (AllowRollOver)
            {
                style += string.Format(".AME_{0}{1}Over\n", clientID, Name);
                style += "{\n";
                if (BackColorOver != Color.Empty)
                {
                    style += string.Format("background-color: {0};\n", Utils.Color2Hex(BackColorOver));
                }
                if (BorderStyleOver != BorderStyle.NotSet)
                {
                    style += string.Format("border-style : {0};\n", BorderStyleOver.ToString());
                    style += string.Format("border-width : {0};\n", BorderWidthOver);
                    style += string.Format("border-color : {0};\n", Utils.Color2Hex(BorderColorOver));
                }

                if (AllowRollOver && BorderStyleOver != BorderStyle.NotSet && BorderWidthOver.Value > 0)
                {
                    int margin = 0;
                    if (BorderWidthOver.Value > BorderWidth.Value)
                    {
                        margin = 0;
                    }
                    else if (BorderWidthOver.Value < BorderWidth.Value)
                    {
                        margin = (int)(BorderWidth.Value - BorderWidthOver.Value);
                    }
                    else
                    {
                        margin = 0;
                    }

                    margin += (int)Margin.Value;

                    style += string.Format("margin : {0}px;\n", margin);
                }
                else
                {
                    style += string.Format("margin : {0}px;\n", Margin);
                }

                if (ForeColorOver != Color.Empty)
                {
                    style += string.Format("color : {0};\n", Utils.Color2Hex(ForeColorOver));
                }

                style += "}\n\n";
            }

            return(style);
        }