Пример #1
0
        private void DeleteTag_OnClick(object sender, RoutedEventArgs e)
        {
            Tag tt = (Tag)dgrCreatedTags.SelectedItem;

            if (tt != null)
            {
                int cc = map.FindTag(tt);
                if (cc > 0)
                {
                    MessageBoxResult mbr =
                        MessageBox.Show(
                            "There are " + cc +
                            " landmarks that use the tag you want to delete. \nIf you click Yes, you agree to remove deleted tag from all landmarks. \nAre you sure you want to continue?",
                            "Tags Found", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (mbr == MessageBoxResult.Yes)
                    {
                        tempLandmarks = map.RemoveTag(tt, tempLandmarks);
                        ExistTags.Remove(tt);
                        existAllTags.Remove(tt);
                        MyTags.Remove(tt);
                        myAllTags.Remove(tt);
                        notSaved = true;
                        MessageBox.Show(
                            "Tag " + tt.TagView + " deleted from " + cc + " landmarks", "Tag Deleted",
                            MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    ExistTags.Remove(tt);
                    existAllTags.Remove(tt);
                    MyTags.Remove(tt);
                    myAllTags.Remove(tt);
                    notSaved = true;
                    MessageBox.Show(
                        "Tag " + tt.TagView + " deleted.",
                        "Tag Deleted", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                MessageBox.Show(
                    "Please select one of the tags.", "Selection Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
        public bool addATag(Tag t)
        {
            Search.Text = "";
            bool found = false;

            if (!forChange)     //ako se ne menja nista, samo trazi govnara
            {
                foreach (var tt in ExistTags)
                {
                    if (tt.ID.Equals(t.ID))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    ExistTags.Add(t);
                    existAllTags.Add(t);
                    notSaved = true;
                    return(true);
                }

                return(false);
            }

            forChange = false;
            //nesto se menja -> treba da se nadje kopija i doda asaf
            if (!copy.Equals(t))
            {
                ExistTags.Remove(copy);
                existAllTags.Remove(copy);
                ExistTags.Add(t);
                existAllTags.Add(t);
                MyTags.Remove(copy);
                myAllTags.Remove(copy);
                MyTags.Add(t);
                myAllTags.Add(t);
            }

            notSaved = true;
            return(true);
        }
Пример #3
0
        private void Go_OnClick(object sender, TextChangedEventArgs e)
        {
            bool flag = false;

            string input = Search.Text.Trim();

            if (ExistTags != null)
            {
                for (int i = ExistTags.Count - 1; i >= 0; i--)
                {
                    ExistTags.RemoveAt(i);
                }

                if (input.Equals("") || input.Equals("Search for tag"))
                {
                    flag = true;
                    foreach (var l in existAllTags)
                    {
                        ExistTags.Add(l);
                    }
                }

                if (flag == false)
                {
                    foreach (var l in existAllTags)
                    {
                        if (l.Similar(input))
                        {
                            ExistTags.Add(l);
                        }
                    }
                }
            }

            flag = false;
            if (MyTags != null)
            {
                for (int i = MyTags.Count - 1; i >= 0; i--)
                {
                    MyTags.RemoveAt(i);
                }

                if (input.Equals("") || input.Equals("Search for tag"))
                {
                    flag = true;
                    foreach (var l in myAllTags)
                    {
                        MyTags.Add(l);
                    }
                }

                if (flag == false)
                {
                    foreach (var l in myAllTags)
                    {
                        if (l.Similar(input))
                        {
                            MyTags.Add(l);
                        }
                    }
                }
            }
        }