Browse Source

added csharp syntax to markdown

tznind 4 years ago
parent
commit
bbfb6b28c0
1 changed files with 7 additions and 10 deletions
  1. 7 10
      docfx/articles/treeview.md

+ 7 - 10
docfx/articles/treeview.md

@@ -16,8 +16,6 @@ var tree = new TreeView()
     Height = 20
     Height = 20
 };
 };
 
 
-Win.Add(tree);
-
 var root1 = new TreeNode("Root1");
 var root1 = new TreeNode("Root1");
 root1.Children.Add(new TreeNode("Child1.1"));
 root1.Children.Add(new TreeNode("Child1.1"));
 root1.Children.Add(new TreeNode("Child1.2"));
 root1.Children.Add(new TreeNode("Child1.2"));
@@ -34,7 +32,7 @@ tree.AddObject(root2);
 Having to create a bunch of TreeNode objects can be a pain especially if you already have your own objects e.g. `House`, `Room` etc.  There are two ways to use your own classes without having to create nodes manually.  Firstly you can implement the `ITreeNode` interface:
 Having to create a bunch of TreeNode objects can be a pain especially if you already have your own objects e.g. `House`, `Room` etc.  There are two ways to use your own classes without having to create nodes manually.  Firstly you can implement the `ITreeNode` interface:
 
 
 
 
-```
+```csharp
 // Your data class
 // Your data class
 private class House : ITreeNode {
 private class House : ITreeNode {
 
 
@@ -67,11 +65,11 @@ private class Room : ITreeNode{
         return Name;
         return Name;
     }
     }
 }
 }
+```
 
 
+After implementing the interface you can add your objects directly to the tree
 
 
-...
-
-// After implementing the interface you can add your objects directly to the tree
+```csharp
 
 
 var myHouse = new House()
 var myHouse = new House()
 {
 {
@@ -93,7 +91,6 @@ var tree = new TreeView()
 
 
 tree.AddObject(myHouse);
 tree.AddObject(myHouse);
 
 
-
 ```
 ```
 
 
 Alternatively you can simply tell the tree how the objects relate to one another by implementing `ITreeBuilder<T>`.  This is a good option if you don't have control of the data objects you are working with.
 Alternatively you can simply tell the tree how the objects relate to one another by implementing `ITreeBuilder<T>`.  This is a good option if you don't have control of the data objects you are working with.
@@ -161,7 +158,7 @@ private class GameObjectTreeBuilder : ITreeBuilder<GameObject> {
 
 
 To use the builder in a tree you would use:
 To use the builder in a tree you would use:
 
 
-```
+```csharp
 var army1 = new Army()
 var army1 = new Army()
 {
 {
     Designation = "3rd Infantry",
     Designation = "3rd Infantry",
@@ -187,7 +184,7 @@ tree.AddObject(army1);
 
 
 Alternatively you can use `DelegateTreeBuilder<T>` instead of implementing your own `ITreeBuilder<T>`.  For example:
 Alternatively you can use `DelegateTreeBuilder<T>` instead of implementing your own `ITreeBuilder<T>`.  For example:
 
 
-```
+```csharp
 tree.TreeBuilder = new DelegateTreeBuilder<GameObject>(
 tree.TreeBuilder = new DelegateTreeBuilder<GameObject>(
     (o)=>o is Army a ? a.Units 
     (o)=>o is Army a ? a.Units 
         : Enumerable.Empty<GameObject>());
         : Enumerable.Empty<GameObject>());
@@ -197,7 +194,7 @@ tree.TreeBuilder = new DelegateTreeBuilder<GameObject>(
 
 
 The default behaviour of TreeView is to use the `ToString` method on the objects for rendering.  You can customise this by changing the `AspectGetter`.  For example:
 The default behaviour of TreeView is to use the `ToString` method on the objects for rendering.  You can customise this by changing the `AspectGetter`.  For example:
 
 
-```
+```csharp
 treeViewFiles.AspectGetter = (f)=>f.FullName;
 treeViewFiles.AspectGetter = (f)=>f.FullName;
 ```
 ```