Add project files.
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using SafeBagDE70.Services;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
///
|
||||
public partial class MainWindow : HandyControl.Controls.Window
|
||||
{
|
||||
private WelcomeUC _welcomeUC;
|
||||
private DepositSMUCv2 _depositUC;
|
||||
private CollectionUC _collectionUC;
|
||||
private InformationUC _informationUC;
|
||||
private ErrorUC _errorUC;
|
||||
private UserControl _currentUC;
|
||||
private UserControl _prevUC;
|
||||
private TimeoutUC _timeoutUC;
|
||||
private MaintainanceUC _maintainanceUC;
|
||||
private EndSessionUC _endSessionUC;
|
||||
private object objLock = new object();
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += MainWindow_Loaded;
|
||||
}
|
||||
|
||||
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.Init();
|
||||
if (_welcomeUC == null) _welcomeUC = new WelcomeUC();
|
||||
if (_collectionUC == null) _collectionUC = new CollectionUC();
|
||||
if (_informationUC == null) _informationUC = new InformationUC();
|
||||
if (_errorUC == null) _errorUC = new ErrorUC();
|
||||
if (_depositUC == null) _depositUC = new DepositSMUCv2();
|
||||
if (_timeoutUC == null) _timeoutUC = new TimeoutUC();
|
||||
if (_maintainanceUC == null) _maintainanceUC = new MaintainanceUC();
|
||||
if (_endSessionUC == null) _endSessionUC = new EndSessionUC();
|
||||
|
||||
|
||||
gridMain.Children.Add(_welcomeUC);
|
||||
gridMain.Children.Add(_depositUC);
|
||||
gridMain.Children.Add(_collectionUC);
|
||||
gridMain.Children.Add(_informationUC);
|
||||
gridMain.Children.Add(_errorUC);
|
||||
gridMain.Children.Add(_timeoutUC);
|
||||
gridMain.Children.Add(_maintainanceUC);
|
||||
gridMain.Children.Add(_endSessionUC);
|
||||
|
||||
ShowWelcomeScreen();
|
||||
//ShowDepositScreen();
|
||||
}
|
||||
|
||||
public void HideAll()
|
||||
{
|
||||
lock(objLock)
|
||||
{
|
||||
foreach (var item in gridMain.Children)
|
||||
{
|
||||
if (item != null)
|
||||
(item as UserControl).Visibility = Visibility.Hidden;
|
||||
}
|
||||
//_collectionUC.Visibility = Visibility.Hidden;
|
||||
//_informationUC.Visibility = Visibility.Hidden;
|
||||
//_errorUC.Visibility = Visibility.Hidden;
|
||||
//_depositUC.Visibility = Visibility.Hidden;
|
||||
//_welcomeUC.Visibility = Visibility.Hidden;
|
||||
//_maintainanceUC.Visibility=Visibility.Hidden;
|
||||
//_endSessionUC.Visibility = Visibility.Hidden;
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
|
||||
}
|
||||
public void ShowEndSessionScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
HideAll();
|
||||
_endSessionUC.Visibility= Visibility.Visible;
|
||||
}
|
||||
public void ShowInformationScreen(string strInfor,bool bContinue=false,bool bPlaySound=true,List<Control> lstControls=null)
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _informationUC;
|
||||
HideAll();
|
||||
_informationUC.Visibility = Visibility.Visible;
|
||||
_informationUC.ShowInfor(strInfor, bContinue, bPlaySound,lstControls);
|
||||
}
|
||||
public void ShowErrorScreen(string strError)
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _errorUC;
|
||||
HideAll();
|
||||
_errorUC.Visibility = Visibility.Visible;
|
||||
_errorUC.ShowInfor(strError);
|
||||
}
|
||||
public void ShowWelcomeScreen()
|
||||
{
|
||||
_depositUC.StopTimers();
|
||||
_depositUC.StopWelcomeTimer();
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _welcomeUC;
|
||||
HideAll();
|
||||
_welcomeUC.Init();
|
||||
|
||||
_welcomeUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void ShowDepositScreen(bool bInit=true)
|
||||
{
|
||||
_depositUC.ResetTimers();
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _depositUC;
|
||||
HideAll();
|
||||
_depositUC.Visibility = Visibility.Visible;
|
||||
if(bInit)
|
||||
{
|
||||
_depositUC.EndTransaction();
|
||||
_depositUC.InitTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowCollectionScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _collectionUC;
|
||||
HideAll();
|
||||
_collectionUC.Init();
|
||||
_collectionUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public bool IsMaintainanceScreen()
|
||||
{
|
||||
return _currentUC == _maintainanceUC;
|
||||
}
|
||||
public DepositSMUCv2 GetDepositScreen()
|
||||
{
|
||||
return _depositUC;
|
||||
}
|
||||
public void ShowMaintainanceScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
HideAll();
|
||||
_maintainanceUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void ShowTimeoutScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
HideAll();
|
||||
_timeoutUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void StopTimers()
|
||||
{
|
||||
_depositUC.StopTimers();
|
||||
}
|
||||
|
||||
public bool DoCheck()
|
||||
{
|
||||
return _depositUC.DoCheck();
|
||||
}
|
||||
public void ResetTimers()
|
||||
{
|
||||
_depositUC.ResetTimers();
|
||||
}
|
||||
public void BackScreen()
|
||||
{
|
||||
HideAll();
|
||||
_prevUC.Visibility = Visibility.Visible;
|
||||
_currentUC = _prevUC;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,211 @@
|
||||
using CoreScanner;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeUC : UserControl
|
||||
{
|
||||
public string? QRCodeContent = null;
|
||||
public string? PinCode = null;
|
||||
public bool IsAuthenticated = false;
|
||||
public CCoreScannerClass? cCoreScannerClass=null;
|
||||
public WelcomeUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitQRCodeScanner();
|
||||
}
|
||||
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string pin = PinCodeBox.Password;
|
||||
|
||||
if (ValidatePin(pin))
|
||||
{
|
||||
PinCode=PinCodeBox.Password.ToString();
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (PinCode != null)
|
||||
{
|
||||
var strPincode = PinCode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblPincodeError.Content = "PINCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid PIN. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ForgotPin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Forgot PIN clicked.");
|
||||
}
|
||||
|
||||
private void Help_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Help clicked.");
|
||||
}
|
||||
|
||||
private bool ValidatePin(string pin)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
private async void PinCodeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var onScreenKeyboardProcess = new ProcessStartInfo("osk.exe")
|
||||
{
|
||||
UseShellExecute = true
|
||||
};
|
||||
Process.Start(onScreenKeyboardProcess);
|
||||
try
|
||||
{
|
||||
//var progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
|
||||
//var keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
|
||||
//Process.Start(keyboardPath);
|
||||
// AutomationElement.FromHandle(-1);
|
||||
|
||||
// string keyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
|
||||
// Process.Start(keyboardPath);
|
||||
//await Launcher.LaunchUriAsync(new Uri("ms-inputapp://"));
|
||||
|
||||
//var onScreenKeyboardProcess = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
|
||||
//{
|
||||
// UseShellExecute = true
|
||||
//};
|
||||
//Process.Start(onScreenKeyboardProcess);
|
||||
|
||||
QrCodePanel.Visibility = Visibility.Collapsed;
|
||||
PinCodePanel.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void btnQRCodeLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PinCodePanel.Visibility = Visibility.Collapsed;
|
||||
QrCodePanel.Visibility=Visibility.Visible;
|
||||
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
|
||||
|
||||
}
|
||||
public void InitQRCodeScanner()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instantiate CoreScanner Class
|
||||
cCoreScannerClass = new CCoreScannerClass();
|
||||
|
||||
// Call Open API
|
||||
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
|
||||
scannerTypes[0] = 1; // 1 for all scanner types
|
||||
short numberOfScannerTypes = 1; // Size of the scannerTypes array
|
||||
int status; // Extended API return code
|
||||
|
||||
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
|
||||
|
||||
// Subscribe for barcode events in cCoreScannerClass
|
||||
|
||||
|
||||
// Let's subscribe for events
|
||||
int opcode = 1001; // Method for Subscribe events
|
||||
string outXML; // XML Output
|
||||
string inXML = "<inArgs>" +
|
||||
"<cmdArgs>" +
|
||||
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
|
||||
"<arg-int>1</arg-int>" + // Comma separated event IDs
|
||||
"</cmdArgs>" +
|
||||
"</inArgs>";
|
||||
|
||||
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("Something wrong please check... " + exp.Message);
|
||||
}
|
||||
}
|
||||
private void OnBarcodeEvent(short eventType, ref string pscanData)
|
||||
{
|
||||
string xmlString = pscanData;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(xmlString);
|
||||
|
||||
XmlNode rawDataNode = xmlDoc.SelectSingleNode("//datalabel");
|
||||
string rawDataHex = rawDataNode.InnerText.Trim();
|
||||
|
||||
QRCodeContent = HexStringToString(rawDataHex);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (QRCodeContent != null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == QRCodeContent).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblQRcodeError.Content = "QRCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static string HexStringToString(string hexString)
|
||||
{
|
||||
string[] hexValues = hexString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] bytes = new byte[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
bytes[i] = Convert.ToByte(hexValues[i], 16);
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user