using PdmSwPlugin.Common.Entity.System;
|
using PdmSwPlugin.Common.Interface;
|
using SolidWorks.Interop.sldworks;
|
using System;
|
using System.Windows;
|
using System.Windows.Controls;
|
using SolidWorks.Interop.swconst;
|
using PdmSwPlugin.Common.Setting;
|
using System.Threading.Tasks;
|
using PdmSwPlugin.Common.Util.Http;
|
using System.Collections.Generic;
|
|
namespace PdmSwPlugin.Main
|
{
|
/// <summary>
|
/// MainTab.xaml 的交互逻辑
|
/// </summary>
|
public partial class MainTab : UserControl, ISwAppSetter
|
{
|
private Action logout;
|
public MainTab(Action logout)
|
{
|
this.logout = logout;
|
InitializeComponent();
|
userLabel.Content = $"欢迎您,{PdmUser.LoginUser?.realname}";
|
configLabel.Content = CustomerSetting.Instance["historyFlag"];
|
}
|
|
private SldWorks swApp;
|
public SldWorks SwApp => swApp;
|
|
public void SetSwApp(SldWorks SwApp)
|
{
|
this.swApp = SwApp;
|
}
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
{
|
if (SwApp.SendMsgToUser2("确定退出登录吗?", (int)swMessageBoxIcon_e.swMbWarning,
|
(int)swMessageBoxBtn_e.swMbYesNo) == (int)swMessageBoxResult_e.swMbHitYes)
|
{
|
logout();
|
}
|
}
|
|
private void Refresh_Click(object sender, RoutedEventArgs e)
|
{
|
configLabel.Content = "刷新中...";
|
Task.Run(() =>
|
{
|
try
|
{
|
Result<Dictionary<string, string>> res = HttpClientCreator.PostSyncAction<Dictionary<string, string>>("openApi/wpf/refreshConfig", null);
|
Dictionary<string, string> setting = res.HandleResult();
|
CustomerSetting.Set(setting);
|
}
|
catch (Exception ex)
|
{
|
|
}
|
finally
|
{
|
Dispatcher.Invoke(() =>
|
{
|
configLabel.Content = CustomerSetting.Instance["historyFlag"];
|
});
|
}
|
});
|
}
|
}
|
}
|