LGES-OC5-PtoP-Welder/AuroraDevices/AuroraLaser/Coherent/Compact/Views/MWLaserCompactCalibSaveDialog.xaml.cs
2026-06-05 13:44:39 +09:00

162 lines
5.2 KiB
C#

using Aurora.Api.Control;
using MahApps.Metro.Controls;
using System.Windows;
using System.Windows.Controls;
namespace AuroraLaser.Views
{
public partial class MWLaserCompactCalibSaveDialog : MetroWindow
{
public enum Result
{
NAN,
Affirmative,
Negative,
}
public enum Type
{
Affirmative = 0,
AffirmativeAndNegative = 1,
}
public string Message { get; private set; }
public Visibility MessageVisiblility {
get => Message == null
? Visibility.Collapsed
: Visibility.Visible;
}
public Visibility ControlVisiblility { get; private set; }
private Result mResult;
public static ePowerModelCalib ResultCalibType { get; private set; }
#region 생성자
protected MWLaserCompactCalibSaveDialog(string title, Type dlgType)
{
InitializeComponent();
mTxtMessage.Visibility = Visibility.Collapsed;
mBorderControl.Visibility = Visibility.Collapsed;
mResult = Result.Negative;
if (dlgType == Type.Affirmative)
mBtnNagative.Visibility = Visibility.Collapsed;
mTxtTitle.Text = title;
}
// 생성자
protected MWLaserCompactCalibSaveDialog(string title, string message, Type dlgType) : this(title, dlgType)
{
mTxtMessage.Text = message;
mTxtMessage.Visibility = Visibility.Visible;
Width = 350;
}
protected MWLaserCompactCalibSaveDialog(string title, string message, Type dlgType, stPowerModelEnable powerModelEnableInfo) : this(title, dlgType)
{
mTxtMessage.Text = message;
mTxtMessage.Visibility = Visibility.Visible;
// radio button enalbe 제어
rbLUT.IsEnabled = powerModelEnableInfo.IsLUTEnable ? true : false;
rbLin1Seg.IsEnabled = powerModelEnableInfo.IsLin1SegEnable ? true : false;
rbLin2Seg.IsEnabled = powerModelEnableInfo.IsLin2SegEnable ? true : false;
// Default 체크 선택: 역순으로 체크하자..
if (rbLin2Seg.IsEnabled) {
rbLin2Seg.IsChecked = true;
} else if (rbLin1Seg.IsEnabled) {
rbLin1Seg.IsChecked = true;
} else if (rbLUT.IsEnabled) {
rbLUT.IsChecked = true;
}
Width = 350;
}
// 생성자
protected MWLaserCompactCalibSaveDialog(string title, ContentControl control, Type dlgType) : this(title, dlgType)
{
mBorderControl.Child = control;
mBorderControl.Visibility = Visibility.Visible;
}
#endregion
private Result Show(Window parent)
{
DialogUtil.ShowDlg(this, parent);
return mResult;
}
public static Result Show(
Window parent,
string title,
string message,
Type dialogType = Type.Affirmative)
{
return new MWLaserCompactCalibSaveDialog(
title,
message,
dialogType).Show(parent);
}
public static Result Show(
Window parent,
string title,
string message,
Type dialogType,
stPowerModelEnable powerModelEnableInfo)
{
return new MWLaserCompactCalibSaveDialog(
title,
message,
dialogType,
powerModelEnableInfo).Show(parent);
}
public static Result Show(
Window parent,
string title,
ContentControl control,
Type dialogType = Type.Affirmative)
{
return new MWLaserCompactCalibSaveDialog(
title,
control,
dialogType) {
SizeToContent = System.Windows.SizeToContent.WidthAndHeight
}.Show(parent);
}
private void Click_Nagative(object sender, RoutedEventArgs e)
{
mResult = Result.Negative;
Close();
}
private void Click_Positive(object sender, RoutedEventArgs e)
{
mResult = Result.Affirmative;
Close();
}
private void HandleCalibSelectorCheck(object sender, RoutedEventArgs e)
{
var name = (string)(sender as RadioButton).Content;
if (name == ePowerModelCalib.LUT.ToString()) {
ResultCalibType = ePowerModelCalib.LUT;
} else if (name == ePowerModelCalib.Lin1Seg.ToString()) {
ResultCalibType = ePowerModelCalib.Lin1Seg;
} else if (name == ePowerModelCalib.Lin2Seg.ToString()) {
ResultCalibType = ePowerModelCalib.Lin2Seg;
}
}
}
}