Преглед изворни кода

mxg:修改/模型数据检查弹窗调整(见原型)

mengxiangge пре 6 година
родитељ
комит
b593d41f5c

+ 1 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/FloorMissCheck.cs

@@ -35,6 +35,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         public FloorMiss()
         {
             Name = "楼层缺失检查";
+            RIsNeedTwoMoreFloors = true;
         }
         [DataCheckProcessAspect]
         public override bool Check()

+ 1 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/FloorSequenceCheck.cs

@@ -33,6 +33,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         public FloorSequenceCheck()
         {
             Name = "楼层标高与楼层顺序号检查";
+            RIsNeedTwoMoreFloors = true;
         }
         [DataCheckProcessAspect]
         public override bool Check()

+ 1 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/GridCheck.cs

@@ -25,6 +25,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
         public GridCheck()
         {
             Name = "轴网检查";
+            RIsNeedTwoMoreFloors = true;
         }
         [DataCheckProcessAspect]
         public override bool Check()

+ 4 - 0
MBI/SAGA.MBI/ToolsData/ModeCheck/ModeCheckBase.cs

@@ -127,6 +127,10 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             get { return m_SpecificationSheet; }
             set { m_SpecificationSheet = value; }
         }
+        /// <summary>
+        /// 两层以上楼层检查才有意义
+        /// </summary>
+        public bool RIsNeedTwoMoreFloors { get; set; }
 
         #endregion
     }

+ 3 - 2
MBI/SAGA.MBI/ToolsData/ModeCheck/WinModeCheckSetting.xaml

@@ -43,7 +43,7 @@
                                 <WrapPanel>
                                     <CheckBox IsChecked="{Binding Path=IsSelected,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                                               Width="Auto" VerticalContentAlignment="Center" 
-                                              Click="TreeItemChecked_OnChecked">
+                                              Click="TreeItem_Click">
                                     </CheckBox>
                                     <Label Content="{Binding Path=Item.TvItemName}"></Label>
                                 </WrapPanel>
@@ -66,7 +66,8 @@
                                 <WrapPanel  >
                                     <CheckBox IsChecked="{Binding Path=RIsChecked,UpdateSourceTrigger=PropertyChanged}" 
                                       IsEnabled="{Binding Path=RIsReadOnly,Converter={StaticResource BoolInverseConverter}}"
-                                      VerticalContentAlignment="Center"></CheckBox>
+                                      VerticalContentAlignment="Center"
+                                              Click="CheckItem_Click"></CheckBox>
                                     <Label Content="{Binding Path=Name}"></Label>
                                 </WrapPanel>
                             </DataTemplate>

+ 50 - 12
MBI/SAGA.MBI/ToolsData/ModeCheck/WinModeCheckSetting.xaml.cs

@@ -28,14 +28,14 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             myListbox.ItemsSource = checkItems;
             Init();
             this.DataContext = this;
-            
+
         }
 
         private void Init()
         {
             ProjectList = MBIControl.ProjectTree.Children;
             if (ProjectList.FirstOrDefault() != null)
-                SetTreeState(ProjectList.FirstOrDefault(), true);
+                SetTreeItemState(ProjectList.FirstOrDefault(), true);
             SavePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
                 $"{MBIControl.ProjectCur}{m_CheckType.GetDescription()}检查结果.xlsx");
             OFImage = CommonTool.GetBtnImagePath(SavePath);
@@ -105,7 +105,7 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             {
                 MessageBox.Show("请选择需要检查的建筑");
                 if (ProjectList.FirstOrDefault() != null)
-                    SetTreeState(ProjectList.FirstOrDefault(), true);
+                    SetTreeItemState(ProjectList.FirstOrDefault(), true);
             }
             else
             {
@@ -135,27 +135,46 @@ namespace SAGA.MBI.ToolsData.ModeCheck
             return context;
         }
 
-        private void TreeItemChecked_OnChecked(object sender, RoutedEventArgs e)
+        private void TreeItem_Click(object sender, RoutedEventArgs e)
         {
             if (sender is CheckBox chk)
             {
                 bool state = chk.IsChecked == true;
                 if (chk.DataContext is TreeNodeItem node)
                 {
-                    //SetTreeState(node, state);
-                    SetChildrenState(node, state);
-                    SetParentState(node, state);
+                    SetTreeItemState(node, state);
                 }
             }
         }
-
-        private void SetTreeState(TreeNodeItem node, bool state)
+        /// <summary>
+        /// 设置节点状态
+        /// </summary>
+        /// <param name="node"></param>
+        /// <param name="state"></param>
+        private void SetTreeItemState(TreeNodeItem node, bool state)
         {
             node.IsSelected = state;
             SetChildrenState(node, state);
             SetParentState(node, state);
+            CheckCheckItem();
         }
-
+        /// <summary>
+        /// 获取检查项的默认选状态
+        /// </summary>
+        private void CheckCheckItem()
+        {
+            var floors = DalProjectTree.GetSelectedFloors();
+            if (floors.Count <= 1)
+            {
+                var checkItems = myListbox.ItemsSource as List<ICheckBase>;
+                checkItems?.ForEach(t => { if (t is ModeCheckBase mbase) if (mbase.RIsNeedTwoMoreFloors) t.RIsChecked = false; });
+            }
+        }
+        /// <summary>
+        /// 设置子节点状态
+        /// </summary>
+        /// <param name="node"></param>
+        /// <param name="state"></param>
         private void SetChildrenState(TreeNodeItem node, bool state)
         {
             foreach (TreeNodeItem child in node.Children)
@@ -163,7 +182,11 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                 child.IsSelected = state;
             }
         }
-
+        /// <summary>
+        /// 设置父节点状态
+        /// </summary>
+        /// <param name="node"></param>
+        /// <param name="state"></param>
         private void SetParentState(TreeNodeItem node, bool state)
         {
             if (node.Parent != null)
@@ -182,11 +205,26 @@ namespace SAGA.MBI.ToolsData.ModeCheck
                         }
                     }
                 }
-                node.Parent.IsSelected = node.Parent.Children.Any(t=>t.IsSelected);
+                node.Parent.IsSelected = node.Parent.Children.Any(t => t.IsSelected);
                 SetParentState(node.Parent, state);
             }
 
         }
+
+        private void CheckItem_Click(object sender, RoutedEventArgs e)
+        {
+            if (sender is CheckBox chk)
+            {
+                if (chk.IsChecked == true)
+                {
+                    var checkItem = chk.DataContext as ModeCheckBase;
+                    if (checkItem.RIsNeedTwoMoreFloors)
+                    {
+                        MessageBox.Show("请选择两个及以上楼层再检查此项");
+                    }
+                }
+            }
+        }
     }
 }