diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs index 5f55752..6704376 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/LectotypeViewModel.cs @@ -202,7 +202,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged var insulatorGraph = occCable.Children.First() as OccCablesInsulatorGraph; var isEncoderLine = GetLineType(occCable.LibraryName,"编码器线"); - var isPowerLine = GetLineType(occCable.LibraryName,"动力线"); + var isPowerLine = GetLineType(occCable.LibraryName,"动力线"); var isBrakePowerLine = GetLineType(occCable.LibraryName,"动力刹车线"); var encoderLength = 0d; @@ -261,7 +261,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged public string GetDocName(FlexDesigner designer) { var docName = designer.Name; - if(docName.Contains("+")) + if (docName.Contains("+")) { return docName.Split('+').FirstOrDefault(); } @@ -345,7 +345,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged //2 合并同轴号的第一条数据 cables.Where(it => it.CurrentLine == 1).ForEach(it => { - if(it.Motor?.Brand != Brands.ANCHUAN) + if (it.Motor?.Brand != Brands.ANCHUAN) { var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1); @@ -564,7 +564,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId); var parts = doc.GetOrganizerOccurrences(docId) .Where(occ => occ.Type == OCC_TYPE.wPART) - .Where(occ => + .Where(occ => (occ.Name?.StartsWith("HK-KT") ?? false) || (occ.Name?.StartsWith("SGMX") ?? false) ) @@ -583,7 +583,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged }; var motorPowerData = motorPowerDatas.FirstOrDefault(it => it.ItemFlag == motor.MotorModelStr); - + if (motorPowerData != null) { motor.MotorPower = motorPowerData.ItemValue; @@ -597,19 +597,19 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged motor.SetError("未填写轴号信息!"); } bool canAdd = true; - if(part.Parents != null && part.Parents.Any()) + if (part.Parents != null && part.Parents.Any()) { var parent = part.Parents.First(); if (parent.Type == OCC_TYPE.wPART) { - if( (parent.Name?.StartsWith("HK-KT") ?? false) + if ((parent.Name?.StartsWith("HK-KT") ?? false) || (parent.Name?.StartsWith("SGMX") ?? false)) { canAdd = false; - } + } } } - if(canAdd) + if (canAdd) { motorsData?.Add(motor); } @@ -725,9 +725,17 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged }); MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires); } - public void AddNotSavedLectotype(Dictionary value) + public void AddNotSavedLectotype(Dictionary value) { - value.ForEach(it => NotSavedLectotypeList.Add(it.Key, it.Value)); + value.ForEach(it => + { + if (NotSavedLectotypeList.Keys.Any((e) => string.Compare(e, it.Key) == 0) == false) + NotSavedLectotypeList.Add(it.Key, it.Value); + else NotSavedLectotypeList[it.Key]=it.Value; + } + + ); + } public void RemoveNotSavedLectotype(Dictionary value) { @@ -736,10 +744,10 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged internal async Task CheckSaved() { - if(NotSavedLectotypeList != null && NotSavedLectotypeList.Any()) + if (NotSavedLectotypeList != null && NotSavedLectotypeList.Any()) { var isContinue = false; - + return isContinue; } else