Ejemplo n.º 1
0
        private void CommandBinding_DeleteCustomTag(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.Wait;
                string res = "";


                // NOTE if we are disabling an image we should also make sure it is not the default
                CustomTagVM tag = null;
                if (obj.GetType() == typeof(CustomTagVM))
                {
                    tag = (CustomTagVM)obj;
                    res = JMMServerVM.Instance.clientBinaryHTTP.DeleteCustomTag(tag.CustomTagID);
                }

                if (res.Length > 0)
                {
                    MessageBox.Show(res, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    CustomTagVM ctagToRemove = null;
                    foreach (CustomTagVM ctag in JMMServerVM.Instance.AllCustomTags)
                    {
                        if (ctag.CustomTagID == tag.CustomTagID)
                        {
                            ctagToRemove = ctag;
                            break;
                        }
                    }

                    if (ctagToRemove != null)
                    {
                        JMMServerVM.Instance.AllCustomTags.Remove(ctagToRemove);
                        JMMServerVM.Instance.ViewCustomTagsAll.Refresh();

                        //TODO: Custom Tags -  update any cached data for affected anime
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 2
0
        void btnAddCustomTag_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Cursor = Cursors.Wait;
                string res = "";

                if (string.IsNullOrWhiteSpace(txtTagName.Text))
                {
                    MessageBox.Show("Please enter a tag name", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    txtTagName.Focus();
                    return;
                }

                JMMServerBinary.Contract_CustomTag contract = new JMMServerBinary.Contract_CustomTag();
                contract.TagName        = txtTagName.Text.Trim();
                contract.TagDescription = txtTagDescription.Text.Trim();


                JMMServerBinary.Contract_CustomTag_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SaveCustomTag(contract);

                if (!string.IsNullOrEmpty(resp.ErrorMessage))
                {
                    MessageBox.Show(res, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    CustomTagVM ctag = new CustomTagVM(resp.CustomTag);
                    JMMServerVM.Instance.AllCustomTags.Add(ctag);
                    JMMServerVM.Instance.ViewCustomTagsAll.Refresh();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
        void btnAddCustomTag_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.Cursor = Cursors.Wait;
                string res = "";

                if (string.IsNullOrWhiteSpace(txtTagName.Text))
                {
                    MessageBox.Show(Properties.Resources.CustomTag_EnterName, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    txtTagName.Focus();
                    return;
                }

                JMMServerBinary.Contract_CustomTag contract = new JMMServerBinary.Contract_CustomTag();
                contract.TagName = txtTagName.Text.Trim();
                contract.TagDescription = txtTagDescription.Text.Trim();

                JMMServerBinary.Contract_CustomTag_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SaveCustomTag(contract);

                if (!string.IsNullOrEmpty(resp.ErrorMessage))
                {
                    MessageBox.Show(res, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    CustomTagVM ctag = new CustomTagVM(resp.CustomTag);
                    JMMServerVM.Instance.AllCustomTags.Add(ctag);
                    JMMServerVM.Instance.ViewCustomTagsAll.Refresh();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
        public void Populate(JMMServerBinary.Contract_AniDB_AnimeDetailed contract, int animeID)
        {
            AnimeID = animeID;

            AnimeTitles = new List<AnimeTitleVM>();
            AnimeTitlesSummary = new List<AnimeTitleVM>();
            AnimeTitlesMain = new List<AnimeTitleVM>();
            AnimeTitlesOfficial = new List<AnimeTitleVM>();
            AnimeTitlesSynonym = new List<AnimeTitleVM>();
            AnimeTitlesShort = new List<AnimeTitleVM>();

            AnimeTags = new List<AnimeTagVM>();
            AnimeTagsSummary = new List<AnimeTagVM>();
            CustomTags.Clear();

            try
            {
                AniDB_Anime = new AniDB_AnimeVM(contract.AniDBAnime);
                UserVote = null;
                if (contract.UserVote != null)
                    UserVote = new AniDB_VoteVM(contract.UserVote);

                UserHasVoted = UserVote != null;
                UserHasNotVoted = UserVote == null;

                if (UserVote == null)
                    UserRating = 0;
                else
                    UserRating = UserVote.VoteValue;

                UserRatingFormatted = Utils.FormatAniDBRating((double)UserRating);
                if (UserVote != null)
                {
                    UserRatingFormatted += " (";
                    if (UserVote.VoteType == 1) UserRatingFormatted += Properties.Resources.VoteTypeAnimePermanent;
                    if (UserVote.VoteType == 2) UserRatingFormatted += Properties.Resources.VoteTypeAnimeTemporary;
                    UserRatingFormatted += ")";
                }

                this.Stat_AllVideoQuality = new HashSet<string>(contract.Stat_AllVideoQuality);
                this.Stat_AllVideoQuality_Episodes = new HashSet<string>(contract.Stat_AllVideoQuality_Episodes);
                this.Stat_AudioLanguages = new HashSet<string>(contract.Stat_AudioLanguages);
                this.Stat_SubtitleLanguages = new HashSet<string>(contract.Stat_SubtitleLanguages);

                foreach (JMMServerBinary.Contract_AnimeTag tag in contract.Tags)
                {
                    AnimeTagVM vtag = new AnimeTagVM(tag);
                    AnimeTags.Add(vtag);
                }
                //AnimeTags.Sort();

                List<SortPropOrFieldAndDirection> sortCriteria = new List<SortPropOrFieldAndDirection>();
                sortCriteria.Add(new SortPropOrFieldAndDirection("Weight", true, SortType.eInteger));
                AnimeTags = Sorting.MultiSort<AnimeTagVM>(AnimeTags, sortCriteria);

                int i = 0;
                /*
                foreach (AnimeTagVM tag in AnimeTags)
                {
                    if (i <= 5)
                        AnimeTagsSummary.Add(tag);
                    else
                        break;
                    i++;
                }
                */

                foreach (JMMServerBinary.Contract_CustomTag ctag in contract.CustomTags)
                {
                    CustomTagVM vtag = new CustomTagVM(ctag);
                    CustomTags.Add(vtag);
                }
                CustomTags.Sort();
                ViewCustomTags.Refresh();

                foreach (JMMServerBinary.Contract_AnimeTitle title in contract.AnimeTitles)
                {
                    AnimeTitleVM vtitle = new AnimeTitleVM(title);
                    AnimeTitles.Add(vtitle);

                    if (title.TitleType.Trim().ToUpper() == Constants.AnimeTitleType.Main.ToUpper())
                        AnimeTitlesMain.Add(vtitle);

                    if (title.TitleType.Trim().ToUpper() == Constants.AnimeTitleType.Official.ToUpper())
                        AnimeTitlesOfficial.Add(vtitle);

                    if (title.TitleType.Trim().ToUpper() == Constants.AnimeTitleType.Synonym.ToUpper())
                        AnimeTitlesSynonym.Add(vtitle);

                    if (title.TitleType.Trim().ToUpper() == Constants.AnimeTitleType.ShortName.ToUpper())
                        AnimeTitlesShort.Add(vtitle);
                }
                i = 0;
                foreach (AnimeTitleVM title in AnimeTitlesOfficial)
                {
                    if (i <= 5)
                        AnimeTitlesSummary.Add(title);
                    else
                        break;
                    i++;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }