diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs index 56e1b1ef..9cb8c72c 100644 --- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs @@ -345,7 +345,13 @@ namespace BeDesignerSCADA.Controls { System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender; if (toggle.Tag == null) return; - CommunicationModel mode=viewModel.communicationPar?.CommunicationDevices?.ToList().Find(par => par.DeviceName == toggle.Tag.ToString()); + + CommunicationPar communication = null; + if (DataBusModel.GetInstance().KeyValues.ContainsKey(viewModel.VariablePath)) + { + communication = DataBusModel.GetInstance().KeyValues[viewModel.VariablePath]; + } + CommunicationModel mode= communication?.CommunicationDevices?.ToList().Find(par => par.DeviceName == toggle.Tag.ToString()); if (mode != null) { mode?.VarTableModels?.ToList().ForEach(par => { viewModel.DevValueList.Add(par.VarName); }); @@ -391,7 +397,12 @@ namespace BeDesignerSCADA.Controls private void namebox_DropDownOpened(object sender, EventArgs e) { viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection(); - viewModel.communicationPar?.CommunicationDevices?.ToList().ForEach(x => { viewModel.DevNameList.Add(x.DeviceName); }); + CommunicationPar communication = null; + if (DataBusModel.GetInstance().KeyValues.ContainsKey(viewModel.VariablePath)) + { + communication = DataBusModel.GetInstance().KeyValues[viewModel.VariablePath]; + } + communication?.CommunicationDevices?.ToList().ForEach(x => { viewModel.DevNameList.Add(x.DeviceName); }); } #endregion } diff --git a/BeDesignerSCADA/ViewModel/DataBusModel.cs b/BeDesignerSCADA/ViewModel/DataBusModel.cs index 32cd725a..83a47665 100644 --- a/BeDesignerSCADA/ViewModel/DataBusModel.cs +++ b/BeDesignerSCADA/ViewModel/DataBusModel.cs @@ -46,10 +46,6 @@ namespace BeDesignerSCADA.ViewModel } #endregion /// - /// 刷新界面 - /// - public Action RefreshTheVariableManagerAction; - /// /// 刷新界面管理器 /// /// @@ -68,7 +64,6 @@ namespace BeDesignerSCADA.ViewModel KeyValues = new ConcurrentDictionary(); } KeyValues[path] = val; - RefreshTheVariableManagerAction?.Invoke(path); IsSucess = true; } } diff --git a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs index 718ae6e1..88163615 100644 --- a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs +++ b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs @@ -37,7 +37,7 @@ namespace BeDesignerSCADA.ViewModel { IsRunning = !IsRunning; }); - DataBusModel.GetInstance().RefreshTheVariableManagerAction += RefreshTheVariableManagerActionHader; + //DataBusModel.GetInstance().RefreshTheVariableManagerAction += RefreshTheVariableManagerActionHader; } #region 变量 @@ -214,13 +214,13 @@ namespace BeDesignerSCADA.ViewModel { try { - if (path == VariablePath && !string.IsNullOrEmpty(VariablePath)) - { - if (DataBusModel.GetInstance().KeyValues.ContainsKey(VariablePath)) - { - communicationPar = DataBusModel.GetInstance().KeyValues[VariablePath]; - } - } + //if (path == VariablePath && !string.IsNullOrEmpty(VariablePath)) + //{ + // if (DataBusModel.GetInstance().KeyValues.ContainsKey(VariablePath)) + // { + // communicationPar = DataBusModel.GetInstance().KeyValues[VariablePath]; + // } + //} } catch (Exception ex) {