Browse Source

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

mengxiangge 5 years ago
parent
commit
911fb4c72d

+ 4 - 0
MBI/SAGA.DotNetUtils/SAGA.DotNetUtils.csproj

@@ -466,6 +466,10 @@
     <Compile Include="WPF\Converter\BoolToVisibilityConverter.cs" />
     <Compile Include="WPF\Converter\StringToImageConverter.cs" />
     <Compile Include="WPF\DataGridResource.cs" />
+    <Compile Include="WPF\Elements\AnnularElement.cs" />
+    <Compile Include="WPF\Elements\Element.cs" />
+    <Compile Include="WPF\Elements\ElementGeometryUtil.cs" />
+    <Compile Include="WPF\Elements\SpaceElement.cs" />
     <Compile Include="WPF\Extend\UIElementExtensions.cs" />
     <Compile Include="WPF\MVVM\BaseCommand.cs" />
     <Compile Include="WPF\MVVM\BasePropertyChanged.cs" />

+ 53 - 0
MBI/SAGA.DotNetUtils/WPF/Elements/AnnularElement.cs

@@ -0,0 +1,53 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:AnnularElement
+ * 作者:xulisong
+ * 创建时间: 2019/5/8 16:59:47
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Shapes;
+
+namespace SAGA.DotNetUtils.WPF
+{
+    public class AnnularElement: TElement
+    {
+        public AnnularElement(List<Point> outPoints)
+        {
+            if (outPoints.Count < 3)
+            {
+                throw new ArgumentNullException(nameof(outPoints));
+            }
+
+            OutPolygon = new PointCollection(outPoints);
+            InPolygons = new ObservableCollection<PointCollection>();
+            
+        }
+        public PointCollection OutPolygon { get; private set; }
+        public ObservableCollection<PointCollection> InPolygons
+        {
+            get;private set;
+        }
+
+        protected override System.Windows.Media.Geometry GetDefiningGeometry()
+        {
+            GeometryGroup group = new GeometryGroup();
+            PathGeometry geometry = ElementGeometryUtil.GetGeometry(OutPolygon);
+            group.Children.Add(geometry);
+            foreach (var  inPolygon in InPolygons)
+            {
+                group.Children.Add(ElementGeometryUtil.GetGeometry(inPolygon));
+            }
+            return group;
+        }
+
+     
+    }
+}

+ 66 - 0
MBI/SAGA.DotNetUtils/WPF/Elements/Element.cs

@@ -0,0 +1,66 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:Element
+ * 作者:xulisong
+ * 创建时间: 2019/5/8 15:29:43
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Shapes;
+
+namespace SAGA.DotNetUtils.WPF
+{
+    public class TElement : Shape
+    {
+        public TElement()
+        {
+            //ElementSelected.SetCanSelected(this, true);
+            //var beheaviors = Interaction.GetBehaviors(this);
+            //beheaviors.Add(new SelectedBehavior());
+            //this.SetValue(Interaction.beh)
+            //this.InheritanceBehavior
+        }
+        /// <summary>
+        /// 当前元素的id
+        /// </summary>
+        public int Id { get; internal set; }
+        protected override System.Windows.Media.Geometry DefiningGeometry
+        {
+            get { return GetDefiningGeometry(); }
+        }
+
+        protected virtual System.Windows.Media.Geometry GetDefiningGeometry()
+        {
+            return null;
+        }
+
+        protected override void OnRender(DrawingContext drawingContext)
+        {
+
+            drawingContext.DrawGeometry(this.Fill, new Pen(this.Stroke, this.StrokeThickness), this.DefiningGeometry);
+            //base.OnRender(drawingContext);
+        }
+        protected override void OnMouseEnter(MouseEventArgs e)
+        {
+            base.OnMouseEnter(e);
+            //ElementSelected.SetIsMouseOver(this, true);
+        }
+        protected override void OnMouseLeave(MouseEventArgs e)
+        {
+            base.OnMouseLeave(e);
+            //ElementSelected.SetIsMouseOver(this, false);
+        }
+        protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
+        {
+            base.OnPreviewMouseLeftButtonUp(e);
+            //ElementSelected.SetIsSelected(this, !ElementSelected.GetIsSelected(this));
+        }
+       
+    }
+}

+ 34 - 0
MBI/SAGA.DotNetUtils/WPF/Elements/ElementGeometryUtil.cs

@@ -0,0 +1,34 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:ElementGeometryUtils
+ * 作者:xulisong
+ * 创建时间: 2019/5/8 17:41:29
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+
+namespace SAGA.DotNetUtils.WPF
+{
+    public static class ElementGeometryUtil
+    {
+        public static PathGeometry GetGeometry(IList<Point> points)
+        {
+            PathGeometry geometry = new PathGeometry();
+            PathFigure figure = new PathFigure();
+            figure.StartPoint = points[0];
+            var usePoints = points.ToList().GetRange(1, points.Count - 1);
+            usePoints.Add(points[0]);
+            figure.Segments = new PathSegmentCollection();
+            //参数的true或false,会影响边框是否显示
+            figure.Segments.Add(new PolyLineSegment(usePoints, true));
+            geometry.Figures.Add(figure);
+            return geometry;
+        }
+    }
+}

