public void NewProject() { //Drawing DrawingHost = new DynamicGeometry.DrawingHost(); DrawingHost.Ribbon.Visibility = System.Windows.Visibility.Collapsed; // Add Behaviors var behaviors = Behavior.LoadBehaviors(typeof(Dragger).Assembly); Behavior.Default = behaviors.First(b => b is Dragger); foreach (var behavior in behaviors) { DrawingHost.AddToolButton(behavior); } var firstDocumentPane = dockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault(); if (firstDocumentPane != null) { LayoutDocument doc = new LayoutDocument(); doc.Title = "Drawing" + drawingCount; drawingCount++; doc.Content = DrawingHost; firstDocumentPane.Children.Add(doc); } //Project Explorer var projectExplorer = dockManager.Layout.Descendents().OfType <LayoutAnchorablePane>().LastOrDefault(); var rightAnchorgroup = dockManager.Layout.Descendents().OfType <LayoutAnchorablePaneGroup>().FirstOrDefault(); if (projectExplorer != null) { // Tạo 2 LayoutAnchorablePane LayoutAnchorablePane l1 = new LayoutAnchorablePane(); LayoutAnchorablePane l2 = new LayoutAnchorablePane(); LayoutAnchorable doc = new LayoutAnchorable(); ICSharpCode.TreeView.SharpTreeView projectTree = new ICSharpCode.TreeView.SharpTreeView() { AllowDrop = true, AllowDropOrder = true }; ICSharpCode.ILSpy.ContextMenuProvider.Add(projectTree); //App.CompositionContainer.ComposeParts(this); projectTree.SelectionChanged += projectTree_SelectionChanged; projectTree.MouseDoubleClick += projectTree_MouseDoubleClick; // Dữ liệu ban đầu BridgesList brl = new BridgesList() { Name = "Bridges List" }; BridgeProject.Items.Bridge br = new BridgeProject.Items.Bridge() { Name = "Bridge 1" }; //Substructures sub1 = new Substructures(); //br.Substructures = sub1; BridgeProject.Items.Bridge br2 = new BridgeProject.Items.Bridge() { Name = "Bridge 2" }; brl.Children.Add(br, br2); BridgeListNode n = new BridgeListNode(brl); foreach (Bridge b in brl.Children) { BridgeNode n1 = new BridgeNode(b) { Text = b.Name }; n.Children.Add(n1); SubstructuresNode subNode = new SubstructuresNode(b.Substructures); n1.Children.Add(subNode); AbutmentsListNode abutsNode = new AbutmentsListNode(b.Substructures.Abutments); subNode.Children.Add(abutsNode); PiersListNode piersNode = new PiersListNode(b.Substructures.Piers); subNode.Children.Add(piersNode); foreach (Abutment a in b.Substructures.Abutments.Children) { AbutmentNode abn = new AbutmentNode(a); abutsNode.Children.Add(abn); } foreach (Pier p in b.Substructures.Piers.Children) { PierNode abn = new PierNode(p); piersNode.Children.Add(abn); } } projectTree.Root = n; // doc.Content = projectTree; doc.Title = "Project Explorer"; doc.ContentId = "projectExplorer"; l1.Children.Add(doc); // PropertyGrid PropertyGridHost = new DynamicGeometry.PropertyGridHost(); PropertyGrid = new ChristianMoser.WpfInspector.UserInterface.Controls.PropertyGrid() { VerticalAlignment = System.Windows.VerticalAlignment.Stretch, ShowMethod = true, }; PropertyGridHost.Children.Add(PropertyGrid); LayoutAnchorable prop = new LayoutAnchorable(); prop.Content = PropertyGridHost; prop.ContentId = "propertyGrid"; prop.Title = "Properties"; l2.Children.Add(prop); rightAnchorgroup.Children.Add(l1); rightAnchorgroup.Children.Add(l2); // //var pe = dockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == "projectExplorer"); //var tree = pe.Content as BridgeFS.Controls.Project; //if (tree != null) //{ // //MessageBox.Show(tree.TreeView.ToString() + "xx"); // Binding b = new Binding(); // b.Source = tree.TreeView; // //b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; // b.Path = new PropertyPath(TreeViewItemChangedMvvm.ViewModelUtils.TreeViewHelper.SelectedItemProperty); // this.PropertyGrid.SetBinding(ChristianMoser.WpfInspector.UserInterface.Controls.PropertyGrid.SelectedObjectProperty, b); //} } dockManager.UpdateLayout(); //MainToolbar.Drawing = DrawingHost.CurrentDrawing; //DrawingHost.CurrentDrawing.SelectionChanged += CurrentDrawing_SelectionChanged; dockManager.ActiveContentChanged += dockManager_ActiveContentChanged; }
public BridgeListNode(BridgesList l) { BrigesList = l; DataObject = l; }