private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            TagBox clickedBox = ((TagBox)sender);

            if (clickedBox.IsChecked == true)
            {
                SelectedTags.Add(clickedBox.TagData);
            }
            else
            {
                SelectedTags.Remove(clickedBox.TagData);
            }
        }
        private void CreateTagBoxes(List <TagObject> AlreadySelectedTags)
        {
            //Create and Add handlers for the Tag Buttons handlers to the buttons.
            //This is done because with redundancy because I want to make sure each of the
            //Lists are sorted alphabetically within their category.
            foreach (TagObject Tag in LocalData.GenreTags)
            {
                TagBox box = new TagBox(Tag);
                box.Click += new RoutedEventHandler(CheckBox_Click);
                if (AlreadySelectedTags.Contains(Tag))
                {
                    box.IsChecked = true;
                }

                GenresTagList.Items.Add(box);
            }
            foreach (TagObject Tag in LocalData.InstrumentTags)
            {
                TagBox box = new TagBox(Tag);
                box.Click += new RoutedEventHandler(CheckBox_Click);
                if (AlreadySelectedTags.Contains(Tag))
                {
                    box.IsChecked = true;
                }

                InstrumentsTagList.Items.Add(box);
            }
            foreach (TagObject Tag in LocalData.LanguageTags)
            {
                TagBox box = new TagBox(Tag);
                box.Click += new RoutedEventHandler(CheckBox_Click);
                if (AlreadySelectedTags.Contains(Tag))
                {
                    box.IsChecked = true;
                }

                LanguagesTagList.Items.Add(box);
            }
        }
Exemplo n.º 3
0
        public TagPage(LocalDataManager LocalData)
        {
            InitializeComponent();
            this.LocalData                = LocalData;
            this.SelectedTags             = new List <TagBox>();
            this.SelectedTypeToAdd        = TagType.Language;
            this.LanguageSelect.IsChecked = true;

            this.TagBoxes = new List <TagBox>();

            //Add handlers to the buttons.
            foreach (TagObject Tag in this.LocalData.Tags)
            {
                TagBox box = new TagBox(Tag);

                //Add TagWindow Specific handelers
                box.Checked   += new RoutedEventHandler(CheckBox_Check);
                box.Unchecked += new RoutedEventHandler(CheckBox_Uncheck);

                TagBoxes.Add(box);

                //Make the buttons visible
                switch (box.TagData.Type)
                {
                case TagType.Genre:
                    GenreTagBox.Items.Add(box);
                    break;

                case TagType.Instrument:
                    InstrumentTagBox.Items.Add(box);
                    break;

                case TagType.Language:
                    LanguageTagBox.Items.Add(box);
                    break;
                }
            }
        }
Exemplo n.º 4
0
        /**
         * This will only occur when add is already active, so when this is clicked
         * the selected tag should be added to tag list.
         *
         * Might be lazy, instead of updating the actualy whole taglist, probably just
         * create a checkbox and add it to the appropriate box once submit is clicked.
         */
        private void TagSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (AddButton.IsChecked == true)
            {
                if (TagSubmissionBox.Text == "" || (LanguageSelect.IsChecked == false && GenreSelect.IsChecked == false && InstrumentSelect.IsChecked == false))
                {
                    ErrorLabel.Content    = "Invalid Request!";
                    ErrorLabel.Foreground = Brushes.Red;
                    return;
                }

                if (this.LocalData.IsATag(TagSubmissionBox.Text))
                {
                    ErrorLabel.Content    = "Tag already exists";
                    ErrorLabel.Foreground = Brushes.Red;
                    return;
                }

                TagObject newTag    = new TagObject(TagSubmissionBox.Text, SelectedTypeToAdd);
                TagBox    newTagBox = new TagBox(newTag);

                LocalData.AddTag(newTag);
                this.TagBoxes.Add(newTagBox);

                switch (SelectedTypeToAdd)
                {
                case TagType.Genre:
                    GenreTagBox.Items.Add(newTagBox);
                    GenreTagBox.Items.Refresh();
                    break;

                case TagType.Instrument:
                    InstrumentTagBox.Items.Add(newTagBox);
                    InstrumentTagBox.Items.Refresh();
                    break;

                case TagType.Language:
                    LanguageTagBox.Items.Add(newTagBox);
                    LanguageTagBox.Items.Refresh();
                    break;
                }

                this.TagSubmissionBox.Text = "";
            }
            else
            {
                foreach (TagBox box in this.SelectedTags)
                {
                    LocalData.RemoveTag(box.TagData);
                    this.TagBoxes.Remove(box);

                    switch (box.TagData.Type)
                    {
                    case TagType.Genre:
                        GenreTagBox.Items.Remove(box);
                        GenreTagBox.Items.Refresh();
                        break;

                    case TagType.Instrument:
                        InstrumentTagBox.Items.Remove(box);
                        InstrumentTagBox.Items.Refresh();
                        break;

                    case TagType.Language:
                        LanguageTagBox.Items.Remove(box);
                        LanguageTagBox.Items.Refresh();
                        break;
                    }
                }
            }
        }