66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
using SafeBagDE70.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
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.Shapes;
|
|
using System.Windows.Threading;
|
|
|
|
namespace SafeBagDE70
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for QRCodeWindow.xaml
|
|
/// </summary>
|
|
public partial class QRCodeWindow : HandyControl.Controls.Window
|
|
{
|
|
private DispatcherTimer timer;
|
|
int countTimer = 0;
|
|
public string QRCodeContent = null;
|
|
public QRCodeWindow()
|
|
{
|
|
InitializeComponent();
|
|
this.KeyDown += QRCodeWindow_KeyDown;
|
|
this.Loaded += QRCodeWindow_Loaded;
|
|
}
|
|
private void QRCodeWindow_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
Keyboard.Focus(this);
|
|
timer = new DispatcherTimer();
|
|
|
|
// Set the timer interval to 1 second
|
|
timer.Interval = TimeSpan.FromMilliseconds(100);
|
|
|
|
// Define the event handler that's called each time the timer elapses
|
|
timer.Tick += Timer_Tick;
|
|
|
|
// Start the timer
|
|
timer.Start();
|
|
}
|
|
private void Timer_Tick(object sender, EventArgs e)
|
|
{
|
|
countTimer++;
|
|
if (QRCodeContent!=null && countTimer == 5)
|
|
{
|
|
DialogResult = true;
|
|
this.Close();
|
|
//finish
|
|
}
|
|
}
|
|
|
|
private void QRCodeWindow_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
QRCodeContent += KeyModel.GetCharFromKey(e.Key);
|
|
countTimer = 0;
|
|
}
|
|
|
|
}
|
|
}
|