private void AutoScript(string statClassName) { TextBox_Result.Clear(); Task.Run(() => { try { int index = StatData.StatDataClass.FindIndex(t => t.ClassName == statClassName); if (index != -1) { AppendTextBox($"正在执行 {StatData.StatDataClass[index].ClassName} 脚本代码"); for (int i = 0; i < StatData.StatDataClass[index].StatInfo.Count; i++) { AppendTextBox($"正在执行 第 {i + 1}/{StatData.StatDataClass[index].StatInfo.Count} 条代码"); Hacks.WriteStat(StatData.StatDataClass[index].StatInfo[i].Hash, StatData.StatDataClass[index].StatInfo[i].Value); Task.Delay(500).Wait(); } AppendTextBox($"{StatData.StatDataClass[index].ClassName} 脚本代码执行完毕"); } } catch (Exception ex) { AppendTextBox($"错误:{ex.Message}"); } }); }
private void AppendTextBox(string str) { this.Dispatcher.Invoke(() => { TextBox_Result.AppendText($"[{DateTime.Now:T}] {str}\r\n"); TextBox_Result.ScrollToEnd(); }); }
private void Enter_2_Click(object sender, RoutedEventArgs e) { if (TextBox_Result.Text == "0") { TextBox_Result.Clear(); } TextBox_Result.Text = TextBox_Result.Text + "2"; }
private void Enter_History_Click(object sender, RoutedEventArgs e) { if (TextBox_Result.Text == "0") { TextBox_Result.Clear(); } i = Int32.Parse(TextBox_Result.Text); OperationPreformed = 'N'; TextBox_Result.Text = ""; }
private void button_click(object sender, EventArgs e) { if ((TextBox_Result.Text == "0") || (isOperationPerformed)) { TextBox_Result.Clear(); // забирає 0 при кліку } Button button = (Button)sender; // виводить клік в TextBox_Result if (button.Text == ".") // не дозволяє нажимати багато разів "." { if (!TextBox_Result.Text.Contains(".")) { TextBox_Result.Text = TextBox_Result.Text + button.Text; } } else { TextBox_Result.Text = TextBox_Result.Text + button.Text; } isOperationPerformed = false; }
private void Button_Click(object sender, EventArgs e) { //Function that gets the button that we click if (isEqualPerformed || isSinPerformed || isCosPerformed || isOneOverXPerformed || isSquarePerformed || isSquareRootPerformed) { //Set everything to false for optimaization of use TextBox_Result.Text = ""; resultValue = 0; isEqualPerformed = false; isSinPerformed = false; isCosPerformed = false; isOneOverXPerformed = false; isSquarePerformed = false; isSquareRootPerformed = false; } if ((TextBox_Result.Text == "0") || isOperationPerformed) { TextBox_Result.Clear(); } isOperationPerformed = false; Button button = (Button)sender; //Take care of point (.) if (button.Text == ".") { if (!TextBox_Result.Text.Contains(".")) { TextBox_Result.Text = TextBox_Result.Text + button.Text; } } else { TextBox_Result.Text = TextBox_Result.Text + button.Text; } }
private void Button_Go_Click(object sender, RoutedEventArgs e) { TextBox_Result.Text = ""; string input = TextBox_Input.Text.Trim(); results.Clear(); int dfn = 4; if (Radio_0.IsChecked == true) { dfn = 0; } if (Radio_1.IsChecked == true) { dfn = 1; } if (Radio_2.IsChecked == true) { dfn = 2; } if (Radio_3.IsChecked == true) { dfn = 3; } if (Radio_4.IsChecked == true) { dfn = 4; } ThreadPool.QueueUserWorkItem((object state) => { try { if (input.Contains("/page/")) //批量 { this.Dispatcher.BeginInvoke(new Action(() => { string pid = GetVidFromUrl(input.Split('\n')[0]); string webSource = GetWebSource( $"https://apis.web.pptv.com/show/videoList?from=web&version=1.0.0&format=jsonp&pid={pid}&cat_id=2&vt=22&tdsourcetag=s_pctim_aiomsg", "Cookie:PUID=bf2a0e4f2cf24517c294-a68a65ed8c50;ppi=302c393939;" ).Replace("{", "\r\n{"); //MessageBox.Show(webSource); Regex regex = new Regex("\"url\":\"(.*)\",\"capture.*isTrailer\":(.*),\"olt\""); MatchCollection matches = regex.Matches(webSource); if (matches.Count == 0) { return; } Button_Go.IsEnabled = false; TextBox_Input.Text = ""; StringBuilder sb = new StringBuilder(); foreach (Match match in matches) { if (match.Groups[2].Value == "false") { sb.Append(match.Groups[1].Value.Replace("\\/", "/") + "\r\n"); } } TextBox_Input.Text = sb.ToString().Trim(); Button_Go.IsEnabled = true; })); return; } foreach (var item in input.Split('\n')) { this.Dispatcher.BeginInvoke(new Action(() => { Button_Go.IsEnabled = false; Button_Go.Content = "解析中"; })); string vid = GetVidFromUrl(item); if (vid == "") { continue; } string api = $"https://play.api.pptv.com/boxplay.api?platform=launcher&type=tv.android&id={vid}"; string webSource = new WebClient() { Encoding = Encoding.UTF8 }.DownloadString(api); string fname = ""; string rid = ""; string sh = ""; string key = ""; Regex fnameRex = new Regex("nm=\"(.*)\".vip", RegexOptions.Compiled); fname = fnameRex.Match(webSource).Groups[1].Value; Regex fileRex = new Regex("<dt ft=\"" + dfn + "\"[\\s\\S]*<\\/dt>", RegexOptions.Compiled); webSource = fileRex.Match(webSource).Value; fileRex = new Regex("rid=\"(.*mp4)", RegexOptions.Compiled); rid = fileRex.Match(webSource).Groups[1].Value; fileRex = new Regex("sh>(.*)<", RegexOptions.Compiled); sh = fileRex.Match(webSource).Groups[1].Value; fileRex = new Regex("<key.*>(.*)</key>"); key = fileRex.Match(webSource).Groups[1].Value; if (sh == "" || rid == "" || key == "") { continue; } string videourl = $"https://{sh}/w/{rid}?platform=launcher&type=tv.android&k={key}"; results.Add(fname, videourl); this.Dispatcher.BeginInvoke(new Action(() => TextBox_Result.AppendText(videourl + "\r\n"))); } this.Dispatcher.BeginInvoke(new Action(() => { Button_Go.IsEnabled = true; Button_Go.Content = "开始解析"; TextBox_Result.Text = TextBox_Result.Text.Trim(); })); } catch (Exception) { this.Dispatcher.BeginInvoke(new Action(() => { Button_Go.IsEnabled = true; Button_Go.Content = "开始解析"; TextBox_Result.Text = TextBox_Result.Text.Trim(); MessageBox.Show("遇到了错误"); })); } }, null); }
private void AppendTextBox(string str) { TextBox_Result.AppendText($"[{DateTime.Now:T}] {str}\r\n"); TextBox_Result.ScrollToEnd(); }