리크 테스트 gui
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.6 KiB

using System;
using System.IO.Ports;
using System.Windows;
using System.Windows.Controls;
using leak_test_project.Utils;
2 weeks ago
using leak_test_project.Models;
namespace leak_test_project.Views
{
public partial class CommunicationWindow : Window
{
public CommunicationWindow()
{
InitializeComponent();
LoadSettings();
}
private void LoadSettings()
{
var config = ConfigManager.Current;
2 weeks ago
// 사용 가능한 시리얼 포트 목록 조회
string[] ports = SerialPort.GetPortNames();
cbSensorPort.ItemsSource = ports;
cbBoard4251Port.ItemsSource = ports;
// 기존 설정 포트 자동 선택
cbSensorPort.SelectedItem = config.SensorPort;
cbBoard4251Port.SelectedItem = config.Board4251Port;
foreach (ComboBoxItem item in cbSensorBaudRate.Items)
{
if (item.Content.ToString() == config.SensorBaudRate.ToString())
{
cbSensorBaudRate.SelectedItem = item;
break;
}
}
2 weeks ago
foreach (ComboBoxItem item in cbBoard4251BaudRate.Items)
2 weeks ago
{
if (item.Content.ToString() == config.Board4251BaudRate.ToString())
2 weeks ago
{
cbBoard4251BaudRate.SelectedItem = item;
2 weeks ago
break;
}
}
}
private void BtnSave_Click(object sender, RoutedEventArgs e)
{
var config = ConfigManager.Current;
2 weeks ago
if (cbSensorPort.SelectedItem != null)
config.SensorPort = cbSensorPort.SelectedItem.ToString();
if (cbBoard4251Port.SelectedItem != null)
config.Board4251Port = cbBoard4251Port.SelectedItem.ToString();
if (cbSensorBaudRate.SelectedItem is ComboBoxItem sensorBaud)
{
if (int.TryParse(sensorBaud.Content.ToString(), out int baud))
config.SensorBaudRate = baud;
}
if (cbBoard4251BaudRate.SelectedItem is ComboBoxItem boardBaud)
2 weeks ago
{
if (int.TryParse(boardBaud.Content.ToString(), out int baud))
config.Board4251BaudRate = baud;
2 weeks ago
}
ConfigManager.Save();
MessageBox.Show("통신 설정이 저장되었습니다.");
this.DialogResult = true;
this.Close();
}
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}