--- /dev/null
+<?xml version="1.0"?>
+<Border BorderWidth="2" Fit="true">
+ <VerticalStack Fit="true" Margin="5">
+ <ListBox Data="{TestList}" Background="0.5,0.5,0.5,0.7"
+ HorizontalAlignment="Center" Width="200" Height="200" Margin="5">
+ <Template>
+ <Border BorderWidth="1" Height="{../HeightPolicy}" Width="{../WidthPolicy}">
+ <HorizontalStack Margin="1" Height="{../../HeightPolicy}" Width="{../../WidthPolicy}" >
+ <Scroller Name="scroller1" Height="{../../../HeightPolicy}" Width="{../../../WidthPolicy}"
+ Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
+ ValueChanged="../../../_scroller_ValueChanged">
+ <VerticalStack Width="{../../../../WidthPolicy}" Height="Fit" MinimumSize="10,10"
+ Name="List" Margin="0"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Left"
+ LayoutChanged="../../../../_list_LayoutChanged"/>
+ </Scroller>
+ <ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
+ Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
+ Width="14" Height="{../../../HeightPolicy}" />
+ </HorizontalStack>
+ </Border>
+ </Template>
+ <ItemTemplate DataType="Crow.Color">
+ <HorizontalStack
+ HorizontalAlignment="Left"
+ Height="Fit" Width="200" Margin="1" Focusable="true"
+ MouseEnter="{Background=hgradient|0:DarkRed|1:Transparent}"
+ MouseLeave="{Background=Transparent}">
+ <GraphicObject Height="12" Width="20" Background="{}" Margin="0" CornerRadius="3"/>
+ <Label Text="{Name}" Margin="0" Width="Stretched"/>
+ </HorizontalStack>
+ </ItemTemplate>
+ </ListBox>
+ <HorizontalStack Fit="true" HorizontalAlignment="Right">
+ <Button Caption="Load list" MouseClick="OnLoadList"/>
+ <Button Caption="Clear" MouseClick="OnClear"/>
+ </HorizontalStack>
+ </VerticalStack>
+</Border>
\ No newline at end of file
<Reference Include="gdk-sharp"/>
<Reference Include="gio-sharp"/>
<Reference Include="glib-sharp"/>
- <Reference Include="OpenTK">
+ <Reference Include="OpenTK">
<HintPath>$(SolutionDir)packages\OpenTK.Next.1.2.2336.6514-pre\lib\net20\OpenTK.dll</HintPath>
</Reference>
</ItemGroup>
<None Include="Interfaces\Unsorted\0.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\Unsorted\testItemTemplateTag.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
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;
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 {
_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;
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)
using System.Xml;
using System.Diagnostics;
using System.Linq;
+using System.Collections.Generic;
+using System.Text;
namespace Crow
{
#endregion
string _template;
+ string _itemTemplate;
+ protected Dictionary<string, IMLStream> itemTemplates;
[XmlAttributeAttribute][DefaultValue(null)]
public string Template {
loadTemplate (Interface.Load (_template, this));
}
}
+ [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
+ public string ItemTemplate {
+ get { return _itemTemplate; }
+ set {
+ if (value == _itemTemplate)
+ return;
+
+ _itemTemplate = value;
+ //TODO:reload list with new template?
+ NotifyValueChanged("ItemTemplate", _itemTemplate);
+ }
+ }
#region GraphicObject overrides
public override GraphicObject FindByName (string nameToFind)
{
xr.Read (); //read first child
if (!xr.IsStartElement ())
continue;
- if (xr.Name == "Template") {
+ if (xr.Name == "ItemTemplate") {
+ string dataType = "default", datas, itemTmp;
+ while (xr.MoveToNextAttribute ()) {
+ if (xr.Name == "DataType")
+ dataType = xr.Value;
+ else if (xr.Name == "Data")
+ datas = xr.Value;
+ }
+ 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));
+
+ }else if (xr.Name == "Template") {
xr.Read ();
Type t = Type.GetType ("Crow." + xr.Name);
loadTemplate (go);
xr.Read ();//go close tag
- xr.Read ();//Template close tag
- break;
+ //xr.Read ();//Template close tag
} else
xr.ReadInnerXml ();
}
//if no template found, load default one
if (this.child == null)
loadTemplate ();
-
+
//normal xml read
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
xr.Read ();
stream.CopyTo (this);
RootType = Interface.GetTopContainerOfXMLStream (this);
}
+ public IMLStream(Byte[] b) : base (b){
+ RootType = Interface.GetTopContainerOfXMLStream (this);
+ }
}
}