public void CreateStyle() { if (Page == null) { throw (new InvalidOperationException("Cannot access the Page class")); } if (Page.Header == null) { throw (new InvalidOperationException("The header tag must be a server control. Set runat attribute of header tag to \'server\'")); } CreateStyle(Page.Header.StyleSheet, GetRootCss()); if (Page.Request.UserAgent.Contains("MSIE")) { CustomStyle Custom = new CustomStyle(); Custom.Style["behavior"] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowCssHoverHtc) + ")"; Page.Header.StyleSheet.CreateStyleRule(Custom, null, "body"); } }
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"); } }
protected override void OnPreRender(System.EventArgs e) { base.OnPreRender(e); if (Page.Header == null) { throw (new Exception("Html Header element not found on page. Set runat attribut of <head> to \'server\'")); } //Control Style Style controlstyle = this.CreateControlStyle(); if (!controlstyle.IsEmpty) { Page.Header.StyleSheet.CreateStyleRule(controlstyle, null, "#" + ClientID); } if (!this.StaticMenuStyle.IsEmpty) { CustomStyle cssstatic = new CustomStyle(this.StaticMenuStyle); Page.Header.StyleSheet.CreateStyleRule(cssstatic, null, "#" + ClientID + " .StaticMenuStyle"); } CustomStyle listyle = new CustomStyle(new Style()); listyle.ListStyle = "none"; listyle.Position = "relative"; listyle.Float = "left"; listyle.Cursor = "default"; Page.Header.StyleSheet.CreateStyleRule(listyle, null, "#" + ClientID + " .StaticMenuStyle li"); if (Orientation == System.Web.UI.WebControls.Orientation.Vertical) { CustomStyle vstyle = new CustomStyle(new Style()); vstyle.Float = "none"; Page.Header.StyleSheet.CreateStyleRule(listyle, null, "#" + ClientID + " .StaticMenuStyle .StaticMenuItemStyle"); } CustomStyle ulstyle = new CustomStyle(new Style()); ulstyle.Display = "block"; ulstyle.Padding = "0"; ulstyle.Margin = "0"; ulstyle.ListStyle = "none"; ulstyle.Position = "absolute"; ulstyle.Visibility = "hidden"; Page.Header.StyleSheet.CreateStyleRule(ulstyle, null, "#" + ClientID + " .StaticMenuStyle ul"); CustomStyle statmenu = new CustomStyle(this.StaticMenuItemStyle); /* * If statmenu.Width.IsEmpty Then * statmenu.Width = Me.DefaultWidth * End If */ if (statmenu.Height.IsEmpty) { statmenu.Height = this.DefaultHeight; } Page.Header.StyleSheet.CreateStyleRule(statmenu, null, "#" + ClientID + " .StaticMenuStyle .StaticMenuItemStyle"); if (!StaticHoverStyle.IsEmpty) { Page.Header.StyleSheet.CreateStyleRule(this.StaticHoverStyle, null, "#" + ClientID + " .StaticMenuStyle .StaticHoverStyle"); } CustomStyle ul = new CustomStyle(new Style()); ul.Visibility = "hidden"; Page.Header.StyleSheet.CreateStyleRule(ul, null, "#" + ClientID + " .StaticMenuStyle .StaticHoverStyle ul ul"); Page.Header.StyleSheet.CreateStyleRule(ul, null, "#" + ClientID + " .StaticMenuStyle .DynamicHoverStyle ul ul"); ul = new CustomStyle(new Style()); ul.Visibility = "visible"; string lis = ""; Page.Header.StyleSheet.CreateStyleRule(ul, null, "#" + ClientID + " .StaticMenuStyle .StaticHoverStyle ul"); for (int i = 0; i <= 7; i++) { Page.Header.StyleSheet.CreateStyleRule(ul, null, "#" + ClientID + " .StaticMenuStyle" + lis + " .DynamicHoverStyle ul"); lis += " li"; } if (!StaticSelectedStyle.IsEmpty) { Page.Header.StyleSheet.CreateStyleRule(this.StaticSelectedStyle, null, "#" + ClientID + " .StaticSelectedStyle"); } if (!DynamicMenuStyle.IsEmpty) { Page.Header.StyleSheet.CreateStyleRule(this.DynamicMenuStyle, null, "#" + ClientID + " .DynamicMenuStyle"); } CustomStyle dynmenu = new CustomStyle(this.DynamicMenuItemStyle); if (dynmenu.Width.IsEmpty) { dynmenu.Width = statmenu.Width; } if (dynmenu.Width.IsEmpty) { dynmenu.Width = DefaultWidth; } if (dynmenu.Height.IsEmpty) { dynmenu.Height = statmenu.Height; } Page.Header.StyleSheet.CreateStyleRule(dynmenu, null, "#" + ClientID + " .DynamicMenuItemStyle"); if (!DynamicHoverStyle.IsEmpty) { Page.Header.StyleSheet.CreateStyleRule(this.DynamicHoverStyle, null, "#" + ClientID + " .DynamicMenuItemStyle:hover"); Page.Header.StyleSheet.CreateStyleRule(this.DynamicHoverStyle, null, "#" + ClientID + " .DynamicHoverStyle"); } if (!DynamicSelectedStyle.IsEmpty) { Page.Header.StyleSheet.CreateStyleRule(this.DynamicSelectedStyle, null, "#" + ClientID + " .DynamicSelectedStyle"); } for (int i = 0; i <= LevelMenuItemStyles.Count - 1; i++) { Page.Header.StyleSheet.CreateStyleRule(this.LevelMenuItemStyles[i], null, "#" + ClientID + " .LevelMenuItemStyles_" + i.ToString()); } for (int i = 0; i <= LevelSelectedStyles.Count - 1; i++) { Page.Header.StyleSheet.CreateStyleRule(this.LevelSelectedStyles[i], null, "#" + ClientID + " .LevelSelectedStyles_" + i.ToString()); } for (int i = 0; i <= LevelSubMenuStyles.Count - 1; i++) { Page.Header.StyleSheet.CreateStyleRule(this.LevelSubMenuStyles[i], null, "#" + ClientID + " .LevelSubMenuStyles_" + i.ToString()); } }
protected override void CreateStyle(IStyleSheet StyleSheet, string RootCss) { IStyleSheet with_1 = StyleSheet; CustomStyle window = new CustomStyle(); window.Style[HtmlTextWriterStyle.BorderCollapse] = "collapse"; window.Style["border"] = "0"; window.Style["padding"] = "0"; window.Style["margin"] = "0"; with_1.CreateStyleRule(window, null, RootCss); //--- TITLE ---- CustomStyle title = new CustomStyle(); title.Style[HtmlTextWriterStyle.Height] = TitleBarSize.ToString(); title.Style["border"] = "0"; title.Style["padding"] = "0"; title.Style["margin"] = "0"; with_1.CreateStyleRule(title, null, RootCss + " tr.title"); //title left CustomStyle titleLeft = new CustomStyle(); titleLeft.Style[HtmlTextWriterStyle.Width] = BorderSize.ToString(); titleLeft.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowTitleLeftGif) + ")"; titleLeft.Style["border"] = "0"; titleLeft.Style["padding"] = "0"; titleLeft.Style["margin"] = "0"; with_1.CreateStyleRule(titleLeft, null, RootCss + " tr.title td.left"); //title center CustomStyle titleCenter = new CustomStyle(); titleCenter.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowTitleGif) + ")"; titleCenter.Style["border"] = "0"; titleCenter.Style["padding"] = "0"; titleCenter.Style["margin"] = "0"; with_1.CreateStyleRule(titleCenter, null, RootCss + " tr.title td.center"); //title right CustomStyle titleRight = new CustomStyle(); titleRight.Style[HtmlTextWriterStyle.Width] = BorderSize.ToString(); titleRight.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowTitleRightGif) + ")"; titleRight.Style["border"] = "0"; titleRight.Style["padding"] = "0"; titleRight.Style["margin"] = "0"; with_1.CreateStyleRule(titleRight, null, RootCss + " tr.title td.right"); //title text with_1.CreateStyleRule(MyWindow.TitleStyle, null, RootCss + " tr.title td.center div.titleText"); //title close CustomStyle titleClose = new CustomStyle(); titleClose.Style[HtmlTextWriterStyle.Overflow] = "hidden"; titleClose.Style["float"] = "right"; titleClose.Style[HtmlTextWriterStyle.Width] = CloseButtonWidth.ToString(); titleClose.Style[HtmlTextWriterStyle.Height] = CloseButtonHeight.ToString(); titleClose.Style[HtmlTextWriterStyle.MarginTop] = "3px"; titleClose.Style[HtmlTextWriterStyle.MarginRight] = "2px"; titleClose.Style["border"] = "0"; titleClose.Style[HtmlTextWriterStyle.Cursor] = "pointer"; titleClose.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowCloseGif) + ")"; with_1.CreateStyleRule(titleClose, null, RootCss + " tr.title td.center div.close"); CustomStyle titleCloseup = new CustomStyle(); titleCloseup.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowCloseUpGif) + ")"; with_1.CreateStyleRule(titleCloseup, null, RootCss + " tr.title td.center div.close:hover"); //--- CONTENT ---- CustomStyle content = new CustomStyle(); content.Style["border"] = "0"; content.Style["padding"] = "0"; content.Style["margin"] = "0"; with_1.CreateStyleRule(content, null, RootCss + " tr.content"); //content left CustomStyle contentLeft = new CustomStyle(); contentLeft.Style[HtmlTextWriterStyle.Width] = BorderSize.ToString(); contentLeft.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowLeftGif) + ")"; contentLeft.Style["border"] = "0"; contentLeft.Style["padding"] = "0"; contentLeft.Style["margin"] = "0"; with_1.CreateStyleRule(contentLeft, null, RootCss + " tr.content td.left"); //content center CustomStyle contentCenter = new CustomStyle(); int newHeight = 100; if (!MyWindow.Height.IsEmpty) { newHeight = (int)MyWindow.Height.Value; } //.Style(HtmlTextWriterStyle.Height) = CStr(newHeight - TitleBarSize.Value - BorderSize.Value) & "px" contentCenter.Style["border"] = "0"; contentCenter.Style["padding"] = "0"; contentCenter.Style["margin"] = "0"; with_1.CreateStyleRule(contentCenter, null, RootCss + " tr.content td.center"); if (!MyWindow.ContentStyle.IsEmpty) { with_1.CreateStyleRule(MyWindow.ContentStyle, null, RootCss + " tr.content td.center"); } //content center div CustomStyle contentCenterDiv = new CustomStyle(); contentCenterDiv.Style[HtmlTextWriterStyle.Overflow] = "auto"; contentCenterDiv.Style[HtmlTextWriterStyle.Height] = (newHeight - 50).ToString() + "px"; with_1.CreateStyleRule(contentCenterDiv, null, RootCss + " tr.content td.center div.content"); //content right CustomStyle contentRight = new CustomStyle(); contentRight.Style[HtmlTextWriterStyle.Width] = BorderSize.ToString(); contentRight.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowRightGif) + ")"; contentRight.Style["border"] = "0"; contentRight.Style["padding"] = "0"; contentRight.Style["margin"] = "0"; with_1.CreateStyleRule(contentRight, null, RootCss + " tr.content td.right"); //--- FOOTER --- CustomStyle footer = new CustomStyle(); footer.Style[HtmlTextWriterStyle.Height] = BorderSize.ToString(); footer.Style["border"] = "0"; footer.Style["padding"] = "0"; footer.Style["margin"] = "0"; with_1.CreateStyleRule(footer, null, RootCss + " tr.footer"); //footer left CustomStyle footerLeft = new CustomStyle(); footerLeft.Style[HtmlTextWriterStyle.Width] = BorderSize.ToString(); footerLeft.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowBottomLeftGif) + ")"; footerLeft.Style["border"] = "0"; footerLeft.Style["padding"] = "0"; footerLeft.Style["margin"] = "0"; with_1.CreateStyleRule(footerLeft, null, RootCss + " tr.footer td.left"); //footer center CustomStyle footerCenter = new CustomStyle(); footerCenter.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowBottomGif) + ")"; footerCenter.Style["border"] = "0"; footerCenter.Style["padding"] = "0"; footerCenter.Style["margin"] = "0"; with_1.CreateStyleRule(footerCenter, null, RootCss + " tr.footer td.center"); //footer right CustomStyle footerRight = new CustomStyle(); footerRight.Style[HtmlTextWriterStyle.Width] = BorderSize.ToString(); footerRight.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + Page.ClientScript.GetWebResourceUrl(this.GetType(), Configuration.Resources.WindowBottomRightGif) + ")"; footerRight.Style["border"] = "0"; footerRight.Style["padding"] = "0"; footerRight.Style["margin"] = "0"; with_1.CreateStyleRule(footerRight, null, RootCss + " tr.footer td.right"); }