更新 UI 和逻辑,添加新功能和改进错误处理
在 `MainWindow.xaml` 中: - 修改 `CheckBox` 控件,绑定 `IsUseDiscoloration` 属性,添加 `IsEnabled="False"` 和 `ToolTip`。 - 添加两个新的 `MenuItem`,分别绑定 `ToSourceAndHideOthers_Click` 和 `ShowAllWire_Click` 事件。 - 移除 `MultiDataTrigger.Conditions` 中的一个 `Condition` 和 `DataGrid.Resources` 中的一个 `Style`。 在 `MainWindow.xaml.cs` 中: - 注释掉 `GoToSource_Click` 方法中的 `HideOthers()` 调用。 - 添加 `OthersWireShow` 方法。 - 添加 `ToSourceAndHideOthers_Click` 和 `ShowAllWire_Click` 方法。 在 `MainViewModel.Check.cs` 中: - 添加 `using System.IO.Packaging;` 引用。 - 修改 `ValidateItem` 方法,注释掉 `IsUseDiscoloration` 的判断。 - 在 `CheckImprintCondition` 方法中,添加对 `DiscolorationDesc` 和 `Insulation` 的检查,改进错误处理逻辑。 在 `MainViewModel.cs` 中: - 初始化 `IsUseDiscoloration` 为 `true`。
This commit is contained in:
parent
058a16eee8
commit
4be42fdc5c
|
@ -100,7 +100,9 @@
|
|||
Margin="2"
|
||||
Content="是否使用变色套"
|
||||
FontSize="14"
|
||||
IsChecked="{Binding IsUseDiscoloration}" />
|
||||
IsChecked="{Binding IsUseDiscoloration}"
|
||||
IsEnabled="False"
|
||||
ToolTip="默认将会检查变色套信息" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</hc:Card>
|
||||
|
@ -233,6 +235,8 @@
|
|||
</StackPanel>
|
||||
</MenuItem.Header>
|
||||
</MenuItem>
|
||||
<MenuItem Click="ToSourceAndHideOthers_Click" Header="转到源并隐藏其他线" />
|
||||
<MenuItem Click="ShowAllWire_Click" Header="显示所有线" />
|
||||
<MenuItem Click="UnIgnoreSelectedError_Click" Header="取消忽略选中项的异常" />
|
||||
<MenuItem
|
||||
Click="Copy_Click"
|
||||
|
@ -270,7 +274,6 @@
|
|||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsError}" Value="false" />
|
||||
<Condition Binding="{Binding IsChecked}" Value="true" />
|
||||
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Background" Value="#18a05d" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
|
@ -278,12 +281,10 @@
|
|||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#aa326cf3" />
|
||||
</Trigger>
|
||||
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Resources>
|
||||
|
||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="MaxHeight" Value="9999" />
|
||||
|
|
|
@ -443,6 +443,7 @@ public partial class MainWindow : System.Windows.Window
|
|||
this.AddToDesignerSelectSet(flexDesigner, list);
|
||||
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, []);
|
||||
flexDesigner.FitToSelectSet();
|
||||
|
||||
//flexDesigner.
|
||||
flexDesigner.SelectSet.OnSelectionChanged();
|
||||
}
|
||||
|
@ -492,6 +493,7 @@ public partial class MainWindow : System.Windows.Window
|
|||
{
|
||||
try
|
||||
{
|
||||
//HideOthers();
|
||||
GoToSource();
|
||||
if (ViewModel.ToSourceAndMinSelf)
|
||||
{
|
||||
|
@ -504,6 +506,68 @@ public partial class MainWindow : System.Windows.Window
|
|||
}
|
||||
}
|
||||
|
||||
private void OthersWireShow(bool show = false)
|
||||
{
|
||||
var selectItems = ModelGenDataGrid.SelectedItems;
|
||||
if (selectItems != null && selectItems.Count > 0)
|
||||
//if (selectItems is List<StuffedDataModel> reportItems)
|
||||
{
|
||||
//foreach (ReportModel item in selectItems)
|
||||
StuffedDataModel item = (StuffedDataModel)selectItems[0];
|
||||
if (item != null)
|
||||
{
|
||||
var reportEntry = datas.FirstOrDefault(it => it.Properties["WireName"].ValueString() == item.WireName);
|
||||
_report.DataSources.GetSources();
|
||||
if (reportEntry.OrigDocIDs == null || reportEntry.OrigDocIDs.Count == 0)
|
||||
{
|
||||
reportEntry.OrigDocIDs = new List<string>();
|
||||
foreach (IDataSource dataSource in _report.DataSources.GetSources())
|
||||
{
|
||||
IFlexStudioDocument documentByID = FlexProject.CurrentProject.GetDocumentByID(dataSource.ParentID);
|
||||
FlexDesigner designer;
|
||||
if ((designer = (documentByID as FlexDesigner)) != null)
|
||||
{
|
||||
FlexProject.CurrentProject.LoadDesignerMetadata(designer);
|
||||
}
|
||||
if (reportEntry.OrigID != null && SelfControler<BaseOccurrence>.FindInstance(reportEntry.OrigID) != null)
|
||||
{
|
||||
reportEntry.OrigDocIDs.Add(documentByID.ID);
|
||||
}
|
||||
FlexProject.CurrentProject.CloseAllUsedDocuments();
|
||||
}
|
||||
}
|
||||
if (reportEntry.OrigDocIDs != null && reportEntry.OrigDocIDs.Any())
|
||||
{
|
||||
var docId = reportEntry.OrigDocIDs.First();
|
||||
var flexDesigner = SelfControler<FlexBaseOrganizer>.FindInstance(docId) as FlexDesigner;
|
||||
if (flexDesigner != null)
|
||||
{
|
||||
var cables = flexDesigner.GetAllOccurrencesByLibID(true);
|
||||
foreach (var cable in cables)
|
||||
{
|
||||
Debug.WriteLine("");
|
||||
Debug.Write(cable.Key);
|
||||
Debug.Write("-->");
|
||||
//Debug.Write(string.Join(",", cable.Value));
|
||||
Debug.WriteLine("");
|
||||
cable.Value.ForEach(it =>
|
||||
{
|
||||
var occ = SelfControler<BaseOccurrence>.FindInstance(it);
|
||||
if (occ is OccWire wire)
|
||||
{
|
||||
wire.SetVisibility(show, null);
|
||||
Debug.WriteLine($"{wire.Name} SetVisibility {show}");
|
||||
}
|
||||
});
|
||||
//Debug.Write("-->");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchBar_SearchStarted(object sender, HandyControl.Data.FunctionEventArgs<string> e)
|
||||
{
|
||||
Trace.WriteLine(e.Info.ToString());
|
||||
|
@ -553,4 +617,27 @@ public partial class MainWindow : System.Windows.Window
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ToSourceAndHideOthers_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
OthersWireShow();
|
||||
GoToSource();
|
||||
if (ViewModel.ToSourceAndMinSelf)
|
||||
{
|
||||
this.WindowState = WindowState.Minimized;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowAllWire_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OthersWireShow(true);
|
||||
GoToSource();
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Packaging;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||
|
@ -36,7 +37,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
CheckWireErpNr(item);
|
||||
CheckRequiredFields(item);
|
||||
if (IsUseDiscoloration)
|
||||
//if (IsUseDiscoloration)
|
||||
{
|
||||
CheckImprint(item);
|
||||
}
|
||||
|
@ -437,7 +438,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
("L3", WireFlagType.Mix, "灰色"),
|
||||
("T", WireFlagType.Mix, "灰色"),
|
||||
|
||||
("PE", null, "绿色")
|
||||
("PE", null, "绿色"),
|
||||
("D-PE", null, "绿色")
|
||||
};
|
||||
|
||||
foreach (var condition in imprintConditions)
|
||||
|
@ -445,18 +447,38 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
CheckImprintCondition(item, condition.Prefix, condition.FlagType, condition.Color);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckImprintCondition(StuffedDataModel item, string imprintPrefix, WireFlagType? flagType, string expectedColor)
|
||||
{
|
||||
if (item.Imprint.StartsWith(imprintPrefix) && (flagType == null || FlagType == flagType))
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.DiscolorationDesc))
|
||||
if (string.IsNullOrEmpty(item.DiscolorationDesc) || item.Insulation == null || string.IsNullOrEmpty(item.Insulation.MaterialCode))
|
||||
{
|
||||
SetItemError(item, "变色管信息为空\r\n");
|
||||
SetItemError(item, "变色管信息为空!\r\n");
|
||||
}
|
||||
else if (!item.DiscolorationDesc.Contains(expectedColor))
|
||||
else
|
||||
{
|
||||
SetItemError(item, $"变色管颜色有误,应该使用{expectedColor}\r\n");
|
||||
|
||||
var discolorationDesc = Consts.regexParenthesesContent.Match(item.DiscolorationDesc).Value;
|
||||
|
||||
if (string.IsNullOrEmpty(discolorationDesc))
|
||||
{
|
||||
SetItemError(item, "变色管信息为空!\r\n");
|
||||
}
|
||||
else if (!discolorationDesc.Equals(expectedColor))
|
||||
{
|
||||
if (imprintPrefix == "D-PE")
|
||||
{
|
||||
if ((item.WireColor == "GNYE" && discolorationDesc != "绿色"))
|
||||
{
|
||||
SetItemError(item, $"变色管颜色有误,应该使用{expectedColor}!\r\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SetItemError(item, $"变色管颜色有误,应该使用{expectedColor}!\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public partial class MainViewModel : INotifyPropertyChanged
|
|||
}
|
||||
}
|
||||
|
||||
private bool _isUseDiscoloration;
|
||||
private bool _isUseDiscoloration = true;
|
||||
/// <summary>
|
||||
/// 是否使用变色管
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue