Пример #1
0
            public Panel(HtmlHelper helper, string id, string title, int leftbuttons, int rightbuttons, Enums.PanelStyle style)
            {
                _writer       = helper.ViewContext.Writer;
                _id           = id;
                _leftbuttons  = leftbuttons;
                _rightbuttons = rightbuttons;

                var paneldiv = new TagBuilder("div");

                paneldiv.AddCssClass("panel-" + style.ToString().ToLower());
                paneldiv.AddCssClass("panel");
                _writer.WriteLine(paneldiv.ToString(TagRenderMode.StartTag));

                var panelheadingdiv = new TagBuilder("div");

                panelheadingdiv.AddCssClass("panel-heading");
                _writer.WriteLine(panelheadingdiv.ToString(TagRenderMode.StartTag));

                TagBuilder paneltitle = new TagBuilder("h3");

                paneltitle.AddCssClass("panel-title");
                paneltitle.Attributes.Add("id", "title");
                paneltitle.SetInnerText(title);
                _writer.WriteLine(paneltitle.ToString());

                _writer.WriteLine(panelheadingdiv.ToString(TagRenderMode.EndTag));

                var panelbodydiv = new TagBuilder("div");

                panelbodydiv.AddCssClass("panel-body");
                _writer.WriteLine(panelbodydiv.ToString(TagRenderMode.StartTag));

                var form = new TagBuilder("form");

                form.Attributes.Add("id", id);
                _writer.WriteLine(form.ToString(TagRenderMode.StartTag));
            }
Пример #2
0
            public Panel(HtmlHelper helper, string title, string classname, string id, string icon, Enums.PanelPadding padding, Enums.PanelStyle style = Enums.PanelStyle.Default)
            {
                _writer = helper.ViewContext.Writer;

                var paneldiv = new TagBuilder("div");

                paneldiv.AddCssClass("panel-" + style.ToString().ToLower());
                paneldiv.AddCssClass("panel");

                var panelheadingdiv = new TagBuilder("div");

                panelheadingdiv.AddCssClass("panel-heading");

                TagBuilder paneltitle = null;

                if (classname != null && id != null && icon != null)
                {
                    paneltitle = new TagBuilder("div");
                    paneltitle.AddCssClass("row");
                    var leftcolumn = new TagBuilder("div");
                    leftcolumn.AddCssClass("col-xs-10");
                    var heading = new TagBuilder("h3");
                    heading.AddCssClass("panel-title");
                    heading.SetInnerText(title);
                    leftcolumn.InnerHtml = heading.ToString();
                    var rightcolumn = new TagBuilder("div");
                    rightcolumn.AddCssClass("col-xs-2");
                    var anchor = new TagBuilder("a");
                    anchor.AddCssClass(classname);
                    anchor.AddCssClass("pull-right");
                    anchor.Attributes.Add("id", id);
                    anchor.Attributes.Add("href", "#");
                    var image = new TagBuilder("img");
                    image.Attributes.Add("src", icon);
                    anchor.InnerHtml      = image.ToString();
                    rightcolumn.InnerHtml = anchor.ToString();
                    paneltitle.InnerHtml  = leftcolumn.ToString() + rightcolumn.ToString();
                }
                else
                {
                    paneltitle = new TagBuilder("h3");
                    paneltitle.AddCssClass("panel-title");
                    paneltitle.SetInnerText(title);
                }

                var panelbodydiv = new TagBuilder("div");

                panelbodydiv.AddCssClass("panel-body");
                if (padding == Enums.PanelPadding.NoHorizontal)
                {
                    panelbodydiv.AddCssClass("site-no-horizontal-padding");
                }
                else if (padding == Enums.PanelPadding.NoVertical)
                {
                    panelbodydiv.AddCssClass("site-no-vertical-padding");
                }
                else if (padding == Enums.PanelPadding.None)
                {
                    panelbodydiv.AddCssClass("site-no-padding");
                }

                panelheadingdiv.InnerHtml = paneltitle.ToString();

                string html = string.Format("{0}{1}{2}", paneldiv.ToString(TagRenderMode.StartTag), panelheadingdiv, panelbodydiv.ToString(TagRenderMode.StartTag));

                _writer.Write(html);
            }