Commit 11276630 authored by 潘栩锋's avatar 潘栩锋 🚴

1.修复 password.json 不存在时,会出错

2.优化 删除DynAreaThick.xaml.cs 多余注解
3.修复 PgGageInfo 多次注入
4.优化 把OnInitAutoScan 移到 FLY.Thick.Base.UI
parent f668ae25
......@@ -142,6 +142,7 @@
<Compile Include="DependOn\LCUS1_dependOn.cs" />
<Compile Include="GageCommands.cs" />
<Compile Include="LCUS1.cs" />
<Compile Include="OnInit\OnInitAutoScan.cs" />
<Compile Include="OnInit\OnInitControllerState.cs" />
<Compile Include="OnInit\OnInitError.cs" />
<Compile Include="OnInit\OnInitGageCommand.cs" />
......
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Thick.Base.UI.OnInit
{
public class OnInitAutoScan : IOnInit
{
IDynAreaService dynAreaService;
FLY.OBJComponents.IService.IWarningService warningService;
ITDGageService tDGageService;
int autoscan_tip_id = -1;
public OnInitAutoScan(IDynAreaService dynAreaService, FLY.OBJComponents.IService.IWarningService warningService, ITDGageService tDGageService, int lv=1)
{
Level = lv;
this.dynAreaService = dynAreaService;
this.warningService = warningService;
this.tDGageService = tDGageService;
}
public int Level { get; }
public void OnInit()
{
dynAreaService.DynArea.PropertyChanged += (s, e) =>
{
DynArea dynArea = s as DynArea;
if (e.PropertyName == "ControllerState")
{
if (dynArea.ControllerState != CTRL_STATE.AUTOSCAN)
{
if (autoscan_tip_id != -1)
{
FLY.ControlLibrary.Window_WarningTip.Stop(autoscan_tip_id);
autoscan_tip_id = -1;
}
}
if (dynArea.ControllerState == CTRL_STATE.PAUSE)
{
FLY.ControlLibrary.Window_WarningTip.Show(
"通知",
"暂停扫描",
TimeSpan.MaxValue);
}
}
else if (e.PropertyName == "AutoScanCounter")
{
if (dynArea.ControllerState == CTRL_STATE.AUTOSCAN)
{
autoscan_tip_id = FLY.ControlLibrary.Window_WarningTip.Show(
"通知",
dynArea.AutoScanCounter.ToString() + "秒后,开始扫描",
TimeSpan.FromSeconds(dynArea.AutoScanCounter),
null,
warningService.Reset,
"取消",
()=> { tDGageService.StartP2(STARTP2_MODE.STOP); });
}
}
};
}
}
}
......@@ -48,8 +48,8 @@ namespace FLY.Thick.Base.UI
}
private void btnGageInfoClick(object sender, RoutedEventArgs e)
{
Page p = (container.IsRegistered<Page>("pgGageInfo")) ? container.Resolve<Page>("pgGageInfo") : new PgGageInfo();
container.BuildUp(p);
Page p = (container.IsRegistered<Page>("pgGageInfo")) ? container.Resolve<Page>("pgGageInfo") : container.Resolve<PgGageInfo>(); ;
//container.BuildUp(p);
NavigationService.Navigate(p);
}
......
......@@ -18,13 +18,7 @@ namespace FLY.Thick.Base.UI.UiModule
{
InitializeComponent();
}
//public void Init(int id)
//{
// //获取设备
// TDGage gage = Application.Current.Properties["Gage"] as TDGage;
// this.DataContext = gage.mDynArea;
// grid_initparam.DataContext = gage.mInitParam;
//}
[InjectionMethod]
public void Init(
IUnityContainer container,
......
......@@ -56,8 +56,17 @@ namespace FLY.Thick.Base.Server
void Load()
{
string json = File.ReadAllText(param_path);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
if (!File.Exists(param_path)) {
return;
}
try
{
string json = File.ReadAllText(param_path);
Newtonsoft.Json.JsonConvert.PopulateObject(json, this);
}
catch {
}
}
#region INotifyPropertyChanged 成员
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment