Exemplo n.º 1
0
        /// drag and drop

        private void MapaSlika_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            startPoint = e.GetPosition(this.mapaSlika);
            promjena   = true;

            int i = 0;

            Manifestation pomSpom = razdaljina(startPoint);

            if (pomSpom != null)
            {
                for (i = 0; i < this.SliciceManifestacije.Count; i++)
                {
                    Image img = (Image)mapaSlika.Children[i];
                    img.Height = 65;
                    img.Width  = 65;

                    mapaSlika.Children.RemoveAt(i);
                    mapaSlika.Children.Insert(i, img);
                    if (pomSpom.Id.Equals(this.SliciceManifestacije[i].Manifestacija))
                    {
                        mapaSlika.Children.RemoveAt(i);
                        mapaSlika.Children.Insert(i, img);
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void BtnEditManifestation_Click(object sender, RoutedEventArgs e)
        {
            Manifestation            man     = (Manifestation)dgManifestations.SelectedItem;
            EditManifestationWindows editMan = new EditManifestationWindows(man);

            editMan.Show();
        }
 public void Dodaj(Manifestation o)
 {
     if (o.ID == Guid.Empty)
     {
         o.ID = Guid.NewGuid();
     }
     if (!_repozitorijum.ContainsKey(o.ID))
     {
         _repozitorijum.Add(o.ID, o);
     }
     MemorisiDatoteku();
 }
 public void Obrisi(Manifestation o)
 {
     foreach (KeyValuePair <Guid, Manifestation> e in _repozitorijum)
     {
         if (e.Value.Id.Equals(o.Id))
         {
             _repozitorijum.Remove(e.Key);
             break;
         }
     }
     //_repozitorijum.Remove(o.ID);
     MemorisiDatoteku();
 }
Exemplo n.º 5
0
        private void MapaSlika_MouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(mapaSlika);
            Vector diff     = startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                Manifestation manifestacijaaa = razdaljina(startPoint);

                if (manifestacijaaa != null) //man prev flse
                {
                    DataObject dragData = new DataObject("myFormat", manifestacijaaa);
                    DragDrop.DoDragDrop((DependencyObject)e.OriginalSource, dragData, DragDropEffects.Move);
                }
            }
        }
Exemplo n.º 6
0
        private void RemoveFromMap_Click(object sender, RoutedEventArgs e)
        {
            if (dataGridManifestations.SelectedItems.Count != 0)
            {
                Manifestation s = (Manifestation)dataGridManifestations.SelectedItems[0];


                Image       image = new Image();
                BitmapImage bit   = new BitmapImage(new Uri(s.ImgString, UriKind.Absolute));
                image.Source = bit;

                if (s.Prevucena == true)
                {
                    mapaSlika.Children.RemoveAt(s.brojNaCanvasu);

                    s.Prevucena = false;
                }
                s.brojNaCanvasu = -1;
                s.Prevucena     = false;
                repManifestacija.MemorisiDatoteku();
                foreach (Manifestation x in manifestationList)
                {
                    if (x.brojNaCanvasu > s.brojNaCanvasu)
                    {
                        x.brojNaCanvasu = x.brojNaCanvasu - 1;
                    }
                }

                manifestationList.Clear();

                foreach (KeyValuePair <Guid, Manifestation> eee in repManifestacija.getAll())
                {
                    if (!manifestationList.Contains(eee.Value))
                    {
                        manifestationList.Add(eee.Value);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void BtnDeleteManifestation_Click(object sender, RoutedEventArgs e)
        {
            Manifestation man = (Manifestation)dgManifestations.SelectedItem;

            if (man != null)
            {
                string msg = "Are you sure you want to delete this manifestation?";
                Delete pom = new Delete(msg);
                pom.ShowDialog();
                if (pom.Delete1)
                {
                    dgManifestations.ItemsSource = null;
                    manifestationList.Remove(man);
                    repManifestacija.Obrisi(man);
                    pomListManifest.Remove(man);

                    repManifestacija.MemorisiDatoteku();

                    dgManifestations.ItemsSource = manifestationList;
                }
            }
        }
Exemplo n.º 8
0
        private void DataGridManifestations_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(null);
            Vector diff     = startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                Manifestation manif = (Manifestation)this.dataGridManifestations.SelectedItem;

                if (manif != null && manif.Prevucena == false)
                {
                    DataObject dragData = new DataObject("myFormat", manif);
                    DragDrop.DoDragDrop((DependencyObject)e.OriginalSource, dragData, DragDropEffects.Move);
                }
                else
                {
                    MapError me = new MapError();
                    me.ShowDialog();
                }
            }
        }
        // public ObservableCollection<String> typesList;
        public EditManifestationWindows(Manifestation m)
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            pomM = m;

            typesList = new ObservableCollection <ManifestationType>();
            foreach (ManifestationType mt in MainWindow.typeList)
            {
                typesList.Add(mt);
            }

            TheList = new ObservableCollection <Tag>();
            foreach (Tag t in MainWindow.tagList)
            {
                TheList.Add(t);
            }
            this.DataContext = this
            ;

            txtID.Text                 = (m.Id).ToString();
            cmbType.SelectedValue      = m.Type;
            dpDate.SelectedDate        = m.Date;
            txtName.Text               = m.Name;
            txtDesc.Text               = m.Description;
            cmbAlc.SelectedValue       = m.ServingAlcohol;
            cmbPrice.SelectedValue     = m.PriceCategory;
            txtVisitors.Text           = (m.Visitors).ToString();
            imgManifestation.Source    = m.Image;
            rbSmoking.IsChecked        = m.Smoking;
            rbNoSmoking.IsChecked      = !(m.Smoking);
            rbInside.IsChecked         = m.Inside;
            rbOutside.IsChecked        = !(m.Inside);
            cbDisabled.IsChecked       = m.ForDisabled;
            comboBoxTags.SelectedValue = m.Tags;
            this.onMap                 = m.Prevucena;

            idStari = m.Id;



            AlcoholList = new List <string> {
                "No Alcohol", "Bring Alcohol", "Buy Alcohol"
            };
            PriceCategoryList = new List <string> {
                "Free", "Low Prices", "Middle Prices", "High Prices"
            };



            DataContext = this;


            txtID.BorderBrush           = new SolidColorBrush(Colors.Transparent);
            txtID.BorderThickness       = new Thickness(0);
            cmbType.BorderBrush         = new SolidColorBrush(Colors.Transparent);
            cmbType.BorderThickness     = new Thickness(0);
            dpDate.BorderBrush          = new SolidColorBrush(Colors.Transparent);
            dpDate.BorderThickness      = new Thickness(0);
            txtName.BorderBrush         = new SolidColorBrush(Colors.Transparent);
            txtName.BorderThickness     = new Thickness(0);
            txtDesc.BorderBrush         = new SolidColorBrush(Colors.Transparent);
            txtDesc.BorderThickness     = new Thickness(0);
            cmbAlc.BorderBrush          = new SolidColorBrush(Colors.Transparent);
            cmbAlc.BorderThickness      = new Thickness(0);
            cmbPrice.BorderBrush        = new SolidColorBrush(Colors.Transparent);
            cmbPrice.BorderThickness    = new Thickness(0);
            txtVisitors.BorderBrush     = new SolidColorBrush(Colors.Transparent);
            txtVisitors.BorderThickness = new Thickness(0);
            rtSmoking.Stroke            = new SolidColorBrush(Colors.Transparent);
            rtSmoking.StrokeThickness   = 0;
            rtInside.Stroke             = new SolidColorBrush(Colors.Transparent);
            rtInside.StrokeThickness    = 0;

            lblErrorVisitors.Visibility = Visibility.Hidden;
            error.Content = "";
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            bool errorId       = false;
            bool errorType     = false;
            bool errorDate     = false;
            bool errorName     = false;
            bool errorDesc     = false;
            bool errorAlc      = false;
            bool errorPrice    = false;
            bool errorVisitors = false;
            bool errorSmoking  = false;
            bool errorInside   = false;



            //Content = "Some fields are not filled correctly!"

            if (String.IsNullOrEmpty(txtID.Text) || String.IsNullOrWhiteSpace(txtID.Text))
            {
                error.Content         = "Some fields are not filled correctly!";
                txtID.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtID.BorderThickness = new Thickness(4);
                errorId = true;
            }
            else
            {
                txtID.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                txtID.BorderThickness = new Thickness(0);
                errorId = false;
            }
            if (cmbType.SelectedItem == null)
            {
                error.Content           = "Some fields are not filled correctly!";
                cmbType.BorderBrush     = new SolidColorBrush(Colors.Red);
                cmbType.BorderThickness = new Thickness(4);
                errorType = true;
            }
            else
            {
                cmbType.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                cmbType.BorderThickness = new Thickness(0);
                errorType = false;
            }
            if (dpDate.SelectedDate == null)
            {
                error.Content          = "Some fields are not filled correctly!";
                dpDate.BorderBrush     = new SolidColorBrush(Colors.Red);
                dpDate.BorderThickness = new Thickness(4);
                errorDate = true;
            }
            else
            {
                dpDate.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                dpDate.BorderThickness = new Thickness(0);
                errorDate = false;
            }
            if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrWhiteSpace(txtName.Text))
            {
                error.Content           = "Some fields are not filled correctly!";
                txtName.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtName.BorderThickness = new Thickness(4);
                errorName = true;
            }
            else
            {
                txtName.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                txtName.BorderThickness = new Thickness(0);
                errorName = false;
            }
            if (String.IsNullOrEmpty(txtDesc.Text) || String.IsNullOrWhiteSpace(txtDesc.Text))
            {
                error.Content           = "Some fields are not filled correctly!";
                txtDesc.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtDesc.BorderThickness = new Thickness(4);
                errorDesc = true;
            }
            else
            {
                txtDesc.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                txtDesc.BorderThickness = new Thickness(0);
                errorDesc = false;
            }
            if (cmbAlc.SelectedItem == null)
            {
                error.Content          = "Some fields are not filled correctly!";
                cmbAlc.BorderBrush     = new SolidColorBrush(Colors.Red);
                cmbAlc.BorderThickness = new Thickness(4);
                errorAlc = true;
            }
            else
            {
                cmbAlc.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                cmbAlc.BorderThickness = new Thickness(0);
                errorAlc = false;
            }
            if (cmbPrice.SelectedItem == null)
            {
                error.Content            = "Some fields are not filled correctly!";
                cmbPrice.BorderBrush     = new SolidColorBrush(Colors.Red);
                cmbPrice.BorderThickness = new Thickness(4);
                errorPrice = true;
            }
            else
            {
                cmbPrice.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                cmbPrice.BorderThickness = new Thickness(0);
                errorPrice = false;
            }
            if (String.IsNullOrEmpty(txtVisitors.Text) || String.IsNullOrWhiteSpace(txtVisitors.Text))
            {
                error.Content               = "Some fields are not filled correctly!";
                txtVisitors.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtVisitors.BorderThickness = new Thickness(4);
                errorVisitors               = true;
            }
            else
            {
                int result;
                if (Int32.TryParse(txtVisitors.Text, out result))
                {
                    lblErrorVisitors.Visibility = Visibility.Hidden;
                    txtVisitors.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                    txtVisitors.BorderThickness = new Thickness(0);
                    errorVisitors = false;
                }
                else
                {
                    lblErrorVisitors.Visibility = Visibility.Visible;
                    txtVisitors.BorderBrush     = new SolidColorBrush(Colors.Red);
                    txtVisitors.BorderThickness = new Thickness(4);
                    errorVisitors = true;
                }
            }
            if (rbInside.IsChecked == false && rbOutside.IsChecked == false)
            {
                error.Content            = "Some fields are not filled correctly!";
                rtInside.Stroke          = new SolidColorBrush(Colors.Red);
                rtInside.StrokeThickness = 4;
                errorInside = true;
            }
            else
            {
                rtInside.Stroke          = new SolidColorBrush(Colors.Transparent);
                rtInside.StrokeThickness = 0;
                errorInside = false;
            }
            if (rbSmoking.IsChecked == false && rbNoSmoking.IsChecked == false)
            {
                error.Content             = "Some fields are not filled correctly!";
                rtSmoking.Stroke          = new SolidColorBrush(Colors.Red);
                rtSmoking.StrokeThickness = 4;
                errorSmoking = true;
            }
            else
            {
                rtSmoking.Stroke          = new SolidColorBrush(Colors.Transparent);
                rtSmoking.StrokeThickness = 0;
                errorSmoking = false;
            }
            if (!errorId && !errorType && !errorDate && !errorName && !errorDesc && !errorAlc && !errorPrice && !errorVisitors && !errorSmoking && !errorInside)
            {
                string            text = cmbType.Text;
                ManifestationType mt   = cmbType.SelectedItem as ManifestationType;


                bool smoking = false;
                if (rbSmoking.IsChecked == true)
                {
                    smoking = true;
                }

                bool inside = false;
                if (rbInside.IsChecked == true)
                {
                    inside = true;
                }

                bool forDisabled = false;
                if (cbDisabled.IsChecked == true)
                {
                    forDisabled = true;
                }


                List <Tag> tags = new List <Tag>();

                foreach (Tag t in TheList)
                {
                    bool x = t.Cekiran;
                    if (x == true)
                    {
                        Console.WriteLine(t.Id);
                        tags.Add(t);
                    }
                }

                if (takeTypePhoto)
                {
                    manifestationImage = mt.Imagee;
                }


                Manifestation m = new Manifestation(Int32.Parse(txtID.Text), mt, dpDate.SelectedDate.Value.Date, manifestationImage,
                                                    txtName.Text, txtDesc.Text, cmbAlc.Text, cmbPrice.Text, Int32.Parse(txtVisitors.Text),
                                                    smoking, inside, forDisabled, tags);



                foreach (Manifestation tt in MainWindow.manifestationList)
                {
                    if (tt.Id == idStari)
                    {
                        MainWindow.manifestationList.Remove(tt);
                        MainWindow.pomListManifest.Remove(tt);
                        MainWindow.repManifestacija.Obrisi(tt);
                        break;
                    }
                }

                MainWindow.manifestationList.Add(m);
                MainWindow.repManifestacija.Dodaj(m);
                // MainWindow.pomListManifest.Add(m);

                if (onMap)
                {
                    Image       image = new Image();
                    BitmapImage bit   = new BitmapImage(new Uri(pomM.ImgString, UriKind.Absolute));
                    image.Source = bit;

                    /* if (pomM.Prevucena == true)
                     * {
                     *
                     *       for (int i = 0; i < MainWindow.sliciceManifestacije.Count; i++)
                     *       {
                     *           Slicice slicica = MainWindow.sliciceManifestacije[i];
                     *           if (slicica.Manifestacija.Id == m.Id)
                     *           {
                     *               MainWindow.AppWindow.mapaSlika.Children.RemoveAt(i);
                     *               slicica.Manifestacija = m;
                     *               Image imagee = new Image();
                     *               imagee.Width = 60;
                     *               imagee.Height = 60;
                     *               BitmapImage bitt = new BitmapImage(new Uri(m.ImgString));
                     *               imagee.Source = bitt;
                     *
                     *               Canvas.SetLeft(imagee, slicica.X);
                     *               Canvas.SetTop(imagee, slicica.Y);
                     *
                     *               MainWindow.AppWindow.mapaSlika.Children.Insert(i, imagee);
                     *
                     *
                     *           }
                     *       }
                     *       //   MainWindow.sliciceManifestacije.Remove(bit);
                     *       //MainWindow.mapaSlika.Children.RemoveAt(s.brojNaCanvasu);
                     *       //    s.Prevucena = false;
                     *       //}
                     *       //s.brojNaCanvasu = -1;
                     *       //s.Prevucena = false;
                     * }*/
                }


                this.Close();
            }
        }
Exemplo n.º 11
0
        private void MapaSlika_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("myFormat"))
            {
                Manifestation manifestacija1 = e.Data.GetData("myFormat") as Manifestation;
                Image         ikonica        = new Image();
                ikonica.Height = 65;
                ikonica.Width  = 65;

                String xxx = "";

                foreach (Tag t in manifestacija1.Tags)
                {
                    xxx += " " + t.Description;
                }
                String toolTip = manifestacija1.Name + "\n" + manifestacija1.Type.Name + "\n" + xxx;

                ikonica.ToolTip = toolTip;



                BitmapImage ikonicaSource = new BitmapImage(new Uri(manifestacija1.ImgString));

                //ikonica.Name = manifestacija1.PomId;
                ikonica.Source = ikonicaSource;


                if (!promjena)
                {
                    this.mapaSlika.Children.Add(ikonica);

                    Point p = e.GetPosition(this.mapaSlika);

                    Canvas.SetLeft(ikonica, p.X);
                    Canvas.SetTop(ikonica, p.Y);
                    Slicice slicica = new Slicice(p.X, p.Y, manifestacija1);
                    if (canDrop(e.GetPosition(this.mapaSlika).X - 40, e.GetPosition(this.mapaSlika).Y - 40, slicica))
                    {
                        this.SliciceManifestacije.Add(slicica);
                        manifestacija1.Prevucena     = true;
                        manifestacija1.brojNaCanvasu = mapaSlika.Children.Count;

                        repozitorijumSlici.Dodaj(slicica);
                    }
                }
                else
                {
                    Point p = e.GetPosition(this.mapaSlika);
                    for (int i = 0; i < this.SliciceManifestacije.Count; i++)
                    {
                        if (this.SliciceManifestacije[i].Manifestacija.Id.Equals(manifestacija1.Id))
                        {
                            Slicice IzmjenaSlicice = this.SliciceManifestacije[i];
                            mapaSlika.Children.RemoveAt(i);
                            mapaSlika.Children.Insert(i, ikonica);



                            Manifestation pomocna = razdaljina(p);
                            if (pomocna != null)
                            {
                                p.X = IzmjenaSlicice.X;
                                p.Y = IzmjenaSlicice.Y;
                            }

                            Canvas.SetLeft(ikonica, p.X);
                            Canvas.SetTop(ikonica, p.Y);

                            this.SliciceManifestacije[i].X = p.X;
                            this.SliciceManifestacije[i].Y = p.Y;
                            break;
                        }
                    }
                }
                manifestationList.Clear();

                foreach (KeyValuePair <Guid, Manifestation> eee in repManifestacija.getAll())
                {
                    if (!manifestationList.Contains(eee.Value))
                    {
                        manifestationList.Add(eee.Value);
                    }
                }

                repManifestacija.MemorisiDatoteku();
            }
        }
