/* ============================================================================== * 功能描述:CheckBase * 创 建 者:Garrett * 创建日期:2018/10/23 15:50:19 * ==============================================================================*/ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using Autodesk.Revit.DB; using NPOI.SS.UserModel; using SAGA.DotNetUtils.Others; namespace Saga.PlugIn.ModelCheck { /// /// CheckBase /// public class ModeCheckBase : ICheckBase, INotifyPropertyChanged { public string Name { get; set; } protected Document m_Document { get; set; } private ObservableCollection results = new ObservableCollection(); public ObservableCollection Results { get { return results; } set { results = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Results))); } } public void Check2(Document doc) { m_Document = doc; ModelCheckState = ModelCheckState.Ending; if (!RIsChecked) return; Check(); //刷新界面 Results = Results; } public virtual bool Check() { throw new NotImplementedException(); } public virtual void Export() { throw new NotImplementedException(); } #region 检查结果 protected ModeCheckBase RBase { get; set; } public void SetBaseCheck(ModeCheckBase checkBase) { RBase = checkBase; } /// /// 是否通过较验 /// public bool IsRight { get; set; } /// /// 提示信息 /// public string RMessage { get; set; } /// /// 设置表可见性 /// public bool SetSheetVisible() { bool result = RIsChecked; //if (result) // result = !(results.All(t => t.IsRight)); //如果有没有通过的项 if (!result) { try { IWorkbook book = DCRExport.GetWorkbook(); int index = book.GetSheetIndex(Name); //隐藏 book.SetSheetHidden(index, SheetState.VeryHidden); //关联项隐藏 foreach (var str in RSPecificationSheet) { int i = book.GetSheetIndex(str); //隐藏 book.SetSheetHidden(i, SheetState.VeryHidden); } } catch (Exception e) { MessageShowBase.Show(e); } } return result; } /// /// 保存并隐藏全部通过的sheet /// public void Export2() { Export(); SetSheetVisible(); } #endregion #region 样式控制 private ModelCheckState m_ModelCheckState = ModelCheckState.Prepare; public ModelCheckState ModelCheckState { get { return m_ModelCheckState; } set { m_ModelCheckState = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ModelCheckState))); } } private bool m_RIsChecked; /// /// 是否选中 /// public bool RIsChecked { get { return m_RIsChecked; } set { m_RIsChecked = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(RIsChecked))); } } private List m_SpecificationSheet = new List(); public event PropertyChangedEventHandler PropertyChanged; /// /// 关联规范项 /// public List RSPecificationSheet { get { return m_SpecificationSheet; } set { m_SpecificationSheet = value; } } #endregion } }