ModeCheckBase.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* ==============================================================================
  2. * 功能描述:CheckBase
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/10/23 15:50:19
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using Autodesk.Revit.DB;
  10. using NPOI.SS.UserModel;
  11. using SAGA.DotNetUtils.Others;
  12. namespace Saga.PlugIn.ModelCheck
  13. {
  14. /// <summary>
  15. /// CheckBase
  16. /// </summary>
  17. public class ModeCheckBase:ICheckBase,INotifyPropertyChanged
  18. {
  19. public string Name { get; set; }
  20. protected Document m_Document { get; set; }
  21. private List<ModeCheckResultBase> results = new List<ModeCheckResultBase>();
  22. internal List<ModeCheckResultBase> Results { get => results; set => results = value; }
  23. public void Check2(Document doc)
  24. {
  25. m_Document = doc;
  26. ModelCheckState = ModelCheckState.Ending;
  27. if (!RIsChecked) return;
  28. Check();
  29. }
  30. public virtual bool Check()
  31. {
  32. throw new NotImplementedException();
  33. }
  34. public virtual void Export()
  35. {
  36. throw new NotImplementedException();
  37. }
  38. #region 检查结果
  39. protected ModeCheckBase RBase { get; set; }
  40. public void SetBaseCheck(ModeCheckBase checkBase)
  41. {
  42. RBase = checkBase;
  43. }
  44. /// <summary>
  45. /// 是否通过较验
  46. /// </summary>
  47. public bool IsRight { get; set; }
  48. /// <summary>
  49. /// 提示信息
  50. /// </summary>
  51. public string RMessage { get; set; }
  52. /// <summary>
  53. /// 设置表可见性
  54. /// </summary>
  55. public bool SetSheetVisible()
  56. {
  57. bool result = RIsChecked;
  58. //if (result)
  59. // result = !(results.All(t => t.IsRight));
  60. //如果有没有通过的项
  61. if (!result)
  62. {
  63. try
  64. {
  65. IWorkbook book = DCRExport.GetWorkbook();
  66. int index = book.GetSheetIndex(Name);
  67. //隐藏
  68. book.SetSheetHidden(index, SheetState.VeryHidden);
  69. //关联项隐藏
  70. foreach (var str in RSPecificationSheet) {
  71. int i = book.GetSheetIndex(str);
  72. //隐藏
  73. book.SetSheetHidden(i, SheetState.VeryHidden);
  74. }
  75. }
  76. catch (Exception e)
  77. {
  78. MessageShowBase.Show(e);
  79. }
  80. }
  81. return result;
  82. }
  83. /// <summary>
  84. /// 保存并隐藏全部通过的sheet
  85. /// </summary>
  86. public void Export2()
  87. {
  88. Export();
  89. SetSheetVisible();
  90. }
  91. #endregion
  92. #region 样式控制
  93. private ModelCheckState m_ModelCheckState=ModelCheckState.Prepare;
  94. public ModelCheckState ModelCheckState
  95. {
  96. get { return m_ModelCheckState; }
  97. set
  98. {
  99. m_ModelCheckState = value;
  100. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ModelCheckState)));
  101. }
  102. }
  103. private bool m_RIsChecked;
  104. /// <summary>
  105. /// 是否选中
  106. /// </summary>
  107. public bool RIsChecked
  108. {
  109. get { return m_RIsChecked;}
  110. set
  111. {
  112. m_RIsChecked = value;
  113. PropertyChanged?.Invoke(this,new PropertyChangedEventArgs(nameof(RIsChecked)));
  114. } }
  115. private List<string> m_SpecificationSheet=new List<string>();
  116. public event PropertyChangedEventHandler PropertyChanged;
  117. /// <summary>
  118. /// 关联规范项
  119. /// </summary>
  120. public List<string> RSPecificationSheet
  121. {
  122. get { return m_SpecificationSheet; }
  123. set { m_SpecificationSheet = value; }
  124. }
  125. #endregion
  126. }
  127. }