Exemplo n.º 12
0
        public MainWindow()
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            DataContext          = this;
            tagList              = new ObservableCollection <Tag>();
            typeList             = new ObservableCollection <ManifestationType>();
            manifestationList    = new ObservableCollection <Manifestation>();
            repManifestacija     = new RepozitorijumManifestacija();
            repTipova            = new RepozitorijumTipova();
            repTagova            = new RepozitorijumTagova();
            repozitorijumSlici   = new RepozitorijumSlicica();
            sliciceManifestacije = new ObservableCollection <Slicice>();
            pomListManifest      = new ObservableCollection <Manifestation>();
            View = CollectionViewSource.GetDefaultView(tagList);
            KriterijumiPretrage = new ObservableCollection <string>()
            {
                "ID",
                "Name",
                "Description",
                "Type",
                "Alcohol",
                "Price",
                "Smoking",
                "For Disabled",
                "Place",
            };



            //group
            CollectionView           view             = (CollectionView)CollectionViewSource.GetDefaultView(manifestationList);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription("typeName");

            view.GroupDescriptions.Add(groupDescription);

            foreach (Manifestation m in manifestationList)
            {
                pomListManifest.Add(m);
            }

            foreach (KeyValuePair <Guid, Manifestation> t in repManifestacija.getAll())
            {
                Manifestation m = new Manifestation(t.Value.Id, t.Value.Type, t.Value.Date, t.Value.Image, t.Value.Name,
                                                    t.Value.Description, t.Value.ServingAlcohol, t.Value.PriceCategory, t.Value.Visitors,
                                                    t.Value.Smoking, t.Value.Inside, t.Value.ForDisabled, t.Value.Tags);
                pomListManifest.Add(m);
            }


            foreach (KeyValuePair <Guid, Tag> t in repTagova.getAll())
            {
                Tag tag = new Tag(t.Value.Id, t.Value.Description, t.Value.Colour);
                tagList.Add(tag);
            }

            foreach (KeyValuePair <Guid, Slicice> t in repozitorijumSlici.getAll())
            {
                Slicice s = new Slicice(t.Value.X, t.Value.Y, t.Value.Manifestacija);

                Image ikonica = new Image();
                ikonica.Height = 65;
                ikonica.Width  = 65;

                BitmapImage ikonicaSource = new BitmapImage(new Uri(s.Manifestacija.ImgString));
                String      xxx           = "";
                foreach (Tag tx in s.Manifestacija.Tags)
                {
                    xxx += " " + tx.Description;
                }
                String toolTip = s.Manifestacija.Name + "\n" + s.Manifestacija.Type.Name + "\n" + xxx;

                ikonica.ToolTip = toolTip;


                s.Manifestacija.Prevucena = true;
                ikonica.Source            = ikonicaSource;
                this.mapaSlika.Children.Add(ikonica);
                Canvas.SetLeft(ikonica, s.X);
                Canvas.SetTop(ikonica, s.Y);
                sliciceManifestacije.Add(s);
            }
            foreach (KeyValuePair <Guid, ManifestationType> t in repTipova.getAll())
            {
                ManifestationType mt = new ManifestationType(t.Value.Id, t.Value.Name, t.Value.Description, t.Value.Imagee);
                typeList.Add(mt);
            }
            foreach (KeyValuePair <Guid, Manifestation> t in repManifestacija.getAll())
            {
                Manifestation m = new Manifestation(t.Value.Id, t.Value.Type, t.Value.Date, t.Value.Image, t.Value.Name,
                                                    t.Value.Description, t.Value.ServingAlcohol, t.Value.PriceCategory, t.Value.Visitors,
                                                    t.Value.Smoking, t.Value.Inside, t.Value.ForDisabled, t.Value.Tags);
                manifestationList.Add(m);
            }
            View        = CollectionViewSource.GetDefaultView(PomListManifest);
            View.Filter = filterManifestacije;
            DataContext = this;

            gridHome.Visibility               = Visibility.Hidden;
            gridViewTags.Visibility           = Visibility.Hidden;
            gridViewTypes.Visibility          = Visibility.Hidden;
            gridViewManifestations.Visibility = Visibility.Hidden;
            gridLogin.Visibility              = Visibility.Visible;
            gridSearch.Visibility             = Visibility.Hidden;

            errorName.Content       = "";
            errorPassword.Content   = "";
            txtName.BorderBrush     = new SolidColorBrush(Colors.Transparent);
            pass.BorderBrush        = new SolidColorBrush(Colors.Transparent);
            txtName.BorderThickness = new Thickness(0);
            pass.BorderThickness    = new Thickness(0);
        }
