tanghai пре 11 година
родитељ
комит
9a032f9b05

+ 1 - 1
CSharp/App/Modules/BehaviorTreeModule/AllTreeViewModel.cs

@@ -16,7 +16,7 @@ namespace Modules.BehaviorTreeModule
         private readonly Dictionary<int, TreeViewModel> treeViewModelsDict =
                 new Dictionary<int, TreeViewModel>();
 
-        public ObservableCollection<TreeNodeViewModel> rootList =
+        public readonly ObservableCollection<TreeNodeViewModel> rootList =
                 new ObservableCollection<TreeNodeViewModel>();
 
         public ObservableCollection<TreeNodeViewModel> RootList

+ 0 - 1
CSharp/App/Modules/BehaviorTreeModule/BehaviorTreeModule.csproj

@@ -88,7 +88,6 @@
   <ItemGroup>
     <Compile Include="TreeInfoViewModel.cs" />
     <Compile Include="AllTreeViewModel.cs" />
-    <Compile Include="OneTreeData.cs" />
     <Compile Include="TreeLayout.cs" />
     <Compile Include="TreeView.xaml.cs">
       <DependentUpon>TreeView.xaml</DependentUpon>

+ 0 - 6
CSharp/App/Modules/BehaviorTreeModule/OneTreeData.cs

@@ -1,6 +0,0 @@
-namespace Modules.BehaviorTreeModule
-{
-    public class OneTreeData
-    {
-    }
-}

+ 9 - 9
CSharp/App/Modules/BehaviorTreeModule/TreeLayout.cs

@@ -24,9 +24,9 @@
             }
             for (int i = 0; i < treeNodeViewModel.Children.Count; ++i)
             {
-                var child = this.treeViewModel.Get(treeNodeViewModel.Children[i]);
+                TreeNodeViewModel child = this.treeViewModel.Get(treeNodeViewModel.Children[i]);
                 child.AncestorModify = treeNodeViewModel.Modify + treeNodeViewModel.AncestorModify;
-                var offspring = this.LeftMostOffspring(child, currentLevel + 1, searchLevel);
+                TreeNodeViewModel offspring = this.LeftMostOffspring(child, currentLevel + 1, searchLevel);
                 if (offspring == null)
                 {
                     continue;
@@ -45,9 +45,9 @@
             }
             for (int i = treeNodeViewModel.Children.Count - 1; i >= 0; --i)
             {
-                var child = this.treeViewModel.Get(treeNodeViewModel.Children[i]);
+                TreeNodeViewModel child = this.treeViewModel.Get(treeNodeViewModel.Children[i]);
                 child.AncestorModify = treeNodeViewModel.Modify + treeNodeViewModel.AncestorModify;
-                var offspring = this.RightMostOffspring(child, currentLevel + 1, searchLevel);
+                TreeNodeViewModel offspring = this.RightMostOffspring(child, currentLevel + 1, searchLevel);
                 if (offspring == null)
                 {
                     continue;
@@ -66,8 +66,7 @@
             right.AncestorModify = 0;
             for (int i = 0; tLeft != null && tRight != null; ++i)
             {
-                double tGap = (tRight.Prelim + tRight.AncestorModify) -
-                              (tLeft.Prelim + tLeft.AncestorModify);
+                double tGap = (tRight.Prelim + tRight.AncestorModify) - (tLeft.Prelim + tLeft.AncestorModify);
                 if (XGap + TreeNodeViewModel.Width - tGap > offset)
                 {
                     offset = XGap + TreeNodeViewModel.Width - tGap;
@@ -85,8 +84,8 @@
             {
                 for (int j = i + 1; j < treeNodeViewModel.Children.Count; ++j)
                 {
-                    var left = this.treeViewModel.Get(treeNodeViewModel.Children[i]);
-                    var right = this.treeViewModel.Get(treeNodeViewModel.Children[j]);
+                    TreeNodeViewModel left = this.treeViewModel.Get(treeNodeViewModel.Children[i]);
+                    TreeNodeViewModel right = this.treeViewModel.Get(treeNodeViewModel.Children[j]);
                     this.AjustSubTreeGap(left, right);
                 }
             }
@@ -170,8 +169,9 @@
             }
         }
 
-        public void ExcuteLayout(TreeNodeViewModel root)
+        public void ExcuteLayout()
         {
+            TreeNodeViewModel root = this.treeViewModel.Root;
             if (root == null)
             {
                 return;

+ 9 - 9
CSharp/App/Modules/BehaviorTreeModule/TreeViewModel.cs

@@ -33,7 +33,7 @@ namespace Modules.BehaviorTreeModule
             this.treeNodeDict[treeNodeViewModel.Id] = treeNodeViewModel;
 
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         public TreeViewModel(List<TreeNodeData> treeNodeDatas)
@@ -45,7 +45,7 @@ namespace Modules.BehaviorTreeModule
                 this.treeNodeDict[treeNodeViewModel.Id] = treeNodeViewModel;
             }
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         public List<TreeNodeData> GetDatas()
@@ -92,7 +92,7 @@ namespace Modules.BehaviorTreeModule
             }
 
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         private void GetChildrenIdAndSelf(TreeNodeViewModel treeNodeViewModel, List<int> children)
@@ -130,7 +130,7 @@ namespace Modules.BehaviorTreeModule
             }
 
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         private void RecursionMove(
@@ -180,7 +180,7 @@ namespace Modules.BehaviorTreeModule
             to.Children.Add(from.Id);
             from.Parent = to;
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         /// <summary>
@@ -201,7 +201,7 @@ namespace Modules.BehaviorTreeModule
             treeNodeViewModel.IsFold = true;
 
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         /// <summary>
@@ -222,7 +222,7 @@ namespace Modules.BehaviorTreeModule
             }
 
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         public void MoveLeft(TreeNodeViewModel treeNodeViewModel)
@@ -241,7 +241,7 @@ namespace Modules.BehaviorTreeModule
             parent.Children.Insert(index - 1, treeNodeViewModel.Id);
 
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
 
         public void MoveRight(TreeNodeViewModel treeNodeViewModel)
@@ -260,7 +260,7 @@ namespace Modules.BehaviorTreeModule
             parent.Children.Insert(index + 1, treeNodeViewModel.Id);
 
             var treeLayout = new TreeLayout(this);
-            treeLayout.ExcuteLayout(this.Root);
+            treeLayout.ExcuteLayout();
         }
     }
 }