/// <summary>Clear the editor's model.</summary> private void ClearModel() { if (ModelRoot != null) { ModelRoot.TreeStructureChanged -= Model_TreeStructureChanged; } ModelRoot = null; ElementGraphArea.Clear(); }
/// <summary>Assign <paramref name="elementBuilderTree"/> as the model for this editor.</summary> private void SetModel(IElementTreeNode elementBuilderTree) { ClearModel(); ModelRoot = elementBuilderTree.Root; ElementBuilderGraph graph = ElementBuilderGraph.Of(elementBuilderTree); ElementGraphArea.LogicCore = new ElementBuilderLogicCore(graph); ElementGraphArea.GenerateGraph(true, true); ElementDescription.DataContext = this; Properties.DataContext = this; XmlLabel.DataContext = this; // I think the animation looks cool when we put a new tree in the GraphArea, but we don't want to trigger that animation every time the selected vertex changes. ZoomCtrl.IsAnimationEnabled = true; ZoomCtrl.ZoomToFill(); ZoomCtrl.IsAnimationEnabled = false; ModelRoot.TreeStructureChanged += Model_TreeStructureChanged; }