Height="{./HeightPolicy}" Width="{./WidthPolicy}"
ValueChanged="./_scroller_ValueChanged">
<VerticalStack LayoutChanged="./_list_LayoutChanged" Spacing="0"
- Height="Fit" Width="{./WidthPolicy}" Name="List" Margin="0" VerticalAlignment="Top"/>
+ Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
</Border>
\ No newline at end of file
HorizontalAlignment="Left"
ValueChanged="../../../_scroller_ValueChanged">
<VerticalStack LayoutChanged="../../../../_list_LayoutChanged"
- Height="Fit" Width="{../../WidthPolicy}" Name="List" Margin="0"
+ Height="Fit" Width="{../../WidthPolicy}" Name="ItemsContainer" Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
</Scroller>
Height="{./HeightPolicy}" Width="{./WidthPolicy}"
ValueChanged="./_scroller_ValueChanged">
<VerticalStack LayoutChanged="./_list_LayoutChanged"
- Height="Fit" Width="{./WidthPolicy}" Name="List" Margin="0" VerticalAlignment="Top"/>
+ Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
</Border>
\ No newline at end of file
Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
ValueChanged="./_scroller_ValueChanged">
<VerticalStack Width="{./WidthPolicy}" Height="-1" MinimumSize="10,10"
- Name="List" Margin="0" VerticalAlignment="Top"
+ Name="ItemsContainer" Margin="0" VerticalAlignment="Top"
LayoutChanged="./_list_LayoutChanged"/>
</Scroller>
<ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
ScrollY="{../scrollbar1.Value}"
ValueChanged="./_scroller_ValueChanged">
<VerticalStack LayoutChanged="./_list_LayoutChanged"
- Height="Fit" Width="{./WidthPolicy}" Name="List" Margin="0" VerticalAlignment="Top"/>
+ Height="Fit" Width="{./WidthPolicy}" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
<ScrollBar
Name="scrollbar1"
<?xml version="1.0"?>
<VerticalStack
- Height="Fit" Width="{../WidthPolicy}" Name="List"/>
\ No newline at end of file
+ Height="Fit" Width="{../WidthPolicy}" Name="ItemsContainer"/>
\ No newline at end of file
idx = testFiles.Length - 1;
this.Title = testFiles [idx] + ". Press <F3> to cycle examples.";
- GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]);
- obj.DataSource = this;
+ try {
+ GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]);
+ obj.DataSource = this;
+ } catch (Exception ex) {
+ Debug.WriteLine (ex.Message + ex.InnerException);
+ }
}
void Tv_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
{
<GraphicObject Width="12" Height="10"/>
<TreeView Name="List" Height="Fit" Width="{./WidthPolicy}">
<Template>
- <VerticalStack Height="Fit" Width="{../WidthPolicy}" Name="List"/>
+ <VerticalStack Height="Fit" Width="{../WidthPolicy}" Name="ItemsContainer"/>
</Template>
</TreeView>
</HorizontalStack>
Margin="2" VerticalScrolling="true" ScrollY="{../scrollbar1.Value}"
ValueChanged="../../../_scroller_ValueChanged">
<VerticalStack Width="{../../../../WidthPolicy}" Height="Fit" MinimumSize="10,10"
- Name="List" Margin="0"
+ Name="ItemsContainer" Margin="0"
VerticalAlignment="Top"
HorizontalAlignment="Left"
LayoutChanged="../../../../_list_LayoutChanged"/>
branches:
only:
- - appveyor
+ - master
clone_depth: 1
namespace Crow
{
- public class ListBox : TemplatedControl
+ public class ListBox : TemplatedGroup
{
#region CTOR
public ListBox () : base() {}
#endregion
- #region events
- public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
- #endregion
-
- Group _list;
- GenericStack _gsList;
- IList data;
- int _selectedIndex;
- int itemPerPage = 50;
- Thread loadingThread = null;
- volatile bool cancelLoading = false;
-
- [XmlAttributeAttribute]public IList Data {
- get {
- return data;
- }
- set {
- if (value == data)
- return;
-
- cancelLoadingThread ();
-
- data = value;
-
- NotifyValueChanged ("Data", data);
-
- lock (CurrentInterface.UpdateMutex)
- _list.ClearChildren ();
- if (_gsList.Orientation == Orientation.Horizontal)
- _gsList.Width = -1;
- else
- _gsList.Height = -1;
-
- if (data == null)
- return;
-
- loadingThread = new Thread (loading);
- loadingThread.IsBackground = true;
- loadingThread.Start ();
- //loadPage(1);
-
- NotifyValueChanged ("SelectedIndex", _selectedIndex);
- NotifyValueChanged ("SelectedItem", SelectedItem);
- SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
- }
- }
-
- [XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{
- get { return _selectedIndex; }
- set {
- if (value == _selectedIndex)
- return;
-
- _selectedIndex = value;
-
- NotifyValueChanged ("SelectedIndex", _selectedIndex);
- NotifyValueChanged ("SelectedItem", SelectedItem);
- SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
- }
- }
- [XmlIgnore]public virtual object SelectedItem{
- get { return data == null ? null : _selectedIndex < 0 ? null : data[_selectedIndex]; }
- }
- protected void raiseSelectedItemChanged(){
- SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
- }
-
- #region TemplatedControl override
- protected override void loadTemplate (GraphicObject template = null)
- {
- base.loadTemplate (template);
- _list = this.child.FindByName ("List") as Group;
- if (_list == null)
- throw new Exception ("ListBox Template MUST contain a Goup widget named 'List'.");
- _gsList = _list as GenericStack;
- }
- #endregion
-
- void loading(){
- if (ItemTemplates == null)
- ItemTemplates = new Dictionary<string, ItemTemplate> ();
- if (!ItemTemplates.ContainsKey ("default"))
- ItemTemplates ["default"] = Interface.GetItemTemplate (ItemTemplate);
-
- for (int i = 1; i <= (data.Count / itemPerPage) + 1; i++) {
- if (cancelLoading)
- return;
- loadPage (i);
- }
- }
- void cancelLoadingThread(){
- if (loadingThread == null)
- return;
- if (!loadingThread.IsAlive)
- return;
- cancelLoading = true;
- loadingThread.Join ();
- cancelLoading = false;
- }
- void loadPage(int pageNum)
- {
- #if DEBUG_LOAD
- Stopwatch loadingTime = new Stopwatch ();
- loadingTime.Start ();
- #endif
-
- Group page = _list.Clone () as Group;
-
- page.Name = "page" + pageNum;
-
- //reset size to fit in the dir of the stacking
- //because _list total size is forced to approx size
- if (_gsList.Orientation == Orientation.Horizontal) {
- page.Width = Measure.Fit;
- page.BindMember ("Height", "../HeightPolicy");
- } else {
- page.Height = Measure.Fit;
- page.BindMember ("Width", "../WidthPolicy");
- }
-
- for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) {
- if (i >= data.Count)
- break;
- if (cancelLoading)
- return;
-
- loadItem (i, page);
-
- //g.LogicalParent = this;
- }
-
- lock (CurrentInterface.LayoutMutex)
- _list.AddChild (page);
-
- #if DEBUG_LOAD
- loadingTime.Stop ();
- Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
- loadingTime.ElapsedTicks,
- loadingTime.ElapsedMilliseconds, this.ToString());
- #endif
- }
- protected void loadItem(int i, Group page){
- GraphicObject g = null;
- ItemTemplate iTemp = null;
- Type dataType = data [i].GetType ();
-
- while (dataType.FullName != "System.Object") {
- if (ItemTemplates.ContainsKey (dataType.FullName)) {
- iTemp = ItemTemplates [dataType.FullName];
- break;
- }
- dataType = dataType.BaseType;
- if (dataType == null)
- break;
- }
-
- if (iTemp == null)
- iTemp = ItemTemplates ["default"];
-
- lock (CurrentInterface.LayoutMutex) {
- g = iTemp.CreateInstance(CurrentInterface);
- page.AddChild (g);
- g.DataSource = data [i];
- }
-
- registerItemClick (g);
-
- if (iTemp.Expand != null && g is Expandable) {
- (g as Expandable).Expand += iTemp.Expand;
- }
- }
- protected virtual void registerItemClick(GraphicObject g){
- g.MouseClick += itemClick;
- }
- protected void _list_LayoutChanged (object sender, LayoutingEventArgs e)
- {
-#if DEBUG_LAYOUTING
- Debug.WriteLine("list_LayoutChanged");
-#endif
- if (_gsList.Orientation == Orientation.Horizontal) {
- if (e.LayoutType == LayoutingType.Width)
- _gsList.Width = approxSize;
- } else if (e.LayoutType == LayoutingType.Height)
- _gsList.Height = approxSize;
- }
- int approxSize
- {
- get {
- if (data == null)
- return -1;
- GenericStack page1 = _list.FindByName ("page1") as GenericStack;
- if (page1 == null)
- return -1;
-
- return page1.Orientation == Orientation.Horizontal ?
- data.Count < itemPerPage ?
- -1:
- (int)Math.Ceiling ((double)page1.Slot.Width / (double)itemPerPage * (double)(data.Count+1)):
- data.Count < itemPerPage ?
- -1:
- (int)Math.Ceiling ((double)page1.Slot.Height / (double)itemPerPage * (double)(data.Count+1));
- }
- }
- internal virtual void itemClick(object sender, MouseButtonEventArgs e){
- SelectedIndex = data.IndexOf((sender as GraphicObject).DataSource);
- }
}
}
{
Execute.Raise (this, null);
}
- void onOpen (object sender, EventArgs e){
+ protected virtual void onOpen (object sender, EventArgs e){
MenuRoot.IsOpened = true;
Open.Raise (this, null);
}
- void onClose (object sender, EventArgs e){
+ protected virtual void onClose (object sender, EventArgs e){
//MenuRoot.IsOpened = true;
Close.Raise (this, null);
}
}
string _template;
- string _itemTemplate;
- public Dictionary<string, ItemTemplate> ItemTemplates = new Dictionary<string, Crow.ItemTemplate>();//TODO: dont instantiate if not used
- //but then i should test if null in msil gen
[XmlAttributeAttribute][DefaultValue(null)]
public string Template {
get { return _template; }
loadTemplate (CurrentInterface.Load (_template));
}
}
- [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)
{
{
//onDraw is overrided to prevent default drawing of background, template top container
//may have a binding to root background or a fixed one.
- //this allow applying root background to random template component
+ //this allow applying root background to random template's component
gr.Save ();
if (ClipToClientRect) {
this.ResolveBindings ();
}
+ //TODO:IXmlSerializable is not used anymore
#region IXmlSerializable
public override System.Xml.Schema.XmlSchema GetSchema(){ return null; }
public override void ReadXml(System.Xml.XmlReader reader)
xr.MoveToElement ();
itemTmp = xr.ReadInnerXml ();
- if (ItemTemplates == null)
- ItemTemplates = new Dictionary<string, ItemTemplate> ();
-
- using (IMLReader iTmp = new IMLReader (null, itemTmp)) {
- ItemTemplates [dataType] =
- new ItemTemplate (iTmp.RootType, iTmp.GetLoader (), dataType, datas);
- }
- if (!string.IsNullOrEmpty (datas))
- ItemTemplates [dataType].CreateExpandDelegate(this);
+// if (ItemTemplates == null)
+// ItemTemplates = new Dictionary<string, ItemTemplate> ();
+//
+// using (IMLReader iTmp = new IMLReader (null, itemTmp)) {
+// ItemTemplates [dataType] =
+// new ItemTemplate (iTmp.RootType, iTmp.GetLoader (), dataType, datas);
+// }
+// if (!string.IsNullOrEmpty (datas))
+// ItemTemplates [dataType].CreateExpandDelegate(this);
continue;
}
using System.Xml;
using System.Reflection;
using System.Collections.Generic;
+using System.ComponentModel;
+using System.Collections;
+using System.Threading;
namespace Crow
{
#endregion
protected Group items;
+ string _itemTemplate;
+
+ #region events
+ public event EventHandler<SelectionChangeEventArgs> SelectedItemChanged;
+ #endregion
+
+ Group _list;
+ IList data;
+ int _selectedIndex;
+ Color selBackground, selForeground;
+
+ int itemPerPage = 50;
+ Thread loadingThread = null;
+ volatile bool cancelLoading = false;
+
+ #region Templating
+ //TODO: dont instantiate ItemTemplates if not used
+ //but then i should test if null in msil gen
+ public Dictionary<string, ItemTemplate> ItemTemplates = new Dictionary<string, Crow.ItemTemplate>();
+
+ [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);
+ }
+ }
+ protected override void loadTemplate(GraphicObject template = null)
+ {
+ base.loadTemplate (template);
+
+ items = this.child.FindByName ("ItemsContainer") as Group;
+ if (items == null)
+ throw new Exception ("TemplatedGroup template Must contain a Group named 'ItemsContainer'");
+ if (items.Children.Count == 0)
+ NotifyValueChanged ("HasChildren", false);
+ else
+ NotifyValueChanged ("HasChildren", true);
+ }
+ #endregion
public virtual List<GraphicObject> Items{ get { return items.Children; }}
+ [XmlAttributeAttribute][DefaultValue(-1)]public int SelectedIndex{
+ get { return _selectedIndex; }
+ set {
+ if (value == _selectedIndex)
+ return;
+
+ _selectedIndex = value;
+
+ NotifyValueChanged ("SelectedIndex", _selectedIndex);
+ NotifyValueChanged ("SelectedItem", SelectedItem);
+ SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
+ }
+ }
+ [XmlIgnore]public virtual object SelectedItem{
+ get { return data == null ? null : _selectedIndex < 0 ? null : data[_selectedIndex]; }
+ }
+
+ [XmlAttributeAttribute]public IList Data {
+ get { return data; }
+ set {
+ if (value == data)
+ return;
+
+ cancelLoadingThread ();
+
+ data = value;
+
+ NotifyValueChanged ("Data", data);
+
+ lock (CurrentInterface.UpdateMutex)
+ ClearItems ();
+
+ if (data == null)
+ return;
+
+ loadingThread = new Thread (loading);
+ loadingThread.IsBackground = true;
+ loadingThread.Start ();
+ //loadPage(1);
+
+ NotifyValueChanged ("SelectedIndex", _selectedIndex);
+ NotifyValueChanged ("SelectedItem", SelectedItem);
+ SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
+ }
+ }
+
+ [XmlAttributeAttribute][DefaultValue("SteelBlue")]//DeepJungleGreen
+ public virtual Color SelectionBackground {
+ get { return selBackground; }
+ set {
+ if (value == selBackground)
+ return;
+ selBackground = value;
+ NotifyValueChanged ("SelectionBackground", selBackground);
+ RegisterForRedraw ();
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue("White")]
+ public virtual Color SelectionForeground {
+ get { return selForeground; }
+ set {
+ if (value == selForeground)
+ return;
+ selForeground = value;
+ NotifyValueChanged ("SelectionForeground", selForeground);
+ RegisterForRedraw ();
+ }
+ }
+
+ protected void raiseSelectedItemChanged(){
+ SelectedItemChanged.Raise (this, new SelectionChangeEventArgs (SelectedItem));
+ }
+
public virtual void AddItem(GraphicObject g){
items.AddChild (g);
NotifyValueChanged ("HasChildren", false);
}
- protected override void loadTemplate(GraphicObject template = null)
- {
- base.loadTemplate (template);
-
- items = this.child.FindByName ("ItemsContainer") as Group;
- if (items == null)
- throw new Exception ("TemplatedGroup template Must contain a Group named 'ItemsContainer'");
- if (items.Children.Count == 0)
- NotifyValueChanged ("HasChildren", false);
- else
- NotifyValueChanged ("HasChildren", true);
- }
#region GraphicObject overrides
public override GraphicObject FindByName (string nameToFind)
throw new NotImplementedException ();
}
#endregion
+
+ void loading(){
+ if (ItemTemplates == null)
+ ItemTemplates = new Dictionary<string, ItemTemplate> ();
+ if (!ItemTemplates.ContainsKey ("default"))
+ ItemTemplates ["default"] = Interface.GetItemTemplate (ItemTemplate);
+
+ for (int i = 1; i <= (data.Count / itemPerPage) + 1; i++) {
+ if (cancelLoading)
+ return;
+ loadPage (i);
+ }
+ }
+ void cancelLoadingThread(){
+ if (loadingThread == null)
+ return;
+ if (!loadingThread.IsAlive)
+ return;
+ cancelLoading = true;
+ loadingThread.Join ();
+ cancelLoading = false;
+ }
+ void loadPage(int pageNum)
+ {
+ #if DEBUG_LOAD
+ Stopwatch loadingTime = new Stopwatch ();
+ loadingTime.Start ();
+ #endif
+
+ Group page = items.Clone () as Group;
+
+ page.Name = "page" + pageNum;
+
+// //reset size to fit in the dir of the stacking
+// //because items total size is forced to approx size
+// if (_gsList.Orientation == Orientation.Horizontal) {
+// page.Width = Measure.Fit;
+ page.BindMember ("Height", "../HeightPolicy");
+ page.BindMember ("Width", "../WidthPolicy");
+// } else {
+// page.Height = Measure.Fit;
+// page.BindMember ("Width", "../WidthPolicy");
+// }
+
+ for (int i = (pageNum - 1) * itemPerPage; i < pageNum * itemPerPage; i++) {
+ if (i >= data.Count)
+ break;
+ if (cancelLoading)
+ return;
+
+ loadItem (i, page);
+
+ //g.LogicalParent = this;
+ }
+
+ lock (CurrentInterface.LayoutMutex)
+ items.AddChild (page);
+
+ #if DEBUG_LOAD
+ loadingTime.Stop ();
+ Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
+ loadingTime.ElapsedTicks,
+ loadingTime.ElapsedMilliseconds, this.ToString());
+ #endif
+ }
+ protected void loadItem(int i, Group page){
+ GraphicObject g = null;
+ ItemTemplate iTemp = null;
+ Type dataType = data [i].GetType ();
+
+ if (ItemTemplates.ContainsKey (dataType.FullName))
+ iTemp = ItemTemplates [dataType.FullName];
+ else
+ iTemp = ItemTemplates ["default"];
+
+ lock (CurrentInterface.LayoutMutex) {
+ g = iTemp.CreateInstance(CurrentInterface);
+ page.AddChild (g);
+ g.DataSource = data [i];
+ }
+
+ registerItemClick (g);
+
+ if (iTemp.Expand != null && g is Expandable) {
+ (g as Expandable).Expand += iTemp.Expand;
+ }
+ }
+ protected virtual void registerItemClick(GraphicObject g){
+ g.MouseClick += itemClick;
+ }
+// protected void _list_LayoutChanged (object sender, LayoutingEventArgs e)
+// {
+// #if DEBUG_LAYOUTING
+// Debug.WriteLine("list_LayoutChanged");
+// #endif
+// if (_gsList.Orientation == Orientation.Horizontal) {
+// if (e.LayoutType == LayoutingType.Width)
+// _gsList.Width = approxSize;
+// } else if (e.LayoutType == LayoutingType.Height)
+// _gsList.Height = approxSize;
+// }
+ int approxSize
+ {
+ get {
+ if (data == null)
+ return -1;
+ GenericStack page1 = items.FindByName ("page1") as GenericStack;
+ if (page1 == null)
+ return -1;
+
+ return page1.Orientation == Orientation.Horizontal ?
+ data.Count < itemPerPage ?
+ -1:
+ (int)Math.Ceiling ((double)page1.Slot.Width / (double)itemPerPage * (double)(data.Count+1)):
+ data.Count < itemPerPage ?
+ -1:
+ (int)Math.Ceiling ((double)page1.Slot.Height / (double)itemPerPage * (double)(data.Count+1));
+ }
+ }
+ internal virtual void itemClick(object sender, MouseButtonEventArgs e){
+ SelectedIndex = data.IndexOf((sender as GraphicObject).DataSource);
+ }
}
}
{
//treeview expect expandable child (or not)
//if their are expandable, some functions and events are added
- public class TreeView : ListBox
+ public class TreeView : TemplatedGroup
{
GraphicObject selectedItemContainer = null;
- Color selBackground;
- Color selForeground;
bool isRoot;
-
+ #region CTOR
public TreeView () : base()
{
}
+ #endregion
+
[XmlAttributeAttribute()][DefaultValue(false)]
public virtual bool IsRoot {
get { return isRoot; }
}
}
- [XmlAttributeAttribute][DefaultValue("SteelBlue")]//DeepJungleGreen
- public virtual Color SelectionBackground {
- get { return selBackground; }
- set {
- if (value == selBackground)
- return;
- selBackground = value;
- NotifyValueChanged ("SelectionBackground", selBackground);
- RegisterForRedraw ();
- }
- }
- [XmlAttributeAttribute][DefaultValue("White")]
- public virtual Color SelectionForeground {
- get { return selForeground; }
- set {
- if (value == selForeground)
- return;
- selForeground = value;
- NotifyValueChanged ("SelectionForeground", selForeground);
- RegisterForRedraw ();
- }
- }
-
[XmlIgnore]public override object SelectedItem {
get {
return selectedItemContainer == null ?
il.Emit (OpCodes.Ldloc_0);//save current go onto the stack if child has to be added
- #region Template and TemplateItems loading
+ #region Template and ItemTemplates loading
if (typeof(TemplatedControl).IsAssignableFrom (crowType)) {
//if its a template, first read template elements
using (IMLReader reader = new IMLReader (il, tmpXml)) {
foreach (string[] iTempId in itemTemplateIds) {
reader.il.Emit (OpCodes.Ldloc_0);//load TempControl ref
reader.il.Emit (OpCodes.Ldfld,//load ItemTemplates dic field
- typeof(TemplatedControl).GetField("ItemTemplates"));
+ typeof(TemplatedGroup).GetField("ItemTemplates"));
reader.il.Emit (OpCodes.Ldstr, iTempId[0]);//load key
reader.il.Emit (OpCodes.Ldstr, iTempId[1]);//load value
reader.il.Emit (OpCodes.Callvirt,
//expand delegate creation
reader.il.Emit (OpCodes.Ldloc_0);//load TempControl ref
reader.il.Emit (OpCodes.Ldfld,//load ItemTemplates dic field
- typeof(TemplatedControl).GetField ("ItemTemplates"));
+ typeof(TemplatedGroup).GetField ("ItemTemplates"));
reader.il.Emit (OpCodes.Ldstr, iTempId [0]);//load key
reader.il.Emit (OpCodes.Callvirt,
typeof(Dictionary<string, ItemTemplate>).GetMethod ("get_Item",
}
#endregion
- public void CreateExpandDelegate (TemplatedControl host){
- Type hostType = typeof(TemplatedControl);//not sure is the best place to put the dyn method
+ public void CreateExpandDelegate (TemplatedGroup host){
+ Type dataType = Type.GetType(strDataType);
+ Type tmpGrpType = typeof(TemplatedGroup);
+ Type hostType = tmpGrpType;//not sure is the best place to put the dyn method
Type evtType = typeof(EventHandler);
- Type listBoxType = typeof(ListBox);
- PropertyInfo piListData = listBoxType.GetProperty ("Data");
+
+ PropertyInfo piData = tmpGrpType.GetProperty ("Data");
MethodInfo evtInvoke = evtType.GetMethod ("Invoke");
ParameterInfo [] evtParams = evtInvoke.GetParameters ();
//check that 'Data' of list is not already set
il.Emit (OpCodes.Ldloc_0);
- il.Emit (OpCodes.Callvirt, piListData.GetGetMethod ());
+ il.Emit (OpCodes.Callvirt, piData.GetGetMethod ());
il.Emit (OpCodes.Brfalse, ifDataIsNull);
il.Emit (OpCodes.Br, gotoEnd);
il.MarkLabel(ifDataIsNull);
//copy the ref of ItemTemplates list TODO: maybe find another way to share it among the nodes?
- FieldInfo fiTemplates = typeof(TemplatedControl).GetField("ItemTemplates");
+ FieldInfo fiTemplates = tmpGrpType.GetField("ItemTemplates");
il.Emit (OpCodes.Ldloc_0);
il.Emit (OpCodes.Ldarg_0);
il.Emit (OpCodes.Ldfld, fiTemplates);
il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetProperty("DataSource").GetGetMethod ());
if (fetchMethodName != "self"){//special keyword self allows the use of recurent list<<<
- Type dataType = Type.GetType(strDataType);
emitGetSubData(il, dataType);
}
//set 'return' from the fetch method as 'data' of the list
- il.Emit (OpCodes.Callvirt, piListData.GetSetMethod ());
+ il.Emit (OpCodes.Callvirt, piData.GetSetMethod ());
il.MarkLabel(gotoEnd);
il.Emit (OpCodes.Ret);