private void viewInfoTile_Click(object sender, RoutedEventArgs e) { if (CatalogListBox.SelectedItems.Count == 0) { MessageBox.Show("You have to select a name before I can fetch information about it!"); } else { if (NetworkUtils.IsConnectedToInternet()) { Manga info = null; string name = CatalogListBox.SelectedItem.ToString(); var task = Task.Factory.StartNew(() => { info = Global.GetMangaInfo(name); }).ContinueWith((tsk) => { if (tsk.Exception == null) Dispatcher.BeginInvoke( new EmptyDelegate( () => { MetroTabItem mti = new MetroTabItem(); mti.IsClosable = true; mti.Header = info.MangaName; mti.Content = new MangaInfoControl(info); metroTabControl1.Items.Add(mti); metroTabControl1.SelectedItem = mti; })); else MessageBox.Show("There was an error grabbing information on that manga!" + Environment.NewLine + "Geeky error details: " + Environment.NewLine + Environment.NewLine + tsk.Exception.ToString() + Environment.NewLine + Environment.NewLine + "NOTE: You can press CTRL + C to copy the contents of this message!"); tsk.Dispose(); }); } else { MessageBox.Show("You are not connected to the internet! Connect and try again!"); } } }
internal void InvokeReadManga(Manga m) { MetroTabItem mti = new MetroTabItem(); mti.IsClosable = true; mti.Header = m.MangaName; mti.Content = new MangaInfoControl(m); metroTabControl1.Items.Add(mti); metroTabControl1.SelectedItem = mti; }