From 3a01c455e09af25109239ab7ca32e66ea1ebc99b Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Thu, 4 Aug 2016 13:12:30 +0200 Subject: * Tests.csproj: * BasicTests.cs: * TreeView.crow: * welcome.crow: * test4.crow: * testWindow2.goml: * testTreeView.crow: * testDirViewer.crow: update tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Interface.cs: * OpenTKGameWindow.cs: perf measures * IMLStream.cs: datas prop * TemplatedControl.cs: ItemTemplate * ListBox.cs: thread sync nouveau fichierĀ : Tests/test.style --- src/GraphicObjects/ListBox.cs | 89 +++++++--------------------------- src/GraphicObjects/TemplatedControl.cs | 27 ++++++----- 2 files changed, 33 insertions(+), 83 deletions(-) (limited to 'src/GraphicObjects') 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 (); - //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 (); //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 -- cgit v1.3.1-4-g156e