Ejemplo n.º 1
0
        public void SaveEtiquette(Etiquette e)
        {
            MapData.Etiquettes.Add(e);


            string dataString = JsonConvert.SerializeObject(MapData.Etiquettes);

            using (StreamWriter writer = new StreamWriter(etiquettePath))
            {
                writer.Write(dataString);
            }
        }
 private void EtiquetteSelectionChanged(object sender, RoutedEventArgs e)
 {
     EnableEditForm(true);
     try
     {
         Etiquette etiquette = dgrMain.SelectedItem as Etiquette;
         this.selected_id       = etiquette.Id.ToString();
         idTextBox.Text         = etiquette.Id.ToString();
         colorPicker.Background = etiquette.Color;
         descTextBox.Text       = etiquette.Description;
     }
     catch (Exception ex) { }
 }
Ejemplo n.º 3
0
        private void AddEtiquette(object sender, RoutedEventArgs e)
        {
            Etiquette etiquette = dgrMain.SelectedItem as Etiquette;
            var       filtered  = Resource.Tags.Where(et => et.Id == etiquette.Id);

            if (filtered.ToList().Count != 0)
            {
                MessageBox.Show("Odabrana etiketa sa id " + etiquette.Id + " već postoji u listi.",
                                "Upozorenje o dodavanju", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                return;
            }
            Resource.Tags.Add(etiquette);
            dgrMain1.ItemsSource = Resource.Tags;
            DataManager.SaveResources();
        }
        private void DeleteItem(object sender, RoutedEventArgs e)
        {
            Etiquette etiquette = dgrMain.SelectedItem as Etiquette;

            if (etiquette == null)
            {
                MessageBox.Show("Nije moguće izvršiti brisanje.",
                                "Upozorenje o brisanju", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            if (MessageBox.Show("Da li ste sigurni da želite da obrišete etiketu sa oznakom " + etiquette.Id + " ?",
                                "Upozorenje o brisanju", MessageBoxButton.YesNo,
                                MessageBoxImage.Warning) == MessageBoxResult.No)
            {
                return;
            }

            this.manager.MapData.Etiquettes.Remove(etiquette);
            this.manager.SaveEtiquettes();
        }
        private void AddEtiquette(object sender, RoutedEventArgs e)
        {
            if (txtBoxId.Text.Length == 0)
            {
                MessageBox.Show("Morate popuniti polje za oznaku etikete.", "Nedovršen unos podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            if (colorPicker.SelectedColor == null)
            {
                MessageBox.Show("Morate odabrati boju etikete.", "Nedovršen unos podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            if (txtBoxDescription.Text.Length == 0)
            {
                MessageBox.Show("Morate popuniti polje za opis etikete.", "Nedovršen unos podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            int id = 0;

            if (!int.TryParse(txtBoxId.Text, out id))
            {
                MessageBox.Show("Oznaka etikete mora biti ceo broj.", "Nedovršen unos podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            var query = this.manager.MapData.Etiquettes.Where(i => i.Id == int.Parse(txtBoxId.Text));

            if (query.ToList().Count != 0)
            {
                MessageBox.Show("Etiketa sa oznakom " + query.ToList().First().Id + " već postoji.", "Duplikat", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            Etiquette etiquette = new Etiquette();

            try
            {
                etiquette.Color       = new SolidColorBrush(colorPicker.SelectedColor.Value);
                etiquette.Id          = int.Parse(txtBoxId.Text);
                etiquette.Description = txtBoxDescription.Text;

                manager.SaveEtiquette(etiquette);
            } catch (Exception ex)
            {
                etiquette.Color       = Brushes.White;
                etiquette.Id          = int.Parse(txtBoxId.Text);
                etiquette.Description = txtBoxDescription.Text;

                manager.SaveEtiquette(etiquette);
            }
            MessageBox.Show("Upravo ste dodali etiketu sa id " + etiquette.Id,
                            "Dodata etiketa", MessageBoxButton.OK,
                            MessageBoxImage.Information);
            txtBoxId.Text          = "";
            txtBoxDescription.Text = "";
            //colorPicker.Background = Brushes.White;
            colorPicker.SelectedColor = null;
        }
        private void ChangeItem(object sender, RoutedEventArgs e)
        {
            if (idTextBox.Text.Length == 0)
            {
                MessageBox.Show("Morate popuniti polje za oznaku etikete.", "Nedovršen unos podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            //if (colorPicker.SelectedColor == null)
            //{
            //    MessageBox.Show("Morate odabrati boju etikete.", "Nedovršen unos podataka", MessageBoxButton.OK,
            //        MessageBoxImage.Error);
            //    return;
            //}

            if (descTextBox.Text.Length == 0)
            {
                MessageBox.Show("Morate popuniti polje za opis etikete.", "Nedovršen unos podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            int id = 0;

            if (!int.TryParse(idTextBox.Text, out id))
            {
                MessageBox.Show("Oznaka etikete mora biti ceo broj.", "Nedovršen unos podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }

            Etiquette etiquette = dgrMain.SelectedItem as Etiquette;

            if (!this.valid)
            {
                MessageBox.Show("Nije moguće izmeniti etiketu " + etiquette.Id,
                                "Upozorenje o izmeni podataka", MessageBoxButton.OK,
                                MessageBoxImage.Error);
                return;
            }
            if (MessageBox.Show("Da li ste sigurni da želite da izmenite podatake za etiketu sa oznakom " + etiquette.Id + " ?",
                                "Upozorenje o izmeni podataka", MessageBoxButton.YesNo,
                                MessageBoxImage.Warning) == MessageBoxResult.No)
            {
                return;
            }

            try
            {
                etiquette.Id          = int.Parse(idTextBox.Text);
                etiquette.Color       = new SolidColorBrush(colorPicker.SelectedColor.Value);
                etiquette.Description = descTextBox.Text;
                this.manager.SaveEtiquettes();
            }
            catch (Exception ex) {
                etiquette.Id          = int.Parse(idTextBox.Text);
                etiquette.Description = descTextBox.Text;
                this.manager.SaveEtiquettes();
            }
        }
Ejemplo n.º 7
0
        private void RemoveEtiquette(object sender, RoutedEventArgs e)
        {
            Etiquette etiquette = dgrMain1.SelectedItem as Etiquette;

            Resource.Tags.Remove(etiquette);
        }