using parkMonitor.viewModel.detail;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
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 parkMonitor.view.writePLCWin {
	/// <summary>写入PLC窗口</summary>
	public partial class WritePLCWin : Window {
		public int addr = 0;
		public string devNameDesc = "";
		public string statusDesc = "";
		public string defValue = "";

		public bool isOk = false;
		public string value = "";

		public WritePLCWin() {
			InitializeComponent();
		}

		public void show(Window parent) {
			Owner = parent;

			isOk = false;
			lblAddr.Text = addr.ToString();
			lblDevNameDesc.Text = devNameDesc;
			lblStatusDesc.Text = statusDesc;
			txtWrite.Text = defValue;

			ShowDialog();
		}

		public void show(Window parent, string _devNameDesc, DevDetailItemVM vm) {
			addr = vm.Address;
			devNameDesc = _devNameDesc;
			statusDesc = vm.Name;
			defValue = vm.RealValue;
			
			show(parent);
		}

		private void btnOk_Click(object sender, RoutedEventArgs e) {
			isOk = true;
			
			value = txtWrite.Text;

			Close();
		}

		private void btnCancel_Click(object sender, RoutedEventArgs e) {
			Close();
		}

		private void txtWrite_TextChanged(object sender, TextChangedEventArgs e) {

		}
	}
}