+ 24 - 0
MBI/SAGA.DotNetUtils/WPF/Elements/SpaceElement.cs

@@ -0,0 +1,24 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:SpaceElement
+ * 作者:xulisong
+ * 创建时间: 2019/8/8 10:17:18
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SAGA.DotNetUtils.WPF
+{
+    public class SpaceElement: AnnularElement
+    {
+        public SpaceElement(List<Point> outPoints):base(outPoints)
+        {
+
+        }
+    }
+}

+ 69 - 0
MBI/SAGA.MBI/Common/TryCatchWrapper.cs

@@ -0,0 +1,69 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:TryCatchWrapper
+ * 作者:xulisong
+ * 创建时间: 2019/8/12 11:09:47
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SAGA.RevitUtils;
+namespace SAGA.MBI.Common
+{
+    /// <summary>
+    /// 捕获异常包裹器
+    /// </summary>
+    public class TryCatchWrapper
+    {
+        private Action<Exception> m_ExceptionHandle;
+        public TryCatchWrapper()
+        {
+
+        }
+        public TryCatchWrapper(Action<Exception> exceptionHandle)
+        {
+            m_ExceptionHandle = exceptionHandle;
+        }
+        public virtual void ExceptionHandle(Exception e)
+        {
+            m_ExceptionHandle?.Invoke(e);
+        }
+        /// <summary>
+        /// 处理信息
+        /// </summary>
+        /// <param name="action"></param>
+        public  void Handled(Action action)
+        {
+            try
+            {
+                action?.Invoke();
+            }
+            catch (Exception e)
+            {
+                ExceptionHandle(e);
+            }
+        }
+        #region 静态相关函数
+
+        public static void SetUIWrapper(Action<Exception> exceptionHandle)
+        {
+            UIWrapper = new TryCatchWrapper(exceptionHandle);
+        }
+        /// <summary>
+        /// UI处理Wrapper
+        /// </summary>
+        public static TryCatchWrapper UIWrapper { get; private set; } = new TryCatchWrapper((e) => MessageShow.Show(e));
+        /// <summary>
+        /// 处理UI封装函数
+        /// </summary>
+        /// <param name="action"></param>
+        public static void HandleUI(Action action)
+        {
+            UIWrapper?.Handled(action);
+        } 
+        #endregion
+    }
+}

+ 1 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -282,6 +282,7 @@
     <Compile Include="Common\PhaseUtil.cs" />
     <Compile Include="Common\RegexConstPattern.cs" />
     <Compile Include="Common\RevitBuiltInParameter.cs" />
+    <Compile Include="Common\TryCatchWrapper.cs" />
     <Compile Include="Common\WaitingView.cs" />
     <Compile Include="DataArrange\DalInfoCode.cs" />
     <Compile Include="Gplot\GplotFileItem.cs" />

+ 3 - 3
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinInsuer.xaml

@@ -22,9 +22,9 @@
             <DataGrid  x:Name="pivotGridControl1" ItemsSource="{Binding Path=Venders}" SelectedItem="{Binding Path=CurrentVender}"
                        dgx:DataGridFilter.IsAutoFilterEnabled="True" Style="{StaticResource ResourceKey={x:Static wpf:DataGridResource.DataGridStyle}}">
                 <DataGrid.Columns>
