/// <summary>
 /// Resets the form elements/selected items and clears the related textboxes
 /// </summary>
 private void ResetForm()
 {
     ProductsListBox.ClearSelected();
     ProductsListBox.SelectedItem = null;
     SelectedProductPricesListBox.ClearSelected();
     SelectedProductPricesListBox.SelectedItem = null;
     PriceTextBox.Text = "";
     IsCurrentlyActivePriceCheckBox.Checked = false;
 }
 /// <summary>
 /// Clears the selected elements in list/comboBoxes, and the product name textBox
 /// </summary>
 private void ClearSelected()
 {
     ProductNameTextBox.Text = "";
     ProductsListBox.ClearSelected();
     ProductsListBox.SelectedItem         = null;
     ProductCategoryComboBox.SelectedItem = null;
     RecipesListBox.ClearSelected();
     RecipesListBox.SelectedItem = null;
 }
Exemple #3
0
        private void AnalyzeBitmap(Bitmap bitmap, TimeSpan time)
        {
            if (ProductDetailsPanel.IsOpen)
            {
                return;
            }

            Result result = barcodeReader.Decode(
                bitmap.Buffers[0].Buffer.ToArray(),
                (int)bitmap.Buffers[0].Pitch, // Should be width here but I haven't found a way to pass both width and stride to ZXing yet
                (int)bitmap.Dimensions.Height,
                BitmapFormat.Gray8);

            if (result != null && IsValidEan(result.Text))
            {
                if (autoFocus != null)
                {
                    autoFocus.BarcodeFound = true;
                }

                string barcode = result.Text;

                var ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    ShowFilteringBarcode(barcode);
                });

                BitmapImageSource       bmpImgSrc = new BitmapImageSource(bitmap);
                WriteableBitmapRenderer renderer  = new WriteableBitmapRenderer(bmpImgSrc, bitmapWithBarcode);
                bitmapWithBarcode = renderer.RenderAsync().AsTask().Result;

                if (barcodeFilter.Update(barcode))
                {
                    Debug.WriteLine(barcode);

                    ignore = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        ProductsListBox.AddProduct(barcode, bitmapWithBarcode);
                        bitmapWithBarcode = new WriteableBitmap(bitmapWithBarcode.PixelWidth, bitmapWithBarcode.PixelHeight);

                        if (HintTextBlock.Visibility == Visibility.Visible)
                        {
                            HintTextBlock.Visibility = Visibility.Collapsed;
                        }

                        ShowActiveBarcode(barcode);
                    });
                }
            }
            else
            {
                if (autoFocus != null)
                {
                    autoFocus.BarcodeFound = false;
                }
            }
        }
Exemple #4
0
        private void ListBoxPopulate()
        {
            var productList = ProductDB.GetAllVendorProducts();
            var collection  = new ObservableCollection <Product>(productList);
            var source      = new Binding();

            ProductsListBox.DataContext = collection;
            ProductsListBox.SetBinding(ListBox.ItemsSourceProperty, source);
        }
Exemple #5
0
 /// <summary>
 /// Resets the form elements/selected items and clears the selected recipe's ingredients list
 /// </summary>
 private void ResetForm()
 {
     ProductsListBox.ClearSelected();
     SelectedRecipeContentListbox.ClearSelected();
     RecipesListBox.ClearSelected();
     RecipeNameTextBox.Text = "";
     SelectedRecipeContent.Clear();
     ClearRecipeContentList();
 }
 /// <summary>
 /// Clears textboxes/resets selected fields and PurchaseDateLabel.Text
 /// </summary>
 private void ClearSelected()
 {
     PriceTextBox.Text      = "";
     PurchaseDateLabel.Text = "Purchase Date";
     ProductsListBox.ClearSelected();
     ProductsListBox.SelectedItem            = null;
     SelectedProductPricesListBox.DataSource = null;
     SelectedProductPricesListBox.ClearSelected();
     SelectedProductPricesListBox.SelectedItem = null;
 }
        private void WireUpProducts()
        {
            //Stops SelectedIndexChanged from doing anything when the listbox is changed by the code.
            ProductsListBox.SelectedIndexChanged -= new EventHandler(ProductsListBox_SelectedIndexChanged);
            //Stops the ListBox from scrolling to the top when changed.
            int topIndex = ProductsListBox.TopIndex;

            ProductsBindingSource.DataSource = Products;
            ProductsListBox.DataSource       = ProductsBindingSource;
            ProductsBindingSource.ResetBindings(false);
            ProductsListBox.ClearSelected();

            ProductsListBox.TopIndex              = topIndex;
            ProductsListBox.SelectedIndexChanged += new EventHandler(ProductsListBox_SelectedIndexChanged);
        }
        // This function is taken from here:
        // https://social.msdn.microsoft.com/Forums/windows/en-US/894d0814-dcf1-4cd6-9cca-2c6239794442/list-box-tooltip
        private void ProductsListBox_MouseMove(object sender, MouseEventArgs e)
        {
            int index = ProductsListBox.IndexFromPoint(e.Location);

            if (index != -1 && index < ProductsListBox.Items.Count)
            {
                if (toolTip.GetToolTip(ProductsListBox) != ProductsListBox.Items[index].ToString())
                {
                    toolTip.SetToolTip(ProductsListBox, ((ProductModel)ProductsListBox.Items[index]).ToolTip);
                }
            }
            else
            {
                toolTip.SetToolTip(ProductsListBox, string.Empty);
            }
        }
