public void GenerujPodglad() { try { Source = BarcodeHandler.UtworzKod(Typ, Tekst, Szerokosc, Wysokosc, CzyPokazacTekst); Info = ""; } catch (Exception ex) { Source = null; Info = ex.Message; } }
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; } }