aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/TemplatedControl.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-08-03 14:21:19 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-08-03 14:21:19 +0200
commitb24819ffb8f629fb0ed70064f90357a42653ae5d (patch)
treeb3636cddb37b4fcc679b81b0afb2b1e1ac12f840 /src/GraphicObjects/TemplatedControl.cs
parent5e7f9ad632b4c42bee7f111c0155b869e3ae4f18 (diff)
ItemTemplate xml element implementation
nouveau fichier : Tests/Interfaces/Unsorted/testItemTemplateTag.crow modifié : Tests/Tests.csproj modifié : src/GraphicObjects/ListBox.cs modifié : src/GraphicObjects/TemplatedControl.cs modifié : src/IMLStream.cs
Diffstat (limited to 'src/GraphicObjects/TemplatedControl.cs')
-rw-r--r--src/GraphicObjects/TemplatedControl.cs39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index 12c2b81f..5b7df01d 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -25,6 +25,8 @@ using System.IO;
using System.Xml;
using System.Diagnostics;
using System.Linq;
+using System.Collections.Generic;
+using System.Text;
namespace Crow
{
@@ -61,6 +63,8 @@ namespace Crow
#endregion
string _template;
+ string _itemTemplate;
+ protected Dictionary<string, IMLStream> itemTemplates;
[XmlAttributeAttribute][DefaultValue(null)]
public string Template {
@@ -76,7 +80,19 @@ namespace Crow
loadTemplate (Interface.Load (_template, this));
}
}
+ [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
+ public string ItemTemplate {
+ get { return _itemTemplate; }
+ set {
+ if (value == _itemTemplate)
+ return;
+
+ _itemTemplate = value;
+ //TODO:reload list with new template?
+ NotifyValueChanged("ItemTemplate", _itemTemplate);
+ }
+ }
#region GraphicObject overrides
public override GraphicObject FindByName (string nameToFind)
{
@@ -121,7 +137,23 @@ namespace Crow
xr.Read (); //read first child
if (!xr.IsStartElement ())
continue;
- if (xr.Name == "Template") {
+ if (xr.Name == "ItemTemplate") {
+ string dataType = "default", datas, itemTmp;
+ while (xr.MoveToNextAttribute ()) {
+ if (xr.Name == "DataType")
+ dataType = xr.Value;
+ else if (xr.Name == "Data")
+ datas = xr.Value;
+ }
+ xr.MoveToElement ();
+ itemTmp = xr.ReadInnerXml ();
+ xr.Read ();//itemTemplate close tag
+ if (itemTemplates == null)
+ itemTemplates = new Dictionary<string, IMLStream> ();
+ //TODO:check encoding
+ itemTemplates[dataType] = new IMLStream (Encoding.UTF8.GetBytes(itemTmp));
+
+ }else if (xr.Name == "Template") {
xr.Read ();
Type t = Type.GetType ("Crow." + xr.Name);
@@ -131,8 +163,7 @@ namespace Crow
loadTemplate (go);
xr.Read ();//go close tag
- xr.Read ();//Template close tag
- break;
+ //xr.Read ();//Template close tag
} else
xr.ReadInnerXml ();
}
@@ -143,7 +174,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 ();