-                <DataGridTextColumn Width="*" Header="厂商名称"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="150" Header="联系人" Binding="{Binding Path=Negotiator }"   ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="120" Header="联系电话" Binding="{Binding Path=PhoneNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="*" Header="厂商名称"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="150" Header="联系人" Binding="{Binding Path=Negotiator }"   ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="120" Header="联系电话" Binding="{Binding Path=PhoneNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
                 </DataGrid.Columns>
 
             </DataGrid>

+ 56 - 43
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinInsuer.xaml.cs

@@ -18,6 +18,7 @@ using System.Linq;
 using System.Windows;
 using SAGA.MBI.RequestData;
 using WPG.Data;
+using TryCatchWrapper = SAGA.MBI.Common.TryCatchWrapper;
 
 namespace SAGA.MBI.WinView.ModeInfoMaintenance
 {
@@ -41,8 +42,11 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
 
         private void WinManufacturer_Loaded(object sender, RoutedEventArgs e)
         {
-            InitData();
-            this.DataContext = this;
+            TryCatchWrapper.HandleUI(() =>
+            {
+                InitData();
+                this.DataContext = this;
+            });
         }
         /// <summary>
         /// 重新初始化界面
@@ -51,7 +55,6 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
         {
             BaseVenders = DalManufacturerLibrary.GetInsuer(MBIControl.ProjectCur.Id);
             Venders = new ObservableCollection<MInsuer>(BaseVenders);
-            //CurrentVender = Venders.FirstOrDefault();
             GotoMatchInfo(m_MEquipment);
 
         }
@@ -112,60 +115,70 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
 
         private void Add_Mode(object sender, RoutedEventArgs e)
         {
-            WinFirmMain main = new WinFirmMain(new WinInsuerBaseInfo());
-            main.Title += "--保险商管理";
-            main.ShowDialog();
-            InitData();
+            TryCatchWrapper.HandleUI(() =>
+            {
+                WinFirmMain main = new WinFirmMain(new WinInsuerBaseInfo());
+                main.Title += "--保险商管理";
+                main.ShowDialog();
+                InitData();
+            });
+          
         }
         private void Update_Mode(object sender, RoutedEventArgs e)
         {
-            // new WinFirmMain(new WinInsuerBaseInfo());
-            Window main = null;
-          
-            if (CurrentVender != null)
-            {
-                var dic = new Dictionary<string, object>();
-                dic.Add("InsuerId", CurrentVender.Id);
-                main=FirmLibPost.StartWindow(@"WinInsuerBaseInfo\WinInsuerInfo\WinInsurancePolicyEditor", dic);
-            }
-            else
+            TryCatchWrapper.HandleUI(() =>
             {
-                main = new WinFirmMain(new WinInsuerBaseInfo());
-            }
-            main.Title += "--保险商管理";
-            main.ShowDialog();
-            InitData();
+                Window main = null;
+
+                if (CurrentVender != null)
+                {
+                    var dic = new Dictionary<string, object>();
+                    dic.Add("InsuerId", CurrentVender.Id);
+                    main = FirmLibPost.StartWindow(@"WinInsuerBaseInfo\WinInsuerInfo\WinInsurancePolicyEditor", dic);
+                }
+                else
+                {
+                    main = new WinFirmMain(new WinInsuerBaseInfo());
+                }
+                main.Title += "--保险商管理";
+                main.ShowDialog();
+                InitData();
+            });          
         }
 
 
         private void BtnSaveChange_OnClick(object sender, RoutedEventArgs e)
         {
-            if (CurrentVender == null)
+            TryCatchWrapper.HandleUI(() =>
             {
-                MessageShow.Infomation("没有选中任何供应商信息");
-                return;
-            }
-            bool isSave = true;
-            if (IsChange)
-            {
-                WinRealityUpdateTime win = new WinRealityUpdateTime();
-                win.Host = "保险公司";
-                win.Owner = this;
-                isSave = win.ShowDialog() == true;
-                if (isSave)
+                if (CurrentVender == null)
+                {
+                    MessageShow.Infomation("没有选中任何供应商信息");
+                    return;
+                }
+                bool isSave = true;
+                if (IsChange)
                 {
-                    if (win.DateTime == null)
+                    WinRealityUpdateTime win = new WinRealityUpdateTime();
+                    win.Host = "保险公司";
+                    win.Owner = this;
+                    isSave = win.ShowDialog() == true;
+                    if (isSave)
                     {
-                        MessageShow.Infomation("更换时间不能为空");
-                        return;
+                        if (win.DateTime == null)
+                        {
+                            MessageShow.Infomation("更换时间不能为空");
+                            return;
+                        }
+                        ChangeRealTime = win.DateTime?.ToString("yyyyMMddHHmmss");
                     }
-                    ChangeRealTime = win.DateTime?.ToString("yyyyMMddHHmmss");
                 }
-            }
-            if(isSave)
-            {
-                this.DialogResult = true;
-            }
+                if (isSave)
+                {
+                    this.DialogResult = true;
+                }
+            });
+           
             
         }
 

+ 7 - 3
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinInsuerContractInfo.xaml.cs

