using parkMonitor.viewModel.detail;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace parkMonitor.viewModel {
	/// <summary>启动窗口ViewModel</summary>
	public class StartDeviceWinServerVM : INotifyPropertyChanged {
		//ip
		string _Ip = "";
		public string Ip {
			get { return _Ip; }
			set { _Ip = value; FirePropertyChanged("Ip"); }
		}

		//ip
		//int _port = 0;
		public int port {
			get {
				try {
					return Int32.Parse(StrPort);
				} catch(Exception) { }
				return 0;
			}
			set {
				if(value <= 0) {
					StrPort = "";
				} else {
					StrPort = value.ToString();
				}
				//Debug.WriteLine(value);
				FirePropertyChanged("port");
			}
		}
		string _StrPort = "";
		public string StrPort {
			get { return _StrPort; }
			set { _StrPort = value; FirePropertyChanged("StrPort"); }
		}

		//命令日志
		string _CommanddLog = "";
		public string CommanddLog {
			get { return _CommanddLog; }
			set { _CommanddLog = value; FirePropertyChanged("CommanddLog"); }
		}

		//命令输入
		string _CommanddInput = "";
		public string CommanddInput {
			get { return _CommanddInput; }
			set { _CommanddInput = value; FirePropertyChanged("CommanddInput"); }
		}

		//详细信息ViewModel
		ObservableCollection<DevDetailItemVM> _DevInfoDetail = new ObservableCollection<DevDetailItemVM>();
		public ObservableCollection<DevDetailItemVM> DevInfoDetail {
			get { return _DevInfoDetail; }
			set { _DevInfoDetail = value; FirePropertyChanged("DevInfoDetail"); }
		}

		public virtual event PropertyChangedEventHandler PropertyChanged;
		public virtual void FirePropertyChanged(string propertyName) {
			if(PropertyChanged != null) {
				PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