Exemplo n.º 13
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            bool errorId       = false;
            bool errorType     = false;
            bool errorDate     = false;
            bool errorName     = false;
            bool errorDesc     = false;
            bool errorAlc      = false;
            bool errorPrice    = false;
            bool errorVisitors = false;
            bool errorSmoking  = false;
            bool errorInside   = false;

            //Content = "Some fields are not filled correctly!"

            if (String.IsNullOrEmpty(txtID.Text) || String.IsNullOrWhiteSpace(txtID.Text))
            {
                error.Content         = "Some fields are not filled correctly!";
                txtID.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtID.BorderThickness = new Thickness(4);
                errorId = true;
            }
            else
            {
                int result;
                if (Int32.TryParse(txtID.Text, out result))
                {
                    lblErrorIDNaN.Visibility = Visibility.Hidden;
                    txtID.BorderBrush        = new SolidColorBrush(Colors.Transparent);
                    txtID.BorderThickness    = new Thickness(0);
                    errorId = false;
                }
                else
                {
                    lblErrorIDNaN.Visibility = Visibility.Visible;
                    txtID.BorderBrush        = new SolidColorBrush(Colors.Red);
                    txtID.BorderThickness    = new Thickness(4);
                    errorId = true;
                }
            }
            if (cmbType.SelectedItem == null)
            {
                error.Content           = "Some fields are not filled correctly!";
                cmbType.BorderBrush     = new SolidColorBrush(Colors.Red);
                cmbType.BorderThickness = new Thickness(4);
                errorType = true;
            }
            else
            {
                cmbType.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                cmbType.BorderThickness = new Thickness(0);
                errorType = false;
            }
            if (dpDate.SelectedDate == null)
            {
                error.Content          = "Some fields are not filled correctly!";
                dpDate.BorderBrush     = new SolidColorBrush(Colors.Red);
                dpDate.BorderThickness = new Thickness(4);
                errorDate = true;
            }
            else
            {
                dpDate.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                dpDate.BorderThickness = new Thickness(0);
                errorDate = false;
            }
            if (String.IsNullOrEmpty(txtName.Text) || String.IsNullOrWhiteSpace(txtName.Text))
            {
                error.Content           = "Some fields are not filled correctly!";
                txtName.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtName.BorderThickness = new Thickness(4);
                errorName = true;
            }
            else
            {
                txtName.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                txtName.BorderThickness = new Thickness(0);
                errorName = false;
            }
            if (String.IsNullOrEmpty(txtDesc.Text) || String.IsNullOrWhiteSpace(txtDesc.Text))
            {
                error.Content           = "Some fields are not filled correctly!";
                txtDesc.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtDesc.BorderThickness = new Thickness(4);
                errorDesc = true;
            }
            else
            {
                txtDesc.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                txtDesc.BorderThickness = new Thickness(0);
                errorDesc = false;
            }
            if (cmbAlc.SelectedItem == null)
            {
                error.Content          = "Some fields are not filled correctly!";
                cmbAlc.BorderBrush     = new SolidColorBrush(Colors.Red);
                cmbAlc.BorderThickness = new Thickness(4);
                errorAlc = true;
            }
            else
            {
                cmbAlc.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                cmbAlc.BorderThickness = new Thickness(0);
                errorAlc = false;
            }
            if (cmbPrice.SelectedItem == null)
            {
                error.Content            = "Some fields are not filled correctly!";
                cmbPrice.BorderBrush     = new SolidColorBrush(Colors.Red);
                cmbPrice.BorderThickness = new Thickness(4);
                errorPrice = true;
            }
            else
            {
                cmbPrice.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                cmbPrice.BorderThickness = new Thickness(0);
                errorPrice = false;
            }
            if (String.IsNullOrEmpty(txtVisitors.Text) || String.IsNullOrWhiteSpace(txtVisitors.Text))
            {
                error.Content               = "Some fields are not filled correctly!";
                txtVisitors.BorderBrush     = new SolidColorBrush(Colors.Red);
                txtVisitors.BorderThickness = new Thickness(4);
                errorVisitors               = true;
            }
            else
            {
                int result;
                if (Int32.TryParse(txtVisitors.Text, out result))
                {
                    lblErrorVisitors.Visibility = Visibility.Hidden;
                    txtVisitors.BorderBrush     = new SolidColorBrush(Colors.Transparent);
                    txtVisitors.BorderThickness = new Thickness(0);
                    errorVisitors = false;
                }
                else
                {
                    lblErrorVisitors.Visibility = Visibility.Visible;
                    txtVisitors.BorderBrush     = new SolidColorBrush(Colors.Red);
                    txtVisitors.BorderThickness = new Thickness(4);
                    errorVisitors = true;
                }
            }
            if (rbInside.IsChecked == false && rbOutside.IsChecked == false)
            {
                error.Content            = "Some fields are not filled correctly!";
                rtInside.Stroke          = new SolidColorBrush(Colors.Red);
                rtInside.StrokeThickness = 4;
                errorInside = true;
            }
            else
            {
                rtInside.Stroke          = new SolidColorBrush(Colors.Transparent);
                rtInside.StrokeThickness = 0;
                errorInside = false;
            }
            if (rbSmoking.IsChecked == false && rbNoSmoking.IsChecked == false)
            {
                error.Content             = "Some fields are not filled correctly!";
                rtSmoking.Stroke          = new SolidColorBrush(Colors.Red);
                rtSmoking.StrokeThickness = 4;
                errorSmoking = true;
            }
            else
            {
                rtSmoking.Stroke          = new SolidColorBrush(Colors.Transparent);
                rtSmoking.StrokeThickness = 0;
                errorSmoking = false;
            }
            if (!errorId && !errorType && !errorDate && !errorName && !errorDesc && !errorAlc && !errorPrice && !errorVisitors && !errorSmoking && !errorInside)
            {
                bool errId = false;
                foreach (Manifestation m in MainWindow.manifestationList)
                {
                    int x = Int32.Parse(txtID.Text);
                    if (x == m.Id)
                    {
                        errId = true;
                        IdErrManifestation errWindow = new IdErrManifestation();
                        errWindow.Show();
                    }
                }
                if (errId == false)
                {
                    string            text = cmbType.Text;
                    ManifestationType mt   = cmbType.SelectedItem as ManifestationType;


                    bool smoking = false;
                    if (rbSmoking.IsChecked == true)
                    {
                        smoking = true;
                    }

                    bool inside = false;
                    if (rbInside.IsChecked == true)
                    {
                        inside = true;
                    }

                    bool forDisabled = false;
                    if (cbDisabled.IsChecked == true)
                    {
                        forDisabled = true;
                    }

                    //   comboBoxTags.Chil
                    List <Tag> tags = new List <Tag>();

                    foreach (Tag t in TheList)
                    {
                        bool x = t.Cekiran;
                        if (x == true)
                        {
                            Console.WriteLine(t.Id);
                            tags.Add(t);
                        }
                    }

                    if (takeTypePhoto)
                    {
                        manifestationImage = mt.Imagee;
                    }


                    Manifestation manifestation = new Manifestation(Int32.Parse(txtID.Text), mt, dpDate.SelectedDate.Value.Date, manifestationImage,
                                                                    txtName.Text, txtDesc.Text, cmbAlc.Text, cmbPrice.Text, Int32.Parse(txtVisitors.Text),
                                                                    smoking, inside, forDisabled, tags);
                    MainWindow.manifestationList.Add(manifestation);
                    MainWindow.repManifestacija.Dodaj(manifestation);
                    MainWindow.pomListManifest.Add(manifestation);


                    this.Close();
                }
            }
        }