mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 22:31:24 +00:00
809 lines
24 KiB
C#
809 lines
24 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Diagnostics;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.IO.IsolatedStorage;
|
||
using System.Net;
|
||
using System.Net.Security;
|
||
using System.Reflection;
|
||
using System.Security.Cryptography;
|
||
using System.Security.Cryptography.X509Certificates;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using AppleBatch_June.Properties;
|
||
using DotNet.Utilities;
|
||
|
||
namespace AppleBatch_June
|
||
{
|
||
public class FormLogin : Form
|
||
{
|
||
public const int WM_SYSCOMMAND = 274;
|
||
|
||
public const int SC_MOVE = 61456;
|
||
|
||
public const int HTCAPTION = 2;
|
||
|
||
private string runTimePatch = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||
|
||
public static string versions = Application.ProductVersion.ToString();
|
||
|
||
private bool isMouseDown;
|
||
|
||
private Point mouseOffset;
|
||
|
||
private IContainer components;
|
||
|
||
private Label label1;
|
||
|
||
private TextBox txtUser;
|
||
|
||
private TextBox txtPwd;
|
||
|
||
private Label label2;
|
||
|
||
private Button button1;
|
||
|
||
private PictureBox pictureBox1;
|
||
|
||
private Label label3;
|
||
|
||
private Label label4;
|
||
|
||
private string path => AppDomain.CurrentDomain.BaseDirectory;
|
||
|
||
private string configPath => path + "account.ini";
|
||
|
||
public FormLogin()
|
||
{
|
||
components = new Container();
|
||
InitializeComponent();
|
||
init();
|
||
}
|
||
|
||
private void Form1_Load(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
// 简化启动检查
|
||
if (path.ToLower().Contains("rar$"))
|
||
{
|
||
MessageBox.Show("检测到程序未解压,请先解压压缩包在打开");
|
||
Environment.Exit(0);
|
||
return;
|
||
}
|
||
|
||
// 设置安全协议
|
||
#pragma warning disable SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||
ServicePointManager.DefaultConnectionLimit = 512;
|
||
ServicePointManager.Expect100Continue = false;
|
||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||
ServicePointManager.ServerCertificateValidationCallback = (object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true;
|
||
#pragma warning restore SYSLIB0014 // ServicePointManager is obsolete in .NET 5+
|
||
|
||
// 延迟数据文件初始化,避免在启动时访问Resources
|
||
Task.Run(() => InitializeDataFiles());
|
||
|
||
// 设置界面颜色
|
||
txtPwd.ForeColor = SystemColors.MenuHighlight;
|
||
txtUser.ForeColor = SystemColors.MenuHighlight;
|
||
|
||
// 启用界面
|
||
base.Enabled = true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"窗体加载失败: {ex.Message}", "启动错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
|
||
private void InitializeDataFiles()
|
||
{
|
||
try
|
||
{
|
||
string appDataPath = runTimePatch + "/AppleBatch";
|
||
|
||
// 确保目录存在
|
||
if (!Directory.Exists(appDataPath))
|
||
{
|
||
Directory.CreateDirectory(appDataPath);
|
||
}
|
||
|
||
// 延迟创建数据库文件
|
||
string dbPath = appDataPath + "/AppleDB.db";
|
||
if (!File.Exists(dbPath))
|
||
{
|
||
try
|
||
{
|
||
if (Resources.AppleDB != null && Resources.AppleDB.Length > 0)
|
||
{
|
||
File.WriteAllBytes(dbPath, Resources.AppleDB);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
// 在UI线程上显示错误
|
||
this.Invoke(new Action(() => {
|
||
MessageBox.Show($"数据库文件创建失败: {ex.Message}", "资源错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
}));
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
// 在UI线程上显示错误
|
||
this.Invoke(new Action(() => {
|
||
MessageBox.Show($"数据目录初始化失败: {ex.Message}", "初始化错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
}));
|
||
}
|
||
}
|
||
|
||
public async void init()
|
||
{
|
||
Task result = Task.Run(delegate
|
||
{
|
||
try
|
||
{
|
||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||
MachineCode machineCode = new MachineCode();
|
||
AppSysConfig.saffMac = Tools.GetMD5_32(machineCode.GetMachineCodeString() + "巴拉拉小魔仙");
|
||
AppSysConfig.newSaffMac = Tools.GetMD5_32(machineCode.GetMachineCodeString(moAddress: true) + "LiuYue_Acbse");
|
||
stopwatch.Stop();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"机器码生成失败: {ex.Message}", "初始化警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
}
|
||
});
|
||
|
||
try
|
||
{
|
||
string[] array = new string[3] { "https://gitee.com/liuyueapp/blogsLiuyue/raw/master/assets/aphos.css", "https://meixi2.oss-us-west-1.aliyuncs.com/host.txt", "https://zjzhuanfa.oss-cn-shenzhen.aliyuncs.com/host.txt" };
|
||
int count = 1;
|
||
int tCount = 1;
|
||
string[] array2 = array;
|
||
|
||
foreach (string hostItem in array2)
|
||
{
|
||
try
|
||
{
|
||
HttpHelper http = new HttpHelper();
|
||
HttpResult httpResult = await Task.Run(delegate
|
||
{
|
||
HttpItem item = new HttpItem
|
||
{
|
||
URL = hostItem,
|
||
Method = "GET",
|
||
Timeout = 5000, // 减少超时时间
|
||
UserAgent = AppleUtlis.getAppleWenUserAgent()
|
||
};
|
||
return http.GetHtml(item);
|
||
});
|
||
if (httpResult.StatusCode != HttpStatusCode.OK || !httpResult.Html.Contains("http://"))
|
||
{
|
||
count++;
|
||
continue;
|
||
}
|
||
tCount = 1;
|
||
string[] array3 = httpResult.Html.Split('\n');
|
||
foreach (string text in array3)
|
||
{
|
||
if (!string.IsNullOrEmpty(text))
|
||
{
|
||
string text2 = text.Split('\n')[0].Trim().TrimEnd('\r');
|
||
try
|
||
{
|
||
if (http.GetHtml(new HttpItem
|
||
{
|
||
URL = text2 + "/hosy/addbak",
|
||
Method = "GET",
|
||
Timeout = 5000
|
||
}).StatusCode == HttpStatusCode.NotFound)
|
||
{
|
||
ApiNetReq.host = text2;
|
||
break;
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
// 继续尝试下一个地址
|
||
continue;
|
||
}
|
||
}
|
||
tCount++;
|
||
}
|
||
break;
|
||
}
|
||
catch
|
||
{
|
||
count++;
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"网络初始化失败,将使用离线模式: {ex.Message}", "网络警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
}
|
||
|
||
await result;
|
||
if (!string.IsNullOrEmpty(ApiNetReq.host))
|
||
{
|
||
SyncInitConfig();
|
||
return;
|
||
}
|
||
|
||
// 如果所有网络请求都失败,提供备用方案
|
||
MessageBox.Show("网络连接失败,程序将在离线模式下运行。\n如需完整功能,请检查网络连接。", "初始化完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
|
||
// 设置默认配置,让程序可以继续运行
|
||
base.Enabled = true;
|
||
}
|
||
|
||
public async void SyncInitConfig()
|
||
{
|
||
try
|
||
{
|
||
_ = Environment.OSVersion.Version;
|
||
string WindowsVersion = "Windows 10 专业版";
|
||
try
|
||
{
|
||
if (new FileInfo(AppDomain.CurrentDomain.FriendlyName).Length > 8013664L)
|
||
{
|
||
WindowsVersion = "OtherVersions";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"系统信息获取失败: {ex.Message}", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
}
|
||
if (string.IsNullOrEmpty(WindowsVersion))
|
||
{
|
||
WindowsVersion = "";
|
||
}
|
||
|
||
try
|
||
{
|
||
HttpResult httpResult = await Task.Run(() => new ApiNetReq().doPost(new Dictionary<string, object>
|
||
{
|
||
{ "account", "123" },
|
||
{ "pwd", "123" }
|
||
}, "ApiSysConfig"));
|
||
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
base.Enabled = true;
|
||
if (!AppSysConfig.loadConfig(httpResult.Html))
|
||
{
|
||
MessageBox.Show("配置加载失败,将使用默认配置", "配置警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
// 使用默认配置继续运行,而不是退出
|
||
base.Enabled = true;
|
||
return;
|
||
}
|
||
string text = AppSysConfig.getConfig("versionsNew").Trim();
|
||
if (text != versions && !string.IsNullOrEmpty(text) && MessageBox.Show("发现新版本,是否更新?" + AppSysConfig.getConfig("versionsTip").Replace("\\n", "\n"), "新版本提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
||
{
|
||
StartProcess("update.exe", new string[2]
|
||
{
|
||
ApiNetReq.host + "/AppleClientApi/getUpFile?version=" + text + "&windowsVersion=" + Tools.ToUrlEncode(WindowsVersion),
|
||
"AppleBatch_June.exe"
|
||
});
|
||
Close();
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("网络配置获取失败,将使用默认配置继续运行", "网络警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
base.Enabled = true;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"配置同步失败,将使用默认配置: {ex.Message}", "配置警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
base.Enabled = true;
|
||
}
|
||
|
||
// 确保界面总是启用
|
||
base.Enabled = true;
|
||
loadConfig();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show($"初始化过程发生错误: {ex.Message}\n\n程序将尝试继续运行", "严重错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
base.Enabled = true;
|
||
loadConfig(); // 尝试加载本地配置
|
||
}
|
||
}
|
||
|
||
public Task DownLoadSQLiteInterop()
|
||
{
|
||
return Task.Run(delegate
|
||
{
|
||
try
|
||
{
|
||
string sourceFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "sqlite.interop.dll");
|
||
string text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "x64/sqlite.interop.dll");
|
||
if (File.Exists(sourceFileName))
|
||
{
|
||
if (!Directory.Exists("x86"))
|
||
{
|
||
Directory.CreateDirectory("x86");
|
||
}
|
||
File.Move(sourceFileName, "x86/sqlite.interop.dll");
|
||
}
|
||
if (Environment.Is64BitOperatingSystem)
|
||
{
|
||
if (File.Exists(text))
|
||
{
|
||
FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||
byte[] array = new byte[fileStream.Length];
|
||
fileStream.Read(array, 0, array.Length);
|
||
fileStream.Close();
|
||
if (Tools.GetMD5_32(array) != "0b03a5acd07d99daea0699e5bd8077a1")
|
||
{
|
||
File.Delete(text);
|
||
}
|
||
}
|
||
if (!File.Exists(text))
|
||
{
|
||
Stopwatch stopwatch = new Stopwatch();
|
||
stopwatch.Start();
|
||
if (!Directory.Exists("x64"))
|
||
{
|
||
Directory.CreateDirectory("x64");
|
||
}
|
||
string address = ApiNetReq.host + "/dll/SQLiteInterop/x64/SQLite.Interop.dll";
|
||
string text2 = text;
|
||
if (!File.Exists(text2))
|
||
{
|
||
string text3 = text2 + ".tmp";
|
||
#pragma warning disable SYSLIB0014 // WebClient is obsolete
|
||
using (WebClient webClient = new WebClient())
|
||
{
|
||
webClient.DownloadFile(address, text3);
|
||
}
|
||
#pragma warning restore SYSLIB0014 // WebClient is obsolete
|
||
File.Move(text3, text2);
|
||
}
|
||
stopwatch.Stop();
|
||
Console.WriteLine($"程序下载耗时:{stopwatch.ElapsedMilliseconds}ms.");
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
}
|
||
});
|
||
}
|
||
|
||
public bool StartProcess(string filename, string[] args)
|
||
{
|
||
try
|
||
{
|
||
string text = "";
|
||
foreach (string text2 in args)
|
||
{
|
||
text = text + text2 + " ";
|
||
}
|
||
text = text.Trim();
|
||
Process process = new Process();
|
||
ProcessStartInfo startInfo = new ProcessStartInfo(filename, text);
|
||
process.StartInfo = startInfo;
|
||
process.StartInfo.UseShellExecute = false;
|
||
process.Start();
|
||
return true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
MessageBox.Show("启动应用程序时出错!原因:" + ex.Message);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
private void Form1_MouseDown(object sender, MouseEventArgs e)
|
||
{
|
||
if (e.Button == MouseButtons.Left)
|
||
{
|
||
isMouseDown = true;
|
||
mouseOffset = new Point(-e.X, -e.Y);
|
||
}
|
||
}
|
||
|
||
public void loadConfig()
|
||
{
|
||
if (!File.Exists(configPath))
|
||
{
|
||
return;
|
||
}
|
||
string text = Tools.readFile(configPath);
|
||
try
|
||
{
|
||
string imgData = new Regex("userName=([\\s\\S]*?);").Match(text).Groups[1].Value.Trim();
|
||
string imgData2 = new Regex("userPwd=([\\s\\S]*?);").Match(text).Groups[1].Value.Trim();
|
||
string key = Tools.GetMD5_32(AppSysConfig.saffMac + "123123").Substring(16);
|
||
string iv = Tools.GetMD5_32(AppSysConfig.saffMac + "123111123").Substring(16);
|
||
txtUser.Text = DESEncrypt.Decrypt(Encoding.UTF8.GetString(Tools.DecodeBase64(imgData)), key, iv);
|
||
if (!text.Contains(";v2"))
|
||
{
|
||
txtPwd.Text = DESEncrypt.Decrypt(Encoding.UTF8.GetString(Tools.DecodeBase64(imgData2)), key, iv);
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
byte[] bytes = ProtectedData.Unprotect(Tools.DecodeBase64(imgData2), getAditionalEntropy(), DataProtectionScope.LocalMachine);
|
||
txtPwd.Text = DESEncrypt.Decrypt(Encoding.UTF8.GetString(bytes), key, iv);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
txtPwd.Text = "";
|
||
}
|
||
}
|
||
if (txtPwd.Text.Length > 0)
|
||
{
|
||
txtPwd.PasswordChar = '*';
|
||
Task.Run(delegate
|
||
{
|
||
Thread.Sleep(100);
|
||
if (!base.IsDisposed)
|
||
{
|
||
Invoke((Action)delegate
|
||
{
|
||
button1_Click(null, null);
|
||
});
|
||
}
|
||
});
|
||
}
|
||
else if (txtUser.Text.Length > 0)
|
||
{
|
||
MessageBox.Show("请重新输入密码");
|
||
}
|
||
}
|
||
catch (Exception ex2)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex2);
|
||
}
|
||
}
|
||
|
||
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
|
||
{
|
||
if (e.Button == MouseButtons.Left)
|
||
{
|
||
isMouseDown = true;
|
||
mouseOffset = new Point(-e.X, -e.Y);
|
||
}
|
||
}
|
||
|
||
private void label4_Click(object sender, EventArgs e)
|
||
{
|
||
base.WindowState = FormWindowState.Minimized;
|
||
Close();
|
||
Application.Exit();
|
||
Environment.Exit(0);
|
||
}
|
||
|
||
private void txtUser_Enter(object sender, EventArgs e)
|
||
{
|
||
if (txtUser.Text == "用户名")
|
||
{
|
||
txtUser.Text = "";
|
||
txtUser.ForeColor = Color.Black;
|
||
}
|
||
}
|
||
|
||
private void txtUser_Leave(object sender, EventArgs e)
|
||
{
|
||
if (txtUser.Text.Length == 0)
|
||
{
|
||
txtUser.Text = "用户名";
|
||
txtUser.ForeColor = SystemColors.MenuHighlight;
|
||
}
|
||
}
|
||
|
||
private void txtPwd_Leave(object sender, EventArgs e)
|
||
{
|
||
if (txtPwd.Text.Length == 0)
|
||
{
|
||
txtPwd.Text = "密码";
|
||
txtPwd.ForeColor = SystemColors.MenuHighlight;
|
||
txtPwd.PasswordChar = '\0';
|
||
}
|
||
}
|
||
|
||
private void txtPwd_Enter(object sender, EventArgs e)
|
||
{
|
||
txtPwd.PasswordChar = '*';
|
||
if (txtPwd.Text == "密码")
|
||
{
|
||
txtPwd.Text = "";
|
||
txtPwd.ForeColor = Color.Black;
|
||
}
|
||
}
|
||
|
||
private byte[] getAditionalEntropy()
|
||
{
|
||
try
|
||
{
|
||
IsolatedStorageFile machineStoreForDomain = IsolatedStorageFile.GetMachineStoreForDomain();
|
||
string s = machineStoreForDomain.GetType().GetProperty("DomainName", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(machineStoreForDomain) as string;
|
||
machineStoreForDomain.Remove();
|
||
machineStoreForDomain.Close();
|
||
machineStoreForDomain.Dispose();
|
||
AppSysConfig.AditionalEntropy = Encoding.UTF8.GetBytes(s);
|
||
return AppSysConfig.AditionalEntropy;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
AppSysConfig.AditionalEntropy = new byte[16]
|
||
{
|
||
9, 1, 5, 8, 6, 3, 5, 2, 4, 2,
|
||
1, 7, 3, 9, 2, 1
|
||
};
|
||
return AppSysConfig.AditionalEntropy;
|
||
}
|
||
}
|
||
|
||
private void label3_Click(object sender, EventArgs e)
|
||
{
|
||
new FromReg().ShowDialog();
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
string[] array = AppSysConfig.getConfig("CaptureNetKeyWork").Split(',');
|
||
//foreach (string text in array)
|
||
//{
|
||
// if (!string.IsNullOrEmpty(text) && Process.GetProcessesByName(text).Length != 0)
|
||
// {
|
||
// MessageBox.Show("软件冲突,请先关闭 " + text + ".");
|
||
// AppleExecuteTask.Stop();
|
||
// Application.Exit();
|
||
// Environment.Exit(0);
|
||
// }
|
||
//}
|
||
string text2 = txtUser.Text.Trim();
|
||
string text3 = txtPwd.Text;
|
||
if (text2.Length >= 3)
|
||
{
|
||
Dictionary<string, object> postData = new Dictionary<string, object>
|
||
{
|
||
{ "account", text2 },
|
||
{ "pwd", text3 }
|
||
};
|
||
HttpResult httpResult = new ApiNetReq().doPost(postData, "ApiLogin");
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
AppSysConfig.userToken = val["Data"]["token"];
|
||
AppSysConfig.userName = val["Data"]["userName"];
|
||
AppSysConfig.userPwd = text3;
|
||
AppSysConfig.integral = val["Data"]["integral"];
|
||
AppSysConfig.freezeIntegral = val["Data"]["freezeIntegral"];
|
||
AppSysConfig.userNumber = val["Data"]["userNumber"];
|
||
AppSysConfig.guid = val["Data"]["guid"];
|
||
AppSysConfig.uid = ShareCodeUtils.codeToId(AppSysConfig.userNumber);
|
||
Hide();
|
||
saveConfig();
|
||
if (Settings.Default.ShowGiftcardBalance)
|
||
{
|
||
FormGiftcardBalance formGiftcardBalance = new FormGiftcardBalance();
|
||
formGiftcardBalance.panUserInfoShow = !Settings.Default.HideGiftcardBalanceInfo;
|
||
formGiftcardBalance.login = this;
|
||
formGiftcardBalance.Show();
|
||
formGiftcardBalance.Activate();
|
||
}
|
||
else
|
||
{
|
||
FromMain fromMain = new FromMain();
|
||
fromMain.login = this;
|
||
fromMain.Show();
|
||
fromMain.Activate();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show(val["Message"].ToString());
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("请求错误,请检测网络");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("账号格式不正确");
|
||
}
|
||
}
|
||
|
||
public void saveConfig()
|
||
{
|
||
Tools.GetMD5_32(AppSysConfig.saffMac + "123123").Substring(16);
|
||
Tools.GetMD5_32(AppSysConfig.saffMac + "123111123").Substring(16);
|
||
string text = Tools.EncodeBase64(Encoding.UTF8.GetBytes(DESEncrypt.Encrypt(txtUser.Text, Tools.GetMD5_32(AppSysConfig.saffMac + "123123").Substring(16), Tools.GetMD5_32(AppSysConfig.saffMac + "123111123").Substring(16))));
|
||
try
|
||
{
|
||
string text2 = Tools.EncodeBase64(ProtectedData.Protect(Encoding.UTF8.GetBytes(DESEncrypt.Encrypt(txtPwd.Text, Tools.GetMD5_32(AppSysConfig.saffMac + "123123").Substring(16), Tools.GetMD5_32(AppSysConfig.saffMac + "123111123").Substring(16))), getAditionalEntropy(), DataProtectionScope.LocalMachine));
|
||
File.WriteAllText(configPath, "userName=" + text + ";\r\nuserPwd=" + text2 + ";v2");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
}
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
private void pictureBox1_Click(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
private void FormLogin_MouseMove(object sender, MouseEventArgs e)
|
||
{
|
||
if (isMouseDown)
|
||
{
|
||
Point mousePosition = Control.MousePosition;
|
||
mousePosition.Offset(mouseOffset.X, mouseOffset.Y);
|
||
base.Location = mousePosition;
|
||
}
|
||
}
|
||
|
||
private void FormLogin_MouseUp(object sender, MouseEventArgs e)
|
||
{
|
||
if (e.Button == MouseButtons.Left)
|
||
{
|
||
isMouseDown = false;
|
||
}
|
||
}
|
||
|
||
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
|
||
{
|
||
if (isMouseDown)
|
||
{
|
||
Point mousePosition = Control.MousePosition;
|
||
mousePosition.Offset(mouseOffset.X, mouseOffset.Y);
|
||
base.Location = mousePosition;
|
||
}
|
||
}
|
||
|
||
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
|
||
{
|
||
if (e.Button == MouseButtons.Left)
|
||
{
|
||
isMouseDown = false;
|
||
}
|
||
}
|
||
|
||
protected override void Dispose(bool disposing)
|
||
{
|
||
if (disposing && components != null)
|
||
{
|
||
components.Dispose();
|
||
}
|
||
base.Dispose(disposing);
|
||
}
|
||
|
||
private void InitializeComponent()
|
||
{
|
||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppleBatch_June.FormLogin));
|
||
this.label1 = new System.Windows.Forms.Label();
|
||
this.txtUser = new System.Windows.Forms.TextBox();
|
||
this.txtPwd = new System.Windows.Forms.TextBox();
|
||
this.label2 = new System.Windows.Forms.Label();
|
||
this.button1 = new System.Windows.Forms.Button();
|
||
this.label3 = new System.Windows.Forms.Label();
|
||
this.label4 = new System.Windows.Forms.Label();
|
||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||
((System.ComponentModel.ISupportInitialize)this.pictureBox1).BeginInit();
|
||
base.SuspendLayout();
|
||
this.label1.AutoSize = true;
|
||
this.label1.Location = new System.Drawing.Point(151, 225);
|
||
this.label1.Name = "label1";
|
||
this.label1.Size = new System.Drawing.Size(47, 17);
|
||
this.label1.TabIndex = 0;
|
||
this.label1.Text = "用户名:";
|
||
this.txtUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||
this.txtUser.Location = new System.Drawing.Point(205, 221);
|
||
this.txtUser.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||
this.txtUser.Name = "txtUser";
|
||
this.txtUser.Size = new System.Drawing.Size(188, 23);
|
||
this.txtUser.TabIndex = 1;
|
||
this.txtUser.Text = "用户名";
|
||
this.txtUser.Enter += new System.EventHandler(txtUser_Enter);
|
||
this.txtUser.Leave += new System.EventHandler(txtUser_Leave);
|
||
this.txtPwd.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||
this.txtPwd.Location = new System.Drawing.Point(205, 261);
|
||
this.txtPwd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||
this.txtPwd.Name = "txtPwd";
|
||
this.txtPwd.Size = new System.Drawing.Size(188, 23);
|
||
this.txtPwd.TabIndex = 3;
|
||
this.txtPwd.Text = "密码";
|
||
this.txtPwd.Enter += new System.EventHandler(txtPwd_Enter);
|
||
this.txtPwd.Leave += new System.EventHandler(txtPwd_Leave);
|
||
this.label2.AutoSize = true;
|
||
this.label2.Location = new System.Drawing.Point(151, 265);
|
||
this.label2.Name = "label2";
|
||
this.label2.Size = new System.Drawing.Size(43, 17);
|
||
this.label2.TabIndex = 2;
|
||
this.label2.Text = "密 码:";
|
||
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||
this.button1.Location = new System.Drawing.Point(205, 300);
|
||
this.button1.Name = "button1";
|
||
this.button1.Size = new System.Drawing.Size(188, 30);
|
||
this.button1.TabIndex = 4;
|
||
this.button1.Text = "登录";
|
||
this.button1.UseVisualStyleBackColor = true;
|
||
this.button1.Click += new System.EventHandler(button1_Click);
|
||
this.label3.AutoSize = true;
|
||
this.label3.Location = new System.Drawing.Point(410, 223);
|
||
this.label3.Name = "label3";
|
||
this.label3.Size = new System.Drawing.Size(68, 17);
|
||
this.label3.TabIndex = 7;
|
||
this.label3.Text = "注册新账号";
|
||
this.label3.Click += new System.EventHandler(label3_Click);
|
||
this.label4.AutoSize = true;
|
||
this.label4.BackColor = System.Drawing.Color.Transparent;
|
||
this.label4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||
this.label4.ForeColor = System.Drawing.Color.Blue;
|
||
this.label4.Location = new System.Drawing.Point(536, 19);
|
||
this.label4.Name = "label4";
|
||
this.label4.Size = new System.Drawing.Size(32, 17);
|
||
this.label4.TabIndex = 8;
|
||
this.label4.Text = "关闭";
|
||
this.label4.Click += new System.EventHandler(label4_Click);
|
||
//this.pictureBox1.Image = AppleBatch_June.Properties.Resources._57fb35f0371a6;
|
||
this.pictureBox1.Location = new System.Drawing.Point(-4, -8);
|
||
this.pictureBox1.Name = "pictureBox1";
|
||
this.pictureBox1.Size = new System.Drawing.Size(596, 205);
|
||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||
this.pictureBox1.TabIndex = 5;
|
||
this.pictureBox1.TabStop = false;
|
||
this.pictureBox1.Click += new System.EventHandler(pictureBox1_Click);
|
||
this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(pictureBox1_MouseDown);
|
||
this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(pictureBox1_MouseMove);
|
||
this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(pictureBox1_MouseUp);
|
||
base.AcceptButton = this.button1;
|
||
base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 17f);
|
||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||
this.BackColor = System.Drawing.Color.WhiteSmoke;
|
||
base.ClientSize = new System.Drawing.Size(593, 389);
|
||
base.Controls.Add(this.label4);
|
||
base.Controls.Add(this.label3);
|
||
base.Controls.Add(this.pictureBox1);
|
||
base.Controls.Add(this.button1);
|
||
base.Controls.Add(this.txtPwd);
|
||
base.Controls.Add(this.label2);
|
||
base.Controls.Add(this.txtUser);
|
||
base.Controls.Add(this.label1);
|
||
this.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
|
||
this.ForeColor = System.Drawing.Color.DarkSlateGray;
|
||
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||
base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
|
||
base.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||
base.Name = "FormLogin";
|
||
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||
this.Text = "Form1";
|
||
base.Load += new System.EventHandler(Form1_Load);
|
||
base.MouseDown += new System.Windows.Forms.MouseEventHandler(Form1_MouseDown);
|
||
base.MouseMove += new System.Windows.Forms.MouseEventHandler(FormLogin_MouseMove);
|
||
base.MouseUp += new System.Windows.Forms.MouseEventHandler(FormLogin_MouseUp);
|
||
((System.ComponentModel.ISupportInitialize)this.pictureBox1).EndInit();
|
||
base.ResumeLayout(false);
|
||
base.PerformLayout();
|
||
}
|
||
}
|
||
}
|