using FLY.FeedbackRenZiJia.Server; using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Security.Cryptography; 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 FLY.FeedbackRenZiJia.UI.Server { /// /// WdSetup.xaml 的交互逻辑 /// public partial class WdSetup : Window { FeedbackHeat feedback; public WdSetup() { InitializeComponent(); } public void Init(FeedbackHeat feedback) { this.feedback = feedback; string address = feedback.PLCep.ToString(); Misc.StringConverter.ToIPEndPoint("192.168.50.60:502"); this.comboBox.ItemsSource = new int[] { 1, 2, 3 }; int version = 3; if (this.feedback.IsClient == false) { version = 1; } else if (address.CompareTo("192.168.251.20:8000") == 0) { version = 2; } else// if (address.CompareTo("192.168.50.60:502") == 0) { version = 3; } this.comboBox.SelectedItem = version; } private void btnOkClick(object sender, RoutedEventArgs e) { if (MessageBox.Show("需要重启,才能生效", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { int version = (int)this.comboBox.SelectedItem; switch (version) { case 1: { feedback.IsClient = false; feedback.Apply(); } break; case 2: { feedback.IsClient = true; feedback.PLCep = Misc.StringConverter.ToIPEndPoint("192.168.251.20:8000"); feedback.Apply(); } break; default: { feedback.IsClient = true; feedback.PLCep = Misc.StringConverter.ToIPEndPoint("192.168.50.60:502"); feedback.Apply(); } break; } //切换为exe的目录,这样程序再次进入时,才能 进入Gage1 文件夹 System.Environment.CurrentDirectory = "../"; //重启软件 AppHelper.AppJustOne.Restart(); } } } }