149 lines
5.0 KiB
C#
149 lines
5.0 KiB
C#
|
|
using CordonelAssemblyLine.Event;
|
|||
|
|
using CordonelAssemblyLine.Model;
|
|||
|
|
using System;
|
|||
|
|
using System.Threading;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Threading;
|
|||
|
|
|
|||
|
|
namespace CordonelAssemblyLine
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaction logic for Leak.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class Leak : Window
|
|||
|
|
{
|
|||
|
|
private LeakViewModel ViewModel = null;
|
|||
|
|
public Leak(CancellationToken globalCancellationToken, Int32 slotNR, Int32? stationID = null, String Tester= "-")
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
ViewModel = new LeakViewModel(slotNR, stationID);
|
|||
|
|
ViewModel.TesterName = Tester;
|
|||
|
|
DataContext = ViewModel;
|
|||
|
|
ViewModel.MeterDetectedHandler += ViewModel_MeterDetectedHandler;
|
|||
|
|
ViewModel.OnStoreDone += ViewModel_OnStoreDone;
|
|||
|
|
tippBox.Text = ViewModel.ToolTipInput;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnPresueFailed_Click(Object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
ViewModel.StoreData(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnPresueOk_Click(Object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
var ret = ViewModel.StoreData(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void LockForPressureTest()
|
|||
|
|
{
|
|||
|
|
Dispatcher.Invoke(DispatcherPriority.Normal,
|
|||
|
|
new Action(() =>
|
|||
|
|
{
|
|||
|
|
ViewModel.LockedPressure = Visibility.Visible;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ViewModel_OnStoreDone(Object sender, StringPressureArgs e)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(e.Content);
|
|||
|
|
|
|||
|
|
if (e.NeedPressure)
|
|||
|
|
{
|
|||
|
|
Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
|
|||
|
|
{
|
|||
|
|
ViewModel.LockedPressureMessage = e.Content;
|
|||
|
|
ViewModel.LockedPressure = Visibility.Visible;
|
|||
|
|
}));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
private void ViewModel_MeterDetectedHandler(Object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
Dispatcher.Invoke(DispatcherPriority.Normal,
|
|||
|
|
new Action(() =>
|
|||
|
|
{
|
|||
|
|
if (sender is null)
|
|||
|
|
{
|
|||
|
|
ViewModel.InputIsEnabled = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
ViewModel.ReloadData(false);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
ViewModel.InputIsEnabled = false;
|
|||
|
|
MessageBox.Show($"Fehler: {ex.Message}");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
));
|
|||
|
|
}
|
|||
|
|
private void Button_Click(Object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
var obj = ((FrameworkElement)sender).DataContext;
|
|||
|
|
if (obj is Xylem.Common.Logic.ProductionOrderCore.TestResults.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;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Window_Closing(Object sender, System.ComponentModel.CancelEventArgs e)
|
|||
|
|
{
|
|||
|
|
ViewModel.Dispose();
|
|||
|
|
this.Title = "";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnLock_Click(Object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
Dispatcher.Invoke(DispatcherPriority.Normal,
|
|||
|
|
new Action(() =>
|
|||
|
|
{
|
|||
|
|
ViewModel.LockedPressure = Visibility.Hidden;
|
|||
|
|
}));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|