ModeCheckBase.cs 4.4 KB

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