新增多个类并重构现有类,优化活动管理逻辑;添加配置文件和自动化功能,更新项目结构
This commit is contained in:
parent
672b63987a
commit
50a20b01e9
17
.vscode/launch.json
vendored
17
.vscode/launch.json
vendored
|
@ -1,7 +1,16 @@
|
||||||
{
|
{
|
||||||
// 使用 IntelliSense 了解相关属性。
|
|
||||||
// 悬停以查看现有属性的描述。
|
|
||||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": []
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": ".NET Core Launch",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "launch",
|
||||||
|
"preLaunchTask": "build",
|
||||||
|
"program": "${workspaceFolder}/bin/Debug/net8.0/Debug.dll",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"console": "externalTerminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
17
.vscode/tasks.json
vendored
17
.vscode/tasks.json
vendored
|
@ -2,15 +2,14 @@
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"type": "dotnet",
|
"label": "build",
|
||||||
"task": "build D:\\Debug\\Debug.csproj",
|
"command": "dotnet",
|
||||||
"file": "D:\\Debug\\Debug.csproj",
|
"type": "process",
|
||||||
"group": {
|
"args": [
|
||||||
"kind": "test",
|
"build",
|
||||||
"isDefault": true
|
"${workspaceFolder}"
|
||||||
},
|
],
|
||||||
"problemMatcher": [],
|
"problemMatcher": "$msCompile"
|
||||||
"label": "dotnet: build D:\\Debug\\Debug.csproj"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
6
App.config
Normal file
6
App.config
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
27
Chouka.cs
27
Chouka.cs
|
@ -1,7 +1,13 @@
|
||||||
|
|
||||||
|
using Debug.MODS;
|
||||||
|
|
||||||
namespace Debug;
|
namespace Debug;
|
||||||
public class ChouKa
|
#pragma warning disable 0414 // 关闭未使用变量的警告
|
||||||
|
#pragma warning disable CS0414
|
||||||
|
public class ChouKa : Activity
|
||||||
{
|
{
|
||||||
|
public const string Title = "抽卡";
|
||||||
|
public const int Priority = 0;
|
||||||
// 10 20 30 50 60 70 80 90
|
// 10 20 30 50 60 70 80 90
|
||||||
int currentsize = 0;
|
int currentsize = 0;
|
||||||
int baodinum = 70; //第一次保底80 往后就用随机数80 ~ 90
|
int baodinum = 70; //第一次保底80 往后就用随机数80 ~ 90
|
||||||
|
@ -10,7 +16,6 @@ public class ChouKa
|
||||||
string[] waile = ["薄荷", "铁锈会员10天"];// 设置歪的物品
|
string[] waile = ["薄荷", "铁锈会员10天"];// 设置歪的物品
|
||||||
string baozan = "name";//设置本次UP池 精品 只能有一个
|
string baozan = "name";//设置本次UP池 精品 只能有一个
|
||||||
|
|
||||||
|
|
||||||
//普通物品抽中数量
|
//普通物品抽中数量
|
||||||
int putongsize = 0;
|
int putongsize = 0;
|
||||||
//精品物品抽中数量
|
//精品物品抽中数量
|
||||||
|
@ -19,10 +24,8 @@ public class ChouKa
|
||||||
int waisize_A = 0, waisize_B = 0;
|
int waisize_A = 0, waisize_B = 0;
|
||||||
//创建随机数生成器
|
//创建随机数生成器
|
||||||
private readonly Random random = new();
|
private readonly Random random = new();
|
||||||
string message = $"普通抽卡概率:{70}%\n精品抽卡概率:{30}%\n歪概率:{10}%\n" +
|
readonly string message = string.Empty;
|
||||||
|
// = $"普通抽卡概率:{70}%\n精品抽卡概率:{30}%\n歪概率:{10}%\n" +"保底 80~90";
|
||||||
"保底 80~90";
|
|
||||||
|
|
||||||
public ChouKa()
|
public ChouKa()
|
||||||
{
|
{
|
||||||
// 清除控制台屏幕
|
// 清除控制台屏幕
|
||||||
|
@ -30,7 +33,7 @@ public class ChouKa
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
while (Program.IsWhile)
|
while (Program.IsWhile)
|
||||||
{
|
{
|
||||||
ModeSwitch.New("抽卡系统", ["返回首页", "普通抽卡*1", "普通抽卡*10"], (a) =>
|
_ = new ModeSwitch("抽卡系统", ["返回首页", "普通抽卡*1", "普通抽卡*10"], (a) =>
|
||||||
{
|
{
|
||||||
switch (a)
|
switch (a)
|
||||||
{
|
{
|
||||||
|
@ -47,11 +50,17 @@ public class ChouKa
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, message + "\n" + "当前保底:" + baodinum + "\n当前歪概率:" + waisize + "\n当前普通概率:" + (100 - baodinum) +
|
}, GetDegree("保底概率", baodinum) +
|
||||||
$"\n普通物品:{putongsize} 精品物品:{baozansize} 歪物品:薄荷{waisize_A} 铁锈会员10天{waisize_B}\n");
|
"\n" + GetDegree("歪概率", waisize) +
|
||||||
|
"\n" + GetDegree("UP概率", 100 - baodinum) +
|
||||||
|
$"\n垃圾:{putongsize} && Up:{baozansize} && 歪物品:薄荷糖:{waisize_A} 橘子{waisize_B}\n");
|
||||||
}
|
}
|
||||||
_ = new Program();
|
_ = new Program();
|
||||||
}
|
}
|
||||||
|
string GetDegree(string message, int num)
|
||||||
|
{
|
||||||
|
return message + ":" + num + "%";
|
||||||
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
@ -9,5 +8,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NAudio" Version="2.2.1" />
|
<PackageReference Include="NAudio" Version="2.2.1" />
|
||||||
|
<!--<Reference
|
||||||
|
Include="System.Windows.Forms" />-->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
11
Debug.dtd
Normal file
11
Debug.dtd
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!ELEMENT Project (PropertyGroup,ItemGroup)>
|
||||||
|
<!ATTLIST Project Sdk NMTOKEN #REQUIRED>
|
||||||
|
<!ELEMENT PropertyGroup (OutputType,TargetFramework,ImplicitUsings,Nullable)>
|
||||||
|
<!ELEMENT OutputType (#PCDATA)>
|
||||||
|
<!ELEMENT TargetFramework (#PCDATA)>
|
||||||
|
<!ELEMENT ImplicitUsings (#PCDATA)>
|
||||||
|
<!ELEMENT Nullable (#PCDATA)>
|
||||||
|
<!ELEMENT ItemGroup (PackageReference)>
|
||||||
|
<!ELEMENT PackageReference EMPTY>
|
||||||
|
<!ATTLIST PackageReference Include NMTOKEN #REQUIRED>
|
||||||
|
<!ATTLIST PackageReference Version NMTOKEN #REQUIRED>
|
29
MODS/Activity.cs
Normal file
29
MODS/Activity.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||||
|
public class Activity
|
||||||
|
{
|
||||||
|
public Activity()
|
||||||
|
{
|
||||||
|
// 获取当前类的类型
|
||||||
|
Type activityType = this.GetType();
|
||||||
|
// Console.WriteLine($"当前对象的类型是:{activityType.Name}");
|
||||||
|
string Title;
|
||||||
|
// 获取静态字段 Title
|
||||||
|
FieldInfo titleSField = activityType.GetField("Title", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy
|
||||||
|
| BindingFlags.NonPublic);
|
||||||
|
if (titleSField != null)
|
||||||
|
{
|
||||||
|
// 获取静态字段的值
|
||||||
|
Title = (string)titleSField.GetValue(null); // 静态字段传 null
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Title = activityType.Name;
|
||||||
|
}
|
||||||
|
// Console.WriteLine($"当前对象的标题是:{Title}");
|
||||||
|
Console.Title = Title ?? "null";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
namespace Debug;
|
namespace Debug.MODS;
|
||||||
public class ModeSwitch
|
public class ModeSwitch
|
||||||
{
|
{
|
||||||
|
|
||||||
private object? class_;
|
private readonly object? class_;
|
||||||
public event Action<int>? Enter;
|
public event Action<int>? Enter;
|
||||||
private readonly string[] str = ["退出"];
|
private readonly string[] str = ["退出"];
|
||||||
private int mode = 0;
|
private int mode = 0;
|
15
MODS/Title.cs
Normal file
15
MODS/Title.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Debug.MODS;
|
||||||
|
public class Title
|
||||||
|
{
|
||||||
|
public string title;
|
||||||
|
public int Priority;
|
||||||
|
public Title(string title, int priority)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.Priority = priority;
|
||||||
|
}
|
||||||
|
}
|
0
MODS/Tutke
Normal file
0
MODS/Tutke
Normal file
106
MODS/TypeHelper.cs
Normal file
106
MODS/TypeHelper.cs
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Debug.MODS;
|
||||||
|
public class TypeHelper<TBase>
|
||||||
|
{
|
||||||
|
public readonly List<Type> result = [];
|
||||||
|
readonly string Title = "Title";
|
||||||
|
readonly string Priority = "Priority";
|
||||||
|
public TypeHelper()
|
||||||
|
{
|
||||||
|
Run();
|
||||||
|
}
|
||||||
|
public TypeHelper(string title, string Priority)
|
||||||
|
{
|
||||||
|
this.Title = title;
|
||||||
|
this.Priority = Priority;
|
||||||
|
Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Run()
|
||||||
|
{
|
||||||
|
GetTypesInheritingFrom();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showUI()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有继承自指定基类的类型
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TBase">基类</typeparam>
|
||||||
|
/// <returns>继承自基类的类型列表</returns>
|
||||||
|
public List<Type> GetTypesInheritingFrom()
|
||||||
|
{
|
||||||
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var type in assembly.GetTypes())
|
||||||
|
{
|
||||||
|
if (typeof(TBase).IsAssignableFrom(type) && type != typeof(TBase))
|
||||||
|
{
|
||||||
|
result.Add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ReflectionTypeLoadException ex)
|
||||||
|
{
|
||||||
|
foreach (var type in ex.Types.Where(t => t != null))
|
||||||
|
{
|
||||||
|
if (typeof(TBase).IsAssignableFrom(type) && type != typeof(TBase))
|
||||||
|
{
|
||||||
|
result.Add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// GetTitles();
|
||||||
|
// 按 `Priority` 常量值排序
|
||||||
|
result.Sort((a, b) => GetPriority(a).CompareTo(GetPriority(b)));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetPriority(Type type)
|
||||||
|
{
|
||||||
|
// 获取 `Priority` 常量字段
|
||||||
|
var field = type.GetField(Priority, BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy
|
||||||
|
| BindingFlags.NonPublic);
|
||||||
|
|
||||||
|
// 确保字段存在且是 `int`
|
||||||
|
if (field != null && field.FieldType == typeof(int))
|
||||||
|
{
|
||||||
|
// Console.WriteLine((int)field.GetValue(null)!);
|
||||||
|
return (int)field.GetValue(null)!; // 获取静态字段的值
|
||||||
|
}
|
||||||
|
return int.MaxValue; // 如果没有 `Priority`,默认放到最后
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||||
|
public string[] GetTitles()
|
||||||
|
{
|
||||||
|
List<string> list = [];
|
||||||
|
foreach (var type in result)
|
||||||
|
{
|
||||||
|
string Title;
|
||||||
|
// 获取静态字段 Title
|
||||||
|
FieldInfo titleSField = type.GetField("Title", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy
|
||||||
|
| BindingFlags.NonPublic);
|
||||||
|
if (titleSField != null)
|
||||||
|
{
|
||||||
|
// 获取静态字段的值
|
||||||
|
Title = (string)titleSField.GetValue(null); // 静态字段传 null
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Title = type.Name;
|
||||||
|
}
|
||||||
|
// Console.WriteLine("正在搜索:" + Title);
|
||||||
|
list.Add(Title ?? "null");
|
||||||
|
}
|
||||||
|
return [.. list];
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,8 +5,9 @@ namespace Debug.MinLong;
|
||||||
#pragma warning disable CA1822 // 将成员标记为 static
|
#pragma warning disable CA1822 // 将成员标记为 static
|
||||||
#pragma warning disable IDE0051 // 删除未使用的私有成员
|
#pragma warning disable IDE0051 // 删除未使用的私有成员
|
||||||
#pragma warning disable IDE1006 // 命名样式
|
#pragma warning disable IDE1006 // 命名样式
|
||||||
public class Main
|
public class Main : Activity
|
||||||
{
|
{
|
||||||
|
const string Title = "小龙快跑";
|
||||||
|
|
||||||
public Main()
|
public Main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Debug.MODS;
|
||||||
|
|
||||||
namespace Debug.ModelingMusic;
|
namespace Debug.ModelingMusic;
|
||||||
public class Music
|
public class Music : Activity
|
||||||
{
|
{
|
||||||
public static string title = "模拟音游 1.5 by";
|
public const string Title = "模拟音游 1.5 by";
|
||||||
//选择的模式
|
//选择的模式
|
||||||
|
private const int Priority = 0;
|
||||||
private static int mode = 0;
|
private static int mode = 0;
|
||||||
public Music()
|
public Music()
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
string[] str = ["返回首页", "启动", "手动测试", "自动测试", "字符串测试", "字符串随机测试"];
|
string[] str = ["返回首页", "启动", "手动测试", "自动测试", "字符串测试", "字符串随机测试"];
|
||||||
ModeSwitch.New(title, str, (a) =>
|
_ = new ModeSwitch(Title, str, (a) =>
|
||||||
{
|
{
|
||||||
mode = a;
|
mode = a;
|
||||||
Console.CursorVisible = false; // 隐藏光标
|
Console.CursorVisible = false; // 隐藏光标
|
||||||
|
|
76
Program.cs
76
Program.cs
|
@ -1,63 +1,57 @@
|
||||||
using System.Text;
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using Debug.ModelingMusic;
|
using Debug.ModelingMusic;
|
||||||
|
using Debug.MODS;
|
||||||
namespace Debug;
|
namespace Debug;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主程序入口 参考 https://blog.csdn.net/oscar999/article/details/141370223
|
/// 主程序入口 参考 https://blog.csdn.net/oscar999/article/details/141370223
|
||||||
/// 在VS Code的终端中,使用dotnet build命令来编译项目。这将在项目目录中生成一个bin文件夹,其中包含编译后的程序集。
|
/// 在VS Code的终端中,使用dotnet build命令来编译项目。这将在项目目录中生成一个bin文件夹,其中包含编译后的程序集。
|
||||||
/// 使用dotnet run命令来运行项目。这将编译项目(如果尚未编译)并运行编译后的程序。
|
/// 使用dotnet run命令来运行项目。这将编译项目(如果尚未编译)并运行编译后的程序。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
|
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern IntPtr LoadKeyboardLayout(string pwszKLID, uint Flags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern IntPtr ActivateKeyboardLayout(IntPtr hkl, uint Flags);
|
||||||
|
const string ENGLISH_KEYBOARD_LAYOUT = "00000409"; // 美国英语布局
|
||||||
|
// 获取所有继承自 Activity 的类
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
// Console.WriteLine("Hello World!");
|
||||||
|
_ = new Program();
|
||||||
|
}
|
||||||
|
//Y,X
|
||||||
|
public static readonly Point[,] chars = new Point[10, 50];
|
||||||
|
public static bool IsWhile = true;
|
||||||
|
public const char ShowChar = ' ';
|
||||||
|
public static Random random = new();
|
||||||
|
public Program()
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
Console.Title = "Tools";//设置窗口标题
|
Console.Title = "Tools";//设置窗口标题
|
||||||
// 设置控制台输出编码,以支持复杂字符
|
// 设置控制台输出编码,以支持复杂字符
|
||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
Console.CursorVisible = false;
|
Console.CursorVisible = false;
|
||||||
// new MusicFrom();
|
var ActivityType = new TypeHelper<Activity>();
|
||||||
_ = new Program();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Y,X
|
|
||||||
public static readonly Point[,] chars = new Point[10, 50];
|
|
||||||
public static bool IsWhile = true;
|
|
||||||
|
|
||||||
public const char ShowChar = ' ';
|
|
||||||
public static Random random = new();
|
|
||||||
|
|
||||||
public Program()
|
|
||||||
{
|
|
||||||
Console.Clear();
|
|
||||||
// ResetChars();
|
// ResetChars();
|
||||||
string[] str = ["抽卡", "搜索引擎", Music.title, "小龙快跑", "贪吃蛇", "铁锈助手(联机模块)[未开发]", "服务器代理"];
|
var modeSwitch = new ModeSwitch("请选择你要执行的操作", ActivityType.GetTitles(), (a) =>
|
||||||
var modeSwitch = new ModeSwitch("请选择你要执行的操作", str, (a) =>
|
|
||||||
{
|
{
|
||||||
switch (a)
|
object[] objects = [this];
|
||||||
|
Type[] paramTypes = Array.ConvertAll(objects, p => p.GetType());
|
||||||
|
ConstructorInfo constructor = ActivityType.result[a].GetConstructor(paramTypes);
|
||||||
|
if (constructor != null)
|
||||||
{
|
{
|
||||||
case 0:
|
Activator.CreateInstance(ActivityType.result[a], objects);
|
||||||
_ = new ChouKa();//抽卡
|
}
|
||||||
break;
|
else
|
||||||
case 1:
|
{
|
||||||
_ = new Mod();
|
Activator.CreateInstance(ActivityType.result[a]);
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
_ = new Music();
|
|
||||||
// _ = new MusicFrom();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
_ = new MinLong.Main();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
_ = new Tanchishe.Main();
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
// _ = new Tanchishe.Main();
|
|
||||||
_ = new Program();
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
_ = new ProxySettingsHelper(this);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}, "作者:MuQing\n使用语言:C#\n使用IDE:VS Code\n使用框架:.NET 8.0 \n测试运行平台:Windows11\n项目地址:https://git.coldmint.top/muqing/ModelingMusicForm.git");
|
}, "作者:MuQing\n使用语言:C#\n使用IDE:VS Code\n使用框架:.NET 8.0 \n测试运行平台:Windows11\n项目地址:https://git.coldmint.top/muqing/ModelingMusicForm.git");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
using Debug.MODS;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
namespace Debug;
|
namespace Debug;
|
||||||
#pragma warning disable CA1416 // 验证平台兼容性
|
#pragma warning disable CA1416 // 验证平台兼容性
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||||
public class ProxySettingsHelper
|
public class ProxySettingsHelper : Activity
|
||||||
{
|
{
|
||||||
|
public const string Title = "服务器代理";
|
||||||
// 引入WinINet API函数
|
// 引入WinINet API函数
|
||||||
[DllImport("wininet.dll", SetLastError = true)]
|
[DllImport("wininet.dll", SetLastError = true)]
|
||||||
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
|
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
|
||||||
|
@ -28,7 +30,7 @@ public class ProxySettingsHelper
|
||||||
SetProxy(true, proxy);
|
SetProxy(true, proxy);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_ = new ProxySettingsHelper(this);
|
_ = new ProxySettingsHelper(class_);
|
||||||
}, $"代理已{(enableProxy ? "开启" : "关闭")},地址: {proxy}");
|
}, $"代理已{(enableProxy ? "开启" : "关闭")},地址: {proxy}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
90
README.md
90
README.md
|
@ -1,31 +1,20 @@
|
||||||
# ModelingDebug
|
# ModelingDebug
|
||||||
|
|
||||||
### C#-Net控制台程序
|
### C#-Net控制台程序
|
||||||
## 功能
|
## 模块继承
|
||||||
1. 抽卡模拟器
|
如果一个类继承了Activity那么使用GetTypesInheritingFrom把他们全部获取
|
||||||
2. 文件/文件夹搜索
|
如果继承了请在里面加入一些可被识别的变量类型
|
||||||
3. 下落字符调试
|
```csharp
|
||||||
4. 小龙快跑 简易游戏
|
public static Title = "模块选择器";
|
||||||
|
public const Title = "模块选择器";
|
||||||
## 集成和使用
|
```
|
||||||
内置选择模式
|
string Title 是模块的标题
|
||||||
可自由添加模块
|
int Priority 是优先级,数字越小越靠前展示
|
||||||
PgUp/W 上选择
|
## 规范使用
|
||||||
PgDn/S 下选择
|
继承了Activity的类的方法并且同时使用了模块选择器的 类 里面要有
|
||||||
1···9快捷数字选择
|
Title Priority
|
||||||
Enter(回车) 确定执行
|
## 选择器
|
||||||
Esc 选择退出 Enter(回车) 返回选择器
|
```
|
||||||
### 使用
|
|
||||||
Visual Studio Code
|
|
||||||
Visual Studio 2022
|
|
||||||
其他能运行C# Net8.0的程序
|
|
||||||
### 方法
|
|
||||||
var 变量 = new ModeSwitch("string", string[], (a) =>
|
|
||||||
{
|
|
||||||
//在这里处理选择逻辑
|
|
||||||
},"message");
|
|
||||||
|
|
||||||
### 例子
|
|
||||||
string[] str = ["模块", "模块", "模块", "模块"];
|
string[] str = ["模块", "模块", "模块", "模块"];
|
||||||
var modeSwitch = new ModeSwitch("请选择你要执行的操作:", str, (a) =>
|
var modeSwitch = new ModeSwitch("请选择你要执行的操作:", str, (a) =>
|
||||||
{
|
{
|
||||||
|
@ -35,21 +24,48 @@
|
||||||
//需要执行的方法模块
|
//需要执行的方法模块
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
//需要执行的方法模块
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
//需要执行的方法模块
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
//需要执行的方法模块
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
//需要执行的方法模块
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printfLine("还没有这个功能");
|
printfLine("还没有这个功能");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
### 新增底部注意提醒词
|
```
|
||||||
public ModeSwitch(string title, string[] a, Action<int> Enter, string message)
|
## 模块选择器
|
||||||
|
正确的说是加载所有Activity的一个选择器
|
||||||
|
显示到页面中(如图)
|
||||||
|

|
||||||
|
## 选择器的使用
|
||||||
|
内置选择模式
|
||||||
|
可自由添加模块
|
||||||
|
PgUp/W 上选择
|
||||||
|
PgDn/S 下选择
|
||||||
|
1···9快捷数字选择
|
||||||
|
Enter(回车) 确定执行
|
||||||
|
Esc 选择退出 Enter(回车) 返回选择器
|
||||||
|
如果选择器被传入了一个类型,则选择器会返回这一个类
|
||||||
|
public ModeSwitch(object class_, string title, string[] a, Action<int> Enter, string message)
|
||||||
|
### 打包和运行
|
||||||
|
Visual Studio Code
|
||||||
|
Visual Studio 2022
|
||||||
|
其他能运行C# Net8.0的程序
|
||||||
|
### 方法
|
||||||
|
1. 模块选择器<br>
|
||||||
|
public ModeSwitch(object class_, string title, string[] a, Action<int> Enter, string message)
|
||||||
|
可选的是class_,message
|
||||||
|
class_是标记我可以用Esc返回这个类
|
||||||
|
message是底部的提示信息你可以在这里标注每个功能的使用方法
|
||||||
|
2. Activity<br>
|
||||||
|
自动获取被他继承子类的Title方法
|
||||||
|
3. TypeHelper<br>
|
||||||
|
获取所有被这个父类继承的子类
|
||||||
|
var ActivityType = new TypeHelper<类>();
|
||||||
|
|
||||||
|
自定义 获取子类的静态标题和优先级的变量定义
|
||||||
|
public TypeHelper(string title, string Priority)
|
||||||
|
|
||||||
|
GetTitles()获取所有子类的标题
|
||||||
|
|
||||||
|
GetTypesInheritingFrom() 获取所有子类 这个默认在创建的时候就执行了
|
||||||
|
|
||||||
|
如果你要获取被获取的类的列表可以使用ActivityType.result这个就是列表
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
|
|
||||||
using Debug;
|
using Debug;
|
||||||
|
using Debug.MODS;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件夹文件搜索引擎操作
|
/// 文件夹文件搜索引擎操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
namespace Debug;
|
namespace Debug;
|
||||||
public class Mod
|
public class Mod : Activity
|
||||||
{
|
{
|
||||||
|
const string Title = "文件搜索";
|
||||||
private static DateTime time;
|
private static DateTime time;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 结束时间
|
/// 结束时间
|
||||||
|
@ -40,7 +42,7 @@ public class Mod
|
||||||
public Mod()
|
public Mod()
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
ModeSwitch.New("搜索模式", ["返回主页", "文件", "文件夹"], MODE);
|
_ = new ModeSwitch("搜索模式", ["返回主页", "文件", "文件夹"], MODE);
|
||||||
}
|
}
|
||||||
public void MODE(int a)
|
public void MODE(int a)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 贪吃蛇主入口
|
/// 贪吃蛇主入口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Main
|
public class Main : Activity
|
||||||
{
|
{
|
||||||
|
const string Title = "贪吃蛇";
|
||||||
readonly int MaxY;
|
readonly int MaxY;
|
||||||
readonly int MaxX;
|
readonly int MaxX;
|
||||||
public Main()
|
public Main()
|
||||||
|
|
90
zidonghua.cs
Normal file
90
zidonghua.cs
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace Debug;
|
||||||
|
public class zidonghua
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct INPUT
|
||||||
|
{
|
||||||
|
public int type;
|
||||||
|
public InputUnion u;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
struct InputUnion
|
||||||
|
{
|
||||||
|
[FieldOffset(0)] public MOUSEINPUT mi;
|
||||||
|
[FieldOffset(0)] public KEYBDINPUT ki;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct MOUSEINPUT
|
||||||
|
{
|
||||||
|
public int dx;
|
||||||
|
public int dy;
|
||||||
|
public int mouseData;
|
||||||
|
public int dwFlags;
|
||||||
|
public int time;
|
||||||
|
public IntPtr dwExtraInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct KEYBDINPUT
|
||||||
|
{
|
||||||
|
public short wVk;
|
||||||
|
public short wScan;
|
||||||
|
public int dwFlags;
|
||||||
|
public int time;
|
||||||
|
public IntPtr dwExtraInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize);
|
||||||
|
|
||||||
|
const int INPUT_MOUSE = 0;
|
||||||
|
const int INPUT_KEYBOARD = 1;
|
||||||
|
const int KEYEVENTF_KEYUP = 0x0002;
|
||||||
|
const int MOUSEEVENTF_LEFTDOWN = 0x0002;
|
||||||
|
const int MOUSEEVENTF_LEFTUP = 0x0004;
|
||||||
|
|
||||||
|
static void SimulateKeyPress(short keyCode)
|
||||||
|
{
|
||||||
|
INPUT[] inputs = new INPUT[2];
|
||||||
|
inputs[0].type = INPUT_KEYBOARD;
|
||||||
|
inputs[0].u.ki.wVk = keyCode;
|
||||||
|
inputs[0].u.ki.dwFlags = 0;
|
||||||
|
|
||||||
|
inputs[1].type = INPUT_KEYBOARD;
|
||||||
|
inputs[1].u.ki.wVk = keyCode;
|
||||||
|
inputs[1].u.ki.dwFlags = KEYEVENTF_KEYUP;
|
||||||
|
|
||||||
|
SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(INPUT)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SimulateMouseClick(int x, int y)
|
||||||
|
{
|
||||||
|
INPUT[] inputs = new INPUT[2];
|
||||||
|
inputs[0].type = INPUT_MOUSE;
|
||||||
|
inputs[0].u.mi.dx = x;
|
||||||
|
inputs[0].u.mi.dy = y;
|
||||||
|
inputs[0].u.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
|
||||||
|
|
||||||
|
inputs[1].type = INPUT_MOUSE;
|
||||||
|
inputs[1].u.mi.dx = x;
|
||||||
|
inputs[1].u.mi.dy = y;
|
||||||
|
inputs[1].u.mi.dwFlags = MOUSEEVENTF_LEFTUP;
|
||||||
|
|
||||||
|
SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(INPUT)));
|
||||||
|
}
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern short VkKeyScan(char ch);
|
||||||
|
public zidonghua()
|
||||||
|
{
|
||||||
|
Thread.Sleep(3000);
|
||||||
|
SimulateKeyPress(VkKeyScan('A'));
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
SimulateMouseClick(500, 500);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user