private async void enabledCheckedBox_Click(object sender, EventArgs e) { Movie.Data temp = movie; string desc = ""; if (enabledCheckedBox.Checked) { desc = "Are you sure you want to DISABLE this movie!"; } else { desc = "Are you sure you want to ENABLE this movie!"; } if (MessageBox.Show(desc, temp.Movie_Info.title, MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { temp.enabled = !enabledCheckedBox.Checked; Debug.WriteLine(await API.Communication.Set.MovieStatus(temp)); var m = await API.Communication.Get.MovieByGuid(temp.guid); if (m.enabled == temp.enabled) { enabledCheckedBox.Checked = (m.enabled == true) ? true : false; Edited = true; } } }
public Edit(Movie.Data data, Button mbutton) { InitializeComponent(); movie = data; movieButton = mbutton; this.Text += "-> " + movie.Movie_Info.title; foreach (Control cont in this.Controls) { if (cont.Name.Contains("TextBox") || cont.Name.Contains("CheckedBox") || cont.Name.Contains("Image")) { GetMovieInfoToObject(cont.Name); } } }
private void GetMovieInfoToObject(string item) { Movie.Data m = new Movie.Data() { Movie_Info = new Movie.Info() }; var sitem = item.Split(new string[] { "TextBox", "CheckedBox", "Image" }, StringSplitOptions.None); if (sitem != null && sitem[0] != "poster") { var prop = m.GetType().GetProperty(sitem[0]); if (prop == null) { //property is maybe in movie info var propinfo = m.Movie_Info.GetType().GetProperty(sitem[0]); if (propinfo != null) { var c = Controls.Find(item, true).First(); SetObject(sitem[0], "info", c); } } else { //property is in movie data var c = Controls.Find(item, true).First(); SetObject(sitem[0], "movie", c); } } else { //item is poster posterImage.BackgroundImage = movieButton.BackgroundImage; posterImage.BackgroundImageLayout = ImageLayout.Stretch; } }