aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/TemplatedControl.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-08-10 07:13:14 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-08-10 07:13:40 +0200
commit1b2e2794fc8c4c8c20ff50fd7fbe842908912d23 (patch)
treee84e01c98b958e9d93214757543639110b07ae4f /src/GraphicObjects/TemplatedControl.cs
parent5a03df5faeda15e2d99c4c656eb62ed21817fdf6 (diff)
parent69c470239bfbab11192f3699f29b5352d74d3630 (diff)
ItemTemplate instantiator, basic listbox ok
Diffstat (limited to 'src/GraphicObjects/TemplatedControl.cs')
-rw-r--r--src/GraphicObjects/TemplatedControl.cs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index b325a0d2..63bdbb21 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -65,8 +65,8 @@ namespace Crow
string _template;
string _itemTemplate;
- public Dictionary<string, ItemTemplate> ItemTemplates;
-
+ public Dictionary<string, ItemTemplate> ItemTemplates = new Dictionary<string, Crow.ItemTemplate>();//TODO: dont instantiate if not used
+ //but then i should test if null in msil gen
[XmlAttributeAttribute][DefaultValue(null)]
public string Template {
get { return _template; }
@@ -84,7 +84,7 @@ namespace Crow
[XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
public string ItemTemplate {
get { return _itemTemplate; }
- set {
+ set {
if (value == _itemTemplate)
return;
@@ -146,7 +146,7 @@ namespace Crow
xr.Read (); //read first child
xr.Read (); //skip root node
- while (!xr.EOF) {
+ while (!xr.EOF) {
if (!xr.IsStartElement ()) {
xr.Read ();
continue;
@@ -164,8 +164,11 @@ namespace Crow
if (ItemTemplates == null)
ItemTemplates = new Dictionary<string, ItemTemplate> ();
- //TODO:check encoding
- ItemTemplates[dataType] = new ItemTemplate (Encoding.UTF8.GetBytes(itemTmp));
+
+ using (IMLReader iTmp = new IMLReader (null, itemTmp)) {
+ ItemTemplates [dataType] =
+ new ItemTemplate (iTmp.RootType, iTmp.GetLoader ());
+ }
if (!string.IsNullOrEmpty (datas))
ItemTemplates [dataType].CreateExpandDelegate(this, dataType, datas);
@@ -197,7 +200,7 @@ namespace Crow
//if no template found, load default one
if (this.child == null)
loadTemplate ();
-
+
//normal xml read
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
xr.Read ();