/// <summary> /// 初始化卡片阅读器 /// </summary> private void InitCardReader() { krpcbCardReader.Items.Clear(); krpcbCardReader.Items.Add(Resources.GetRes().GetString("None")); KeyboardHook hook = new KeyboardHook(); var availbleScanners = hook.GetKeyboardDevices(); if (null != availbleScanners && availbleScanners.Count > 0) { foreach (var item in availbleScanners.Distinct()) { if (!krpcbCardReader.Items.Contains(String.Format("{0:X}", item.GetHashCode()))) { krpcbCardReader.Items.Add(String.Format("{0:X}", item.GetHashCode())); if (String.Format("{0:X}", item.GetHashCode()) == Resources.GetRes().CardReader) { krpcbCardReader.SelectedIndex = krpcbCardReader.Items.Count - 1; } } } } if (krpcbCardReader.SelectedIndex == -1) { krpcbCardReader.SelectedIndex = 0; } }
/// <summary> /// 更换读卡 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void krpcbCardReader_SelectedIndexChanged(object sender, EventArgs e) { if (IsOnlyLocal && _isLoaded) { if (cardHooked) { hookCard.RemoveHook(); cardHooked = false; } if (krpcbCardReader.SelectedIndex != 0) { var availbleScanners = hookCard.GetKeyboardDevices(); string first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == krpcbCardReader.Text).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookCard.SetDeviceFilter(first); hookCard.KeyPressed -= OnCardKey; hookCard.KeyPressed += OnCardKey; cardHooked = true; hookCard.AddHook(this); } } } }
/// <summary> /// 更换读卡 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void krpcbCardReader_SelectedIndexChanged() { if (this.IsDisplay) { if (cardHooked) { hookCard.RemoveHook(); cardHooked = false; } RoomStateModel model = resultCardList.Where(x => x.UseState).FirstOrDefault(); if (null != model) { var availbleScanners = hookCard.GetKeyboardDevices(); string first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == model.RoomNo).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookCard.SetDeviceFilter(first); hookCard.KeyPressed -= OnCardKey; hookCard.KeyPressed += OnCardKey; cardHooked = true; hookCard.AddHook(_element as Window); } } } }
/// <summary> /// 初始化卡片阅读器 /// </summary> private void InitCardReader() { resultCardList.Clear(); this.CardList.Children.Clear(); RoomStateModel nullRoomStateModel = new RoomStateModel() { RoomNo = Resources.GetRes().GetString("None") }; resultCardList.Add(nullRoomStateModel); try { KeyboardHook hook = new KeyboardHook(); var availbleScanners = hook.GetKeyboardDevices(); if (null != availbleScanners && availbleScanners.Count > 0) { foreach (var item in availbleScanners.Distinct()) { RoomStateModel model = new RoomStateModel() { RoomNo = String.Format("{0:X}", item.GetHashCode()) }; if (String.Format("{0:X}", item.GetHashCode()) == Resources.GetRes().CardReader) { model.UseState = true; } if (resultCardList.Where(x => x.RoomNo == model.RoomNo).Count() == 0) { resultCardList.Add(model); } } } } catch (Exception ex) { ExceptionPro.ExpLog(ex); } foreach (var item in resultCardList) { AddCardItem(item); } if (resultCardList.Where(x => x.UseState).Count() == 0) { nullRoomStateModel.UseState = true; } }
public MainWindow() { InitializeComponent(); Font font = new Font(Resources.GetRes().GetString("FontName2"), float.Parse(Resources.GetRes().GetString("FontSize"))); this.Text = Resources.GetRes().GetString("SoftServiceName"); krplUpdateInfo.Text = Resources.GetRes().GetString("UpdateInfo"); tsbAout.Text = tsmiAbout.Text = Resources.GetRes().GetString("About"); tsbExpenditure.Text = tsmiExpenditure.Text = Resources.GetRes().GetString("ExpenditureManager"); tsbRoom.Text = tsmiRoom.Text = Resources.GetRes().GetString("RoomManager"); tsbMembers.Text = tsmiMember.Text = Resources.GetRes().GetString("MemberManager"); tsbProduct.Text = tsmiProduct.Text = Resources.GetRes().GetString("ProductManager"); tsbProductType.Text = tsmiProductType.Text = Resources.GetRes().GetString("ProductTypeManager"); tsbMain.Text = tsmiMain.Text = Resources.GetRes().GetString("MainPage"); tsbOrder.Text = tsmiOrder.Text = Resources.GetRes().GetString("IncomeManager"); tsbChangePassword.Text = tsmiChangePassword.Text = Resources.GetRes().GetString("ChangePassword"); tsbChangeSet.Text = tsmiChangeSet.Text = Resources.GetRes().GetString("ChangeSet"); tsmiSupplier.Text = Resources.GetRes().GetString("SupplierManager"); tsmiRequest.Text = Resources.GetRes().GetString("RequestManager"); tsmiAdminLog.Text = Resources.GetRes().GetString("AdminLog"); tsmiBalance.Text = Resources.GetRes().GetString("BalanceManager"); tsmiFinanceLog.Text = Resources.GetRes().GetString("FinanceLog"); tsmiStatistic.Text = Resources.GetRes().GetString("Statistic"); Assembly asm = Assembly.LoadFrom(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Res.dll")); tsbAout.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.About.png")); tsbExpenditure.Image = tsmiExpenditure.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Expenditure.png")); tsbRoom.Image = tsmiRoom.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Room.png")); tsbProduct.Image = tsmiProduct.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Product.png")); tsbProductType.Image = tsmiProductType.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.ProductType22.png")); tsbMain.Image = tsmiMain.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Main.png")); tsbOrder.Image = tsmiOrder.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Order.png")); tsbMembers.Image = tsmiMember.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Members.png")); tsbChangePassword.Image = tsmiChangePassword.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.ChangePassword.png")); tsbChangeSet.Image = tsmiChangeSet.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.ChangeSet.png")); tsmiExit.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Exit.png")); tsmiDevice.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Device.png")); tsmiAdmin.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Admin.png")); tsmiPrinter.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Printer.png")); tsmiSupplier.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Suppliers.png")); tsmiRequest.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Request.png")); tsmiAdminLog.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.AdminLog.png")); tsmiFinanceLog.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.FinanceLog.png")); tsmiBalance.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.BalanceManager.png")); tsmiStatistic.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Statistic.png")); tsList.ImageScalingSize = new Size(32.RecalcMagnification(), 32.RecalcMagnification()); this.Icon = new Icon(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.TradingSystem.ico")); tsmiFile.Text = Resources.GetRes().GetString("File"); tsmiMenu.Text = Resources.GetRes().GetString("Menu"); tsmiLanguage.Text = Resources.GetRes().GetString("Language"); tsmiExit.Text = Resources.GetRes().GetString("Exit"); tsmiSystem.Text = Resources.GetRes().GetString("System"); tsmiAdmin.Text = Resources.GetRes().GetString("AdminManager"); tsmiDevice.Text = Resources.GetRes().GetString("DeviceManager"); tsmiPrinter.Text = Resources.GetRes().GetString("PrinterManager"); tsbAout.Font = tsmiAbout.Font = font; tsbExpenditure.Font = tsmiExpenditure.Font = font; tsbMembers.Font = tsmiMember.Font = font; tsbRoom.Font = tsmiRoom.Font = font; tsbProduct.Font = tsmiProduct.Font = font; tsbProductType.Font = tsmiProductType.Font = font; tsbMain.Font = tsmiMain.Font = font; tsbOrder.Font = tsmiOrder.Font = font; tsbChangePassword.Font = tsmiChangePassword.Font = font; tsbChangeSet.Font = tsmiChangeSet.Font = font; tsmiFile.Font = font; tsmiMenu.Font = font; tsmiExit.Font = font; tsmiSystem.Font = tsmiAdmin.Font = tsmiDevice.Font = tsmiPrinter.Font = tsmiStatistic.Font = tsmiSupplier.Font = tsmiRequest.Font = tsmiAdminLog.Font = tsmiFinanceLog.Font = tsmiBalance.Font = font; tsmiLanguage.Font = font; tsmiLanguage.DropDownItems.Clear(); foreach (var item in Resources.GetRes().AllLangList.OrderBy(x => x.Value.LangOrder)) { ToolStripMenuItem tsmi = new ToolStripMenuItem(); tsmi.Font = font; if (!string.IsNullOrWhiteSpace(Resources.GetRes().GetString("Tsmi_Lang_Icon", new System.Globalization.CultureInfo(item.Value.Culture.Name))) && "-" != Resources.GetRes().GetString("Tsmi_Lang_Icon", new System.Globalization.CultureInfo(item.Value.Culture.Name))) { tsmi.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC." + Resources.GetRes().GetString("Tsmi_Lang_Icon", new System.Globalization.CultureInfo(item.Value.Culture.Name)))); } tsmi.Tag = item.Value.LangIndex; tsmi.Size = new System.Drawing.Size(88, 22); tsmi.Text = item.Value.LangName; tsmi.Click += new System.EventHandler(this.tsmi_Click); tsmiLanguage.DropDownItems.Add(tsmi); if (Resources.GetRes().CurrentLangIndex == item.Value.LangIndex) { tsmi.Checked = true; tsmi.Enabled = false; } } //语言 if (Resources.GetRes().MainLangIndex == 0) { krplKeyInfo.Text = Resources.GetRes().KEY_NAME_0; krplNameInfo.Text = Resources.GetRes().AdminModel.AdminName0; } else if (Resources.GetRes().MainLangIndex == 1) { krplKeyInfo.Text = Resources.GetRes().KEY_NAME_1; krplNameInfo.Text = Resources.GetRes().AdminModel.AdminName1; } else if (Resources.GetRes().MainLangIndex == 2) { krplKeyInfo.Text = Resources.GetRes().KEY_NAME_2; krplNameInfo.Text = Resources.GetRes().AdminModel.AdminName2; } krplAdminInfo.Text = GetModeName(Resources.GetRes().AdminModel.Mode); //定时检查 LoadingKeyCheck(); //更新 SetUpdate(); // 开启有权限的菜单 EnableByMenu(); // 打开主页 if (tsbMain.Enabled) { tsbMain_Click(null, null); } // 注册热键(开钱想) RegHotKey(); this.Shown += (z, y) => { if (!_isLoaded) { _isLoaded = true; // 点歌系统设置呼叫器时间(消准) if (Resources.GetRes().IsRequired("Vod")) { // 设置设备(呼叫器)时间 Task.Factory.StartNew(() => { Common.GetCommon().SetDeviceTime(); }); } // 加载第二屏幕 if (Resources.GetRes().DisplaySecondMonitor) { FullScreenMonitor.Instance.Initial(this.Location.X, this.Location.Y, this.Width, this.Height); } // 扫码,刷卡 // 扫条码处理 hookBarcode = new KeyboardHook(); var availbleScanners = hookBarcode.GetKeyboardDevices(); string first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().BarcodeReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookBarcode.SetDeviceFilter(first); hookBarcode.KeyPressed += OnBarcodeKey; hookBarcode.AddHook(this); } hookCard = new KeyboardHook(); first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().CardReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookCard.SetDeviceFilter(first); hookCard.KeyPressed += OnCardKey; hookCard.AddHook(this); } } }; }
public MainViewModel(UIElement element, Action relogin, Action refreshRoomList) { this._element = element; this._reLogin = relogin; this._refreshRoomList = refreshRoomList; Notification.Instance.NotificationLanguage += (obj, value, args) => { _element.Dispatcher.BeginInvoke(new Action(() => { SetCurrentName(); })); }; // 添加处理事件 this._element.AddHandler(PublicEvents.PopupEvent, new RoutedEventHandler(HandlePopop), true); _msg = new MsgViewModel(SetMsgCommand); _key = new KeyViewModel(SetKeyCommand); _animation = new AnimationViewModel(); // 设置语言 SetCurrentName(); // 定时检测 LoadingCheck(); // 更新检测 SetUpdate(); // 更新检测 SetUpdate(); // 注册睡眠唤醒(免得session失效) SystemEvents.PowerModeChanged -= this.SystemEvents_PowerModeChanged; SystemEvents.PowerModeChanged += this.SystemEvents_PowerModeChanged; (_element as Window).Loaded += (z, y) => { if (!_isLoaded) { _isLoaded = true; // 扫码,刷卡 // 扫条码处理 hookBarcode = new KeyboardHook(); var availbleScanners = hookBarcode.GetKeyboardDevices(); string first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().BarcodeReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookBarcode.SetDeviceFilter(first); hookBarcode.KeyPressed += OnBarcodeKey; hookBarcode.AddHook(_element as Window); } hookCard = new KeyboardHook(); first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().CardReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookCard.SetDeviceFilter(first); hookCard.KeyPressed += OnCardKey; hookCard.AddHook(_element as Window); } } }; }
/// <summary> /// 初始化 /// </summary> public void Init() { Selected.RoomDisplay = false; Common.GetCommon().OpenPriceMonitor("0"); // 刷新第二屏幕 if (FullScreenMonitor.Instance._isInitialized) { FullScreenMonitor.Instance.RefreshSecondMonitorList(null); } // 语言默认, 或者上次选择 if (Resources.GetRes().DefaultOrderLang == -1) { LanguageMode = Resources.GetRes().MainLang.LangIndex; } else { LanguageMode = Resources.GetRes().DefaultOrderLang; } // 刷新第二屏语言 if (FullScreenMonitor.Instance._isInitialized) { FullScreenMonitor.Instance.RefreshSecondMonitorLanguage(Resources.GetRes().GetMainLangByLangIndex(LanguageMode).LangIndex, -1); } DisplayMode = 2; Selected.TotalPrice = 0; Selected.CurrentSelectedList.Clear(); Selected.CurrentSelectedListNew.Clear(); Products.ProductList.Clear(); Products.ProductListNew.Clear(); Selected.ResetPage(); // 刷新产品 Products.Init(-1); Selected.HasAddress = 1; RefreshState(); if (!IsScanReady) { IsScanReady = true; // 扫条码 Notification.Instance.NotificationBarcodeReader += Instance_NotificationBarcodeReader; // 扫码,刷卡 // 扫条码处理 hookBarcode = new KeyboardHook(); var availbleScanners = hookBarcode.GetKeyboardDevices(); string first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().BarcodeReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookBarcode.SetDeviceFilter(first); hookBarcode.KeyPressed += OnBarcodeKey; hookBarcode.AddHook(_element as Window); } hookCard = new KeyboardHook(); first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().CardReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookCard.SetDeviceFilter(first); hookCard.KeyPressed += OnCardKey; hookCard.AddHook(_element as Window); } } }