Esempio n. 1
0
        public WaybillDetailsView()
        {
            InitializeComponent();
            DataContextChanged += OnDataContextChanged;

            var element = Rounding;
            var items   = DescriptionHelper.GetDescriptions(typeof(Rounding));

            element.ItemsSource       = items;
            element.DisplayMemberPath = "Name";

            var binding = new Binding("Waybill.Rounding");

            binding.Converter          = new ComboBoxSelectedItemConverter();
            binding.ConverterParameter = items;
            BindingOperations.SetBinding(element, Selector.SelectedItemProperty, binding);

            DataContextChanged += (sender, args) => {
                if (model == null)
                {
                    return;
                }
                var handler = new BarcodeHandler(this, model.Settings);
                handler.Barcode.Subscribe(x => Execute(model.BarcodeScanned(x)));
            };
        }
        internal void SaveCodeToFile()
        {
            var dateStamp = DateTime.Now.ToString("yyyyMMddHHmm");
            var fileName  = $"{SelectedCodeFormat.ToString()}-{CodeText}";//-{dateStamp}

            ImgSource = new ImageSourceConverter().ConvertFromString(BarcodeHandler.BitmapToFile((BitmapImage)ImgSource, fileName)) as ImageSource;
        }
        public WindowNowyKodKr(NowyKodKrModel nowy_kodkr = null, int id_pola = 0)
        {
            InitializeComponent();
            if (nowy_kodkr != null)
            {
                NowyKodKrVM.CzyEdycja       = true;
                NowyKodKrVM.IdPola          = nowy_kodkr.IdPola;
                NowyKodKrVM.Nazwa           = nowy_kodkr.Nazwa;
                NowyKodKrVM.Tekst           = nowy_kodkr.Tekst;
                NowyKodKrVM.Typ             = nowy_kodkr.Typ;
                NowyKodKrVM.Szerokosc       = nowy_kodkr.Szerokosc;
                NowyKodKrVM.Wysokosc        = nowy_kodkr.Wysokosc;
                NowyKodKrVM.CzyPokazacTekst = nowy_kodkr.CzyPokazacTekst;
                NowyKodKrVM.FontFamily      = nowy_kodkr.FontFamily;
                NowyKodKrVM.FontSize        = nowy_kodkr.FontSize;
                NowyKodKrVM.FontWeight      = nowy_kodkr.FontWeight;


                NowyKodKrVM.GenerujPodglad();
            }
            else
            {
                NowyKodKrVM.IdPola = id_pola;
            }
            NowyKodKr        = new NowyKodKrModel();
            NowyKodKr.IdPola = NowyKodKrVM.IdPola;

            NowyKodKrVM.ListaTypow = BarcodeHandler.PobierzListeTypow();
        }
 public void GenerujPodglad()
 {
     try
     {
         Source = BarcodeHandler.UtworzKod(Typ, Tekst, Szerokosc, Wysokosc, CzyPokazacTekst);
         Info   = "";
     }
     catch (Exception ex)
     {
         Source = null;
         Info   = ex.Message;
     }
 }
        public Frontend2()
        {
            InitializeComponent();

            Loaded += (sender, args) => {
                DataGridHelper.Focus(Lines);
            };
            KeyDown += (sender, args) => {
                if (args.Key == Key.D && ((Keyboard.Modifiers & ModifierKeys.Control) != 0))
                {
                    Model.ShowDescription();
                }
                if (args.Key == Key.F1)
                {
                    Execute(Model.Help());
                }
                if (args.Key == Key.F7)
                {
                    Execute(Model.Close());
                }
                if (args.Key == Key.F3)
                {
                    Model.Clear();
                }
                if (args.Key == Key.U && ((Keyboard.Modifiers & ModifierKeys.Control) != 0))
                {
                    Execute(Model.Unpack());
                }
                if (args.Key == Key.F4)
                {
                    Execute(Model.ReturnCheck());
                }
            };

            DataContextChanged += (sender, args) => {
                if (Model == null)
                {
                    return;
                }
                var handler = new BarcodeHandler(this, Model.Settings);
                handler.Barcode.Subscribe(x => Execute(Model.BarcodeScanned(x)));
            };

            new Editable().Attach(Lines);
            StyleHelper.ApplyStyles(typeof(CheckLine), Lines, Application.Current.Resources, Legend);
        }
        private void RefreshCode()
        {
            try
            {
                TextHint = "";

                if (SelectedCodeFormat != 0)
                {
                    if (!string.IsNullOrWhiteSpace(CodeText))
                    {
                        // QR
                        //ImgSource = BarcodeHandler.GenerateCode(SelectedCodeFormat, CodeText, CodeWidth, CodeHeight, PureCode, CodeMargin);

                        // BARCODE
                        ImgSource = BarcodeHandler.GenerateBarcode(SelectedCodeFormat, CodeText, CodeWidth, CodeHeight, PureCode);

                        //var i = new Image();
                        //System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)BarcodeHandler.GetBarcodeImage(SelectedCodeFormat, CodeText, CodeWidth, CodeHeight, PureCode);
                        //var bi = new BitmapImage();
                        //using (var ms = new MemoryStream())
                        //{
                        //    bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
                        //    ms.Position = 0;
                        //    bi.BeginInit();
                        //    bi.CacheOption = BitmapCacheOption.OnLoad;
                        //    bi.StreamSource = ms;
                        //    bi.EndInit();
                        //}
                        //i.Source = bi;
                        //BarcodeImage = i;
                    }
                    else
                    {
                    }
                }
                else
                {
                    TextHint = "Wybierz typ kodu";
                }
            }
            catch (Exception ex)
            {
                ImgSource = null;
                TextHint  = ex.Message;
            }
        }
