125 lines
4.5 KiB
C#
125 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Threading;
|
|
using ProductionUiCordonel.Data;
|
|
using ProductionUiCordonel.Model;
|
|
|
|
namespace ProductionUiCordonel.ctls
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ctlMultiModePicking.xaml
|
|
/// </summary>
|
|
public partial class ctlMultiModePicking : UserControl
|
|
{
|
|
private PickingMultiModeViewModel ViewModel;
|
|
public ctlMultiModePicking()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
public void setViewModel(PickingMultiModeViewModel viewModel)
|
|
{
|
|
ViewModel = viewModel;
|
|
ViewModel.MeterDetectedHandler += ViewModel_MeterDetectedHandler;
|
|
viewModel.OnDataChanged += PickingData_OnDataChanged;
|
|
ViewModel.OnUpdateUi += UpdatePickingUi;
|
|
}
|
|
|
|
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
|
|
{
|
|
|
|
|
|
var ts = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
|
|
ViewModel.CurrentMeter.Login();
|
|
ViewModel.CurrentMeter.WriteRegister("GENESISFLOW_SealDisplay", 0);
|
|
ViewModel.CurrentMeter.WriteRegister("POWERMON_WarnFromClamp", (UInt32)473040000);
|
|
ViewModel.CurrentMeter.WriteRegister("SYSTEM_CalendarSeconds", Convert.ToInt32(ts.TotalSeconds));
|
|
ViewModel.CurrentMeter.SetLcdText(false, new Byte[] { 0x12, 0x34 });
|
|
|
|
|
|
//ViewModel.ReloadData(false);
|
|
}
|
|
}
|
|
));
|
|
}
|
|
|
|
private void UpdatePickingUi(Object sender, EventArgs e)
|
|
{
|
|
icPicking.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
|
|
{
|
|
lblStatus.Content = ViewModel.StatusText;
|
|
lblStatus.Background = ViewModel.StatusColor;
|
|
lblPickingOrder.Content = $"{ViewModel.Order}({ViewModel.Done}/{ViewModel.ToDo}";
|
|
if (ViewModel.Done > 0 && ViewModel.Done >= ViewModel.ToDo)
|
|
{
|
|
MessageBox.Show("Order is Finish");
|
|
lblStatus.Content = "Please input a new order number";
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
private void PickingData_OnDataChanged(Object sender, EventArgs e)
|
|
{
|
|
if (sender is ObservableCollection<IPickingResultData> newData)
|
|
{
|
|
icPicking.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { icPicking.ItemsSource = newData; }));
|
|
}
|
|
|
|
icPicking.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { lblStatus.Content = ViewModel.StatusText; lblStatus.Background = ViewModel.StatusColor; }));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//private void UpdatePickingUi(string state, System.Windows.Media.Brush StateColor, string Order, int toDo, int Done)
|
|
//{
|
|
// icPicking.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
|
|
// {
|
|
// lblStatus.Content = state;
|
|
// lblStatus.Background = StateColor;
|
|
// lblPickingOrder.Content = $"{Order}({Done}/{toDo}";
|
|
// txtHiddenInput.Focus();
|
|
// if (Done > 0 && Done >= toDo)
|
|
// {
|
|
// MessageBox.Show("Order is Finish");
|
|
// txtOrderNr.Text = "";
|
|
// lblStatus.Content = "Please input a new order number";
|
|
// }
|
|
|
|
// }));
|
|
|
|
//}
|
|
|
|
//private void PickingData_OnDataChanged(object sender, EventArgs e)
|
|
//{
|
|
// if (sender is ObservableCollection<IPickingResultData> newData)
|
|
// {
|
|
// icPicking.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { icPicking.ItemsSource = newData; }));
|
|
// }
|
|
|
|
// icPicking.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { lblStatus.Content = PickingData.StatusText; lblStatus.Background = PickingData.StatusColor; }));
|
|
|
|
|
|
|
|
|
|
//}
|
|
}
|
|
}
|