aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-09-13 15:06:21 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-09-13 15:06:21 +0200
commit3877825a82ea3c48bcd782f3e49c9037a0cac0c1 (patch)
tree237c30cc42e1de8b00a239d4ff72996923e90eae /src/GraphicObjects
parent5a72cb51a2ab0a34e546f16a3cea61d44e943793 (diff)
allow goml loading from memory stream with single call to
getTopGraphicObject type when loading several time the same template.
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/ListBox.cs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs
index 5811e5ac..ea7f9ec5 100644
--- a/src/GraphicObjects/ListBox.cs
+++ b/src/GraphicObjects/ListBox.cs
@@ -23,6 +23,10 @@ using System.Collections;
using System.Xml.Serialization;
using System.ComponentModel;
//TODO: implement ItemTemplate node in xml
+using System.IO;
+using System.Diagnostics;
+
+
namespace go
{
[DefaultTemplate("#go.Templates.Listbox.goml")]
@@ -70,12 +74,35 @@ namespace go
_list.Children.Clear ();
if (data == null)
return;
+
+ #if DEBUG
+ Stopwatch loadingTime = new Stopwatch ();
+ loadingTime.Start ();
+ #endif
+
+ MemoryStream ms = new MemoryStream ();
+ using (Stream stream = Interface.GetStreamFromPath (ItemTemplate)) {
+
+ stream.CopyTo (ms);
+ }
+
+ Type t = Interface.GetTopContainerOfGOMLStream (ms);
+
foreach (var item in data) {
- GraphicObject g = Interface.Load (ItemTemplate, item);
+ ms.Seek(0,SeekOrigin.Begin);
+ GraphicObject g = Interface.Load (ms, t, item);
g.MouseClick += itemClick;
_list.addChild(g);
}
+ ms.Dispose ();
+
+ #if DEBUG
+ loadingTime.Stop ();
+ Debug.WriteLine("Listbox Loading: {0} ticks \t, {1} ms",
+ loadingTime.ElapsedTicks,
+ loadingTime.ElapsedMilliseconds);
+ #endif
}
}
void itemClick(object sender, OpenTK.Input.MouseButtonEventArgs e){