<Compile Include="src\CompilerServices\MemberReference.cs" />
<Compile Include="src\CompilerServices\Bindings.cs" />
<Compile Include="src\StyleReader.cs" />
+ <Compile Include="src\IMLStream.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
using System.Collections;
using System.Xml.Serialization;
using System.ComponentModel;
-//TODO: implement ItemTemplate node in xml
using System.IO;
using System.Diagnostics;
using System.Xml;
IList data;
int _selectedIndex;
string _itemTemplate;
- int itemPerPage = 20;
- MemoryStream templateStream = null;
- Type templateBaseType = null;
+ int itemPerPage = 50;
Thread loadingThread = null;
volatile bool cancelLoading = false;
+ IMLStream templateStream = null;
+
[XmlAttributeAttribute]public IList Data {
get {
return data;
}
#endregion
void loading(){
- lock (Interface.CurrentInterface.UpdateMutex) {
- templateStream = new MemoryStream ();
- using (Stream stream = Interface.GetStreamFromPath (ItemTemplate))
- stream.CopyTo (templateStream);
- templateBaseType = Interface.GetTopContainerOfXMLStream (templateStream);
- }
+ templateStream = new IMLStream (ItemTemplate);
for (int i = 1; i <= (data.Count / itemPerPage) + 1; i++) {
if (cancelLoading)
return;
break;
if (cancelLoading)
return;
- templateStream.Seek (0, SeekOrigin.Begin);
- GraphicObject g = Interface.Load (templateStream, templateBaseType);
+
+ GraphicObject g = Interface.Load (templateStream);
g.MouseClick += itemClick;
lock (Interface.CurrentInterface.UpdateMutex)
--- /dev/null
+//
+// IMLStream.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2016 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.IO;
+
+namespace Crow
+{
+ public class IMLStream : MemoryStream {
+ public Type RootType;
+ public IMLStream(string path) : base (){
+ using (Stream stream = Interface.GetStreamFromPath (path))
+ stream.CopyTo (this);
+ RootType = Interface.GetTopContainerOfXMLStream (this);
+ }
+ }
+}
+
return tmp;
}
+ internal static GraphicObject Load (IMLStream stream, object hostClass = null){
+ stream.Seek (0, SeekOrigin.Begin);
+ return Load(stream, stream.RootType, hostClass);
+ }
internal static GraphicObject Load (Stream stream, Type type, object hostClass = null)
{
#if DEBUG_LOAD