RaUI/Source/Itrycn_Project2/FrmStart.cs
zilinsoft b4e236fd55 ### 2025-01-06 星期一更新
------
#### OnLineUpgradeConfig    V1.0.2501.0601
- *.[修复]修复用户管理列表无法默认勾选已选择用户的BUG。
#### RaUI    V4.0.2501.0601
- *.[新增]RyFiles类新增SetFileDate、SetFileCreationTime、SetFileLastWriteTime方法。
- *.[新增]RyFiles.CopyBigFile方法现在会同步来源文件的创建和修改时间。
- *.[新增]ryQuickSQL类新增GetPostData函数,将数据快速转成Post数据。
- *.[改进]执行MySQL下的ExecuteNonQuery时,如果遇到连接关闭错误,允许重连并重新执行。
- *.[改进]IDbInterface在执行新的SQL语句前,自动清空最后错误。
- *.[修复]修复LayeredForm窗体以正常窗体打开的时候,文本框无法编辑的BUG。
- *.[修复]修复ApkOp获取apk权限时可能带乱码的BUG。
- *.[修复]修复WeifenLuo.WinFormsUI.Docking的ResourceManager.GetString路径不对导致报错的BUG。
2025-01-06 11:14:35 +08:00

434 lines
20 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using HtmlAgilityPack;
using IfacesEnumsStructsClasses;
using Itrycn_Project2;
using RaUI.UI.LayeredForm;
using ryCommon;
using ryCommonDb;
using ryControls;
using RyWeb;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Itrycn_Project2
{
public partial class FrmStart : RySkins.SKinForm
{
/// <summary>
/// 最大日志数量
/// </summary>
private int MaxLogsCount { get; set; } = 1000;
readonly string[] prog_args;
public FrmStart(string[] args)
{
//var img = RyImage.LoadPic("http://pic.2265.com/upload/2024-2/2024261342151467.png");
InitializeComponent();
prog_args = args;
//配置软件信息
notifyIcon1.Text = Soft_ConstInfo.Soft_Title;
Text = Soft_ConstInfo.Soft_Title + " V" + RySoft.VersionStr;
if (!Soft_ConstInfo.ShowTray) { notifyIcon1.Visible = false; }
if (!Soft_ConstInfo.DonateVisabled) { ToolStripMenuItem.Text = "关于"; }
if (Soft_ConstInfo.Soft_Url.Length == 0) { ToolStripMenuItem.PerformClick(); }
notifyIcon1.Icon = Icon;
OlvLogTime.AspectGetter = delegate (object x) { return ((LogInfo)x).LogTime.ToDateTimeStr(); };
OlvLogText.AspectGetter = delegate (object x) { return ((LogInfo)x).LogText; };
LvLogs.FormatRow += delegate (object x, BrightIdeasSoftware.FormatRowEventArgs e) {
LogInfo item = (LogInfo)e.Model;
if (item.Color != Color.Black)
{
e.Item.ForeColor = item.Color;
}
};
//var href = "http://www.87g.com/youxi/4740.html";
//var dd = href.StartsWith("@");
//var kk= GetSection(RyFiles.ReadAllText("E:\\My Datas\\My Codes\\毕方项目\\CSharp\\ryProcessManager\\Bin\\Debug\\11111111.txt"),"//h3 | //h4");
//HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
//htmlDoc.LoadHtml("<div class=\"inlink_div\"><h4>您还感兴趣</h4><p class=\"inlink_p\"><span>  <a href=\"http://www.87g.com/youxi/4740.html\" class=\"inlink_page\" target=\"_blank\">水果缤纷手游下载</a>:《水果缤纷》作为一款休闲消除类手机游戏,现游戏安卓版本可供玩家试玩。当各种缤纷水果来袭,绝对让你眼花缭乱,还能分得清水果品种去准确消除么?快加入游戏,看看你的眼力!</span><span>  <a href=\"http://www.87g.com/youxi/56805.html\" class=\"inlink_page\" target=\"_blank\">烦人的橘子游戏下载</a>:烦人的橘子是一款鬼畜趣味的水果作战游戏,延续了动漫中的怪物的角色形象和场景设计,借鉴了打棒球的游戏玩法,玩家需要抓住时机,将各种表情丑陋甚至看起来贱兮兮的水果一棒子打到指定的位置来闯关,超级魔性!</span></p></div>");
}
public static Dictionary<string, string> GetSection(string content_html, string xpath_section)
{
Dictionary<string, string> dict_section = new Dictionary<string, string>();
var html_item = Section(content_html, xpath_section, out string section_name2);
if (!dict_section.ContainsKey(section_name2)) { dict_section.Add(section_name2, html_item); }
string Section(string content, string section_xpath, out string section_name)
{
HtmlAgilityPack.HtmlDocument htmlDoc2 = new HtmlAgilityPack.HtmlDocument();
htmlDoc2.LoadHtml(content);
HtmlNodeCollection body_anchor = htmlDoc2.DocumentNode.SelectNodes("//body");//筛选出网站的链接
if (body_anchor != null && body_anchor.Count > 0)
{
htmlDoc2.LoadHtml(body_anchor[0].InnerHtml);
}
HtmlNode next;
HtmlNode child = htmlDoc2.DocumentNode.FirstChild;
string childname;
string html_text = "";
section_name = "";
while (child != null)
{
next = child.NextSibling;
#region
//lastName = childname;
if (child.NodeType == HtmlNodeType.Element)
{
childname = child.Name.ToLower();
//RyFiles.WriteAllText(Application.StartupPath+"\\11111111.txt", content_html);
HtmlAgilityPack.HtmlDocument htmlDoc_item = new HtmlAgilityPack.HtmlDocument();
htmlDoc_item.LoadHtml(child.OuterHtml);
HtmlNodeCollection an_xpath = htmlDoc_item.DocumentNode.SelectNodes(section_xpath);//筛选出网站的链接
if (an_xpath != null && an_xpath.Count > 0) //如果包含段落,则继续进入查看
{
if (an_xpath[0].ParentNode == null || an_xpath[0].ParentNode.NodeType == HtmlNodeType.Document)
{
if (section_name.Length == 0) { section_name = "总览"; }
if (dict_section.ContainsKey(section_name)) { dict_section[section_name] = html_text; }
else { dict_section.Add(section_name, html_text); }
section_name = an_xpath[0].InnerText.Trim();
html_text = "";
}
else
{
return Section(child.InnerHtml, section_xpath, out section_name);
}
}
else
{
if (child.Name.ToLower() == "br")
{ html_text += "\r\n"; }
else if (child.Name.ToLower() == "p")
{ html_text += "\r\n" + child.OuterHtml; }
else
{
html_text += child.OuterHtml;
}
}
}
else if (child.NodeType == HtmlNodeType.Text)
{
html_text += child.OuterHtml;
}
#endregion
child = next;
}
return html_text;
}
return dict_section;
}
/// <summary>
/// 添加日志
/// </summary>
/// <param name="log"></param>
public void AddLog(string log)
{
AddLog(log, "", Color.Black);
}
/// <summary>
/// 添加日志
/// </summary>
/// <param name="log"></param>
/// <param name="color"></param>
public void AddLog(string log, Color color)
{
AddLog(log, "", color);
}
/// <summary>
/// 添加日志
/// </summary>
/// <param name="log"></param>
/// <param name="tag"></param>
/// <param name="color"></param>
public void AddLog(string log, string tag, Color color)
{
try
{
this.Invoke(new Action(() =>
{
var count = LvLogs.GetItemCount();
if (count > MaxLogsCount)
{
LvLogs.RemoveObject(LvLogs.GetModelObject(count-1));
}
LvLogs.InsertObjects(0, new LogInfo[] { new LogInfo() { LogTime = DateTime.Now, LogText = log,LogTag=tag, Color = color } });
OlvLogTime.Text = "时间(" + LvLogs.GetItemCount() + ")";
}));
}
catch { }
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
var topmost = this.TopMost;
this.TopMost = true;
this.Show();
this.TopMost = topmost;
}
private void 退ToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Windows.Forms.Application.Exit();
}
private void FrmStart_Shown(object sender, EventArgs e)
{
ryCommon.Ini ini = new Ini(Soft_ConstInfo.UserDataFolder + "\\Win.dat");
ini.WriteIni(Soft_ConstInfo.Soft_Id, "hwnd", Handle.ToInt32());
if (prog_args.Length >= 1)
{
//如果是自启动,并且开启了右下角托盘图标,则隐藏自身。
if (prog_args[0] == Soft_ConstInfo.Soft_Pram && Soft_ConstInfo.ShowTray)
this.Hide();
}
}
private void FrmStart_FormClosing(object sender, FormClosingEventArgs e)
{
if (Soft_ConstInfo.ShowTray && Public_Config.HideByCloseBtn && e.CloseReason== CloseReason.UserClosing)
{
e.Cancel = true;
this.Hide();
notifyIcon1.ShowBalloonTip(3000, Soft_ConstInfo.Soft_Title, "软件已经最小化到此处,请右击托盘图标进行关闭。", ToolTipIcon.Info);
return;
}
if (!Soft_MemInfo.IsCanCloseForm)
{
e.Cancel = true;
RySkins.Msg.ShowMsg("当前还有操作正在运行,请稍后关闭软件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
protected override void WndProc(ref System.Windows.Forms.Message msg)
{
switch (msg.Msg)
{
case 17189: //处理消息
{
#region
switch (msg.WParam.ToInt32())
{
case 100://
#region
if ((int)msg.LParam.ToInt32() == 100)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Top = (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2;
this.Left = (Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2;
//RyForm.SetActiveWindow(Handle);
RyForm.BringToTop(Handle);
ToolStripMenuItem.PerformClick();
this.BringToFront();
this.Select();
this.Focus();
RyForm.BringToTop(Handle);
}
#endregion
break;
}
#endregion
}
break;
default:
base.WndProc(ref msg);//调用基类函数处理非自定义消息。
break;
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Soft_ConstInfo.DonateVisabled)
{
FrmAbout frm = new FrmAbout();
frm.ShowDialog();
frm.Dispose();
}
else
{
RySkins.Msg.ShowMsg(Soft_ConstInfo.AboutText.Replace("#softname#", Soft_ConstInfo.Soft_Title).Replace("#ver#", "V" + RySoft.VersionStr), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
ryCommon.RyFiles.OpenUrl(Soft_ConstInfo.Soft_Url);
}
private void FrmStart_Load(object sender, EventArgs e)
{
ryComboBox1.SelectedIndex=0;
//var process = Process.GetProcessesByName("bds");
//System.Net.ServicePointManager.DefaultConnectionLimit = 50;
QuickWeb web = new QuickWeb();
var http = web.UrlEncode("猫咪&mdash;&mdash;安安");
//web.Referer = "http://k73dx12.tengapk.com/android/dreamhouse.mod.apk";
//var kk = web.GetSize("http://42.248.92.71:2080/k73dx12.tengapk.com/android/dreamhouse.mod.apk?wsiphost=ipdbme&wsrid_tag=66b17fe7_PS-HYN-01IIQ27_63791-5797-s1t1722908647649&ip_type=0");
//IDbInterface db = new MySqlDataProvider();
//var aa= RyImage.LoadPic("C:\\Users\\李凤鑫\\Desktop\\2024115135247764860.png");
//RyWeb.QuickWeb web = new RyWeb.QuickWeb();
//var size= web.GetSize("https://oss-admin.blazingcats.com/Product/Package/100_llfz_101_llfzgw_1656930048.apk");
//size = web.GetSize("https://oss-admin.blazingcats.com/Product/Package/100_llfz_101_llfzgw_1656930048.apk");
//textBox2.Text = web.Get("https://apkpure.com/cn/animation-throwdown-epic-ccg/com.kongregate.mobile.throwdown.google/download").Html;
//ryCommon.ApkOp apkOp = new ApkOp();
//apkOp.AAPT_Path = "E:\\My Datas\\My Codes\\毕方项目\\CSharp\\ryProcessManager\\Bin\\Debug\\SysDb\\Tools\\ApkLook\\aapt.exe";
//var kk = apkOp.Read_Apk("C:\\Users\\李凤鑫\\Desktop\\com.epicgames.portal.apk");
// objectListView1.InsertObjects(0, new LogInfo[] { new LogInfo() });
//var en= ryCommon.TxtFileEncoder.GetEncoding(@"E:\My Datas\毕方项目\CSharp\ryProcessManager\Bin\Debug\SysDb\applist.lst");
//var hosts = ryCommon.RyFiles.ReadAllText(@"E:\My Datas\毕方项目\CSharp\ryProcessManager\Bin\Debug\UserDb\Hosts.txt");
//var result = ryCommon.Hosts.AddHosts(hosts);
//var kk= ryCommon.ProcessExt.GetPath(24348);
//var img = RyImage.LoadPic(@"C:\Users\zilin\Desktop\1.jpg");
//var watermark =new Bitmap(RyImage.LoadPic(@"C:\Users\zilin\Desktop\water.png"));
//var pos= new List<WatermarkPosition>(new WatermarkPosition[] { WatermarkPosition.FullScreenTile });
//pictureBox1.Image = img.ReSizeW(300);
//pictureBox1.Image= img.DrawWatermark(watermark, WatermarkPosition.FullScreenTile, 0,0,20f);
//ryCommon.PinYin.Convert("李凤鑫");
Public_Config.LoadSetting();
//Itrycn_Project.Itrycn_Db.CreateTable();
//var dbver = Itrycn_Db.GetDbVer();
//if(dbver==1) //初始版本,并是当前要求的数据库
//{
//}
//else
//{
// MessageBox.Show("不支持当前数据库版本,这可能是以下原因导致的:\r\n1.数据库已损坏;'\r\n2.当前数据库是由新版软件创建的(请更新软件后重试)。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Application.Exit();
// return;
//}
//IDbInterface db = new SQLiteDataProvider();
//if (db.ConnDb(@"E:\My Datas\毕方项目\CSharp\ryProcessManager\Bin\Debug\UserDb\MyDb.dat|ry3H3Db") == 1)
//{
//}
//db.Free();
LiveUpdate.RyUpdate update = new LiveUpdate.RyUpdate(Soft_ConstInfo.Update_Url);
update.CheckUpdate();
//Thread th = new Thread(Start);
//th.Start();
//void Start()
//{
// while(true)
// {
// LvLogs.ClearObjects();
// AddLog("测试测试");
// Thread.Sleep(200);
// }
//}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmSetting frm = new FrmSetting();
if(frm.ShowDialog()==DialogResult.OK)
{
Public_Config.LoadSetting();
}
frm.Dispose();
}
/// <summary>
/// 日志信息
/// </summary>
public class LogInfo
{
/// <summary>
/// 日志时间
/// </summary>
public DateTime LogTime { get; set; } = DateTime.Now;
/// <summary>
/// 日志内容
/// </summary>
public string LogText { get; set; }
/// <summary>
/// 日志Tag
/// </summary>
public string LogTag { get; set; }
/// <summary>
/// 日志文字颜色
/// </summary>
public Color Color { get; set; } = Color.Black;
}
private void Button1_Click(object sender, EventArgs e)
{
LvLogs.ClearObjects();
AddLog("测试测试");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//var text = "";
//try
//{
// HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
// htmlDoc.LoadHtml(textBox2.Text);
// HtmlNodeCollection anchors = htmlDoc.DocumentNode.SelectNodes(textBox1.Text);
// if (anchors != null)
// {
// for (int i = 0; i < anchors.Count; i++)
// {
// if (text != "") { text += "<br><br>"; }
// if (i % 2 == 0)
// {
// text += "<span style='color:green'>" + System.Web.HttpUtility.HtmlEncode(anchors[i].OuterHtml) + "</span>";
// }
// else
// {
// text += "<span style='color:blue'>" + System.Web.HttpUtility.HtmlEncode(anchors[i].OuterHtml) + "</span>";
// }
// }
// }
//}
//catch (Exception ex){
// text = "<span style='color:red'>" + System.Web.HttpUtility.HtmlEncode(ex.Message) + "</span>";
//}
//htmlPanel1.Text = System.Web.HttpUtility.HtmlEncode(textBox1.Text);
}
ILayeredForm subForm = null;
private void button2_Click(object sender, EventArgs e)
{
subForm = new FormTest();
subForm.Layered(button2);
subForm.Disposed += (a, b) =>
{
subForm = null;
};
subForm.Show();
}
private void button3_Click(object sender, EventArgs e)
{
Form form=(Form)Activator.CreateInstance(typeof(FrmTest2)); ;
ShowInCenter(form, this);
ryCommon.RyForm.BringToTop(form.Handle);
ryCommon.RyForm.SetActiveWindow(form.Handle);
try
{
if (!form.IsDisposed) form.Show();
}
catch { }
}
private void textBoxEx21_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
MessageBox.Show("111");
}
}
private void textBoxEx21_LongTimeNoChanged(object sender, EventArgs e)
{
MessageBox.Show("222");
}
}
}