95 lines
2.7 KiB
C#
95 lines
2.7 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System.Net.Http;
|
|
using System.Windows;
|
|
using System.Windows.Media.Imaging;
|
|
using Zerolauncher.Manager;
|
|
|
|
namespace Zerolauncher.dialog
|
|
{
|
|
/// <summary>
|
|
/// RegDialog.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class RegDialog : Window
|
|
{
|
|
private HttpClient client;
|
|
private string user;
|
|
private string password;
|
|
public RegDialog(String acc, String pwd)
|
|
{
|
|
user = acc;
|
|
password = pwd;
|
|
InitializeComponent();
|
|
client = new();
|
|
FleshPic(null, null);
|
|
}
|
|
|
|
private async void FleshPic(object _, RoutedEventArgs e)
|
|
{
|
|
// var main_ip = UpDateData.game_url;
|
|
// HttpResponseMessage? response = null;
|
|
// try
|
|
// {
|
|
// response = await client.GetAsync($"http://{main_ip}/module/captcha.php");
|
|
// if (response != null)
|
|
// {
|
|
// foreach (var item in response.Headers)
|
|
// Console.WriteLine($"{item.Key}");
|
|
// }
|
|
// //var bin = response.Content.ReadAsStream();
|
|
// //verify = ocr.RunInference(new Bitmap(bin));
|
|
// //using (var fileStream = File.Create("tmp.png"))
|
|
// //{
|
|
// // bin.Seek(0, SeekOrigin.Begin);//设置复制开始的地方
|
|
// // bin.CopyTo(fileStream);
|
|
// //}
|
|
// using (var stream = response.Content.ReadAsStream())
|
|
// {
|
|
// BitmapImage bitmap = new BitmapImage();
|
|
// bitmap.BeginInit();
|
|
// bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
|
// bitmap.StreamSource = stream;
|
|
// bitmap.EndInit();
|
|
// bitmap.Freeze(); // 为了线程安全
|
|
//
|
|
// CapPic.Source = bitmap; // 设置Image控件的Source
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// Console.WriteLine($" 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
|
// }
|
|
}
|
|
|
|
private async void okButton_Click(object _, RoutedEventArgs e)
|
|
{
|
|
// var main_ip = UpDateData.game_url;
|
|
// var values = new Dictionary<string, string>
|
|
// {
|
|
// { "rUsername", user },
|
|
// { "rPassword", password },
|
|
// { "rPasswords", password },
|
|
// { "rEmail", BottomMarginTextBox.Text },
|
|
// { "rCode", RightMarginTextBox.Text }
|
|
// };
|
|
// var content = new FormUrlEncodedContent(values);
|
|
// try
|
|
// {
|
|
// var response = await client.PostAsync($"http://{main_ip}/form/register.php", content);
|
|
// var src = await response.Content.ReadAsStringAsync();
|
|
// var jsonObj = JObject.Parse(src);
|
|
// MessageBox.Show(jsonObj["content"].ToString(), jsonObj["title"].ToString());
|
|
// if(int.Parse(jsonObj["type"].ToString()) == 0) Close();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// MessageBox.Show($"类型:{ex.GetType().Name},消息:{ex.Message}", "发生错误喵");
|
|
// }
|
|
}
|
|
|
|
private void cancelButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}
|