private void GetVideoList_Click(object sender, EventArgs e) { String input = TargetUrl.Text.Trim(); if (String.IsNullOrEmpty(input)) { MessageBox.Show("请输入网址", "出错了", MessageBoxButtons.OK); return; } bool isVaild = false; bool hasPlugin = false; targetPlugin = null; foreach (IPlugin plugin in AddinManager.GetExtensionObjects <IPlugin>()) { hasPlugin = true; if (plugin.isVaild(input)) { isVaild = true; if (targetPlugin == null) { targetPlugin = plugin; } else if (targetPlugin.GetVersionNumber() < plugin.GetVersionNumber()) { targetPlugin = plugin; } } } if (!hasPlugin) { MessageBox.Show("没有找到插件...\n请检查plugins目录是否存在或者重新下载程序", "出错了", MessageBoxButtons.OK); System.Diagnostics.Process.Start("http://vdhelper.sinaapp.com"); return; } if (isVaild) { if (!getlistWorker.IsBusy) { VideoInfoList.Items.Clear(); ChangeState(true); MessageLabel.Text = "获取中...请等待"; getlistWorker.RunWorkerAsync(); } else { MessageBox.Show("上一个任务还没有完成,请等待", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (DialogResult.OK == MessageBox.Show("你输入的地址错误,请检查后重新输入\r\n如果不清楚要输入何种类型的网址,请点击确认访问http://vdhelper.sinaapp.com/support.html", "出错了", MessageBoxButtons.OKCancel)) { System.Diagnostics.Process.Start("http://vdhelper.sinaapp.com/support.html?1.6"); } TargetUrl.Text = string.Empty; TargetUrl.Focus(); } }
private void StartButton_Click(object sender, RoutedEventArgs e) { //Validate if (!IsValidUrl()) { MessageBox.Show("Incorrect url. Try Again", Title, MessageBoxButton.OK, MessageBoxImage.Information); TargetUrl.Focus(); TargetUrl.SelectAll(); return; } if (StartPosition.Value > EndPosition.Value) { MessageBox.Show("Incorrect users range. Try Again", Title, MessageBoxButton.OK, MessageBoxImage.Information); return; } if (manager.UserCount == 0) { MessageBox.Show("No users in file. Try Again", Title, MessageBoxButton.OK, MessageBoxImage.Information); return; } //Initialize StartButton.IsEnabled = false; TargetUrl.IsReadOnly = true; StartPosition.IsEnabled = false; EndPosition.IsEnabled = false; manager.FirstWatcher = (StartPosition.Value != null) ? (int)(StartPosition.Value - 1) : 0; manager.LastWatcher = EndPosition.Value ?? manager.UserCount; manager.Channel = TargetUrl.Text.Trim(); if (CaptchaCheckBox.IsChecked == true) { ReCaptchaSettings settings = new ReCaptchaSettings { ApiKey = RuCaptchaApiKey.Text.Trim(), FirstDelay = FirstCaptchaWait.Value.HasValue ? (int)FirstCaptchaWait.Value : -1, SecondDelay = FirstCaptchaWait.Value.HasValue ? (int)SecongCaptchaWait.Value : -1, Attempts = CaptchaRequest.Value.HasValue ? (int)CaptchaRequest.Value : -1 }; manager.SetCaptchaSolver(settings); } //Start Overlay overLay = new Overlay() { Owner = this, MyMessage = "Starting..." }; bool isOverlayClosed = false; manager.WatcherManagerCreatedEvent += (s, arg) => { overLay.Dispatcher.Invoke(() => overLay.Close()); isOverlayClosed = true; EnablePreview.Dispatcher.Invoke(() => EnablePreview.IsEnabled = true); SaveButton.Dispatcher.Invoke(() => SaveButton.IsEnabled = true); mainTabControl.Dispatcher.Invoke(() => OptionsTabItem.IsEnabled = false); }; manager.StartAsync(); if (!isOverlayClosed) { overLay.ShowDialog(); } }