Esempio n. 7
0
 void before_each()
 {
     productList = new Dictionary <string, decimal>();
     handler     = new BarcodeHandler(productList);
 }
Esempio n. 8
0
        private void DodajElementDoEtykiety(INowyElement _nowe_pole, double left = 5, double top = 5, bool edycja = false)
        {
            FrameworkElement nowyElement;

            switch (_nowe_pole.TypPola)
            {
            case TypyPol.Canvas:
                break;

            case TypyPol.Txt:
                if (!edycja)
                {
                    MainVM.DrzewoElementow[1].Subelementy.Add(new ElementEtykiety {
                        NazwaElementu = _nowe_pole.Nazwa
                    });
                }
                nowyElement = new Label();
                (nowyElement as Label).Name                       = (_nowe_pole as NowyTekstModel).Nazwa;
                (nowyElement as Label).Content                    = (_nowe_pole as NowyTekstModel).Tekst;
                (nowyElement as Label).BorderThickness            = (_nowe_pole as NowyTekstModel).GruboscRamki;
                (nowyElement as Label).BorderBrush                = (_nowe_pole as NowyTekstModel).KolorRamki;
                (nowyElement as Label).FontFamily                 = (_nowe_pole as NowyTekstModel).FontFamily;
                (nowyElement as Label).FontSize                   = (_nowe_pole as NowyTekstModel).FontSize;
                (nowyElement as Label).FontWeight                 = (_nowe_pole as NowyTekstModel).FontWeight;
                (nowyElement as Label).FontStyle                  = (_nowe_pole as NowyTekstModel).FontStyle;
                (nowyElement as Label).Height                     = (_nowe_pole as NowyTekstModel).Wysokosc;
                (nowyElement as Label).Width                      = (_nowe_pole as NowyTekstModel).Szerokosc;
                (nowyElement as Label).HorizontalContentAlignment = (_nowe_pole as NowyTekstModel).WyrownanieWPoziomie;
                (nowyElement as Label).VerticalContentAlignment   = (_nowe_pole as NowyTekstModel).WyrownanieWPionie;
                (nowyElement as Label).Padding                    = new Thickness(0);
                (nowyElement as Label).Background                 = new SolidColorBrush(Colors.White);
                (nowyElement as Label).Foreground                 = new SolidColorBrush(Colors.Black);

                ListaElementow2.Add(_nowe_pole);
                EtykietaCanvas.Children.Add(nowyElement);
                Canvas.SetLeft(nowyElement, left);
                Canvas.SetTop(nowyElement, top);

                nowyElement.PreviewMouseLeftButtonDown += this.MouseLeftButtonDown;
                nowyElement.PreviewMouseLeftButtonUp   += this.OnPreviewMouseLeftButtonUp;
                nowyElement.Cursor = Cursors.SizeAll;
                break;

            case TypyPol.TxtDb:
                break;

            case TypyPol.Pic:
                if (!edycja)
                {
                    MainVM.DrzewoElementow[3].Subelementy.Add(new ElementEtykiety {
                        NazwaElementu = _nowe_pole.Nazwa
                    });
                }
                nowyElement = new Image();
                (nowyElement as Image).Name   = (_nowe_pole as NowyObrazModel).Nazwa;
                (nowyElement as Image).Source = new ImageSourceConverter().ConvertFromString((_nowe_pole as NowyObrazModel).PelnaSciezka) as ImageSource;
                RotateTransform rotateTransform = new RotateTransform((_nowe_pole as NowyObrazModel).KatObrotu);
                (nowyElement as Image).LayoutTransform = rotateTransform;

                ListaElementow2.Add(_nowe_pole);
                EtykietaCanvas.Children.Add(nowyElement);
                Canvas.SetLeft(nowyElement, left);
                Canvas.SetTop(nowyElement, top);

                nowyElement.PreviewMouseLeftButtonDown += this.MouseLeftButtonDown;
                nowyElement.PreviewMouseLeftButtonUp   += this.OnPreviewMouseLeftButtonUp;
                nowyElement.Cursor = Cursors.SizeAll;
                break;

            case TypyPol.PicDb:
                break;

            case TypyPol.Barcode:
                if (!edycja)
                {
                    MainVM.DrzewoElementow[5].Subelementy.Add(new ElementEtykiety {
                        NazwaElementu = _nowe_pole.Nazwa
                    });
                }
                nowyElement = new Image();
                (nowyElement as Image).Name = (_nowe_pole as NowyKodKrModel).Nazwa;

                (nowyElement as Image).Source = BarcodeHandler.UtworzKod((_nowe_pole as NowyKodKrModel).Typ
                                                                         , (_nowe_pole as NowyKodKrModel).Tekst
                                                                         , (_nowe_pole as NowyKodKrModel).Szerokosc
                                                                         , (_nowe_pole as NowyKodKrModel).Wysokosc
                                                                         , (_nowe_pole as NowyKodKrModel).CzyPokazacTekst);

                ListaElementow2.Add(_nowe_pole);
                EtykietaCanvas.Children.Add(nowyElement);
                Canvas.SetLeft(nowyElement, left);
                Canvas.SetTop(nowyElement, top);

                nowyElement.PreviewMouseLeftButtonDown += this.MouseLeftButtonDown;
                nowyElement.PreviewMouseLeftButtonUp   += this.OnPreviewMouseLeftButtonUp;
                nowyElement.Cursor = Cursors.SizeAll;
                break;

            case TypyPol.BarcodeDb:
                break;

            default:
                break;
            }
        }