private async void btnSearch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtExpression.Text.Trim())) { return; } EnableControlls(false); picPoster.Image = null; SearchData data; if (rbMovie.Checked) { data = await _apiLib.SearchMovieAsync(txtExpression.Text.Trim()); } else { data = await _apiLib.SearchSeriesAsync(txtExpression.Text.Trim()); } _searchData = data; if (!string.IsNullOrEmpty(data.ErrorMessage)) { MetroMessageBox.Show(this, data.ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); EnableControlls(true); return; } FillListBox(); EnableControlls(true); }
protected override async void OnLoad(EventArgs e) { Theme = metroStyleManager1.Theme = Properties.Settings.Default.Theme; Style = metroStyleManager1.Style = Properties.Settings.Default.Style; string colorName = Style.ToString(); if (colorName == "Default") { colorName = "Blue"; } FolderColumn.LinkColor = FolderColumn.VisitedLinkColor = Color.FromName(colorName); var items = new List <GridData>(); var dirs = new List <DirectoryInfo>(); // MOVE if (Properties.Settings.Default.OperationType == OperationType.Movies) { string dir = Properties.Settings.Default.MoviesDirectory; var dinfo = new DirectoryInfo(dir); foreach (var fi in dinfo.GetFiles()) { // Create Folder string nameOnly = fi.Name.Replace(fi.Extension, ""); nameOnly = Utils.RemoveDlSiteName(nameOnly, Properties.Settings.Default.RemoveSites); string newFolder = $"{dir}\\{nameOnly}"; Directory.CreateDirectory(newFolder); // Moving File fi.MoveTo($"{newFolder}\\{nameOnly}{fi.Extension}"); } dirs = new DirectoryInfo(dir).GetDirectories().Where(dx => !dx.Name.StartsWith("0")).ToList(); } else if (Properties.Settings.Default.OperationType == OperationType.MovieFile) { string file = Properties.Settings.Default.MovieFile; var fi = new FileInfo(file); // Create Folder string nameOnly = fi.Name.Replace(fi.Extension, ""); nameOnly = Utils.RemoveDlSiteName(nameOnly, Properties.Settings.Default.RemoveSites); string newFolder = $"{fi.Directory.FullName}\\{nameOnly}"; Directory.CreateDirectory(newFolder); // Moving File fi.MoveTo($"{newFolder}\\{nameOnly}{fi.Extension}"); dirs.Add(fi.Directory); } // ADD To GridData foreach (var di in dirs) { var data = await _apiLib.SearchMovieAsync(di.Name); if (!string.IsNullOrEmpty(data.ErrorMessage)) { MetroMessageBox.Show(this, data.ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); OnReady?.Invoke(); return; } if (data.Results.Count == 1) { var result = data.Results.First(); var titleData = await _apiLib.TitleAsync(result.Id); items.Add(new GridData(true, di.Name, titleData.FullTitle, titleData.OriginalTitle, titleData.Id)); } else { var searchForm = new SearchForm(data); if (searchForm.ShowDialog() == DialogResult.OK) { var result = searchForm.Result; var titleData = await _apiLib.TitleAsync(result.Id); if (string.IsNullOrEmpty(titleData.ErrorMessage)) { items.Add(new GridData(true, di.Name, titleData.FullTitle, titleData.OriginalTitle, titleData.Id)); } else { MetroMessageBox.Show(this, data.ErrorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); OnReady?.Invoke(); return; } } else { // Not add } } dgv.DataSource = new List <GridData>(items); } await Task.Delay(100); InfoColumn.Text = "info..."; InfoColumn.UseColumnTextForButtonValue = true; SearchAgainColumn.Text = "search again"; SearchAgainColumn.UseColumnTextForButtonValue = true; dgv.DataSource = new List <GridData>(items); OnReady?.Invoke(); base.OnLoad(e); }