aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/ListBox.cs89
-rw-r--r--src/GraphicObjects/TemplatedControl.cs27
-rw-r--r--src/IMLStream.cs4
-rw-r--r--src/Interface.cs10
4 files changed, 45 insertions, 85 deletions
diff --git a/src/GraphicObjects/ListBox.cs b/src/GraphicObjects/ListBox.cs
index c315d81d..826eb388 100644
--- a/src/GraphicObjects/ListBox.cs
+++ b/src/GraphicObjects/ListBox.cs
@@ -112,11 +112,11 @@ namespace Crow
}
#endregion
void loading(){
- if (itemTemplates == null) {
+ if (itemTemplates == null)
itemTemplates = new Dictionary<string, IMLStream> ();
- //TODO:check encoding
+ if (!itemTemplates.ContainsKey ("default"))
itemTemplates["default"] = new IMLStream (ItemTemplate);
- }
+
for (int i = 1; i <= (data.Count / itemPerPage) + 1; i++) {
if (cancelLoading)
return;
@@ -160,23 +160,30 @@ namespace Crow
return;
GraphicObject g = null;
+ IMLStream itemStream = 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"]);
- g.MouseClick += itemClick;
+ if (itemTemplates.ContainsKey (dataType.FullName)) {
+ itemStream = itemTemplates [dataType.FullName];
+ } else {
+ itemStream = itemTemplates ["default"];
+ }
- lock (Interface.CurrentInterface.UpdateMutex)
+ lock (Interface.CurrentInterface.UpdateMutex) {
+ g = Interface.Load (itemStream);
page.AddChild (g);
- g.DataSource = data [i];
+ g.DataSource = data [i];
+ }
+ g.MouseClick += itemClick;
+ if (!string.IsNullOrEmpty (itemStream.Datas)) {
+
+ }
//g.LogicalParent = this;
}
lock (Interface.CurrentInterface.UpdateMutex)
_list.AddChild (page);
-
+
#if DEBUG_LOAD
loadingTime.Stop ();
Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
@@ -216,66 +223,6 @@ namespace Crow
void itemClick(object sender, MouseButtonEventArgs e){
SelectedIndex = data.IndexOf((sender as GraphicObject).DataSource);
}
-
- #region IXmlSerializable
-// public override System.Xml.Schema.XmlSchema GetSchema(){ return null; }
-// public override void ReadXml(System.Xml.XmlReader reader)
-// {
-// //Template could be either an attribute containing path or expressed inlined
-// //as a Template Element
-// using (System.Xml.XmlReader subTree = reader.ReadSubtree())
-// {
-// subTree.Read ();
-//
-// string template = reader.GetAttribute ("Template");
-// string tmp = subTree.ReadOuterXml ();
-//
-// //Load template from path set as attribute in templated control
-// if (string.IsNullOrEmpty (template)) {
-// //seek for template tag first
-// using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
-// //load template first if inlined
-//
-// xr.Read (); //skip current node
-//
-// while (!xr.EOF) {
-// xr.Read (); //read first child
-// if (!xr.IsStartElement ())
-// continue;
-// if (xr.Name == "Template") {
-// xr.Read ();
-//
-// Type t = Type.GetType ("Crow." + xr.Name);
-// GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
-// (go as IXmlSerializable).ReadXml (xr);
-//
-// loadTemplate (go);
-//
-// xr.Read ();//go close tag
-// xr.Read ();//Template close tag
-// break;
-// } else {
-// xr.ReadInnerXml ();
-// }
-// }
-// }
-// } else
-// loadTemplate (Interface.Load (template, this));
-//
-//
-// //normal xml read
-// using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
-// xr.Read ();
-// base.ReadXml(xr);
-// }
-// }
-// }
-// public override void WriteXml(System.Xml.XmlWriter writer)
-// {
-// //TODO:
-// throw new NotImplementedException();
-// }
- #endregion
}
}
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs
index 5b7df01d..590ca84b 100644
--- a/src/GraphicObjects/TemplatedControl.cs
+++ b/src/GraphicObjects/TemplatedControl.cs
@@ -131,14 +131,16 @@ namespace Crow
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
//load template first if inlined
- xr.Read (); //skip current node
+ xr.Read (); //read first child
+ xr.Read (); //skip root node
- while (!xr.EOF) {
- xr.Read (); //read first child
- if (!xr.IsStartElement ())
+ while (!xr.EOF) {
+ if (!xr.IsStartElement ()) {
+ xr.Read ();
continue;
+ }
if (xr.Name == "ItemTemplate") {
- string dataType = "default", datas, itemTmp;
+ string dataType = "default", datas = "", itemTmp;
while (xr.MoveToNextAttribute ()) {
if (xr.Name == "DataType")
dataType = xr.Value;
@@ -147,13 +149,16 @@ namespace Crow
}
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));
+ itemTemplates [dataType].Datas = datas;
- }else if (xr.Name == "Template") {
+ continue;
+ }
+ if (xr.Name == "Template") {
xr.Read ();
Type t = Type.GetType ("Crow." + xr.Name);
@@ -161,11 +166,9 @@ namespace Crow
(go as IXmlSerializable).ReadXml (xr);
loadTemplate (go);
-
- xr.Read ();//go close tag
- //xr.Read ();//Template close tag
- } else
- xr.ReadInnerXml ();
+ continue;
+ }
+ xr.ReadInnerXml ();
}
}
} else
diff --git a/src/IMLStream.cs b/src/IMLStream.cs
index 776a70e7..7207327d 100644
--- a/src/IMLStream.cs
+++ b/src/IMLStream.cs
@@ -25,7 +25,9 @@ namespace Crow
{
public class IMLStream : MemoryStream {
public Type RootType;
- public IMLStream(string path) : base (){
+ //TODO:this has nothing to do in there, I should derive IMLStream
+ public string Datas;
+ public IMLStream(string path) : base (){
using (Stream stream = Interface.GetStreamFromPath (path))
stream.CopyTo (this);
RootType = Interface.GetTopContainerOfXMLStream (this);
diff --git a/src/Interface.cs b/src/Interface.cs
index 208bd2a4..3cfed981 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -284,7 +284,7 @@ namespace Crow
#if MEASURE_TIME
public Stopwatch clippingTime = new Stopwatch ();
public Stopwatch layoutTime = new Stopwatch ();
- public Stopwatch guTime = new Stopwatch ();
+ public Stopwatch updateTime = new Stopwatch ();
public Stopwatch drawingTime = new Stopwatch ();
#endif
@@ -377,12 +377,20 @@ namespace Crow
if (!Monitor.TryEnter (UpdateMutex))
return;
+ #if MEASURE_TIME
+ updateTime.Restart();
+ #endif
+
processLayouting ();
clippingRegistration ();
processDrawing ();
+ #if MEASURE_TIME
+ updateTime.Stop ();
+ #endif
+
Monitor.Exit (UpdateMutex);
}
void processLayouting(){