105040 Update 增加数据丢失提示

This commit is contained in:
lihanbo 2025-01-24 08:46:21 +08:00
parent 860ce040ed
commit ea476590da
3 changed files with 33 additions and 17 deletions

View File

@ -21,6 +21,7 @@ using static Sinvo.EplanHpD.Plugin.WPFUI.Utils.LectotypeManager;
using System.Linq;
using EPLAN.Harness.ProjectCore.Occurrences;
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
using Sinvo.EplanHpD.Plugin.Service.Model;
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
@ -95,11 +96,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
//var motor = Motor as MotorModel;
if(Motor is CableLectotypeViewModel motor)
{
WeakReferenceMessenger.Default.Send<LectotypeMessage>(new LectotypeMessage
WeakReferenceMessenger.Default.Send<LectotypeMessage,string>(new LectotypeMessage
(new System.Collections.Generic.Dictionary<string, string>
{
{motor.Motor.MotorModelStr,motor.Motor.AxisNo}
}));
}), "Lectotype"
);
}
}
@ -131,6 +133,15 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
if (ViewModel.SaveToDb())
{
if (Motor is CableLectotypeViewModel motor)
{
WeakReferenceMessenger.Default.Send(new LectotypeMessage
(new System.Collections.Generic.Dictionary<string, string>
{
{motor.Motor.MotorModelStr,motor.Motor.AxisNo}
}), "LectotypeSaved"
);
}
Growl.Success("保存成功", "CableLectotypeMessage");
}
else

View File

@ -43,11 +43,13 @@
<Button
Width="100"
Click="btnOK_Click"
Content="是" />
Content="是"
Style="{StaticResource ButtonDanger}" />
<Button
Width="100"
Click="btnCancel_Click"
Content="否" />
Content="否"
Style="{StaticResource ButtonInfo}" />
</StackPanel>
</StackPanel>
</Grid>

View File

@ -45,6 +45,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
this.DataContext = ViewModel = new LectotypeViewModel(docId);
Application.Current.SetMainWindow(this);
RegisterEvent();
}
public void RegisterEvent()
{
WeakReferenceMessenger.Default.Register<CommonMessage>("RowDetailsVisibility", (sender, message) =>
{
if (System.Enum.IsDefined(typeof(DataGridRowDetailsVisibilityMode), message.Value))
@ -60,23 +64,29 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
DrawPDFDrawer.IsOpen = true;
}
});
WeakReferenceMessenger.Default.Register<LectotypeMessage>("Lectotype", (sender, message) =>
WeakReferenceMessenger.Default.Register<LectotypeMessage,string>("Lectotype", "Lectotype", (sender, message) =>
{
if (message.Value != null)
{
ViewModel.AddNotSavedLectotype(message.Value);
}
});
WeakReferenceMessenger.Default.Register<LectotypeMessage>("LectotypeSaved", (sender, message) =>
WeakReferenceMessenger.Default.Register<LectotypeMessage,string>("LectotypeSaved", "LectotypeSaved", (sender, message) =>
{
if(message.Value != null)
if (message.Value != null)
{
ViewModel.RemoveNotSavedLectotype(message.Value);
}
});
Growl.Register("CableLectotypeMessage", GrowlParent);
}
public void UnRegisterEvent()
{
WeakReferenceMessenger.Default.Unregister<CommonMessage>("RowDetailsVisibility");
WeakReferenceMessenger.Default.Unregister<OpenDrawMessage>("OpenDraw");
WeakReferenceMessenger.Default.Unregister<LectotypeMessage>("Lectotype");
WeakReferenceMessenger.Default.Unregister<LectotypeMessage>("LectotypeSaved");
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
@ -197,16 +207,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
private void Window_Closed(object sender, System.EventArgs e)
{
//DrawPDFHelper.ClearCache();
WeakReferenceMessenger.Default.Unregister<CommonMessage>("RowDetailsVisibility");
WeakReferenceMessenger.Default.Unregister<OpenDrawMessage>("OpenDraw");
WeakReferenceMessenger.Default.Unregister<LectotypeMessage>("Lectotype");
WeakReferenceMessenger.Default.Unregister<LectotypeMessage>("LectotypeSaved");
UnRegisterEvent();
MotorExcelHelper.Instance.CloseStream();
}
}
private void ViewDrawingButton_Click(object sender, RoutedEventArgs e)
{
if (sender is Button btn && btn.Tag != null)