/// <summary> /// Update the row from a season. /// </summary> /// <param name="episode"></param> public void Update(Entity.Season season) { this.Title = season.Title; this.Type = season.Type; this.SetCover(season.DisplayCover); // Set Status if (season.UserStatus != null) { if (season.UserStatus.Type == 0) { this.StringSmallStatus = season.UserStatus.Text; } else { this.StringBigStatus = season.UserStatus.Text; } } else { this.Status = (Entity.DefaultStatus)season.StatusId; } this.NumberOfSeasons = 0; this.NumberOfEpisodes = season.EpisodesOwned; this.Number = season.Number.ToString(); this.SetEpisodesValues(season.EpisodesViewed, season.EpisodesOwned, season.EpisodesTotal); }
/// <summary> /// Clear stored series, current serie and current season. /// </summary> private void ClearSeries() { this.series.Clear(); this.currentSerie = null; this.currentSeason = null; }
/* * ============================================ * Private * ============================================ */ /// <summary> /// Initialize the window's content. /// </summary> private void InitContent(Entity.Season season = null) { this.Owner = App.Current.MainWindow; List <Entity.Studio> studios = Repository.Studio.Instance.GetAll(); foreach (Entity.Studio studio in studios) { this.AddCommboBoxItem(this.ComboBox_Studio, studio.Name, studio.Id); if (season != null && studio.Id == season.StudioId) { this.SelectValue(this.ComboBox_Studio, studio.Name); } } // Add types foreach (Constants.Type type in Enum.GetValues(typeof(Constants.Type))) { this.AddCommboBoxItem(this.ComboBox_Type, Lang.Content(type.ToString().ToLower()), type); } // Add sources foreach (Constants.Source source in Enum.GetValues(typeof(Constants.Source))) { this.AddCommboBoxItem(this.ComboBox_Source, Lang.Content(source.ToString().ToLower()), source); } }
/// <summary> /// Add a season row to the list. /// </summary> /// <param name="tile"></param> public IItem Add(Entity.Season season, bool insert = false) { IItem row = this.CreateItemFromSeason(this.Count, season); this.Add(row); return(row); }
/// <summary> /// Get the label to be displayed for a season. /// </summary> /// <param name="season"></param> /// <returns></returns> private string GetSeasonLabel(Entity.Season season) { if (this.isSeasonalView) { return(season.Premiered); } return(season.Grouping != null ? season.Grouping : ""); }
public int Add(Entity.Season season) { // Add to database season.Id = this.SeasonRepository.Add(season); // Add to list this.seasons.Add(season); return(season.Id); }
/// <summary> /// Create a row item from a season. /// </summary> /// <param name=""></param> /// <returns></returns> public IItem CreateItemFromSeason(ushort index, Entity.Season season, bool placeLabel = false) { Row row = new Row(index); row.Update(season); // Create an empty context menu now to prevent the collection one to open instead when right clicking a tile. row.Image_Cover.ContextMenu = new ContextMenu(); return(row); }
/// <summary> /// Insert a season tile under the label corresponding to its type. /// </summary> /// <param name="season"></param> /// <returns></returns> private IItem InsertAfterTag(Entity.Season season) { string seasonLabel = this.GetSeasonLabel(season); int index = 0; bool found = false; // Seach the label in the list foreach (UIElement element in this.grid_Content.Children) { Tile tileElement = (Tile)element; if (tileElement.Tag.ToString() == seasonLabel) { found = true; } else if (found) { break; // Index found } index++; } // Important: we should only set the last agrument of CreateItemFromSeason() to false if index is inferior to this.grid_Content.Children.Count. bool shouldPlaceLabel = false; if (index >= this.grid_Content.Children.Count) { shouldPlaceLabel = true; } Tile tile = (Tile)this.CreateItemFromSeason(this.Count, season, shouldPlaceLabel); tile.CoverWidth = this.itemWidth; tile.CoverHeight = this.ItemHeight; // Display it this.grid_Content.Children.Insert(index, tile); // Calculate its position if (!this.isLabeled) { this.PlaceItems(index); } else { this.PlaceItemsWithLabels(index); } return(tile); }
/// <summary> /// Add a season tile to the list. /// </summary> /// <param name="tile"></param> public IItem Add(Entity.Season season, bool insert = false) { // As we use labels we want the tile to be added in the right category if (insert && this.isLabeled) { return(this.InsertAfterTag(season)); } // Without labels we can just add it at the end of the list. IItem tile = this.CreateItemFromSeason(this.Count, season, true); this.Add(tile); return(tile); }
public void UpdateEpisodesValues(Entity.Season season) { string[] keys = { "episodes_Owned", "episodes_Total", "episodes_Viewed" }; string[] values = { season.EpisodesOwned.ToString(), season.EpisodesTotal.ToString(), season.EpisodesViewed.ToString() }; App.db.Update(Entity.Season.TABLE, season.Id, keys, values); }
/// <summary> /// Create a tile item from a season. /// </summary> /// <param name=""></param> /// <returns></returns> public IItem CreateItemFromSeason(ushort index, Entity.Season season, bool placeLabel = true) { Tile tile = new Tile(index); // Add the label, only for the season view mode if (this.isLabeled) { string nextLabel = this.GetSeasonLabel(season); // Set the label as a tag tile.Tag = nextLabel; // Only place a label if different from the previous one if (placeLabel && nextLabel != this.previousLabel) { this.previousLabel = nextLabel; // Add space between the last and next row of tiles to place the label if (index != 0) { this.row += 1; if (this.firstLabelAdded) { this.row += 0.2; } this.addedTiles = 0; } this.AddLabel(this.previousLabel); } } // Add the tile tile.Update(season); // Create an empty context menu now to prevent the collection one to open instead when right clicking a tile. tile.Image_Cover.ContextMenu = new ContextMenu(); return(tile); }
/// <summary> /// Existing season constructor. /// </summary> /// <param name="season"></param> /// <param name="userStatusList"></param> public SeasonEdit(Entity.Season season, List <Entity.UserStatus> userStatusList) { InitializeComponent(); this.InitContent(season); this.SetStatusInCombo(userStatusList); this.LoadGroupings(season.SerieId); this.Title = Lang.Text("editSeason", "Edit a season"); this.Button_Add.Content = Lang.EDIT; this.Browse_Cover.AddFilter(Constants.IMAGE_FILTER); this.SeasonTitle = season.Title; this.Number = season.Number; this.EpisodesCount = season.EpisodesTotal; this.Cover = (season.Cover == "no") ? "" : season.Cover; this.StudioId = season.StudioId; this.Seasonal = season.Seasonal; this.Year = season.Year; this.Month = season.Month; this.Day = season.Day; this.Cover = season.Cover; this.StatusId = season.StatusId; this.ComboBox_Source.SelectedIndex = season.SourceIndex; this.TextBox_Grouping.Text = season.Grouping; this.DateInput.Seasons.SelectedIndex = (int)season.Seasonal; this.ComboBox_Type.SelectedIndex = (int)season.Type; if (season.WideEpisode) { this.Radio_Wide.IsChecked = true; } else { this.Radio_Narrow.IsChecked = true; } }
/* * ====================================== * Action * ====================================== */ #region Action /// <summary> /// Add an entity in database. /// </summary> /// <param name="episode"></param> /// <returns>created entity ID</returns> public int Add(Entity.Season season) { App.db.Insert(Entity.Season.TABLE, this.table.GetKeysAndValues(season)); return(App.db.LastId(Entity.Season.TABLE)); }
/// <summary> /// Update the whole entity. /// </summary> /// <param name="season"></param> public void Update(Entity.Season season) { App.db.Update(Entity.Season.TABLE, season.Id, this.table.GetKeysAndValues(season)); }
/// <summary> /// Update a field from the entity. /// Faster than updating the whole entity but slower than UpdateField(). /// </summary> /// <param name="season"></param> /// <param name="field"></param> public void Update(Entity.Season season, string field) { App.db.Update(Entity.Season.TABLE, season.Id, this.table.GetKeyValue(season, field)); }
/// <summary> /// Clear stored series, current serie and current season. /// </summary> private void ClearSeasons() { this.seasons.Clear(); this.currentSeason = null; }
private Entity.Season FillEntityFromTuple(Dictionary <string, string> tuple) { Entity.Season season = (Entity.Season) this.table.FillEntityFromTuple(Entity.Season.TABLE, new Entity.Season(), tuple); return(season); }