58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
namespace CordonelAssemblyLine
|
|
{
|
|
using Stichproben.Cordonel;
|
|
|
|
using System.ComponentModel;
|
|
using System.Windows;
|
|
|
|
public partial class ShouldBePressureTestedModal : Window
|
|
{
|
|
private ShouldBePressureTestedModal(int pcbId)
|
|
{
|
|
this.InitializeComponent();
|
|
|
|
if (this.DataContext is ShouldBePressureTestedModalVM vm)
|
|
{
|
|
if (vm.ShouldBePressureTested(pcbId))
|
|
{
|
|
this.ShowDialog();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CloseModal(object _, RoutedEventArgs _1)
|
|
=> this.Close();
|
|
|
|
public static void Check(int pcbId)
|
|
=> new ShouldBePressureTestedModal(pcbId);
|
|
}
|
|
|
|
public class ShouldBePressureTestedModalVM : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
private string ruleText;
|
|
public string RuleText
|
|
{
|
|
get => this.ruleText;
|
|
set
|
|
{
|
|
this.ruleText = value;
|
|
|
|
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(RuleText)));
|
|
}
|
|
}
|
|
|
|
internal bool ShouldBePressureTested(int pcbId)
|
|
{
|
|
var assemblyLocation = typeof(App).Assembly.Location;
|
|
var stichproben = new Stichproben(assemblyLocation);
|
|
var result = stichproben.ShouldBePressureTested(pcbId);
|
|
|
|
this.RuleText = $"{result.Rule}% von {result.Count} Stk.";
|
|
|
|
return result.ShouldBePressureTested;
|
|
}
|
|
}
|
|
}
|