public SearchInformation AddSearchToDictionary(SearchInformation setting) { var item = this.AddSearchToDictionaryMain(setting); item.SetDateToNow(); return(item); }
public bool CheckSimilarity(SearchInformation other) { if (object.ReferenceEquals(this, other)) { return(!this.Root.IsEdited); } return(this.HasSameSearch(other) && this.HasSameSort(other)); }
public bool SettingEquals(SearchInformation other) { if (object.ReferenceEquals(this, other)) { return(true); } return(this.HasSameSearch(other) && this.HasSameSort(other)); }
public bool HasSameSort(SearchInformation other) { if (other == null) { return(false); } return(this.SortSettings.SequenceEqual(other.SortSettings, (x, y) => x.ValueEquals(y))); }
public bool HasSameSearch(SearchInformation other) { if (other == null) { return(false); } return(this.Root.ValueEquals(other.Root)); }
private SearchInformation AddSearch(SearchInformation setting) { setting.SetNewKey(); //var key = Guid.NewGuid().ToString(); //setting.Key = key; this.SearchSettings.Add(setting.Key, setting); return(setting); }
public bool ValueEquals(SearchInformation other) { if (this.Name != other.Name || this.DateLastUsed != other.DateLastUsed || this.ThumbnailFilePath != other.ThumbnailFilePath) { return(false); } return(this.SettingEquals(other)); }
/// <summary> /// アルバムからアイテムを削除 /// </summary> /// <param name="item"></param> public void MarkSearchUnfavorite(SearchInformation item) { if (item == null) { return; } var index = this.FavoriteSearchList.FindIndex(x => x.Key.Equals(item.Key)); if (index >= 0) { this.FavoriteSearchList.RemoveAt(index); } }
/// <summary> /// 検索条件をアルバムに登録 /// </summary> /// <param name="item"></param> public void MarkSearchFavorite(SearchInformation item) { if (item == null) { return; } if (item.Key.IsNullOrEmpty()) { item.SetNewKey(); //item.Key = Guid.NewGuid().ToString(); } if (!this.FavoriteSearchList.Any(x => x.Key.Equals(item.Key))) { item.Name = this.GenerateAlbumName(); this.FavoriteSearchList.Insert(0, item); } }
private SearchInformation AddSearchToDictionaryMain(SearchInformation setting) { if (setting.Key == null || !this.SearchSettings.ContainsKey(setting.Key)) { //内容の同じ検索が履歴に残っていたら置き換える var resembler = this.SearchSettings .FirstOrDefault(x => x.Value.HasSameSearch(setting)); if (resembler.Value != null) { var newitem = setting; if (newitem.ThumbnailFilePath == null) { newitem.ThumbnailFilePath = resembler.Value.ThumbnailFilePath; } this.SearchSettings[resembler.Key] = newitem; newitem.Key = resembler.Key; return(newitem); } return(this.AddSearch(setting)); } var existing = this.SearchSettings[setting.Key]; if (existing.HasSameSearch(setting)) { var item = setting; this.SearchSettings[setting.Key] = item; item.Key = setting.Key; return(item); } else { return(this.AddSearch(setting)); } }
public void RefreshList(SearchInformation setting) { this.RefreshSearchHistory(); if (setting == null) { return; } var favoriteIndex = this.FavoriteSearchList .FindIndex(x => x.Key != null && x.Key.Equals(setting.Key)); if (this.FavoriteSearchList.ContainsIndex(favoriteIndex)) { if (!this.FavoriteSearchList[favoriteIndex].ValueEquals(this.SearchSettings[setting.Key])) { Debug.WriteLine($"{this.FavoriteSearchList[favoriteIndex].Name},{this.SearchSettings[setting.Key].Name}"); this.SearchSettings[setting.Key].Name = this.FavoriteSearchList[favoriteIndex].Name; } this.FavoriteSearchList.RemoveAt(favoriteIndex); this.FavoriteSearchList.Insert(favoriteIndex, this.SearchSettings[setting.Key]); } }