aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/ListBox.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/ListBox.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/ListBox.cs')
-rw-r--r--src/GraphicObjects/ListBox.cs36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs
index e7a1c330..c315d81d 100644
--- a/src/GraphicObjects/ListBox.cs
+++ b/src/GraphicObjects/ListBox.cs
@@ -45,13 +45,10 @@ namespace Crow
GenericStack _gsList;
IList data;
int _selectedIndex;
- string _itemTemplate;
int itemPerPage = 50;
Thread loadingThread = null;
volatile bool cancelLoading = false;
- IMLStream templateStream = null;
-
[XmlAttributeAttribute]public IList Data {
get {
return data;
@@ -86,24 +83,7 @@ namespace Crow
SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
}
}
- [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
- public string ItemTemplate {
- get { return _itemTemplate; }
- set {
- if (value == _itemTemplate)
- return;
-
- _itemTemplate = value;
-
- if (templateStream != null) {
- templateStream.Dispose ();
- templateStream = null;
- }
- //TODO:reload list with new template?
- NotifyValueChanged("ItemTemplate", _itemTemplate);
- }
- }
[XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{
get { return _selectedIndex; }
set {
@@ -131,8 +111,12 @@ namespace Crow
_gsList = _list as GenericStack;
}
#endregion
- void loading(){
- templateStream = new IMLStream (ItemTemplate);
+ void loading(){
+ if (itemTemplates == null) {
+ itemTemplates = new Dictionary<string, IMLStream> ();
+ //TODO:check encoding
+ itemTemplates["default"] = new IMLStream (ItemTemplate);
+ }
for (int i = 1; i <= (data.Count / itemPerPage) + 1; i++) {
if (cancelLoading)
return;
@@ -174,8 +158,14 @@ namespace Crow
break;
if (cancelLoading)
return;
+
+ GraphicObject g = null;
+ Type dataType = data [i].GetType ();
+ if (itemTemplates.ContainsKey (dataType.FullName))
+ g = Interface.Load (itemTemplates [dataType.FullName]);
+ else if (itemTemplates.ContainsKey ("default"))
+ g = Interface.Load (itemTemplates ["default"]);
- GraphicObject g = Interface.Load (templateStream);
g.MouseClick += itemClick;
lock (Interface.CurrentInterface.UpdateMutex)