Browse Source

1

样式分支
fyf 2 years ago
parent
commit
75253368c4
2 changed files with 52 additions and 5 deletions
  1. +7
    -0
      BeDesignerSCADA/MainWindow.xaml
  2. +45
    -5
      BeDesignerSCADA/MainWindow.xaml.cs

+ 7
- 0
BeDesignerSCADA/MainWindow.xaml View File

@@ -122,6 +122,13 @@
</StackPanel>
</Button>

<Button x:Name="LoadBtnValue" Margin="4 0 0 0" Padding="0" Click="LoadBtnValue_Click">
<StackPanel Orientation="Horizontal" Margin="8 0">
<icon:PackIconModern Kind="DiskDownload" VerticalAlignment="Center" Width="14"/>
<TextBlock Text="变量管理" Margin="4 0" VerticalAlignment="Center"/>
</StackPanel>
</Button>

<Button x:Name="MNBtn" Margin="4 0 0 0" Padding="0" Click="MNBtn_Click">
<StackPanel Orientation="Horizontal" Margin="8 0">
<icon:PackIconModern Kind="MessageSend" VerticalAlignment="Center" Width="14"/>


+ 45
- 5
BeDesignerSCADA/MainWindow.xaml.cs View File

@@ -113,6 +113,33 @@ namespace BeDesignerSCADA

#region 其他事件操作
/// <summary>
/// 传入变量管理器地址
/// </summary>
/// <param name="path"></param>
public void VariableManagerPath(string path)
{
try
{
viewModel.VariablePath = path;
DataBusModel.GetInstance().RefreshVariableManager(path);
}
catch (Exception ex)
{

}
}
private void LoadBtnValue_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "变量管理器文件|*.json";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
viewModel.VariablePath = ofd.FileName;
bool isSucess= DataBusModel.GetInstance().RefreshVariableManager(ofd.FileName);
System.Windows.MessageBox.Show(isSucess ? "加载成功!" : "加载失败!");
}
}
/// <summary>
/// 运行
/// </summary>
/// <param name="sender"></param>
@@ -288,9 +315,16 @@ namespace BeDesignerSCADA
{
System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
if (toggle.Tag == null) return;
if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(toggle.Tag.ToString()))

CommunicationPar communication = null;
if (DataBusModel.GetInstance().KeyValues.ContainsKey(viewModel.VariablePath))
{
Class_DataBus.GetInstance().Dic_DeviceData[toggle.Tag.ToString()].Keys?.ToList().ForEach(key => { viewModel.DevValueList.Add(key); });
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); });
}
}
}
@@ -332,11 +366,17 @@ namespace BeDesignerSCADA
/// <param name="e"></param>
private void namebox_DropDownOpened(object sender,EventArgs e)
{
//viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>();
//Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); });
viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>();
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

}
}

Loading…
Cancel
Save