void editLastViewedLabel(object sender) { TableLayoutPanel seriesTable = (TableLayoutPanel)Controls.Find("seriesTable", true)[0]; try { Label currLastViewedLabel = (Label)sender; int id = Convert.ToInt32(currLastViewedLabel.Name.Split('_')[1]); string text = currLastViewedLabel.Text; seriesTable.Controls.Remove(currLastViewedLabel); TextBox newTextBox = Context.Controls.CreateTextBox("lastViewedBox_" + id, text); newTextBox.KeyDown += newTextBox_KeyDown; newTextBox.LostFocus += newTextBox_LostFocus; seriesTable.Controls.Add(newTextBox, 2, id + 1); newTextBox.Focus(); } catch { TextBox currLastViewedTextBox = new TextBox(); foreach (Control currControl in seriesTable.Controls) { if (currControl.GetType() == typeof(TextBox)) { currLastViewedTextBox = (TextBox)currControl; } } int id = Convert.ToInt32(currLastViewedTextBox.Name.Split('_')[1]); string text = currLastViewedTextBox.Text; if (!Episode.IsValidEpisodeString(text)) { Variables.IsAddFormOpened = true; Notifications.ShowError("The format of the given episode number is incorrect. Please give a correct one.", "Invalid episode number"); return; } seriesTable.Controls.Remove(currLastViewedTextBox); Label newLabel = Context.Controls.CreateLabel("lastViewed_" + id, text, false); newLabel.Cursor = Cursors.Hand; newLabel.Click += lastViewedLabel_Click; seriesTable.Controls.Add(newLabel, 2, id + 1); Internal.Variables.SeriesList[id].LastViewed = new Episode(text); Context.IO.WriteSeries(); Control currLastEpLabel = Controls.Find("lastEp_" + id, true)[0]; if (Internal.Variables.SeriesList[id].LastEpisode.SeasonNumber > Internal.Variables.SeriesList[id].LastViewed.SeasonNumber || (Internal.Variables.SeriesList[id].LastEpisode.SeasonNumber == Internal.Variables.SeriesList[id].LastViewed.SeasonNumber && Internal.Variables.SeriesList[id].LastEpisode.EpisodeNumber > Internal.Variables.SeriesList[id].LastViewed.EpisodeNumber)) { currLastEpLabel.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, 238); } else if (Internal.Variables.SeriesList[id].LastEpisode.SeasonNumber < Internal.Variables.SeriesList[id].LastViewed.SeasonNumber || (Internal.Variables.SeriesList[id].LastEpisode.SeasonNumber == Internal.Variables.SeriesList[id].LastViewed.SeasonNumber && Internal.Variables.SeriesList[id].LastEpisode.EpisodeNumber < Internal.Variables.SeriesList[id].LastViewed.EpisodeNumber)) { Deactivate -= Form1_Deactivate; MessageBox.Show(this, "The number of the last viewed episode has to be smaller than the one of the newest episode.", "Invalid episode number", MessageBoxButtons.OK, MessageBoxIcon.Error); Show(); Deactivate += Form1_Deactivate; editLastViewedLabel(newLabel); } else { currLastEpLabel.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 238); } } }
public Series(int Id, string Name, string ImdbId, Episode LastViewed, Episode LastEpisode, Episode NextEpisode, DateTime NextEpisodeAirDate, int DateKnown, int NotificationSent) { this.Id = Id; this.Name = Name; this.ImdbId = ImdbId; this.LastViewed = LastViewed; this.LastEpisode = LastEpisode; this.NextEpisode = NextEpisode; this.NextEpisode.AirDate = NextEpisodeAirDate; this.DateKnown = DateKnown; this.NotificationSent = NotificationSent; }