private void recursiveModel(Project project, NormalTable normal, core.Table currentTable, core.Key parentKey, string name, ICollection <TreeNode> children) { core.Key tableKey; if (parentKey == null) { tableKey = new core.Key(name); } else { tableKey = new core.Key(name, parentKey); } TreeNode node = new TreeNode(tableKey, currentTable); children.Add(node); if (currentTable.HasReference(name)) { string refName = currentTable.GetReference(name); core.Table refTable = project.GetTable(refName); foreach ((string namesub, double weight) in refTable) { recursiveModel(project, normal, refTable, tableKey, namesub, node.Children()); } } }
private void displayTreeModel(core.Table table, NormalTable normal, ICollection <TreeNode> nodes) { projectTree.Items.Clear(); foreach (TreeNode child in nodes) { TreeViewItem viewChild = displayTreeModelRecursive(project, normal, child); projectTree.Items.Add(viewChild); } }
private void modelTree(Project project, core.Table table, NormalTable normal) { clearModel(); ICollection <TreeNode> convert = viewModel; foreach ((string name, _) in table) { recursiveModel(project, normal, table, null, name, convert); } }
private TreeViewItem displayTreeModelRecursive(Project project, NormalTable normal, TreeNode node) { TreeViewItem item = createTreeViewItem(node.Name, node.GetRawWeight(), node.GetNormalWeight(normal), node); foreach (TreeNode child in node) { TreeViewItem viewChild = displayTreeModelRecursive(project, normal, child); item.Items.Add(viewChild); } return(item); }
protected void SetTableRaw(core.Table table) { if (selected == null) { clearModel(); } else { NormalTable tabe = selected.Normalize(project); modelTree(project, selected, tabe); displayTreeModel(selected, tabe, viewModel); } }
public void TestMethod1() { Project project = new Project(); Table pj = new Table("test"); pj.AddKey("one", 1.0); pj.AddKey("two", 1.0); pj.AddKey("three", 1.0); pj.AddKey("four", 1.0); NormalTable normal = pj.Normalize(project); double expected = 0.25; double actual = normal[new Key("one")]; Assert.IsTrue(floatEqual(expected, actual), $"Acual is {normal[new Key("one")]}"); }
public void TestTableReferences() { Project project = new Project(); Table pj = new Table("dtest111"); pj.AddKey("one", 1.0); pj.AddKey("two", 1.0); pj.AddKey("three", 1.0); pj.AddKey("four", 1.0); Table pj2 = new Table("test2"); pj2.AddKey("apple", 1.0); pj2.AddKey("orange", 1.0); pj2.AddKey("banana", 1.0); pj2.AddKey("peach", 1.0); project.RegisterTable(pj); project.RegisterTable(pj2); pj.AddReference("one", "test2"); NormalTable normal = pj.Normalize(project); Key key = new Key("apple", new Key("one")); Key keyOne = new Key("one"); Key keyApple = new Key("apple"); Assert.IsTrue(normal.HasKey(keyOne), $"{keyOne.FullName} is not present"); Assert.IsFalse(normal.HasKey(keyApple), $"{keyApple.FullName} is present"); Assert.IsTrue(normal.HasKey(key), $"{key.FullName} is not present"); double expected = 0.25 * 0.25; double actual = normal[key]; Assert.IsTrue(floatEqual(expected, actual), $"Acual is {actual} Expected is {expected}"); }
public double GetNormalWeight(NormalTable table) { return(table[TableKey]); }