laatzen/Common/CordonelAssemblyLine/MainWindow.xaml.cs
Roland Drabesch e293fc408e After FAI
2022-09-22 16:07:58 +02:00

163 lines
5.8 KiB
C#

using System.Linq;
using System.Threading;
using System.Windows;
namespace CordonelAssemblyLine
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private CancellationTokenSource cancellation = new CancellationTokenSource();
private Picking PickingWindow;
private Leak LeakWindow;
private Marriage MarriageWindow;
public string PickingSlot { get; set; }
public string PickingBarcode { get; set; }
public string LeakSlot { get; set; }
public string LeakStationId { get; set; }
public string MarriageSlot { get; set; }
public string MarriageBarcode { get; set; }
public MainWindow()
{
InitializeComponent();
PickingSlot = System.Configuration.ConfigurationManager.AppSettings["PickingSlot"].ToString();
PickingBarcode = System.Configuration.ConfigurationManager.AppSettings["PickingBarcode"].ToString();
LeakSlot = System.Configuration.ConfigurationManager.AppSettings["LeakSlot"].ToString();
LeakStationId = System.Configuration.ConfigurationManager.AppSettings["LeakStationId"].ToString();
MarriageSlot = System.Configuration.ConfigurationManager.AppSettings["MarriageSlot"].ToString();
MarriageBarcode = System.Configuration.ConfigurationManager.AppSettings["MarriageBarcode"].ToString();
txtPickingBarcode.Text = PickingBarcode;
txtPickingSlot.Text = PickingSlot;
txtLeakStation.Text = LeakStationId;
txtLeakSlot.Text = LeakSlot;
txtMarrieageBarcode.Text = MarriageBarcode;
txtMarrieageSlot.Text = MarriageSlot;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (PickingWindow?.Title == "")
{
PickingWindow = null;
}
if (PickingWindow == null)
{
var tmp = 0;
if (int.TryParse(txtPickingSlot.Text, out tmp))
{
PickingWindow = new Picking(cancellation.Token, txtPickingBarcode.Text, tmp);
PickingWindow.Show();
}
}
else
{
PickingWindow.Focus();
}
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
if (LeakWindow?.Title == "")
{
LeakWindow = null;
}
if (LeakWindow == null)
{
var tmpSlot = 0;
var tmpStation = 0;
if (int.TryParse(txtLeakSlot.Text, out tmpSlot) && int.TryParse(txtLeakStation.Text, out tmpStation))
{
LeakWindow = new Leak(cancellation.Token, tmpSlot, tmpStation, txtTester.Text);
LeakWindow.Show();
}
}
else
{
LeakWindow.Focus();
}
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
if (MarriageWindow?.Title == "")
{
MarriageWindow = null;
}
if (MarriageWindow == null)
{
var tmp = 0;
if (int.TryParse(txtMarrieageSlot.Text, out tmp))
{
MarriageWindow = new Marriage(cancellation.Token, tmp, txtMarrieageBarcode.Text);
MarriageWindow.Show();
}
}
else
{
MarriageWindow.Focus();
}
}
private System.Collections.Generic.List<Ui.ProductionControls.ctlPictureProgressBar.ImageElement> progressbars = new System.Collections.Generic.List<Ui.ProductionControls.ctlPictureProgressBar.ImageElement>();
string el1 = "nicht so lang";
string el2 = "Maximal dreißig zeichen 30!!!";
string el3 = "viel zu viele zeichen man kann auch nicht alles haben3";
private void Btn1_Click(object sender, RoutedEventArgs e)
{
progressbars.Add(new Ui.ProductionControls.ctlPictureProgressBar.ImageElement() { Image = Ui.ProductionControls.Enums.Img.Cloud, Name = el1});
progressbars.Add(new Ui.ProductionControls.ctlPictureProgressBar.ImageElement() { Image = Ui.ProductionControls.Enums.Img.Compare, Name = el2});
progressbars.Add(new Ui.ProductionControls.ctlPictureProgressBar.ImageElement() { Image = Ui.ProductionControls.Enums.Img.Irda, Name = el3 });
progressBar.AddRange(progressbars);
progressbars.Where(n => n.Name == el1).First().State = Ui.ProductionControls.Enums.ImgStatus.InProgress;
}
private void Btn2_Click(object sender, RoutedEventArgs e)
{
progressbars.Where(n => n.Name == el1).First().State = Ui.ProductionControls.Enums.ImgStatus.Success;
progressbars.Where(n => n.Name == el2).First().State = Ui.ProductionControls.Enums.ImgStatus.InProgress;
}
private void Btn3_Click(object sender, RoutedEventArgs e)
{
progressbars.Where(n => n.Name == el2).First().State = Ui.ProductionControls.Enums.ImgStatus.Success;
progressbars.Where(n => n.Name == el3).First().State = Ui.ProductionControls.Enums.ImgStatus.InProgress;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (PickingWindow != null)
{
PickingWindow.Close();
}
if (LeakWindow != null)
{
LeakWindow.Close();
}
if (MarriageWindow != null)
{
MarriageWindow.Close();
}
}
}
}