169 lines
5.9 KiB
C#
169 lines
5.9 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Threading;
|
|
using ProductionUiCordonelLegacy.Event;
|
|
using ProductionUiCordonelLegacy.Model;
|
|
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
|
|
|
namespace ProductionUiCordonelLegacy.ctls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ctlMultiModePressure.xaml
|
|
/// </summary>
|
|
public partial class ctlMultiModePressure : UserControl
|
|
{
|
|
public event EventHandler<StringArgs> OnBarcodeInput;
|
|
|
|
private PressureMultiModeViewModel ViewModel;
|
|
public ctlMultiModePressure()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void setViewModel(PressureMultiModeViewModel viewModel)
|
|
{
|
|
ViewModel = viewModel;
|
|
viewModel.MeterDetectedHandler += ViewModel_MeterDetectedHandler;
|
|
ViewModel.OnStoreDone += ViewModel_OnStoreDone;
|
|
//OnBarcodeInput = "PressureControl_OnBarcodeInput"
|
|
//
|
|
if (viewModel.ChildName == "PressureHY")
|
|
{
|
|
ViewModel.StationID = 1;
|
|
lblHeadline.Content = "hydraulisch Dichtheitsprüfung";
|
|
txtLeakrate.Visibility = Visibility.Hidden;
|
|
lblLeakrate.Visibility = Visibility.Hidden;
|
|
listViewTestPotins.Visibility = Visibility.Hidden;
|
|
}
|
|
else
|
|
{
|
|
ViewModel.StationID = 2;
|
|
lblHeadline.Content = "Helium Dichtheitsprüfung";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ViewModel_MeterDetectedHandler(Object sender, EventArgs e)
|
|
{
|
|
Dispatcher.Invoke(DispatcherPriority.Normal,
|
|
new Action(() =>
|
|
{
|
|
Boolean update = false;
|
|
if (sender is null)
|
|
{
|
|
ViewModel.InputIsEnabled = false;
|
|
}
|
|
else
|
|
{
|
|
ViewModel.ReloadData(false);
|
|
}
|
|
}
|
|
));
|
|
}
|
|
|
|
private void BtnPresueOk_Click(Object sender, RoutedEventArgs e)
|
|
{
|
|
ViewModel.StoreData(true);
|
|
}
|
|
|
|
private void BtnPresueFailed_Click(Object sender, RoutedEventArgs e)
|
|
{
|
|
ViewModel.StoreData(false);
|
|
}
|
|
private void ViewModel_OnStoreDone(Object sender, StringArgs e)
|
|
{
|
|
MessageBox.Show(e.Content);
|
|
}
|
|
private Int32? BarcodeInputActiveOffset;
|
|
private String BarcodeInput = "";
|
|
|
|
private void TextBox_TextChanged(Object sender, TextChangedEventArgs e)
|
|
{
|
|
if (sender is TextBox txtSender)
|
|
{
|
|
var c = e.Changes.First();
|
|
if (c.RemovedLength == 0)
|
|
{
|
|
var input = txtSender.Text.Substring(c.Offset, c.AddedLength);
|
|
if (BarcodeInputActiveOffset.HasValue)
|
|
{
|
|
BarcodeInput = $"{BarcodeInput}{input}";
|
|
|
|
if (input == Environment.NewLine)
|
|
{
|
|
var tmpOffset = BarcodeInputActiveOffset.Value;
|
|
BarcodeInputActiveOffset = null;
|
|
//OnBarcodeInput?.Invoke(null, new StringArgs(BarcodeInput));
|
|
txtSender.Text = txtSender.Text.Replace(BarcodeInput, "");
|
|
BarcodeInput = "";
|
|
txtSender.Focus();
|
|
txtSender.CaretIndex = tmpOffset;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ViewModel != null && ViewModel.BarcodeTrigger.Any(t => t == input))
|
|
{
|
|
|
|
BarcodeInput = txtSender.Text.Substring(c.Offset, c.AddedLength);
|
|
BarcodeInputActiveOffset = c.Offset;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void Button_Click(Object sender, RoutedEventArgs e)
|
|
{
|
|
String input = "";
|
|
var obj = ((FrameworkElement)sender).DataContext;
|
|
if (obj is PressureTestPoints ptp)
|
|
{
|
|
ViewModel.Result.SetAllTestPoints(ptp.Input);
|
|
|
|
|
|
}
|
|
var d = listViewTestPotins.DataContext;
|
|
listViewTestPotins.DataContext = null;
|
|
listViewTestPotins.DataContext = d;
|
|
// var c = e.Changes.First();
|
|
// if (c.RemovedLength == 0)
|
|
// {
|
|
// var input = txtSender.Text.Substring(c.Offset, c.AddedLength);
|
|
// if (BarcodeInputActiveOffset.HasValue)
|
|
// {
|
|
// BarcodeInput = $"{BarcodeInput}{input}";
|
|
|
|
// if (input == System.Environment.NewLine)
|
|
// {
|
|
// var tmpOffset = BarcodeInputActiveOffset.Value;
|
|
// BarcodeInputActiveOffset = null;
|
|
// OnBarcodeInput?.Invoke(null, new StringArgs(BarcodeInput));
|
|
// txtSender.Text = txtSender.Text.Replace(BarcodeInput, "");
|
|
// BarcodeInput = "";
|
|
// txtSender.Focus();
|
|
// txtSender.CaretIndex = tmpOffset;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// if (ViewModel != null && ViewModel.BarcodeTrigger.Any(t => t == input))
|
|
// {
|
|
|
|
// BarcodeInput = txtSender.Text.Substring(c.Offset, c.AddedLength);
|
|
// BarcodeInputActiveOffset = c.Offset;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
//}
|
|
}
|
|
}
|
|
}
|