123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- /* ==============================================================================
- * 功能描述:VMCreateFacility
- * 创 建 者:Garrett
- * 创建日期:2019/10/23 9:46:45
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using Autodesk.Revit.DB;
- using Saga.PlugIn.ModelCheck;
- using SAGA.DotNetUtils.Others;
- using SAGA.DotNetUtils.WPF;
- namespace Saga.PlugIn.CreateFacility
- {
- /// <summary>
- /// VMCreateFacility
- /// </summary>
- public class VMCreateFacility:BaseViewModelStub
- {
- public VMCreateFacility(Document doc)
- {
- m_Document = doc;
- ModelFilePath = doc.PathName;
- }
- private Document m_Document;
- private string m_TabCode;
- /// <summary>
- /// 标记码
- /// </summary>
- public string TabCode
- {
- get { return m_TabCode; }
- set
- {
- m_TabCode = value;
- NotifyPropertyChanged("TabCode");
- MFacilityTabCode = ParseFacilityTabCode.Parse(value);
- }
- }
- private MFacilityTabCode m_MFacilityTabCode;
- public MFacilityTabCode MFacilityTabCode
- {
- get { return m_MFacilityTabCode; }
- set
- {
- m_MFacilityTabCode = value;
- FacilityLocated = $"{value?.BuildingName}-{value?.FloorName}";
- }
- }
- private string m_FacilityLocated;
- /// <summary>
- /// 设备所在位置
- /// </summary>
- public string FacilityLocated
- {
- get { return m_FacilityLocated; }
- set
- {
- m_FacilityLocated = value;
- NotifyPropertyChanged("FacilityLocated");
- }
- }
- private string m_ModelFilePath;
- /// <summary>
- /// 模型文件地址
- /// </summary>
- public string ModelFilePath
- {
- get { return m_ModelFilePath; }
- set
- {
- m_ModelFilePath = value;
- NotifyPropertyChanged("ModelFilePath");
- }
- }
- #region command
- [Command]
- public void PasteTabCode(object param)
- {
- IDataObject iData = Clipboard.GetDataObject();
- if (iData.GetDataPresent(DataFormats.Text))
- {
- TabCode = (String)iData.GetData(DataFormats.Text);
- }
- }
- public bool CanPasteTabCode(object param)
- {
- return true;
- }
- [Command]
- public void ClearTabCode(object param)
- {
- TabCode = null;
- }
- public bool CanClearTabCode(object param)
- {
- return true;
- }
- [Command]
- public void Execute(object param)
- {
- if (string.IsNullOrEmpty(MFacilityTabCode.Id))
- {
- MessageShowBase.Infomation("粘贴设备类数据异常,请检查");
- return;
- }
- //选择设备类
- var facilityCodes = MFacilityTabCode.EquipClasses;
- WinSelectDeviceClass win=new WinSelectDeviceClass(facilityCodes);
- if (facilityCodes.Count > 1)
- {
- if(win.ShowDialog()!=true)
- return;
- }
- var facilityClass = win.SelectedCode;
- if (facilityClass == null)
- {
- MessageShowBase.Infomation("粘贴设备类数据异常,请检查");
- return;
- }
- //判断是否存在
- var id = CreateFacilityRevitUtils.FindFacility(m_Document, facilityClass.code, MFacilityTabCode.Id);
- if (!string.IsNullOrEmpty(id))
- {
- WinTipExisted winTipExisted=new WinTipExisted(id);
- if (winTipExisted.ShowDialog() == true)
- TabCode = null;
- return;
- }
- //创建
- id = CreateFacilityRevitUtils.CreateFacility(m_Document, facilityClass, MFacilityTabCode.BIMLocation,
- MFacilityTabCode.Id);
- if (!string.IsNullOrEmpty(id))
- {
- CreateFacilityRevitUtils.FocusFacility(id);
- WinTipCreateSuccess winTipCreateSuccess = new WinTipCreateSuccess(id);
- winTipCreateSuccess.ShowDialog();
- }
- }
- public bool CanExecute(object param)
- {
- return MFacilityTabCode!=null;
- }
- #endregion
- }
- }
|