RaUI/Source/Itrycn_Project2/OTools/FrmScan.cs
zilinsoft 7ff45b3074 ## 📅2026-06-04 星期四更新
### RaUI    V4.0.2606.0401
- *.[新增]QuickWeb新增支持重试次数。
- *.[新增]RySetting类新增支持json格式设置存储和获取。
- *.[新增]RySetting类新增支持读取设置到内存,然后按配置名称读取。
- *.[新增]新增SuperFileSearch类,文件查找。
- *.[新增]QuickWeb新增CurPageUrl属性。
- *.[新增]HardWare新增支持获取显示器信息。
- *.[新增]HardWare新增GetWMI函数。
- *.[改进]QuickWeb类的UA从IE改为Edge。
- *.[改进]Hosts类IP与域名分隔符从\t改为三个空格。
- *.[改进]RyImage的CropOrFill函数,如果输入的长宽比例与原图一致,则返回原图的副本而不是原图。
- *.[改进]RySoft类的CompareVer函数支持特殊格式的版本号。
- *.[改进]QuickWeb的ConvertUrl函数新增支持自动从CurPageUrl获取。
- *.[改进]DateDiff函数对时间差异小于等于10秒的,自动加上毫秒数据。
- *.[修复]修复ObjectListView控件的AspectGetter方法可能调用null对象的问题。
- *.[修复]修复日期选择控件在获取节假日数据时,会因为节假日文件夹无法访问而报错的问题。
- *.[修复]修复某些情况下剪切板权限问题导致ObjectListView控件报错。
- *.[修复]修复RyImage的CropOrFill函数图片比例不一致时,也是返回原图副本的BUG。
### Itrycn_Project2    V1.0.2606.0401
- *.[改进]将公共调用,无需新增内容的部分代码,改到Public文件夹下
2026-06-04 09:40:37 +08:00

150 lines
5.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Itrycn_Project2;
using ryCommon;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace Itrycn_Project2
{
public partial class FrmScan : RySkins.SKinForm
{
/// <summary>
/// 最大日志数量
/// </summary>
private int MaxLogsCount { get; set; } = 1000;
public FrmScan()
{
InitializeComponent();
//配置软件信息
OlvGameName.AspectGetter = delegate (object x) { return ((ItemInfo)x).Name; };
OlvAddTime.AspectGetter = delegate (object x) { return ((ItemInfo)x).AddTime.ToDateTimeStr(); };
OlvLogTime.AspectGetter = delegate (object x) { return ((Public.Class.LogInfo)x).LogTime.ToDateTimeStr(); };
OlvLogText.AspectGetter = delegate (object x) { return ((Public.Class.LogInfo)x).LogText; };
LvLogs.FormatRow += delegate (object x, BrightIdeasSoftware.FormatRowEventArgs e) {
Public.Class.LogInfo item = (Public.Class.LogInfo)e.Model;
if (item.Color != Color.Black)
{
e.Item.ForeColor = item.Color;
}
};
}
private void FrmStart_Shown(object sender, EventArgs e)
{
}
private void FrmStart_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void FrmStart_Load(object sender, EventArgs e)
{
}
/// <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 Public.Class.LogInfo[] { new Public.Class.LogInfo() { LogTime = DateTime.Now, LogText = log, LogTag = tag, Color = color } });
OlvLogTime.Text = "时间(" + LvLogs.GetItemCount() + ")";
}));
}
catch { }
}
/// <summary>
/// 显示状态
/// </summary>
/// <param name="state"></param>
private void ShowState(string state)
{
this.Invoke(new Action(() =>
{
TsState.Text = "状态:" + state;
}));
}
bool IsRunning = false;
#pragma warning disable CS0414 // 字段“FrmScan.IsExit”已被赋值但从未使用过它的值
bool IsExit = false;
#pragma warning restore CS0414 // 字段“FrmScan.IsExit”已被赋值但从未使用过它的值
private void BtnScan_Click(object sender, EventArgs e)
{
if (IsRunning) { IsExit = true; return; }
IsRunning = true;
BtnScan.Text = "停止";
LvCbResult.ClearObjects();
LvLogs.ClearObjects();
TabLogs.Text = "日志(" + LvLogs.GetItemCount() + ")";
TsState.Text = "状态:正在加载数据...";
OlvGameName.Text = "游戏名[" + LvCbResult.GetItemCount() + "]";
Thread th = new Thread(Start);
th.Start();
void Start()
{
List<ItemInfo> list = new List<ItemInfo>();
//RyWeb.QuickWeb ry3h3 = new RyWeb.QuickWeb();
//↓将扫描的代码写在下面
//↑将扫描的代码写在上面
IsExit = false;
IsRunning = false;
this.Invoke(new Action(() =>
{
//LvCbResult.AddObjects(list);
OlvGameName.Text = "游戏名[" + LvCbResult.GetItemCount() + "]";
TsState.Text = "状态:扫描完毕,共发现" + LvCbResult.GetItemCount() + "个.";
BtnScan.Text = "扫描";
}));
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (LvLogs.SelectedObject == null) { return; }
var item = (Public.Class.LogInfo)LvLogs.SelectedObject;
RyFiles.CopyToClip(item.LogText);
}
class ItemInfo
{
public string Name { get; set; } = "";
public DateTime AddTime { get; set; }
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
LvLogs.CopyObjectsToClipboard();
}
}
}