private void Commit() { if (string.IsNullOrEmpty(CommitMessage)) { MainWindow.Instance.Dispatcher.Invoke(() => { MainWindow.ShowMessage("Not so fast...", "Please provide a commit message", MessageDialogStyle.Affirmative); }); return; } // Tag has been typed in but not added if (!string.IsNullOrEmpty(TagString) && CustomTags.All(x => x.Tag != TagString)) { MessageDialogResult result = MessageDialogResult.Negative; MainWindow.Instance.Dispatcher.Invoke(async() => { result = await MainWindow.ShowMessage("Missing Tag", "You seem to have a tag that has not been added. Do you want to continue without adding the tag?", MessageDialogStyle.AffirmativeAndNegative); }).Wait(); if (result == MessageDialogResult.Negative) { return; } } OperationStatusDialog.Start("Commit"); bool commitSuccessful = _areaVM.Area.Commit(CommitMessage, false, GetCommitTags()); if (commitSuccessful && PushOnCommit) { _areaVM.ExecuteClientCommand((c) => c.Push(), "push", true); } OperationStatusDialog.Finish(); CommitMessage = string.Empty; TagPresets.ForEach(x => x.IsChecked = false); MainWindow.Instance.Dispatcher.Invoke(() => CustomTags.Clear()); Refresh(); }
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); } }
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>(); AnimeCategories = new List <AnimeCategoryVM>(); AnimeCategoriesSummary = new List <AnimeCategoryVM>(); 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 = contract.Stat_AllVideoQuality; this.Stat_AllVideoQuality_Episodes = contract.Stat_AllVideoQuality_Episodes; this.Stat_AudioLanguages = contract.Stat_AudioLanguages; this.Stat_SubtitleLanguages = contract.Stat_SubtitleLanguages; foreach (JMMServerBinary.Contract_AnimeCategory cat in contract.Categories) { AnimeCategoryVM vcat = new AnimeCategoryVM(cat); AnimeCategories.Add(vcat); } AnimeCategories.Sort(); int i = 0; foreach (AnimeCategoryVM cat in AnimeCategories) { if (i <= 5) { AnimeCategoriesSummary.Add(cat); } else { break; } i++; } foreach (JMMServerBinary.Contract_AnimeTag tag in contract.Tags) { AnimeTagVM vtag = new AnimeTagVM(tag); AnimeTags.Add(vtag); } AnimeTags.Sort(); 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); } }