예제 #1
0
        /// <summary>
        /// Convert a control settings into formatted string that is usable on the javascript.
        /// </summary>
        /// <returns>The javascript configuration string.</returns>
        private string GetConfigurationString()
        {
            StringBuilder configString = new StringBuilder();
            string        basePath     = BasePath;

            if (basePath.StartsWith("~"))
            {
                basePath = ResolveUrl(basePath);
            }
            configString.AppendFormat("{0}={1}", "basepath", HttpUtility.UrlEncode(basePath));
            configString.Append("&");
            configString.AppendFormat("{0}={1}", "doctype", HttpUtility.UrlEncode(DocumentType));
            configString.Append("&");
            configString.AppendFormat("{0}={1}", "textformat", TextFormat);
            configString.Append("&");
            string imagePath = ImagePath.StartsWith("~") ? ResolveUrl(ImagePath) : ImagePath;

            configString.AppendFormat("{0}={1}", "imagepath", imagePath);
            configString.Append("&");

            if (string.IsNullOrEmpty(EditorImagePath) == false)
            {
                string toolbarImages = EditorImagePath.StartsWith("~") ? ResolveUrl(EditorImagePath) : EditorImagePath;
                configString.AppendFormat("{0}={1}", "editorimagepath", toolbarImages);
                configString.Append("&");
            }
            if (string.IsNullOrEmpty(EditorCss) == false)
            {
                string editorCSS = EditorCss.StartsWith("~") ? ResolveUrl(EditorCss) : EditorCss;
                configString.AppendFormat("{0}={1}", "editorcss", editorCSS);
                configString.Append("&");
            }
            configString.AppendFormat("{0}={1}", "mode", Mode.ToString("D"));
            configString.Append("&");
            configString.AppendFormat("{0}={1}", "usebroncr", UserBRonCarriageReturn);
            configString.Append("&");
            configString.Append("fontsize=");
            int i = 1;

            foreach (FontUnit u in TypeDescriptor.GetConverter(ControlStyle.Font.Size).GetStandardValues())
            {
                if (3 < i)
                {
                    configString.AppendFormat("{0}*{1},", i - 3, u);
                }
                i++;
            }
            configString.Remove(configString.Length - 1, 1);
            configString.Append("&fonts=");
            if (0 != ControlStyle.Font.Names.Length)
            {
                for (i = 0; i < ControlStyle.Font.Names.Length; i++)
                {
                    configString.AppendFormat("{0};", ControlStyle.Font.Names[i]);
                }
                configString.Remove(configString.Length - 1, 1);
            }
            else
            {
                // default font
                configString.Append("Arial;Times New Roman;Verdana;Tahoma");
            }

            return(configString.ToString());
        }