Exemple #1
0
        private static object CreateTemplate(object obj, string templatePropertyName)
        {
            var code = GetTemplateCode(obj, templatePropertyName);

            if (code == null)
            {
                return(null);
            }
            XmlnsDictionary.New(); //模板内的加载,需要使用自己的xmlns空间

#if (DEBUG)
            FrameworkTemplate.PushTrackCode(code);
            object template = XamlReader.ReadComponent(code);
            FrameworkTemplate.PopTrackCode();
#endif

#if (!DEBUG)
            object template = XamlReader.ReadComponent(code);
#endif
            XmlnsDictionary.Pop();
            //if (template == null) throw new WebException("没有找到类型" + objType.FullName + "的模板" + templatePropertyName + "定义");
            if (template == null)
            {
                return(null);
            }
            return(template);
        }
Exemple #2
0
 /// <summary>
 /// 克隆模板
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
     if (string.IsNullOrEmpty(this.TemplateCode))
     {
         throw new XamlException("没有定义模板代码,不能克隆模板");
     }
     return(XamlReader.ReadComponent(this.TemplateCode));
 }
Exemple #3
0
        /// <summary>
        /// 将xaml代码解析并写入画刷
        /// </summary>
        /// <param name="xaml"></param>
        /// <returns></returns>
        public void DrawXaml(string xaml)
        {
            var e = XamlReader.ReadComponent(xaml) as UIElement;

            if (e == null)
            {
                return;
            }
            e.Render(this);
        }
Exemple #4
0
        protected override void Load(object obj, HtmlNode objNode)
        {
            var ctx   = LoadContext.Current;
            var style = ctx.Parent as XamlStyle;

            if (style == null)
            {
                throw new XamlException("Setter的父对象必须为XamlStyle");
            }
            var targetType = style.TargetType;

            if (targetType == null)
            {
                throw new XamlException("请指定正确的Style.TargetType属性");
            }

            var propertyName = objNode.GetAttributeValue("Property", string.Empty);

            if (string.IsNullOrEmpty(propertyName))
            {
                throw new XamlException("请指定正确的Setter.Property属性");
            }

            var setter = obj as Setter;

            setter.Property = DependencyProperty.GetProperty(targetType, propertyName);

            string value = objNode.GetAttributeValue("Value", string.Empty);

            if (!string.IsNullOrEmpty(value))
            {
                //简单值
                var propertyInfo = targetType.ResolveProperty(propertyName);
                PropertiesLoader.SetValue(setter, Setter.ValueProperty, propertyInfo, value);
            }
            else
            {
                var valueNode = objNode.SelectSingleNodeEx("Setter.Value");
                if (valueNode != null)
                {
                    setter.Value = XamlReader.ReadComponent(valueNode.InnerHtml);
                }
            }
        }
Exemple #5
0
        private string GetInputsHtml(DTObject config)
        {
            var           items = config.GetList("items");
            StringBuilder html  = new StringBuilder();

            html.AppendLine("<ContentControl xmlns=\"http://schemas.codeart.cn/web/xaml\" xmlns:m=\"http://schemas.codeart.cn/web/xaml/metronic\" xmlns:ms=\"http://schemas.codeart.cn/web/xaml/metronic/sealed\">");
            foreach (var item in items)
            {
                html.Append("<Column xs=\"12\" md=\"12\" class=\"col-trim dynamicItem\">");
                html.Append(GenerateHtml(item));
                html.AppendLine("</Column>");
            }
            html.Append("</ContentControl>");

            ContentControl content = XamlReader.ReadComponent(html.ToString()) as ContentControl;
            var            brush   = new PageBrush();

            content.Render(brush);
            var code = brush.GetCode();

            return(code);
        }
Exemple #6
0
 public void Render(PageBrush brush, string xaml)
 {
     if (this.CollectionPhase)
     {
         var e = XamlReader.ReadComponent(xaml) as UIElement;
         if (e == null)
         {
             return;
         }
         if (_elements == null)
         {
             _elements = new List <UIElement>();
         }
         _elements.Add(e);
         e.Render(brush);
     }
     else
     {
         //在非收集阶段,需要得到对应的组件,并渲染
         var e = _queue.Dequeue();
         e.Render(brush);
     }
 }
        public static string GetCode(string xaml)
        {
            var obj = XamlReader.ReadComponent(xaml) as UIElement;

            return(GetCode(obj));
        }