@@ -46,9 +46,13 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
   
         public WinInsuerContractInfo(MEquipment equipment) : this()
         {
-            m_MEquipment = equipment;
-            this.m_Vm = new VMInsuerContractInfo(m_MEquipment);
-            this.DataContext = this.m_Vm;
+            TryCatchWrapper.HandleUI(() =>
+            {
+                m_MEquipment = equipment;
+                this.m_Vm = new VMInsuerContractInfo(m_MEquipment);
+                this.DataContext = this.m_Vm;
+            });
+           
         }
         public void UpdateWPG(object obj)
         {

+ 3 - 3
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinMaintenanceDealer.xaml

@@ -22,9 +22,9 @@
             <DataGrid  x:Name="pivotGridControl1" ItemsSource="{Binding Path=Venders}" SelectedItem="{Binding Path=CurrentVender}"
                        dgx:DataGridFilter.IsAutoFilterEnabled="True" Style="{StaticResource ResourceKey={x:Static wpf:DataGridResource.DataGridStyle}}" >
                 <DataGrid.Columns>
-                    <DataGridTextColumn Width="*" Header="厂商名称"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                    <DataGridTextColumn Width="150" Header="联系人" Binding="{Binding Path=Negotiator}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                    <DataGridTextColumn Width="120" Header="联系电话" Binding="{Binding Path=PhoneNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="*" Header="厂商名称"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="150" Header="联系人" Binding="{Binding Path=Negotiator}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="120" Header="联系电话" Binding="{Binding Path=PhoneNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
                 </DataGrid.Columns>
              
             </DataGrid>

+ 67 - 50
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinMaintenanceDealer.xaml.cs

@@ -28,6 +28,7 @@ using SAGA.MBI.Model;
 using SAGA.MBI.RequestData;
 using SAGA.RevitUtils;
 using WPG.Data;
+using TryCatchWrapper = SAGA.MBI.Common.TryCatchWrapper;
 
 namespace SAGA.MBI.WinView.ModeInfoMaintenance
 {
@@ -54,8 +55,12 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
 
         private void WinManufacturer_Loaded(object sender, RoutedEventArgs e)
         {
-            InitData();
-            this.DataContext = this;
+
+            TryCatchWrapper.HandleUI(() =>
+            {
+                InitData();
+                this.DataContext = this;
+            });
         }
         public void InitData()
         {
@@ -109,68 +114,80 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
         }
         private void Update_Mode(object sender, RoutedEventArgs e)
         {
-            Window main = null;
-            if (CurrentVender != null)
-            {
-                var dic = new Dictionary<string, object>();
-                dic.Add("MaintainerId",CurrentVender.Id);
-                main=FirmLibPost.StartWindow(@"WinMaintainerBaseInfo\WinMaintainerInfo\WinMaintainerProjectAsset", dic);
-            }
-            else
+            TryCatchWrapper.HandleUI(() =>
             {
-                main = new WinFirmMain(new WinMaintainerBaseInfo());
-            }
-            main.Title += "--维修商管理";
-            main.ShowDialog();
-            InitData();
+                Window main = null;
+                if (CurrentVender != null)
+                {
+                    var dic = new Dictionary<string, object>();
+                    dic.Add("MaintainerId", CurrentVender.Id);
+                    main = FirmLibPost.StartWindow(@"WinMaintainerBaseInfo\WinMaintainerInfo\WinMaintainerProjectAsset", dic);
+                }
+                else
+                {
+                    main = new WinFirmMain(new WinMaintainerBaseInfo());
+                }
+                main.Title += "--维修商管理";
+                main.ShowDialog();
+                InitData();
+            });
+          
         }
         private void SearchInputEditor_Click(object sender, RoutedEventArgs e)
         {
-            SearchInputEditor editor = sender as SearchInputEditor;
-            if (editor == null) return;
-            var inputText = editor.Text;
-            List<MMaintenanceDealer> newList = null;
-            if (string.IsNullOrEmpty(inputText))
+            TryCatchWrapper.HandleUI(() =>
             {
-                newList = new List<MMaintenanceDealer>(BaseVenders);
+                SearchInputEditor editor = sender as SearchInputEditor;
+                if (editor == null) return;
+                var inputText = editor.Text;
+                List<MMaintenanceDealer> newList = null;
+                if (string.IsNullOrEmpty(inputText))
+                {
+                    newList = new List<MMaintenanceDealer>(BaseVenders);
 
-            }
-            else
-            {
-                var newInput = inputText.ToUpper();
-                newList = BaseVenders.Where(c => c.Name.ToUpper().Contains(newInput) || c.Pinyin.Contains(newInput)).ToList();
-            }
-            Venders = new ObservableCollection<MMaintenanceDealer>(newList);
-            //CurrentVender = Venders.FirstOrDefault();
+                }
+                else
+                {
+                    var newInput = inputText.ToUpper();
+                    newList = BaseVenders.Where(c => c.Name.ToUpper().Contains(newInput) || c.Pinyin.Contains(newInput)).ToList();
+                }
+                Venders = new ObservableCollection<MMaintenanceDealer>(newList);
+                //CurrentVender = Venders.FirstOrDefault();
+            });
+         
         }
         private void BtnSaveChange_OnClick(object sender, RoutedEventArgs e)
         {
-            if (CurrentVender == null)
+            TryCatchWrapper.HandleUI(() =>
             {
-                MessageShow.Infomation("没有选中任何供应商信息");
-                return;
-            }
-            bool isSave = true;
-            if (IsChange)
-            {
-                WinRealityUpdateTime win = new WinRealityUpdateTime();
-                win.Host = "维修商";
-                win.Owner = this;
-                isSave = win.ShowDialog() == true;
-                if (isSave)
+                if (CurrentVender == null)
                 {
-                    if (win.DateTime == null)
+                    MessageShow.Infomation("没有选中任何供应商信息");
+                    return;
+                }
+                bool isSave = true;
+                if (IsChange)
+                {
+                    WinRealityUpdateTime win = new WinRealityUpdateTime();
+                    win.Host = "维修商";
+                    win.Owner = this;
+                    isSave = win.ShowDialog() == true;
+                    if (isSave)
                     {
-                        MessageShow.Infomation("更换时间不能为空");
-                        return;
+                        if (win.DateTime == null)
+                        {
+                            MessageShow.Infomation("更换时间不能为空");
+                            return;
+                        }
+                        ChangeRealTime = win.DateTime?.ToString("yyyyMMddHHmmss");
                     }
-                    ChangeRealTime = win.DateTime?.ToString("yyyyMMddHHmmss");
                 }
-            }
-            if (isSave)
-            {
-                this.DialogResult = true;
-            }
+                if (isSave)
+                {
+                    this.DialogResult = true;
+                }
+            });
+           
         }
 
         private void BtnCancel_OnClick(object sender, RoutedEventArgs e)

+ 5 - 5
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinManufacturer.xaml

@@ -22,11 +22,11 @@
             <DataGrid  x:Name="pivotGridControl1" ItemsSource="{Binding Path=Venders}"  SelectedItem="{Binding Path=CurrentVender}"
                        dgx:DataGridFilter.IsAutoFilterEnabled="True" Style="{StaticResource ResourceKey={x:Static wpf:DataGridResource.DataGridStyle}}">
                 <DataGrid.Columns>
-                <DataGridTextColumn Width="*" MinWidth="150" Header="生产厂家"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="120" Header="品牌" Binding="{Binding Path=Brand}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="130" Header="型号" Binding="{Binding Path=ModeNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="100" Header="保养周期(天)" Binding="{Binding Path=MaintainPeriod}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="100" Header="使用寿命(年)" Binding="{Binding Path=ServiceLife}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="*" MinWidth="150" Header="生产厂家"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="120" Header="品牌" Binding="{Binding Path=Brand}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn  IsReadOnly="True" Width="130" Header="型号" Binding="{Binding Path=ModeNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="100" Header="保养周期(天)" Binding="{Binding Path=MaintainPeriod}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="100" Header="使用寿命(年)" Binding="{Binding Path=ServiceLife}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
                 </DataGrid.Columns>
             </DataGrid>
         </Grid>

+ 65 - 46
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinManufacturer.xaml.cs

@@ -18,6 +18,7 @@ using SAGA.MBI.Model;
 using SAGA.MBI.RequestData;
 using SAGA.RevitUtils;
 using WPG.Data;
+using TryCatchWrapper = SAGA.MBI.Common.TryCatchWrapper;
 
 namespace SAGA.MBI.WinView.ModeInfoMaintenance
 {
@@ -41,8 +42,11 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
 
         private void WinManufacturer_Loaded(object sender, RoutedEventArgs e)
         {
-            InitData();
-            this.DataContext = this;
+            TryCatchWrapper.HandleUI(() =>
+            {
+                InitData();
+                this.DataContext = this;
+            });
         }
         public void InitData()
         {
@@ -85,22 +89,25 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
         /// <param name="e"></param>
         private void Add_Mode(object sender, RoutedEventArgs e)
         {
-            //MessageBox.Show("添加型号");
-            Window main = null;
-            if (CurrentVender != null)
+            TryCatchWrapper.HandleUI(() =>
             {
-                var dic = new Dictionary<string, object>();
-                dic.Add("ManufactureId", CurrentVender.VenderId);
-                main = FirmLibPost.StartWindow(@"WinManufactureBaseInfo\WinManufactureInfo", dic);
-            }
+                Window main = null;
+                if (CurrentVender != null)
+                {
+                    var dic = new Dictionary<string, object>();
+                    dic.Add("ManufactureId", CurrentVender.VenderId);
+                    main = FirmLibPost.StartWindow(@"WinManufactureBaseInfo\WinManufactureInfo", dic);
+                }
 
-            else
-            {
-                main = new WinFirmMain(new WinManufactureBaseInfo());
-            }
-            main.Title += "--生产商管理";
-            main.ShowDialog();
-            InitData();
+                else
+                {
+                    main = new WinFirmMain(new WinManufactureBaseInfo());
+                }
+                main.Title += "--生产商管理";
+                main.ShowDialog();
+                InitData();
+            });
+          
         }
         /// <summary>
         /// 修改型号
@@ -109,43 +116,52 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
         /// <param name="e"></param>
         private void Update_Type(object sender, RoutedEventArgs e)
         {
-            Window main = null;
-            if (CurrentVender != null)
-            {
-                var dic = new Dictionary<string, object>();
-                dic.Add("ManufactureId", CurrentVender.VenderId);
-                dic.Add("BrandId", CurrentVender.BrandId);
-                dic.Add("ProductId", CurrentVender.ProductId);
-                main = FirmLibPost.StartWindow(@"WinManufactureBaseInfo\WinManufactureInfo\WinProductType", dic);
-            }
 
-            else
+            TryCatchWrapper.HandleUI(() =>
             {
+                Window main = null;
+                if (CurrentVender != null)
+                {
+                    var dic = new Dictionary<string, object>();
+                    dic.Add("ManufactureId", CurrentVender.VenderId);
+                    dic.Add("BrandId", CurrentVender.BrandId);
+                    dic.Add("ProductId", CurrentVender.ProductId);
+                    main = FirmLibPost.StartWindow(@"WinManufactureBaseInfo\WinManufactureInfo\WinProductType", dic);
+                }
 
-                main = new WinFirmMain(new WinManufactureBaseInfo());
-            }
-            main.Title += "--生产商管理";
-            main.ShowDialog();
-            InitData();
+                else
+                {
+
+                    main = new WinFirmMain(new WinManufactureBaseInfo());
+                }
+                main.Title += "--生产商管理";
+                main.ShowDialog();
+                InitData();
+            });
+         
         }
         private void SearchInputEditor_Click(object sender, RoutedEventArgs e)
         {
-            SearchInputEditor editor = sender as SearchInputEditor;
-            if (editor == null) return;
-            var inputText = editor.Text;
-            List<MManufacturer> newList = null;
-            if (string.IsNullOrEmpty(inputText))
+            TryCatchWrapper.HandleUI(() =>
             {
-                newList = new List<MManufacturer>(BaseVenders);
+                SearchInputEditor editor = sender as SearchInputEditor;
+                if (editor == null) return;
+                var inputText = editor.Text;
+                List<MManufacturer> newList = null;
+                if (string.IsNullOrEmpty(inputText))
+                {
+                    newList = new List<MManufacturer>(BaseVenders);
 
-            }
-            else
-            {
-                var newInput = inputText;//.ToUpper();
-                newList = BaseVenders.Where(c => c.Name.Contains(newInput)||c.Brand.Contains(newInput) || c.ModeNumber.Contains(newInput)).ToList();
-            }
-            Venders = new ObservableCollection<MManufacturer>(newList);
-            //CurrentVender = Venders.FirstOrDefault();
+                }
+                else
+                {
+                    var newInput = inputText;//.ToUpper();
+                    newList = BaseVenders.Where(c => c.Name.Contains(newInput) || c.Brand.Contains(newInput) || c.ModeNumber.Contains(newInput)).ToList();
+                }
+                Venders = new ObservableCollection<MManufacturer>(newList);
+
+            });
+           
         }
         private void BtnSaveChange_OnClick(object sender, RoutedEventArgs e)
         {
@@ -251,7 +267,10 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
         }
         public static string GetValueDisplay(ManufacturerUpdateItem updateItem)
         {
-            return $"{updateItem.BrandName}+{updateItem.ProductTypeName}+{updateItem.VenderName}";
+            List<string> displays = new List<string>() { updateItem.BrandName, updateItem.ProductTypeName, updateItem.VenderName };
+            displays = displays.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
+            return string.Join("+", displays);
+           // return $"{updateItem.BrandName}+{updateItem.ProductTypeName}+{updateItem.VenderName}";
         }
         public static string GetValueDisplay(MRevitEquipBase equipment)
         {

+ 3 - 3
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinSupply.xaml

@@ -22,9 +22,9 @@
             <DataGrid  x:Name="pivotGridControl1"  ItemsSource="{Binding Path=Venders}" SelectedItem="{Binding Path=CurrentVender}" 
                        dgx:DataGridFilter.IsAutoFilterEnabled="True" Style="{StaticResource ResourceKey={x:Static wpf:DataGridResource.DataGridStyle}}">
                 <DataGrid.Columns>
-                <DataGridTextColumn Width="*" Header="供应商名称"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="150" Header="联系人" Binding="{Binding Path=Negotiator}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
-                <DataGridTextColumn Width="120" Header="联系电话" Binding="{Binding Path=PhoneNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn  IsReadOnly="True" Width="*" Header="供应商名称"  Binding="{Binding Path=Name}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True"  Width="150" Header="联系人" Binding="{Binding Path=Negotiator}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
+                    <DataGridTextColumn IsReadOnly="True" Width="120" Header="联系电话" Binding="{Binding Path=PhoneNumber}"  ElementStyle="{StaticResource ResourceKey={x:Static wpf:DataGridResource.ElementStyle}}"></DataGridTextColumn>
                 </DataGrid.Columns>
             </DataGrid>
         </Grid>

+ 50 - 36
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinSupply.xaml.cs

@@ -31,6 +31,7 @@ using SAGA.MBI.RequestData;
 using SAGA.MBI.Tools;
 using SAGA.RevitUtils;
 using WPG.Data;
+using TryCatchWrapper = SAGA.MBI.Common.TryCatchWrapper;
 
 namespace SAGA.MBI.WinView.ModeInfoMaintenance
 {
@@ -54,10 +55,11 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
 
         private void WinManufacturer_Loaded(object sender, RoutedEventArgs e)
         {
-
-            InitData();
-            this.DataContext = this;
-
+            TryCatchWrapper.HandleUI(() =>
+            {
+                InitData();
+                this.DataContext = this;
+            });
         }
         /// <summary>
         /// 重新初始化界面
@@ -98,48 +100,60 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
         }
         private void Add_Mode(object sender, RoutedEventArgs e)
         {
-            WinFirmMain main = new WinFirmMain(new WinSellerBaseInfo());
-            main.Title += "--供应商管理";
-            main.ShowDialog();
-            InitData();
+          
+            TryCatchWrapper.HandleUI(() =>
+            {
+                WinFirmMain main = new WinFirmMain(new WinSellerBaseInfo());
+                main.Title += "--供应商管理";
+                main.ShowDialog();
+                InitData();
+            });
         }
         private void Update_Mode(object sender, RoutedEventArgs e)
         {
-            Window main = null;
-
-            if (CurrentVender != null)
-            {
-                var dic = new Dictionary<string, object>();
-                dic.Add("SellerId", CurrentVender.Id);
-                main = FirmLibPost.StartWindow(@"WinSellerBaseInfo\WinSellerInfo\WinSellerProjectContract", dic);
-            }
-            else
+            TryCatchWrapper.HandleUI(() =>
             {
-                main = new WinFirmMain(new WinSellerBaseInfo());
-            }
-            main.Title += "--供应商管理";
-            main.ShowDialog();
-            InitData();
+                Window main = null;
+
+                if (CurrentVender != null)
+                {
+                    var dic = new Dictionary<string, object>();
+                    dic.Add("SellerId", CurrentVender.Id);
+                    main = FirmLibPost.StartWindow(@"WinSellerBaseInfo\WinSellerInfo\WinSellerProjectContract", dic);
+                }
+                else
+                {
+                    main = new WinFirmMain(new WinSellerBaseInfo());
+                }
+                main.Title += "--供应商管理";
+                main.ShowDialog();
+                InitData();
+            });
+           
         }
         
         private void SearchInputEditor_Click(object sender, RoutedEventArgs e)
         {
-            SearchInputEditor editor = sender as SearchInputEditor;
-            if (editor == null) return;
-            var inputText = editor.Text;
-            List<MSupply> newList = null;
-            if (string.IsNullOrEmpty(inputText))
+            TryCatchWrapper.HandleUI(() =>
             {
-                newList = new List<MSupply>(BaseVenders);
+                SearchInputEditor editor = sender as SearchInputEditor;
+                if (editor == null) return;
+                var inputText = editor.Text;
+                List<MSupply> newList = null;
+                if (string.IsNullOrEmpty(inputText))
+                {
+                    newList = new List<MSupply>(BaseVenders);
 
-            }
-            else
-            {
-                var newInput = inputText.ToUpper();
-                newList = BaseVenders.Where(c => c.Name.ToUpper().Contains(newInput) || c.Pinyin.Contains(newInput)).ToList();
-            }
-            Venders = new ObservableCollection<MSupply>(newList);
-            //CurrentVender = Venders.FirstOrDefault();
+                }
+                else
+                {
+                    var newInput = inputText.ToUpper();
+                    newList = BaseVenders.Where(c => c.Name.ToUpper().Contains(newInput) || c.Pinyin.Contains(newInput)).ToList();
+                }
+                Venders = new ObservableCollection<MSupply>(newList);
+                //CurrentVender = Venders.FirstOrDefault();
+            });
+           
         }
 
         private void BtnSaveChange_OnClick(object sender, RoutedEventArgs e)

+ 7 - 3
MBI/SAGA.MBI/WinView/ModeInfoMaintenance/WinSupplyContractInfo.xaml.cs

@@ -39,9 +39,13 @@ namespace SAGA.MBI.WinView.ModeInfoMaintenance
         }    
         public WinSupplyContractInfo(MEquipment equipment) : this()
         {
-            m_MEquipment = equipment;
-            this.m_Vm = new VMSupplyContractInfo(m_MEquipment);
-            this.DataContext = this.m_Vm;
+          
+            TryCatchWrapper.HandleUI(() =>
+            {
+                m_MEquipment = equipment;
+                this.m_Vm = new VMSupplyContractInfo(m_MEquipment);
+                this.DataContext = this.m_Vm;
+            });
         }
         public void UpdateWPG(object obj)
         {

+ 38 - 32
MBI/SAGA.MBI/WinView/Space/WinCreateSpace.xaml.cs

@@ -5,6 +5,7 @@ using System.IO;
 using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Documents;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Shapes;
@@ -16,6 +17,7 @@ using Point = System.Windows.Point;
 using System.Windows.Media.Animation;
 using System.Windows.Threading;
 using Autodesk.Revit.UI;
+using SAGA.DotNetUtils.WPF;
 using SAGA.MBI.DataArrange;
 using SAGA.MBI.Model;
 using SAGA.MBI.WinView.ModeInfoMaintenance;
@@ -1003,20 +1005,20 @@ namespace SAGA.MBI.WinView.Space
                 if (lbSpaces.SelectedItems.Count == 0) return;
                 var space = lbSpaces.SelectedItems[0] as MISpace;
                 var bimId = space.BimID.Split(':')[1];
-                foreach (var polyline in this.canvas.Children.OfType<WPolyline>())
+                foreach (var spaceELement in this.canvas.Children.OfType<SpaceElement>())
                 {
-                    if (polyline.Tag is Autodesk.Revit.DB.Mechanical.Space s)
+                    if (spaceELement.Tag is Autodesk.Revit.DB.Mechanical.Space s)
                     {
                         if (s.Id.ToString() == (bimId))
                         {
-                            polyline.Fill = Brushes.Aquamarine;
+                            spaceELement.Fill = Brushes.Aquamarine;
 
                             //显示属性窗口
                             ShowSpaceProperty(s);
                         }
-                        else if (polyline.Fill == Brushes.Aquamarine)
+                        else if (spaceELement.Fill == Brushes.Aquamarine)
                         {
-                            polyline.Fill = Brushes.Transparent;
+                            spaceELement.Fill = Brushes.Transparent;
                         }
                     }
                 }
@@ -1036,7 +1038,6 @@ namespace SAGA.MBI.WinView.Space
         {
             MRevitEquipBase equipment = DalCommon.GetEquipmentQueryId(space);
             ShowSpaceProperty(equipment);
-
         }
       
 
@@ -1072,22 +1073,37 @@ namespace SAGA.MBI.WinView.Space
             var seg = mySegments.FirstOrDefault();
             if (seg == null)
             {
-                MessageBox.Show(space.Id.IntegerValue + "");
                 return;
             }
+            SpaceElement spaceElement = null;
+            for (int i = 0; i < mySegments.Count; i++)
+            {
+                var useSeg = mySegments[i];
+                List<Point> datas = new List<Point>();
+                foreach (BoundarySegment segment in useSeg)
+                {
+                    datas.AddRange(segment.GetCurve().Tessellate().Select(xyz => xyz.ToW2DPoint()).ToList());
+                }
 
-
-            List<Point> datas = new List<Point>();
-            foreach (BoundarySegment segment in seg)
+                datas = datas.Select(p => { return MovePoint(new Point(p.X, p.Y)); }).ToList();
+                if (i == 0)
+                {
+                    spaceElement = new SpaceElement(datas);
+                }
+                else if (spaceElement!=null)
+                {
+                    spaceElement.InPolygons.Add(new PointCollection(datas));
+                }
+            }
+            //var polyLine = this.CreateDefaultPolyLine(datas, Brushes.Transparent);
+            if (spaceElement != null)
             {
-                datas.AddRange(segment.GetCurve().Tessellate().Select(xyz => xyz.ToW2DPoint()).ToList());
+                spaceElement.Tag = space;//此处比较重要,这个是判断曲线是否为轮廓线的关键
+                spaceElement.Fill = Brushes.Transparent;
+                spaceElement.MouseLeftButtonDown +=Space_MouseDown;
+                this.canvas.Children.Add(spaceElement);
             }
-
-            var polyLine = this.CreateDefaultPolyLine(datas, Brushes.Transparent);
-            polyLine.Tag = space;//此处比较重要,这个是判断曲线是否为轮廓线的关键
-            polyLine.Fill = Brushes.Transparent;
-
-            polyLine.MouseLeftButtonDown += PolyLine_MouseDown;
+           
         }
 
         /// <summary>
