aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-06 07:07:57 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-06 07:07:57 +0100
commita330b907a9c9252c480ea352606d961bdc7c3ecb (patch)
tree668d654fc989beac33c1f07d788606d9eeec5b13 /src
parent5aa236608a006dd8f529b791a0ae2f9992902bc0 (diff)
:book:, default item template loading if none defined for TemplatedGroup
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs6
-rw-r--r--src/IML/Node.cs3
-rw-r--r--src/Instantiator.cs7
-rw-r--r--src/Interface.cs6
-rw-r--r--src/ItemTemplate.cs25
5 files changed, 40 insertions, 7 deletions
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index 81ea25fb..55726b50 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -71,9 +71,9 @@ namespace Crow
///
/// ItemTemplate file may contains either a single template without the
/// ItemTemplate enclosing tag, or several item templates each enclosed
- /// in a separate tag
+ /// in a separate tag.
/// </summary>
- [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")]
+ [XmlAttributeAttribute]
public string ItemTemplate {
get { return _itemTemplate; }
set {
@@ -344,7 +344,7 @@ namespace Crow
}
string getItempKey(Type dataType, object o){
try {
- return dataType.GetProperty (_dataTest).GetGetMethod ().Invoke (o, null).ToString();
+ return dataType.GetProperty (_dataTest).GetGetMethod ().Invoke (o, null)?.ToString();
} catch {
return dataType.FullName;
}
diff --git a/src/IML/Node.cs b/src/IML/Node.cs
index 8b85388b..2ca90e8c 100644
--- a/src/IML/Node.cs
+++ b/src/IML/Node.cs
@@ -85,6 +85,9 @@ namespace Crow.IML
public bool HasTemplate {
get { return typeof (TemplatedControl).IsAssignableFrom (CrowType);}
}
+ public bool IsTemplatedGroup {
+ get { return typeof (TemplatedGroup).IsAssignableFrom (CrowType);}
+ }
public static implicit operator string (Node sn)
{
diff --git a/src/Instantiator.cs b/src/Instantiator.cs
index 5f187c58..b79fbc82 100644
--- a/src/Instantiator.cs
+++ b/src/Instantiator.cs
@@ -207,7 +207,7 @@ namespace Crow.IML
/// </summary>
/// <returns>the string triplet dataType, itemTmpID read as attribute of this tag</returns>
/// <param name="reader">current xml text reader</param>
- /// /// <param name="itemTemplatePath">file containing the templates if its a dedicated one</param>
+ /// <param name="itemTemplatePath">file containing the templates if its a dedicated one</param>
string[] parseItemTemplateTag (XmlReader reader, string itemTemplatePath = "") {
string dataType = "default", datas = "", path = "";
while (reader.MoveToNextAttribute ()) {
@@ -307,6 +307,11 @@ namespace Crow.IML
}
}
}
+ if (!ctx.nodesStack.Peek ().IsTemplatedGroup)
+ return;
+ //add the default item template if no default is defined
+ if (!itemTemplateIds.Any(ids=>ids[0] == "default"))
+ itemTemplateIds.Add (new string [] { "default", "#Crow.DefaultItem.template", "" });
//copy item templates (review this)
foreach (string [] iTempId in itemTemplateIds) {
ctx.il.Emit (OpCodes.Ldloc_0);//load TempControl ref
diff --git a/src/Interface.cs b/src/Interface.cs
index 32b9549e..b16acc07 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -224,9 +224,9 @@ namespace Crow
}
static void loadCursors(){
//Load cursors
- XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[3];
- XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[3];
- XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[3];
+ XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0];
+ XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0];
+ XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0];
XCursor.NE = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0];
XCursor.SW = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0];
XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0];
diff --git a/src/ItemTemplate.cs b/src/ItemTemplate.cs
index d0c6873e..915aafd8 100644
--- a/src/ItemTemplate.cs
+++ b/src/ItemTemplate.cs
@@ -43,6 +43,9 @@ namespace Crow
/// <summary>
/// Derived from Instantiator with sub data fetching facilities for hierarchical data access.
+ ///
+ /// ItemTemplate stores the dynamic method for instantiating the control tree defined in a valid IML file.
+ ///
/// </summary>
public class ItemTemplate : Instantiator {
public EventHandler Expand;
@@ -51,18 +54,36 @@ namespace Crow
string fetchMethodName;
#region CTOR
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Crow.ItemTemplate"/> class by parsing the file passed as argument.
+ /// </summary>
+ /// <param name="path">IML file to parse</param>
+ /// <param name="_dataType">type this item will be choosen for, or member of the data item</param>
+ /// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param>
public ItemTemplate(string path, string _dataType = null, string _fetchDataMethod = null)
: base(path) {
strDataType = _dataType;
fetchMethodName = _fetchDataMethod;
}
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Crow.ItemTemplate"/> class by parsing the IML fragment passed as arg.
+ /// </summary>
+ /// <param name="path">IML fragment to parse</param>
+ /// <param name="_dataType">type this item will be choosen for, or member of the data item</param>
+ /// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param>
public ItemTemplate (Stream ImlFragment, string _dataType, string _fetchDataMethod)
:base(ImlFragment)
{
strDataType = _dataType;
fetchMethodName = _fetchDataMethod;
}
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Crow.ItemTemplate"/> class using the opened XmlReader in args.
+ /// </summary>
+ /// <param name="path">XML reader positionned before or at the root node</param>
+ /// <param name="_dataType">type this item will be choosen for, or member of the data item</param>
+ /// <param name="_fetchDataMethod">for hierarchical data, method to call for children fetching</param>
public ItemTemplate (XmlReader reader, string _dataType = null, string _fetchDataMethod = null)
:base(reader)
{
@@ -71,6 +92,10 @@ namespace Crow
}
#endregion
+ /// <summary>
+ /// Creates the expand delegate.
+ /// </summary>
+ /// <param name="host">Host.</param>
public void CreateExpandDelegate (TemplatedGroup host){
Type dataType = CompilerServices.tryGetType(strDataType);
if (dataType == null) {