Ejemplo n.º 1
0
        private void EdytujElement(INowyElement _edytowanyElement)
        {
            var edytowanyElement = ZnajdzElementPoNazwie(_edytowanyElement.Nazwa);

            if (edytowanyElement != null)
            {
                double tmpLeft = Canvas.GetLeft(edytowanyElement);
                double tmpTop  = Canvas.GetTop(edytowanyElement);

                //ListaElementow.Remove(edytowanyElement);

                var found = ListaElementow2.Find(r => r.Nazwa == edytowanyElement.Name);
                if (found != null)
                {
                    ListaElementow2.Remove(found);
                }

                EtykietaCanvas.Children.Remove(edytowanyElement);

                DodajElementDoEtykiety(_edytowanyElement, tmpLeft, tmpTop, true);
            }
        }
Ejemplo n.º 2
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;
            }
        }