@@ -1095,19 +1111,17 @@ namespace SAGA.MBI.WinView.Space
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-        private void PolyLine_MouseDown(object sender, MouseButtonEventArgs e)
+        private void Space_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            if ((sender is WPolyline line) && m_isDraw == null)
+            if ((sender is SpaceElement sapceElement) && m_isDraw == null)
             {
                 //找到已亮显的空间
-                var showSpaces = this.canvas.Children.OfType<WPolyline>().FirstOrDefault(t => t is WPolyline l && l.Fill == Brushes.Aquamarine);
+                var showSpaces = this.canvas.Children.OfType<SpaceElement>().FirstOrDefault(s => s.Fill == Brushes.Aquamarine);
 
                 //先清除
                 if (showSpaces != null) showSpaces.Fill = Brushes.Transparent;
-                line.Fill = Brushes.Aquamarine;
-                //MessageBox.Show(line.Tag+"");
-
-                if (line.Tag is Autodesk.Revit.DB.Mechanical.Space space)
+                sapceElement.Fill = Brushes.Aquamarine;
+                if (sapceElement.Tag is Autodesk.Revit.DB.Mechanical.Space space)
                 {
                     //反选右侧树
                     for (int i = 0; i < lbSpaces.Items.Count; i++)
@@ -1120,10 +1134,7 @@ namespace SAGA.MBI.WinView.Space
                             break;
                         }
                     }
-
                     //显示属性板
-
-
                     ShowSpaceProperty(space);
                 }
             }
@@ -1144,11 +1155,6 @@ namespace SAGA.MBI.WinView.Space
         {
             MoveElement(0.1, new Point());
         }
-
-        //创建定时器,以检测所有操作是否全部保存完成
-        private DispatcherTimer timer;
-
-       
         private void CanvasDefaultTips()
         {
             string tips = "请选择一个需要进行空间管理的楼层";