protected void CreatePropertyGrid() { propertyGridScrollViewer = new PropertyGridHost(); // Grid st = new Grid(); st.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); st.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); st.RowDefinitions.Add(new RowDefinition()); st.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; st.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; PropertyGrid = new PropertyGrid(); MEFHost.Instance.SatisfyImportsOnce(PropertyGrid); TitleLabel title = new TitleLabel() { Text = "Properties", //FontSize = 12, //FontWeight = FontWeights.Bold, //Background = Brushes.White, Foreground = Brushes.White, Margin = new Thickness(5, 2, 5, 2), }; FigureItems = new ComboBox(); FigureItems.ItemsSource = null; List <IFigure> figureIncludes = new List <IFigure>(); if (CurrentDrawing != null) { if (CurrentDrawing.Figures != null) { foreach (IFigure f in CurrentDrawing.Figures) { if (!(f is IPoint)) { figureIncludes.Add(f); } } } } FigureItems.ItemsSource = figureIncludes; FigureItems.SelectionChanged += FigureItems_SelectionChanged; pg = new PropertyGrid() { VerticalAlignment = System.Windows.VerticalAlignment.Stretch, }; //pg.MinWidth = 200; //pg.Background = Brushes.Red; st.Children.Add(title); //st.Children.Add(FigureItems); st.Children.Add(pg); // Grid.SetRow(title, 0); Grid.SetRow(FigureItems, 1); Grid.SetRow(pg, 2); propertyGridScrollViewer.Children.Add(st); PropertyGrid.VisibilityChanged += PropertyGrid_VisibilityChanged; Canvas.SetZIndex(propertyGridScrollViewer, (int)ZOrder.StatusBar); PropertyGrid.ValueDiscoveryStrategy = new ExcludeByDefaultValueDiscoveryStrategy(); propertyGridScrollViewer.Visibility = Visibility.Hidden; }
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; }