!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Tools / LuaRemoteDebugger / Aga.Controls / Tree / SortedTreeModel.cs
blob99bf246c16d408da12fc6602347fa674566582cf
1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
3 using System;
4 using System.Collections.Generic;
5 using System.Text;
6 using System.Collections;
8 namespace Aga.Controls.Tree
10 public class SortedTreeModel: TreeModelBase
12 private ITreeModel _innerModel;
13 public ITreeModel InnerModel
15 get { return _innerModel; }
18 private IComparer _comparer;
19 public IComparer Comparer
21 get { return _comparer; }
22 set
24 _comparer = value;
25 OnStructureChanged(new TreePathEventArgs(TreePath.Empty));
29 public SortedTreeModel(ITreeModel innerModel)
31 _innerModel = innerModel;
32 _innerModel.NodesChanged += new EventHandler<TreeModelEventArgs>(_innerModel_NodesChanged);
33 _innerModel.NodesInserted += new EventHandler<TreeModelEventArgs>(_innerModel_NodesInserted);
34 _innerModel.NodesRemoved += new EventHandler<TreeModelEventArgs>(_innerModel_NodesRemoved);
35 _innerModel.StructureChanged += new EventHandler<TreePathEventArgs>(_innerModel_StructureChanged);
38 void _innerModel_StructureChanged(object sender, TreePathEventArgs e)
40 OnStructureChanged(e);
43 void _innerModel_NodesRemoved(object sender, TreeModelEventArgs e)
45 OnStructureChanged(new TreePathEventArgs(e.Path));
48 void _innerModel_NodesInserted(object sender, TreeModelEventArgs e)
50 OnStructureChanged(new TreePathEventArgs(e.Path));
53 void _innerModel_NodesChanged(object sender, TreeModelEventArgs e)
55 OnStructureChanged(new TreePathEventArgs(e.Path));
58 public override IEnumerable GetChildren(TreePath treePath)
60 if (Comparer != null)
62 ArrayList list = new ArrayList();
63 IEnumerable res = InnerModel.GetChildren(treePath);
64 if (res != null)
66 foreach (object obj in res)
67 list.Add(obj);
68 list.Sort(Comparer);
69 return list;
71 else
72 return null;
74 else
75 return InnerModel.GetChildren(treePath);
78 public override bool IsLeaf(TreePath treePath)
80 return InnerModel.IsLeaf(treePath);