|
|
|
using DyeingComputer.ViewModel;
|
|
|
|
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.Navigation;
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
|
|
|
namespace DyeingComputer.View
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// EngineerSetView.xaml 的交互逻辑
|
|
|
|
/// </summary>
|
|
|
|
public partial class EngineerSetView : UserControl
|
|
|
|
{
|
|
|
|
public EngineerSetView()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
CountDown();
|
|
|
|
// 获取所有可用串口端口,并添加到comboBoxCOM
|
|
|
|
string[] ports = System.IO.Ports.SerialPort.GetPortNames();
|
|
|
|
comboBoxCOM.ItemsSource = ports;
|
|
|
|
comboBoxCOM.Text = Configini.IniReadvalue("SYS", "COM");
|
|
|
|
|
|
|
|
string[] Language = { "en-US", "zh-CN", "zh -TW" };
|
|
|
|
comboBoxLanguage.ItemsSource = Language;
|
|
|
|
comboBoxLanguage.Text = Configini.IniReadvalue("SYS", "Language");
|
|
|
|
}
|
|
|
|
//调用配置文件
|
|
|
|
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
|
|
|
|
|
|
|
private void comboBoxCOM_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
{
|
|
|
|
Configini.IniWritevalue("SYS", "COM", comboBoxCOM.SelectedValue.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void comboBoxLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
{
|
|
|
|
Configini.IniWritevalue("SYS", "Language", comboBoxLanguage.SelectedValue.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CountDown()
|
|
|
|
{
|
|
|
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
|
|
|
{
|
|
|
|
Interval = TimeSpan.FromSeconds(1)//秒
|
|
|
|
};
|
|
|
|
timer1s.Tick += Tick_Event_1S;
|
|
|
|
timer1s.Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
|
|
|
{
|
|
|
|
RX.Text = MainWindowViewModel.RX.ToString();
|
|
|
|
TX.Text = MainWindowViewModel.TX.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|