Example #1
0
        private void OnHistoryClicked(object sender, EventArgs e)
        {
            BarcodeHistoryUserControl target = sender as BarcodeHistoryUserControl;

            if (CurrentBarcode != null && target == CurrentBarcode)
            {
                return;
            }

            ScrollToTarget(target);
        }
Example #2
0
        private void LoadHistory()
        {
            HistoryStackpanel.Children.Clear();

            foreach (Row r in DatabaseStatements.GetHistory())
            {
                BarcodeHistoryUserControl temp = new BarcodeHistoryUserControl(
                    new Barcode(
                        r.GetValue <string>("value"),
                        (BarcodeFormat)Enum.Parse(typeof(BarcodeFormat), r.GetValue <string>("type"))),
                    DateTime.Parse(r.GetValue <string>("date")));

                temp.Deleted += OnHistoryDeleted;
                temp.Clicked += OnHistoryClicked;

                HistoryStackpanel.Children.Add(temp);
            }
        }
Example #3
0
        private void ScrollToTarget(BarcodeHistoryUserControl target, string textToSet = "")
        {
            if (CurrentBarcode != null)
            {
                CurrentBarcode.MainGrid.Background = (SolidColorBrush) new BrushConverter().ConvertFrom(ColorConstants.Blue);
            }
            CurrentBarcode = target;
            CurrentBarcode.MainGrid.Background = (SolidColorBrush) new BrushConverter().ConvertFrom(ColorConstants.Orange);
            HistoryScrollViewer.ScrollToVerticalOffset(target.TranslatePoint(new System.Windows.Point(), HistoryStackpanel).Y);

            if (string.IsNullOrEmpty(textToSet))
            {
                ScanTextBox.Text = target.Barcode.Text.Replace(BarcodeConstants.FNC1.ToString(), BarcodeConstants.FNC1_DisplayPlaceholder);
            }
            else
            {
                ScanTextBox.Text = textToSet.Replace(BarcodeConstants.FNC1.ToString(), BarcodeConstants.FNC1_DisplayPlaceholder);
            }

            BarcodeTypeComboBox.SelectedItem = target.Barcode.Format;
            ScanTextBox.SelectAll();
        }
Example #4
0
        private void HandleScan(Barcode barcode)
        {
            if (barcode is null)
            {
                return;
            }

            BarcodeHistoryUserControl temp = TryGetHistory(barcode, barcode.Text);

            if (temp is null)
            {
                temp          = new BarcodeHistoryUserControl(barcode, DateTime.Now, barcode.Text);
                temp.Deleted += OnHistoryDeleted;
                temp.Clicked += OnHistoryClicked;
                HistoryStackpanel.Children.Insert(0, temp);
                DatabaseStatements.InsertBarcode(barcode.Text, barcode.Format);
            }

            ScrollToTarget(temp, barcode.Text);

            WriteText(barcode.Text);
        }
Example #5
0
 private void DeleteHistory(BarcodeHistoryUserControl history)
 {
     DatabaseStatements.DeleteHistory(history.Barcode.Text, history.Barcode.Format);
     HistoryStackpanel.Children.Remove(history);
 }