/// <summary> /// Check for barcode reader key combinations when textcomposition is entered /// </summary> /// <param name="sender">Object that triggered the event</param> /// <param name="e">Event details</param> private void HandleBarcodeScan(object sender, TextCompositionEventArgs e) { // leftCtrl + B focus upcText and set reading to true if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.B)) { UPCText.Text = ""; UPCText.Focus(); reading = true; } // leftCtrl + J take the UPC from UPCText and find the item if it exists // otherwise clear fields and prepare for new item entry else if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.J)) { if (reading) { // find the item associated with the upc entered ItemDTO lItem = itemDTOs .Cast <ItemDTO>() .Where(item => item.UPC.Equals(UPCText.Text)).FirstOrDefault(); if (lItem != null) { CategoryListComboBox.SelectedIndex = CategoryListComboBox.Items.IndexOf(Category.createDTOFromCategory(lItem.Category)); InventoryListBox.SelectedIndex = InventoryListBox.Items.IndexOf(lItem); } else { InventoryListBox.SelectedIndex = -1; string upc = UPCText.Text; ClearInputs(); UPCText.Text = upc; } } reading = false; } }
public InventoryPage() { InitializeComponent(); UPCText.Focus(); PopulateItemList(); FillCategoryComboBox(); FillItemList(itemDTOs); }