Exemple #1
0
        public ShowTags()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            SelectedTag = null;
            DataContext = this;
            Tags        = Database.getInstance().Tags;
        }
Exemple #2
0
        public AddTag()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            tag         = new ManifestationTag();
            DataContext = tag;

            idError          = false;
            descriptionError = false;
            openedAsDialog   = false;
        }
Exemple #3
0
        public EditTag(string tagId)
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            oldId = tagId;

            mTag = new ManifestationTag(Database.GetTag(tagId));
            if (mTag.Color != null)
            {
                ColorPicker.SelectedColor = (Color)ColorConverter.ConvertFromString(tag.Color);
            }
            DataContext = tag;

            idError          = false;
            descriptionError = false;
        }
Exemple #4
0
        private void autoCompleteBoxTag_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (Database.GetTag(autoCompleteBoxTags.Text) == null && !string.IsNullOrWhiteSpace(autoCompleteBoxTags.Text))
                {
                    AddTag dialog = new AddTag(autoCompleteBoxTags.Text);
                    dialog.ShowDialog();

                    // If it has successfully added a new tag
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        ManifestationTag tag = new ManifestationTag(Database.getInstance().Tags.Last());
                        Manifestation.Tags.Add(tag);
                        comboBoxTags.SelectedItems.Add(tag);

                        autoCompleteBoxTags.SelectedItem = null;
                        autoCompleteBoxTags.Text         = string.Empty;
                    }
                    autoCompleteBoxTags.SelectedItem = null;
                    autoCompleteBoxTags.Text         = string.Empty;
                }
                else if (!string.IsNullOrWhiteSpace(autoCompleteBoxTags.Text))
                {
                    ManifestationTag tag = new ManifestationTag(Database.GetTag(autoCompleteBoxTags.Text));

                    bool found = false;
                    foreach (var item in comboBoxTags.SelectedItems)
                    {
                        if (((ManifestationTag)item).Id.Equals(tag.Id))
                        {
                            found = true;
                        }
                    }
                    if (!found)
                    {
                        Manifestation.Tags.Add(tag);
                        comboBoxTags.SelectedItems.Add(tag);
                    }

                    autoCompleteBoxTags.SelectedItem = null;
                    autoCompleteBoxTags.Text         = string.Empty;
                }
            }
        }
Exemple #5
0
 private void buttonDelete_Click(object sender, RoutedEventArgs e)
 {
     if (SelectedTag != null)
     {
         if (manifestationsHaveTag(SelectedTag.Id))
         {
             DeleteTag dialog = new DeleteTag(SelectedTag.Id);
             dialog.ShowDialog();
         }
         else
         {
             Database.DeleteTag(SelectedTag);
             SelectedTag = null;
         }
     }
     else
     {
         MessageBox.Show("Molimo, odaberite etiketu za brisanje", "Brisanje etikete");
     }
 }
        public DeleteTag(string tagId)
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            Manifestations = Database.getInstance().Manifestations;
            mTag           = Database.GetTag(tagId);

            manifestationsWithTag = new ObservableCollection <Manifestation>();

            foreach (var manifestation in Manifestations)
            {
                foreach (var tag in manifestation.Tags)
                {
                    if (tag.Id.Equals(mTag.Id))
                    {
                        manifestationsWithTag.Add(manifestation);
                    }
                }
            }
            DataContext = this;
        }
Exemple #7
0
        private void buttonAddNewTag_Click(object sender, RoutedEventArgs e)
        {
            // if it hasn't been found in database, open dialog to add it
            if (Database.GetTag(autoCompleteBoxTags.Text) == null)
            {
                AddTag dialog;
                if (string.IsNullOrWhiteSpace(autoCompleteBoxTags.Text))
                {
                    dialog = new AddTag();
                }
                else
                {
                    dialog = new AddTag(autoCompleteBoxTags.Text);
                }
                dialog.ShowDialog();

                // If it has successfully added a new tag
                if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                {
                    ManifestationTag tag = new ManifestationTag(Database.getInstance().Tags.Last());

                    // make sure tag is't already added
                    bool found = false;
                    foreach (var manifestationTag in Manifestation.Tags)
                    {
                        if (manifestationTag.Id.Equals(tag.Id))
                        {
                            found = true;
                            SelectedTags.Add(manifestationTag);
                        }
                    }
                    if (!found)
                    {
                        Manifestation.Tags.Add(tag);
                        SelectedTags.Add(tag);
                    }
                }
            }
            // if it has been found in database
            else
            {
                ManifestationTag tag = new ManifestationTag(Database.GetTag(autoCompleteBoxTags.Text));

                // make sure tag is't already added
                bool found = false;
                foreach (var manifestationTag in Manifestation.Tags)
                {
                    if (manifestationTag.Id.Equals(tag.Id))
                    {
                        found = true;
                        SelectedTags.Add(manifestationTag);
                    }
                }
                if (!found)
                {
                    Manifestation.Tags.Add(tag);
                    SelectedTags.Add(tag);
                }
            }

            // reset field
            autoCompleteBoxTags.SelectedItem = null;
            autoCompleteBoxTags.Text         = string.Empty;
        }