Пример #1
0
        /// <summary>
        /// 从字符串中返回其中的控件部分wec:
        /// </summary>
        /// <param name="inputStr"></param>
        /// <returns></returns>
        string GetWeControl(string inputStr)
        {
            Match     match   = TheRegexs[0].Match(inputStr);
            WeControl control = GetWeControlFromString(inputStr);

            if (!Controls.Contains(control))
            {
                Controls.Add(control);
            }
            return(match.Value);
        }
Пример #2
0
        /// <summary>
        /// 从文本中解析控件,放到<div>容器里返回
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        private string  ConvertWeControlsToDiv(string source)
        {
            StringBuilder sb = new StringBuilder();
            WeControl     wc = GetWeControlFromString(source);

            sb.Append(String.Format("<DIV xmlns:wec=\"http://www.WestEngine.com\" tag=\"{0}\" contenteditable=\"false\" style=\"border:solid gray 1px dotted;width:100px;height:50px;background-color: #aaffaa;\">\r\n", wc.TagPrefix));
            sb.Append(String.Format("<DIV tag=\"{0}\">控件:{1}<br>{2}</div>\r\n", wc.TagName, wc.ChineseName, wc.ID));
            sb.Append("<DIV tag=\"content\">\r\n");
            sb.Append(String.Format("<?xml:namespace prefx = {0} />\r\n", wc.TagPrefix));
            sb.Append(source);
            sb.Append("</DIV>\r\n");
            sb.Append("</DIV>\r\n");

            return(sb.ToString());
        }
Пример #3
0
        /// <summary>
        /// 从文本中解析控件,返回WeControl控件描述对象
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        WeControl GetWeControlFromString(string source)
        {
            WeControl wc    = new WeControl();
            Regex     r     = new Regex(@"\<wec:\w*");
            Match     match = r.Match(source);

            if (match.Success)
            {
                wc.TagPrefix   = match.Value.Substring(1, 3);
                wc.TagName     = match.Value.Substring(5);
                wc.ChineseName = GetChineseNameAttribute(source);
                wc.ID          = GetIDAttribute(source);
                wc.CssFile     = GetCssFileAttribute(source);
            }
            return(wc);
        }
Пример #4
0
        /// <summary>
        /// 从文本中解析子模板,放到<div>容器里返回
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        private string ConvertSubtemplateToDiv(string source)
        {
            StringBuilder sb    = new StringBuilder();
            WeControl     wc    = new WeControl();
            Regex         r     = new Regex(@"\<wet:\w*");
            Match         match = r.Match(source);

            string tagPrefix  = match.Value.Substring(1, 3);
            string tagName    = match.Value.Substring(5);
            string templateID = GetIDAttribute(source);

            sb.Append(String.Format("<DIV xmlns:wet=\"http://www.WestEngine.com\" tag=\"{0}\" contenteditable=\"false\" style=\"border:solid gray 1px dotted;width:100px;height:50px;background-color: #faf0aa;\">\r\n", tagPrefix));
            sb.Append(String.Format("<DIV tag=\"{0}\">子模板:<br>{1}</div>\r\n", tagName, templateID));
            sb.Append("<DIV tag=\"content\">\r\n");
            sb.Append(String.Format("<?xml:namespace prefx = {0} />\r\n", tagPrefix));
            sb.Append(source);
            sb.Append("</DIV>\r\n");
            sb.Append("</DIV>\r\n");

            return(sb.ToString());
        }
Пример #5
0
        /// <summary>
        /// 复制数据控件的css文件到引用模板的相关路径
        /// </summary>
        /// <param name="ControlTag"></param>
        /// <param name="ControlID"></param>
        /// <returns></returns>
        public bool CopyStyleSheet(WeControl control, ref string fullname)
        {
            if (string.IsNullOrEmpty(control.CssFile)) //使用默认css
            {
                HttpContext Context        = HttpContext.Current;
                string      controlCssFile = Context.Server.MapPath(Constants.ControlUrlPath) + "\\styles\\" + control.TagName + ".css";

                string   templateCssFile = fileName.Remove(fileName.LastIndexOf("\\")) + "\\styles\\" + fileName.Substring(fileName.LastIndexOf("\\"), fileName.LastIndexOf(".") - fileName.LastIndexOf("\\")) + "_" + control.TagName + ".css";
                FileInfo cfile           = new FileInfo(controlCssFile);

                if (cfile.Exists)
                {
                    FileInfo tfile = new FileInfo(templateCssFile);
                    if (!tfile.Exists)
                    {
                        string        path = fileName.Remove(fileName.LastIndexOf("\\")) + "\\styles\\";
                        DirectoryInfo di   = new DirectoryInfo(path);
                        if (!di.Exists)
                        {
                            di.Create();
                        }

                        cfile.CopyTo(templateCssFile);
                    }

                    fullname = templateCssFile.Substring(templateCssFile.LastIndexOf("\\") + 1);
                    return(true);
                }
            }
            else //使用指定css
            {
                fullname = control.CssFile;
                return(true);
            }
            return(false);
        }