wenxiangchao
3 天以前 b544d5cccd76735e034c8055918a50927b437474
HMI.ParameterManage/ParameterSetting.xaml.cs
@@ -1,6 +1,7 @@
using HMI.Base;
using HMI.Core.Entity;
using HMI.Core.Manager;
using HMI.Core.Setting;
using HMI.Core.Util;
using HMI.UI.Util;
using HMI.Util;
@@ -29,6 +30,8 @@
                Set(ref datasource, value);
            }
        }
        public List<string> groups = new List<string>();
        public ParameterSetting()
        {
@@ -77,10 +80,12 @@
            {
                Datasource = ParameterManager.GetCommonParameter<ObservableCollection<ParameterData>>()
                ?? new ObservableCollection<ParameterData>();
                groups = Datasource.Where(d => !string.IsNullOrEmpty(d.ShowGroup)).Select(d => d.ShowGroup).Distinct().ToList();
            }
            catch (Exception ex)
            {
                Datasource = new ObservableCollection<ParameterData>();
                groups = new List<string>();
                log.Error("Refresh Data Failed.", ex);
                ToastHelper.Error(Window.GetWindow(this), $"{this.lang("App.RefreshFailed")}: {ex.Message}");
            }
@@ -101,7 +106,7 @@
                    Title = title,
                    Owner = Window.GetWindow(this)
                };
                if (modal.Open(data ?? new ParameterData(), Datasource) == true)
                if (modal.Open(data ?? new ParameterData(), Datasource, groups) == true)
                {
                    if (index == -1)
                    {
@@ -243,5 +248,21 @@
            Loaded -= UserControl_Loaded;
        }
        public override bool CanActive()
        {
            if (ParamSetting.IsOptRequirePassword)
            {
                var win = new RequirePasswordWindow
                {
                    Owner = Window.GetWindow(this),
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };
                return win.ShowDialog() == true;
            }
            else
            {
                return true;
            }
        }
    }
}