コード例 #1
0
        /// <summary>
        /// Retrieves a string representing the current menu array
        /// </summary>
        /// <returns>
        /// The current menu array
        /// </returns>
        public string ToMenuArray()
        {
            var wc = new WebColorConverter();

            var sb = new StringBuilder();

            sb.Append("=new Array(");
            sb.Append(CleanForJavascript(this.Text));
            sb.Append(", ");
            sb.Append(CleanForJavascript(this.Link));
            sb.Append(", ");
            sb.Append(CleanForJavascript(this.BackgroundImage));
            sb.Append(", ");
            sb.Append(this.Childs.Count);
            sb.Append(", ");
            if (this.Height.Value > 0)
            {
                sb.Append(this.Height.Value);
            }
            else
            {
                sb.Append(20);
            }

            sb.Append(", ");
            if (this.Width.Value > 0)
            {
                sb.Append(this.Width.Value);
            }
            else
            {
                sb.Append((this.Text.Length * 7) + 15);
            }

            sb.Append(", ");
            sb.Append(CleanForJavascript(wc.ConvertToString(this.ControlStyle.BackColor)));
            sb.Append(", ");
            sb.Append(CleanForJavascript(wc.ConvertToString(this.ControlHiStyle.BackColor)));
            sb.Append(", ");
            sb.Append(CleanForJavascript(wc.ConvertToString(this.ControlStyle.ForeColor)));
            sb.Append(", ");
            sb.Append(CleanForJavascript(wc.ConvertToString(this.ControlHiStyle.ForeColor)));
            sb.Append(", ");
            sb.Append(CleanForJavascript(wc.ConvertToString(this.ControlStyle.BorderColor)));
            sb.Append(");");
            sb.Append("\n");

            return sb.ToString();
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: divyang4481/appleseedapp
        /// <summary>
        /// Retrieves a string representing the current menu array
        /// </summary>
        /// <param name="prefix">
        /// The prefix.
        /// </param>
        /// <returns>
        /// The current menu array
        /// </returns>
        protected string ToMenuArray(string prefix)
        {
            var wc = new WebColorConverter();

            var sb = new StringBuilder();

            sb.Append("<script type = 'text/javascript'>\n");
            sb.Append("  function Go(){return}\n");
            sb.Append("</script>\n");

            sb.Append("<script type = 'text/javascript'>\n");

            sb.Append("var NoOffFirstLineMenus = ");
            sb.Append(this.Childs.Count);
            sb.Append(";\n");

            // MH:
            sb.Append("var CssItemClassName = ");
            sb.Append("\"");
            sb.Append(this.ControlItemStyle.CssClass);
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var CssHiClassName = ");
            sb.Append("\"");
            sb.Append(this.ControlHiStyle.CssClass);
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var CssSubClassName = ");
            sb.Append("\"");
            sb.Append(this.ControlSubStyle.CssClass);
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var CssHiSubClassName = ");
            sb.Append("\"");
            sb.Append(this.ControlHiSubStyle.CssClass);
            sb.Append("\"");
            sb.Append(";\n");

            // MH:
            sb.Append("var LowBgColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.BackColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var LowSubBgColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ControlSubStyle.BackColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var HighBgColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ControlHiStyle.BackColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var HighSubBgColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ControlHiSubStyle.BackColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var FontLowColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ForeColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var FontSubLowColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ControlSubStyle.ForeColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var FontHighColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ControlHiStyle.ForeColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var FontSubHighColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ControlHiSubStyle.ForeColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var BorderColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.BorderColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var BorderSubColor = ");
            sb.Append("\"");
            sb.Append(wc.ConvertToString(this.ControlSubStyle.BorderColor));
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var BorderWidth = ");
            sb.Append(this.BorderWidth.Value);
            sb.Append(";\n");

            sb.Append("var BorderBtwnElmnts = ");
            sb.Append(this.BorderBtwnElmnts ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var FontFamily = ");
            sb.Append("\"");
            sb.Append(this.Font.Name);
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var FontSize = ");
            sb.Append(this.Font.Size.Unit.Value);
            sb.Append(";\n");

            sb.Append("var FontBold = ");
            sb.Append(this.Font.Bold ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var FontItalic = ");
            sb.Append(this.Font.Italic ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var MenuTextCentered = ");
            sb.Append("\"");
            sb.Append(this.MenuTextCentered.ToString().ToLower());
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var MenuCentered = ");
            sb.Append("\"");
            sb.Append(this.MenuCentered.ToString().ToLower());
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var MenuVerticalCentered = ");
            sb.Append("\"");
            sb.Append(this.MenuVerticalCentered.ToString().ToLower());
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var ChildOverlap = ");
            sb.Append(this.ChildOverlap.ToString(new CultureInfo("en-US").NumberFormat));
            sb.Append(";\n");

            sb.Append("var ChildVerticalOverlap = ");
            sb.Append(this.ChildVerticalOverlap.ToString(new CultureInfo("en-US").NumberFormat));
            sb.Append(";\n");

            sb.Append("var LeftPaddng = ");
            sb.Append(this.LeftPaddng);
            sb.Append(";\n");

            sb.Append("var TopPaddng = ");
            sb.Append(this.TopPaddng);
            sb.Append(";\n");

            sb.Append("var StartTop = ");
            sb.Append(this.StartTop);
            sb.Append(";\n");

            sb.Append("var StartLeft = ");
            sb.Append(this.StartLeft);
            sb.Append(";\n");

            sb.Append("var VerCorrect = ");
            sb.Append(this.VerCorrect);
            sb.Append(";\n");

            sb.Append("var HorCorrect = ");
            sb.Append(this.HorCorrect);
            sb.Append(";\n");

            sb.Append("var FirstLineHorizontal = ");
            sb.Append(this.Horizontal ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var MenuFramesVertical = ");
            sb.Append(this.MenuFramesVertical ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var DissapearDelay = ");
            sb.Append(this.DissapearDelay);
            sb.Append(";\n");

            sb.Append("var TakeOverBgColor = ");
            sb.Append(this.TakeOverBgColor ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var FirstLineFrame = ");
            sb.Append("\"");
            sb.Append(this.FirstLineFrame);
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var SecLineFrame = ");
            sb.Append("\"");
            sb.Append(this.SecLineFrame);
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var DocTargetFrame = ");
            sb.Append("\"");
            sb.Append(this.DocTargetFrame);
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var HideTop = ");
            sb.Append(this.HideTop ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var TargetLoc = ");
            sb.Append("\"");

            // sb.Append(TargetLoc);
            // sb.Append(this.Controls[0].ClientID);
            sb.Append("MenuPos"); // NS4 bug fix
            sb.Append("\"");
            sb.Append(";\n");

            sb.Append("var MenuWrap = ");
            sb.Append(this.MenuWrap ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var RightToLeft = ");
            sb.Append(this.RightToLeft ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var UnfoldsOnClick = ");
            sb.Append(this.UnfoldsOnClick ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var WebMasterCheck = ");
            sb.Append(this.WebMasterCheck ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var ShowArrow = ");
            sb.Append(this.ShowArrow ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var KeepHilite = ");
            sb.Append(this.KeepHilite ? 1 : 0);
            sb.Append(";\n");

            sb.Append("var Arrws = ");
            sb.Append("[");
            for (var i = 0; i <= this.arrws.GetUpperBound(0); i++)
            {
                sb.Append("\"");
                sb.Append(this.ImagesPath + this.arrws[i].ImageUrl);
                sb.Append("\", ");
                sb.Append(this.arrws[i].Width.Value);
                sb.Append(", ");
                sb.Append(this.arrws[i].Height.Value);
                if (i != this.arrws.GetUpperBound(0))
                {
                    sb.Append(", ");
                }
            }

            sb.Append("]");
            sb.Append(";\n");

            sb.Append("function BeforeStart(){;}\n");
            sb.Append("function AfterBuild(){;}\n");
            sb.Append("function BeforeFirstOpen(){;}\n");
            sb.Append("function AfterCloseAll(){;}\n");

            sb.Append(this.Childs.ToMenuArray(prefix));

            sb.Append("</script>\n");
            sb.AppendFormat("<script type = 'text/javascript' src = '{0}menu_com.js'></script>\n", this.ClientScriptPath);
            sb.Append("<noscript>Your browser does not support script</noscript>\n");

            return sb.ToString();
        }