基本信息
源码名称:扫码枪 扫描二维码即可通行(wpf),可用于签到
源码大小:0.55M
文件格式:.zip
开发语言:C#
更新时间:2019-03-04
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using Common;
using Common.Dialog;
using Common.Log;
using NeoVisitor.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
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 NeoVisitor
{
/// <summary>
/// 主控系统
/// </summary>
public partial class MainWindow : Window
{
private MainViewModel vm = null;
private FuncTimeout timeout = null;
private DispatcherTimer _updateTimer = null;
private string[] _rebootWeekofday = null;
public MainWindow()
{
InitializeComponent();
vm = new Core.MainViewModel();
this.DataContext = vm;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
timeout = new FuncTimeout();
AutoRun();
vm.Init();
_rebootWeekofday = ConfigProfile.Instance.RebootWeekofDay.Split(',');
_updateTimer = new DispatcherTimer();
_updateTimer.Interval = TimeSpan.FromSeconds(1);
_updateTimer.Tick = UpdateTimer_Tick;
_updateTimer.Start();
}
private void UpdateTimer_Tick(object sender, EventArgs e)
{
txtBarcode.Focus();
RebootMachine();
}
private void RebootMachine()
{
int day = (int)DateTime.Now.DayOfWeek;
if (_rebootWeekofday.Length < day)
return;
if (_rebootWeekofday[day] == "1")
{
var nowTime = DateTime.Now.ToString("HH:mm");
if (nowTime == ConfigProfile.Instance.RebootTime)
{
_updateTimer.Stop();
LogHelper.Info("执行重启计划 {0}", nowTime);
RebootMachineAPI.ExitWindow();
}
}
}
private void AutoRun()
{
var appName = System.Windows.Forms.Application.ProductName;
var executePath = System.Windows.Forms.Application.ExecutablePath;
Funs.runWhenStart(false, appName, executePath);
}
private void Image_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.Close();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
var dialog = CustomDialog.Confirm("确认退出系统吗?");
if (dialog == MessageBoxResult.No)
{
e.Cancel = true;
return;
}
vm.Dispose();
}
private void txtBarcode_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
if (txtBarcode.Text.Length > 0)
{
var qrcode = txtBarcode.Text;
Task.Factory.StartNew(() =>
{
vm.ReadBarCode(qrcode);
vm.QRCode = "";
});
}
}
}
}
}