Exemple #9
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            Grid secondRowBaseGrid = button.Parent as Grid;

            TextBox secondRowBaseGridSecondChildren = (secondRowBaseGrid.Children[0] as ScrollViewer).Content as TextBox;
            Grid    baseGrid = secondRowBaseGrid.Parent as Grid;

            Grid  firstRowBaseGrid = baseGrid.Children[0] as Grid;
            Image firstRowBaseGridFirstChildren = firstRowBaseGrid.Children[0] as Image;

            TextBlock firstRowSecondChildren = ((firstRowBaseGrid.Children[1] as Grid).Children[0] as ScrollViewer).Content as TextBlock;

            if (ProductImage.Source.ToString() == _productimagepath.ToString() || string.IsNullOrWhiteSpace(secondRowBaseGridSecondChildren.Text))
            {
                MessageBox.Show("You must upload image and write about details of new product.");
                return;
            }



            if (_isprodchanged == true)
            {
                _prodtextblock.Text = secondRowBaseGridSecondChildren.Text;
                _prodimage.Source   = firstRowBaseGridFirstChildren.Source;
                _isprodchanged      = false;
            }
            else
            {
                Product product = new Product
                {
                    Name         = secondRowBaseGridSecondChildren.Text,
                    ProductImage = firstRowBaseGridFirstChildren.Source.ToString()
                };

                ProductsListBox.Items.Add(product);

                ProductsListBox.ScrollIntoView(ProductsListBox.Items[ProductsListBox.Items.Count - 1]);
            }


            firstRowBaseGridFirstChildren.Source = new BitmapImage(_productimagepath);
            secondRowBaseGridSecondChildren.Text = default;
            firstRowSecondChildren.Text          = "Upload product image.";
            MessageBox.Show("New Product added successfully");
        }
Exemple #10
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);
            this.SetupStatusBar();

            // Prevent screen timeout
            displayRequest.RequestActive();

            Application.Current.Resuming     += OnResuming;
            Application.Current.Suspending   += OnSuspending;
            Window.Current.VisibilityChanged += OnWindowVisibilityChanged;

            var ignore = InitializeCaptureAsync();

            if (ProductDetailsPanel.IsOpen)
            {
                ProductDetailsPanel.Close();
            }

            ProductsListBox.RemoveReportedProducts();
        }
        private void WireUpProducts()
        {
            ProductsListBox.SelectedIndexChanged -= new EventHandler(ProductsListBox_SelectedIndexChanged);
            int topIndex = ProductsListBox.TopIndex;

            for (int i = 0; i < AllProducts.Count; i++)
            {
                var  index = SelectedProducts.FindIndex(selectedProduct => selectedProduct.id == AllProducts[i].id);
                bool isInSelectedProducts = index >= 0;
                AllProducts[i].SetDisplayName(isInSelectedProducts);
            }

            AllProductsBindingSource.DataSource = AllProducts;
            ProductsListBox.DataSource          = AllProductsBindingSource;
            ProductsListBox.DisplayMember       = nameof(ProductModel.DisplayName);
            AllProductsBindingSource.ResetBindings(false);
            ProductsListBox.ClearSelected();

            ProductsListBox.TopIndex              = topIndex;
            ProductsListBox.SelectedIndexChanged += new EventHandler(ProductsListBox_SelectedIndexChanged);
        }
 /// <summary>
 /// When the form loads, initialize the  ProductsListBox
 /// </summary>
 private void SelectProductForm_Load(object sender, EventArgs e)
 {
     ProductsListBox.DataSource    = ProductList;
     ProductsListBox.DisplayMember = "Name";
     ProductsListBox.ClearSelected();
 }