78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace FAtoPA.Net
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for Window1.xaml
|
|
/// </summary>
|
|
public partial class InputBox : Window
|
|
{
|
|
private String _key;
|
|
public String FsmState { get => _key; }
|
|
private short _value;
|
|
public short ModbusRegister { get => _value; }
|
|
private List<short> ModbusRegisters;
|
|
|
|
|
|
public InputBox(string key, short value)
|
|
{
|
|
_key = key;
|
|
_value = value;
|
|
ModbusRegisters = new List<short>();
|
|
for (short i = 0; i < 10; i++)
|
|
{
|
|
ModbusRegisters.Add(i);
|
|
}
|
|
InitializeComponent();
|
|
cbModbusRegister.ItemsSource = ModbusRegisters;
|
|
|
|
txtLogicalState.Text = key;
|
|
cbModbusRegister.SelectedIndex = ModbusRegisters.IndexOf(value);
|
|
|
|
|
|
DataContext = this;
|
|
|
|
}
|
|
|
|
private void Cancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.DialogResult = false;
|
|
Close();
|
|
}
|
|
|
|
private void OK_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (cbModbusRegister.SelectedIndex != -1)
|
|
{
|
|
var selected = cbModbusRegister.SelectedItem;
|
|
if (selected != null)
|
|
{
|
|
short vv = (short)selected;
|
|
if (vv!= _value)
|
|
{
|
|
_value = vv;
|
|
this.DialogResult = true;
|
|
} else { this.DialogResult = false; }
|
|
Close();
|
|
return;
|
|
}
|
|
|
|
}
|
|
MessageBox.Show("Please select a Modbus Register");
|
|
}
|
|
}
|
|
|
|
}
|