207 lines
7.6 KiB
C#
207 lines
7.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using ProductionUiCordonelLegacy.Model;
|
|
|
|
namespace ProductionUiCordonelLegacy
|
|
{
|
|
/// <summary>
|
|
/// Interaktionslogik für MultiMode.xaml
|
|
/// </summary>
|
|
public partial class MultiMode : Window
|
|
{
|
|
//#region Raw Input API
|
|
|
|
//[DllImport("User32.dll")]
|
|
//extern static uint GetRawInputDeviceList(IntPtr pRawInputDeviceList, ref uint uiNumDevices, uint cbSize);
|
|
|
|
//[DllImport("User32.dll")]
|
|
//extern static uint GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize);
|
|
|
|
//[DllImport("User32.dll")]
|
|
//extern static bool RegisterRawInputDevices(RAWINPUTDEVICE[] pRawInputDevice, uint uiNumDevices, uint cbSize);
|
|
|
|
//[DllImport("User32.dll")]
|
|
//extern static uint GetRawInputData(IntPtr hRawInput, uint uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
|
|
|
|
//#endregion
|
|
|
|
MultiModeMasterViewModel multiModeMasterViewModel = new MultiModeMasterViewModel();
|
|
|
|
private List<MultiModeChild> Childs = new List<MultiModeChild>();
|
|
|
|
public ApplicationSettings AppSettings { get; private set; }
|
|
//class RawInputDevice : InputDevice
|
|
//{
|
|
// public override IInputElement Target => throw new NotImplementedException();
|
|
|
|
// public override PresentationSource ActiveSource => throw new NotImplementedException();
|
|
//}
|
|
public MultiMode()
|
|
{
|
|
|
|
DataContext = multiModeMasterViewModel;
|
|
|
|
InitializeComponent();
|
|
Topmost = false;
|
|
}
|
|
private void keyUp(Object sender, KeyEventArgs e)
|
|
{
|
|
|
|
}
|
|
public void SetBaseFocus()
|
|
{
|
|
//foreach (var item in Childs)
|
|
//{
|
|
// item.Key.Activate();
|
|
//}
|
|
//this.Activate();
|
|
//txtBarcodeInput.Focus();
|
|
|
|
}
|
|
|
|
|
|
private MultiModeChild addChild(IMultiModeChildViewModel model)
|
|
{
|
|
var a = new MultiModeChild(model);
|
|
|
|
a.Show();
|
|
return a;
|
|
}
|
|
CancellationTokenSource cts;
|
|
|
|
private void Window_Loaded(Object sender, RoutedEventArgs e)
|
|
{
|
|
cts = new CancellationTokenSource();
|
|
AppSettings = new ApplicationSettings("MultiProductionUiConfig.json");
|
|
multiModeMasterViewModel.StartPicking(cts);
|
|
//var trigger = new List<string>();
|
|
|
|
//if (AppSettings.ChildForms == null || !AppSettings.ChildForms.Any())
|
|
//{
|
|
// AppSettings.ChildForms = new List<ApplicationSettings.MultiFormChilds>();
|
|
|
|
// AppSettings.ChildForms.Add(new ApplicationSettings.MultiFormChilds() { Name = "Picking", Slot = 1, ViewModelType = typeof(PickingMultiModeViewModel), StartPos = null, Visisble = true, TextPort = "COM11" });
|
|
// AppSettings.ChildForms.Add(new ApplicationSettings.MultiFormChilds() { Name = "PressureHE", Slot = 3, ViewModelType = typeof(PressureMultiModeViewModel), StartPos = null, Visisble = true, TextPort = null });
|
|
// AppSettings.ChildForms.Add(new ApplicationSettings.MultiFormChilds() { Name = "PressureHY", Slot = 1, ViewModelType = typeof(PressureMultiModeViewModel), StartPos = null, Visisble = true, TextPort = null });
|
|
// AppSettings.ChildForms.Add(new ApplicationSettings.MultiFormChilds() { Name = "Marriage", Slot = 4, ViewModelType = typeof(MarriageMultiModeViewModel), StartPos = null, Visisble = true, TextPort = "COM1" });
|
|
// AppSettings.Update("MultiProductionUiConfig.json");
|
|
//}
|
|
|
|
|
|
////AppSettings.ChildForms.ForEach(c => trigger.Add(c.TextPort.ToString()));
|
|
|
|
//cts = new CancellationTokenSource();
|
|
|
|
//foreach (var item in AppSettings.ChildForms)
|
|
//{
|
|
// if (item.Visisble)
|
|
// {
|
|
|
|
|
|
// IMultiModeChildViewModel mdl = null;
|
|
// if (item.ViewModelType == typeof(PickingMultiModeViewModel))
|
|
// {
|
|
// mdl = new PickingMultiModeViewModel(item.Name, item.Slot, trigger, AppSettings.StationId);
|
|
// }
|
|
// else if (item.ViewModelType == typeof(PressureMultiModeViewModel))
|
|
// {
|
|
// mdl = new PressureMultiModeViewModel(item.Name, item.Slot, trigger, AppSettings.StationId);
|
|
// }
|
|
// else if (item.ViewModelType == typeof(MarriageMultiModeViewModel))
|
|
// {
|
|
// mdl = new MarriageMultiModeViewModel(item.Name, item.Slot, trigger, AppSettings.StationId);
|
|
// }
|
|
// if (mdl == null)
|
|
// {
|
|
// throw new ApplicationException("Bad configuration or old software");
|
|
// }
|
|
// var child = addChild(mdl);
|
|
|
|
// child.StartTextInputListener(item.TextPort, cts.Token);
|
|
|
|
// if (item.StartPos != null)
|
|
// {
|
|
// child.WindowStartupLocation = WindowStartupLocation.Manual;
|
|
// child.Top = item.StartPos.Top;
|
|
// child.Left = item.StartPos.Left;
|
|
// child.Height = item.StartPos.Height;
|
|
// child.Width = item.StartPos.Width;
|
|
// child.UseDefaultPos = false;
|
|
// }
|
|
// child.PosChanged += delegate (object val, EventArgs a)
|
|
// {
|
|
// if (val is MultiModeChild mmc)
|
|
// {
|
|
// if (mmc.ViewModel is BaseMultiModeChildViewModel baseChild)
|
|
// {
|
|
// var aasd = AppSettings.ChildForms.FirstOrDefault(c => c.Name == baseChild.ChildName);
|
|
// aasd.StartPos = new ApplicationSettings.Pos() { Height = mmc.Height, Left = mmc.Left, Top = mmc.Top, Width = mmc.Width };
|
|
|
|
// AppSettings.Update("MultiProductionUiConfig.json");
|
|
// }
|
|
// }
|
|
|
|
// };
|
|
|
|
|
|
// child.Show();
|
|
|
|
// Childs.Add(child);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
//SetBaseFocus();
|
|
}
|
|
|
|
private void delegeChild_PosChange(Object sender, EventArgs e)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
private void TxtBarcodeInput_TextChanged(Object sender, TextChangedEventArgs e)
|
|
{
|
|
//if (sender is TextBox text)
|
|
//{
|
|
// if (text.Text.ToLower().Contains("clear"))
|
|
// {
|
|
// text.Text = string.Empty;
|
|
// }
|
|
// else if (text.Text.Contains(System.Environment.NewLine))
|
|
// {
|
|
// foreach (var dispatchChild in Childs.Where(x => x.Value == text.Text[0]))
|
|
// {
|
|
// dispatchChild.Key.InputText(text.Text.Substring(1, text.Text.Length - 1).Trim());
|
|
// }
|
|
|
|
// text.Text = "";
|
|
// SetBaseFocus();
|
|
// }
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
private void Window_Closed(Object sender, EventArgs e)
|
|
{
|
|
|
|
cts.Cancel();
|
|
|
|
|
|
foreach (var item in Childs)
|
|
{
|
|
item.Dispose();
|
|
|
|
item.Close();
|
|
}
|
|
}
|
|
}
|
|
}
|