| | |
| | | using HStation.RevitDev.RevitDataExport.Service;
|
| | | using HStation.RevitDev.RevitDataExport.Utility;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using System.Windows;
|
| | | using System.Windows.Controls;
|
| | |
| | | /// <summary>
|
| | | /// WPF_FamilyPanel.xaml 的交互逻辑
|
| | | /// </summary>
|
| | | public partial class Wpf_InstancePanel : UserControl, IDockablePaneProvider
|
| | | public partial class Wpf_InstancePanel : Page, IDockablePaneProvider
|
| | | {
|
| | | public Wpf_InstancePanel()
|
| | | {
|
| | | InitializeComponent();
|
| | | InitializeControls();
|
| | | InitializeControlsData();
|
| | | }
|
| | |
|
| | | private void InitializeControls()
|
| | | private void InitializeControlsData()
|
| | | {
|
| | | var values = Enum.GetValues(typeof(RevitType));
|
| | | this.tabControl.Items.Clear();
|
| | |
| | | private DataGrid CreateDataGrid(RevitType revitType)
|
| | | {
|
| | | var dataGrid = new DataGrid();
|
| | | dataGrid.RowHeight = 20;
|
| | | dataGrid.IsReadOnly = true;
|
| | | dataGrid.LoadingRow += DataGrid_LoadingRow;
|
| | | dataGrid.SelectionUnit = DataGridSelectionUnit.Cell;
|
| | |
| | | try
|
| | | {
|
| | | DataGrid dataGrid = sender as DataGrid;
|
| | | var selectItem = dataGrid.SelectedCells;
|
| | | var selectCell = selectItem[0];
|
| | | var columnIndex = selectCell.Column.DisplayIndex;
|
| | | if (columnIndex == 0)
|
| | | var selectCells = dataGrid.SelectedCells;
|
| | | if (selectCells.Count == 0) { return; }
|
| | |
|
| | | var selectCell = selectCells[0];
|
| | | if (selectCell.Column.Header.ToString() == "编号")
|
| | | {
|
| | | ShowElement(selectCell);
|
| | | string id = (selectCell.Item as ElementModel).编号;
|
| | | UIDocumentUtils.ShowElement(id);
|
| | | }
|
| | | else if (columnIndex == 2)
|
| | | else if (selectCell.Column.Header.ToString() == "连接构件")
|
| | | {
|
| | | ShowLinkedElements(selectCell);
|
| | | string ids = (selectCell.Item as ElementModel).连接构件;
|
| | | UIDocumentUtils.ShowLinkedElements(ids);
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | TaskDialog.Show("错误", ex.Message);
|
| | | }
|
| | | }
|
| | |
|
| | | private void ShowLinkedElements(DataGridCellInfo selectCell)
|
| | | {
|
| | | string ids = (selectCell.Item as ElementModel).LinkIds;
|
| | | if (string.IsNullOrEmpty(ids))
|
| | | {
|
| | | return;
|
| | | }
|
| | | var idArray = ids.Split(',');
|
| | | var idList = idArray.Select(x => new ElementId(int.Parse(x)))?.ToList();
|
| | | GlobalResource.CurrentUIDocument.Selection.SetElementIds(idList);
|
| | | GlobalResource.CurrentUIDocument.ShowElements(idList);
|
| | | }
|
| | |
|
| | | private void ShowElement(DataGridCellInfo selectCell)
|
| | | {
|
| | | string id = (selectCell.Item as ElementModel).Id;
|
| | | if (string.IsNullOrEmpty(id))
|
| | | {
|
| | | return;
|
| | | }
|
| | | var elemId = new ElementId(int.Parse(id));
|
| | | GlobalResource.CurrentUIDocument.Selection.SetElementIds(
|
| | | new List<ElementId> { elemId });
|
| | | GlobalResource.CurrentUIDocument.ShowElements(elemId);
|
| | | }
|
| | |
|
| | | private void DataGrid_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
| | |
| | | DataGrid dataGrid = sender as DataGrid;
|
| | | var selectCells = dataGrid.SelectedCells;
|
| | |
|
| | | string ids = (selectCells[0].Item as ElementModel).LinkIds;
|
| | | string ids = (selectCells[0].Item as ElementModel).连接构件;
|
| | | var idArray = ids.Split(',');
|
| | | var idList = idArray.Select(x => new ElementId(int.Parse(x)))?.ToList();
|
| | | GlobalResource.CurrentUIDocument.Selection.SetElementIds(idList);
|
| | |
| | | private void CreateRows(DataGrid dataGrid, RevitType revitType)
|
| | | {
|
| | | var models = RevitMepElementService.GetElementModels(revitType);
|
| | | dataGrid.ItemsSource = models;
|
| | | WpfBindingUtils.Binding2(dataGrid, revitType, models);
|
| | | //WpfBindingUtils.Binding(dataGrid, revitType, models);
|
| | | }
|
| | |
|
| | | public void SetupDockablePane(DockablePaneProviderData data)
|
| | | {
|
| | | data.FrameworkElement = this;
|
| | | DockablePaneState state = new DockablePaneState();
|
| | | state.DockPosition = DockPosition.Bottom;
|
| | | state.MinimumWidth = GlobalResource.ThumbnailSize;
|
| | | state.MinimumHeight = GlobalResource.ThumbnailSize;
|
| | | data.InitialState = state;
|
| | | data.InitialState = new DockablePaneState
|
| | | {
|
| | | DockPosition = DockPosition.Bottom,
|
| | | MinimumHeight = 200
|
| | | };
|
| | | }
|
| | |
|
| | | private void reflesh_Click(object sender, RoutedEventArgs e)
|
| | |
| | |
|
| | | public void UpdateForm()
|
| | | {
|
| | | InitializeControls();
|
| | | InitializeControlsData();
|
| | | }
|
| | | }
|
| | | }
|