5 Commits

Author SHA1 Message Date
247e35484c 1.1.5 (#12)
* <feat> + git批量操作工具
* <feat> + json工具
2022-12-07 10:05:56 +08:00
2efc7ac76e 1.1.3 (#11)
* <feat> + ip工具
2022-12-05 17:36:51 +08:00
deebd018f4 fix (#10)
* <fix> 信息窗口避开鼠标指针指向区域
2022-12-05 16:40:44 +08:00
1ba7f3fcfe fix (#9)
* <fix> 隐藏控制台窗口,避免捕获到截屏
2022-12-05 16:28:09 +08:00
f2e8b8b891 1.1.2 (#7)
* <feat> + 屏幕坐标颜色选取工具
2022-12-05 16:05:58 +08:00
39 changed files with 985 additions and 890 deletions

12
.config/dotnet-tools.json Normal file
View File

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-t4": {
"version": "2.3.1",
"commands": [
"t4"
]
}
}
}

3
.gitignore vendored
View File

@ -802,4 +802,5 @@ FodyWeavers.xsd
# User Define
build/
nuget.config
nuget.config
*.[Dd]esigner.cs

View File

@ -1,7 +1,6 @@
<wpf:ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xml:space="preserve">
xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml:space="preserve">
<s:String x:Key="/Default/CodeStyle/CSharpFileLayoutPatterns/Pattern/@EntryValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"&gt;
&lt;TypePattern&gt;
@ -11,6 +10,7 @@
&lt;Kind.Order&gt;
&lt;DeclarationKind&gt;Interface&lt;/DeclarationKind&gt;
&lt;DeclarationKind&gt;Class&lt;/DeclarationKind&gt;
&lt;DeclarationKind&gt;Record&lt;/DeclarationKind&gt;
&lt;DeclarationKind&gt;Enum&lt;/DeclarationKind&gt;
&lt;DeclarationKind&gt;Struct&lt;/DeclarationKind&gt;
&lt;DeclarationKind&gt;Delegate&lt;/DeclarationKind&gt;

13
src/Color/Main.cs Normal file
View File

@ -0,0 +1,13 @@
namespace Dot.Color;
public sealed class Main : ToolBase<Option>
{
public Main(Option opt) : base(opt) { }
public override Task Run()
{
Application.Run(new WinMain());
return Task.CompletedTask;
}
}

75
src/Color/MouseHook.cs Normal file
View File

@ -0,0 +1,75 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Dot.Color;
public class MouseHook : IDisposable
{
[StructLayout(LayoutKind.Explicit)]
private struct Msllhookstruct
{
// [FieldOffset(20)] private readonly nint dwExtraInfo;
// [FieldOffset(12)] private readonly uint flags;
// [FieldOffset(8)] private readonly uint mouseData;
// [FieldOffset(16)] private readonly uint time;
[FieldOffset(0)] public readonly int X;
[FieldOffset(4)] public readonly int Y;
}
public event MouseEventHandler MouseEvent = delegate { };
private const int _WH_MOUSE_LL = 14;
private const int _WM_LBUTTONDOWN = 0x0201;
private const int _WM_MOUSEMOVE = 0x0200;
private bool _disposed;
private readonly nint _hookId;
public MouseHook()
{
_hookId = SetHook(HookCallback);
}
~MouseHook()
{
Dispose(false);
}
private void Dispose(bool disposing)
{
if (_disposed) return;
if (disposing) { }
if (_hookId != default) Win32.UnhookWindowsHookEx(_hookId);
_disposed = true;
}
private nint HookCallback(int nCode, nint wParam, nint lParam)
{
if (nCode < 0 || (_WM_MOUSEMOVE != wParam && _WM_LBUTTONDOWN != wParam))
return Win32.CallNextHookEx(_hookId, nCode, wParam, lParam);
var hookStruct = (Msllhookstruct)Marshal.PtrToStructure(lParam, typeof(Msllhookstruct))!;
MouseEvent(null, new MouseEventArgs( //
wParam == _WM_MOUSEMOVE ? MouseButtons.None : MouseButtons.Left //
, 0 //
, hookStruct.X //
, hookStruct.Y //
, 0));
return Win32.CallNextHookEx(_hookId, nCode, wParam, lParam);
}
private static nint SetHook(Win32.LowLevelMouseProc proc)
{
using var curProcess = Process.GetCurrentProcess();
using var curModule = curProcess.MainModule!;
return Win32.SetWindowsHookEx(_WH_MOUSE_LL, proc, Win32.GetModuleHandle(curModule.ModuleName), 0);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}

4
src/Color/Option.cs Normal file
View File

@ -0,0 +1,4 @@
namespace Dot.Color;
[Verb("color", HelpText = nameof(Str.ScreenPixelTool), ResourceType = typeof(Str))]
public class Option : OptionBase { }

48
src/Color/Win32.cs Normal file
View File

@ -0,0 +1,48 @@
using System.Runtime.InteropServices;
namespace Dot.Color;
public static partial class Win32
{
public delegate nint LowLevelMouseProc(int nCode, nint wParam, nint lParam);
private const string _GDI32_DLL = "gdi32.dll";
private const string _KERNEL32_DLL = "kernel32.dll";
private const string _USER32_DLL = "user32.dll";
public const int SW_HIDE = 0;
[LibraryImport(_USER32_DLL)]
internal static partial nint CallNextHookEx(nint hhk, int nCode, nint wParam, nint lParam);
[LibraryImport(_KERNEL32_DLL)]
internal static partial nint GetConsoleWindow();
[LibraryImport(_USER32_DLL)]
internal static partial nint GetDesktopWindow();
[LibraryImport(_KERNEL32_DLL, StringMarshalling = StringMarshalling.Utf16)]
internal static partial nint GetModuleHandle(string lpModuleName);
[LibraryImport(_GDI32_DLL)]
internal static partial uint GetPixel(nint dc, int x, int y);
[LibraryImport(_USER32_DLL)]
internal static partial nint GetWindowDC(nint hWnd);
[LibraryImport(_USER32_DLL)]
internal static partial int ReleaseDC(nint hWnd, nint dc);
[LibraryImport(_USER32_DLL)]
internal static partial nint SetWindowsHookEx(int idHook, LowLevelMouseProc lpfn, nint hMod, uint dwThreadId);
[LibraryImport(_USER32_DLL)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool ShowWindow(nint hWnd, int nCmdShow);
[LibraryImport(_USER32_DLL)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool UnhookWindowsHookEx(nint hhk);
}

83
src/Color/WinInfo.cs Normal file
View File

@ -0,0 +1,83 @@
using System.Drawing.Drawing2D;
namespace Dot.Color;
public class WinInfo : Form
{
private const int _WINDOW_SIZE = 480; //窗口大小
private const int _ZOOM_RATE = 16; //缩放倍率
private bool _disposed;
private readonly Graphics _graphics;
private readonly PictureBox _pbox;
public WinInfo()
{
FormBorderStyle = FormBorderStyle.None;
TopMost = true;
MinimizeBox = false;
MaximizeBox = false;
Size = new Size(_WINDOW_SIZE, _WINDOW_SIZE);
StartPosition = FormStartPosition.Manual;
Location = new Point(0, 0);
_pbox = new PictureBox();
_pbox.Location = new Point(0, 0);
_pbox.Size = Size;
_pbox.Image = new Bitmap(_WINDOW_SIZE, _WINDOW_SIZE);
_graphics = Graphics.FromImage(_pbox.Image);
_graphics.InterpolationMode = InterpolationMode.NearestNeighbor; //指定最临近插值法,禁止平滑缩放(模糊)
_graphics.CompositingQuality = CompositingQuality.HighQuality;
_graphics.SmoothingMode = SmoothingMode.None;
_pbox.MouseEnter += PboxOnMouseEnter;
Controls.Add(_pbox);
}
~WinInfo()
{
Dispose(false);
}
private void PboxOnMouseEnter(object sender, EventArgs e)
{
// 信息窗口避开鼠标指针指向区域
Location = new Point(Location.X, Location.Y == 0 ? Screen.PrimaryScreen!.Bounds.Height - _WINDOW_SIZE : 0);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (_disposed) return;
if (disposing) {
_graphics?.Dispose();
_pbox?.Dispose();
}
_disposed = true;
}
public void UpdateImage(Bitmap img, int x, int y)
{
// 计算复制小图的区域
var copySize = new Size(_WINDOW_SIZE / _ZOOM_RATE, _WINDOW_SIZE / _ZOOM_RATE);
_graphics.DrawImage(img, new Rectangle(0, 0, _WINDOW_SIZE, _WINDOW_SIZE) //
, x - copySize.Width / 2 // 左移x使光标位置居中
, y - copySize.Height / 2 // 上移y使光标位置居中
, copySize.Width, copySize.Height, GraphicsUnit.Pixel);
using var pen = new Pen(System.Drawing.Color.Aqua); //绘制准星
_graphics.DrawRectangle(pen, _WINDOW_SIZE / 2 - _ZOOM_RATE / 2 //
, _WINDOW_SIZE / 2 - _ZOOM_RATE / 2 //
, _ZOOM_RATE, _ZOOM_RATE);
// 取鼠标位置颜色
var posColor = img.GetPixel(x, y);
// 绘制底部文字信息
_graphics.FillRectangle(Brushes.Black, 0, _WINDOW_SIZE - 30, _WINDOW_SIZE, 30);
_graphics.DrawString($"{Str.ClickCopyColor} X: {x} Y: {y} RGB({posColor.R},{posColor.G},{posColor.B})"
, new Font(FontFamily.GenericSerif, 10) //
, Brushes.White, 0, _WINDOW_SIZE - 20);
// 触发重绘
_pbox.Refresh();
}
}

72
src/Color/WinMain.cs Normal file
View File

@ -0,0 +1,72 @@
using TextCopy;
namespace Dot.Color;
public class WinMain : Form
{
private readonly Bitmap _bmp;
private bool _disposed;
private readonly WinInfo _winInfo = new(); //小图窗口
public WinMain()
{
// 隐藏控制台窗口,避免捕获到截屏
Win32.ShowWindow(Win32.GetConsoleWindow(), Win32.SW_HIDE);
FormBorderStyle = FormBorderStyle.None;
Size = Screen.PrimaryScreen!.Bounds.Size;
StartPosition = FormStartPosition.Manual;
Location = new Point(0, 0);
Opacity = 0.01d; //主窗体加载截图过程设置为透明避免闪烁
_bmp = new Bitmap(Size.Width, Size.Height);
using var g = Graphics.FromImage(_bmp);
g.CopyFromScreen(0, 0, 0, 0, Size);
}
~WinMain()
{
Dispose(false);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (_disposed) return;
if (disposing) {
_bmp?.Dispose();
_winInfo?.Dispose();
}
_disposed = true;
}
protected override void OnKeyUp(KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape) Application.Exit();
}
protected override void OnLoad(EventArgs e)
{
_winInfo.Show();
}
protected override void OnMouseDown(MouseEventArgs e)
{
var color = _bmp.GetPixel(e.X, e.Y);
ClipboardService.SetText(
$"{e.X},{e.Y} #{color.R.ToString("X2")}{color.G.ToString("X2")}{color.B.ToString("X2")}({color.R},{color.G},{color.B})");
Application.Exit();
}
protected override void OnMouseMove(MouseEventArgs e)
{
// 移动鼠标时更新小图窗口
_winInfo.UpdateImage(_bmp, e.X, e.Y);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(_bmp, 0, 0);
Opacity = 1;
}
}

View File

@ -1,6 +1,6 @@
namespace Dot;
public class DirOption : IOption
public class DirOption : OptionBase
{
[Option('f', "filter", HelpText = nameof(Str.FileSearchPattern), Default = "*.*", ResourceType = typeof(Str))]
public string Filter { get; set; }

111
src/Git/Main.cs Normal file
View File

@ -0,0 +1,111 @@
using System.Diagnostics;
using System.Text;
using NSExt.Extensions;
namespace Dot.Git;
public class Main : ToolBase<Option>
{
private const int _POS_Y_MSG = 74; //git command rsp 显示的位置 y
private const int _POST_Y_LOADING = 70; //loading 动画显示的位置 y
private const int _REP_PATH_LENGTH_LIMIT = 32; //仓库路径长度显示截断阈值
private (int x, int y) _cursorPosBackup; //光标位置备份
private readonly Encoding _gitOutputEnc; //git command rsp 编码
private List<string> _repoPathList; //仓库目录列表
public Main(Option opt) : base(opt)
{
_gitOutputEnc = Encoding.GetEncoding(Opt.GitOutputEncoding);
if (!Directory.Exists(Opt.Path))
throw new ArgumentException(nameof(Opt.Path) //
, string.Format(Str.PathNotFound, Opt.Path));
}
private async ValueTask DirHandle(string dir, CancellationToken cancelToken)
{
var row = _repoPathList.FindIndex(x => x == dir); // 行号
var tAnimate = LoadingAnimate(_POST_Y_LOADING, _cursorPosBackup.y + row, out var cts);
// 打印 git command rsp
void ExecRspReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data is null) return;
var msg = Encoding.UTF8.GetString(_gitOutputEnc.GetBytes(e.Data));
ConcurrentWrite(_POS_Y_MSG, _cursorPosBackup.y + row, new string(' ', Console.WindowWidth - _POS_Y_MSG));
ConcurrentWrite(_POS_Y_MSG, _cursorPosBackup.y + row, msg);
}
// 启动git进程
{
var startInfo = new ProcessStartInfo {
CreateNoWindow = true
, WorkingDirectory = dir
, FileName = "git"
, Arguments = Opt.Args
, UseShellExecute = false
, RedirectStandardOutput = true
, RedirectStandardError = true
};
using var p = Process.Start(startInfo);
p!.OutputDataReceived += ExecRspReceived;
p.ErrorDataReceived += ExecRspReceived;
p.BeginOutputReadLine();
p.BeginErrorReadLine();
await p.WaitForExitAsync();
}
cts.Cancel();
await tAnimate;
cts.Dispose();
}
private void StashCurorPos()
{
_cursorPosBackup = Console.GetCursorPosition();
}
public override async Task Run()
{
// 查找git仓库目录
{
Console.Write(Str.FindGitReps, Opt.Path);
StashCurorPos();
var tAnimate = LoadingAnimate(_cursorPosBackup.x, _cursorPosBackup.y, out var cts);
_repoPathList = Directory.GetDirectories(Opt.Path, ".git" //
, new EnumerationOptions //
{
MaxRecursionDepth = Opt.MaxRecursionDepth
, RecurseSubdirectories = true
, IgnoreInaccessible = true
, AttributesToSkip = FileAttributes.ReparsePoint
})
.Select(x => Directory.GetParent(x)!.FullName)
.ToList();
cts.Cancel();
await tAnimate;
cts.Dispose();
}
// 打印git仓库目录
{
Console.WriteLine(Str.Ok);
StashCurorPos();
var i = 0;
Console.WriteLine( //
string.Join(Environment.NewLine
, _repoPathList.Select(
x => $"{++i}: {new DirectoryInfo(x).Name.Sub(0, _REP_PATH_LENGTH_LIMIT)}"))
//
);
}
// 并行执行git命令
await Parallel.ForEachAsync(_repoPathList, DirHandle);
Console.SetCursorPosition(_cursorPosBackup.x, _cursorPosBackup.y + _repoPathList.Count);
}
}

19
src/Git/Option.cs Normal file
View File

@ -0,0 +1,19 @@
namespace Dot.Git;
[Verb("git", HelpText = nameof(Str.GitTool), ResourceType = typeof(Str))]
public class Option : OptionBase
{
[Option('a', "args", HelpText = nameof(Str.GitArgs), Default = "status", ResourceType = typeof(Str))]
public string Args { get; set; }
[Option('e', "git-output-encoding", HelpText = nameof(Str.GitOutputEncoding), Default = "utf-8"
, ResourceType = typeof(Str))]
public string GitOutputEncoding { get; set; }
[Option('d', "max-recursion-depth", HelpText = nameof(Str.MaxRecursionDepth), Default = int.MaxValue
, ResourceType = typeof(Str))]
public int MaxRecursionDepth { get; set; }
[Value(0, HelpText = nameof(Str.FolderPath), Default = ".", ResourceType = typeof(Str))]
public string Path { get; set; }
}

View File

@ -2,7 +2,7 @@ using TextCopy;
namespace Dot.Guid;
public sealed class Main : Tool<Option>
public sealed class Main : ToolBase<Option>
{
public Main(Option opt) : base(opt) { }

View File

@ -1,7 +1,7 @@
namespace Dot.Guid;
[Verb("guid", HelpText = nameof(Str.GuidTool), ResourceType = typeof(Str))]
public class Option : IOption
public class Option : OptionBase
{
[Option('u', "upper", HelpText = nameof(Str.UseUppercase), Default = false, ResourceType = typeof(Str))]
public bool Upper { get; set; } //normal options here

27
src/IP/Main.cs Normal file
View File

@ -0,0 +1,27 @@
using System.Net.NetworkInformation;
using System.Net.Sockets;
namespace Dot.IP;
public sealed class Main : ToolBase<Option>
{
public Main(Option opt) : base(opt) { }
public override async Task Run()
{
foreach (var item in NetworkInterface.GetAllNetworkInterfaces()) {
if (item.NetworkInterfaceType != NetworkInterfaceType.Ethernet ||
item.OperationalStatus != OperationalStatus.Up)
continue;
foreach (var ip in item.GetIPProperties().UnicastAddresses)
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
Console.WriteLine(@$"{item.Name}: {ip.Address}");
}
using var http = new HttpClient();
Console.Write(Str.PublicIP);
var str = await http.GetStringAsync("http://httpbin.org/ip");
Console.WriteLine(str);
}
}

4
src/IP/Option.cs Normal file
View File

@ -0,0 +1,4 @@
namespace Dot.IP;
[Verb("ip", HelpText = nameof(Str.Ip), ResourceType = typeof(Str))]
public class Option : OptionBase { }

68
src/Json/Main.cs Normal file
View File

@ -0,0 +1,68 @@
using System.Text.Json;
using NSExt.Extensions;
using TextCopy;
namespace Dot.Json;
public class Main : ToolBase<Option>
{
private readonly object _inputObj;
public Main(Option opt) : base(opt)
{
var inputText = ClipboardService.GetText();
if (inputText.NullOrWhiteSpace()) throw new ArgumentException(Str.InputTextIsEmpty);
try {
_inputObj = inputText.Object<object>();
}
catch (JsonException) {
try {
inputText = UnescapeString(inputText);
_inputObj = inputText.Object<object>();
return;
}
catch (JsonException) { }
throw new ArgumentException(Str.InvalidJsonString);
}
}
private async Task<string> ConvertToString()
{
var ret = await JsonCompress();
ret = ret.Replace("\"", "\\\"");
return ret;
}
private Task<string> JsonCompress()
{
var ret = _inputObj.Json();
return Task.FromResult(ret);
}
private Task<string> JsonFormat()
{
var ret = _inputObj.Json(true);
return Task.FromResult(ret);
}
private static string UnescapeString(string text)
{
return text.Replace("\\\"", "\"");
}
public override async Task Run()
{
string result = null;
if (Opt.Compress)
result = await JsonCompress();
else if (Opt.ConvertToString)
result = await ConvertToString();
else if (Opt.Format) result = await JsonFormat();
if (result.NullOrWhiteSpace()) return;
await ClipboardService.SetTextAsync(result!);
}
}

15
src/Json/Option.cs Normal file
View File

@ -0,0 +1,15 @@
namespace Dot.Json;
[Verb("json", HelpText = nameof(Str.Json), ResourceType = typeof(Str))]
public class Option : OptionBase
{
[Option('c', "compress", HelpText = nameof(Str.CompressJson), Default = false, ResourceType = typeof(Str))]
public bool Compress { get; set; }
[Option('s', "convert-to-string", HelpText = nameof(Str.FormatJson), Default = false, ResourceType = typeof(Str))]
public bool ConvertToString { get; set; }
[Option('f', "format", HelpText = nameof(Str.FormatJson), Default = true, ResourceType = typeof(Str))]
public bool Format { get; set; }
}

341
src/Lang/Str.Designer.cs generated
View File

@ -1,341 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Dot.Lang {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Str {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Str() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Dot.Lang.Str", typeof(Str).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to 转换换行符为LF.
/// </summary>
public static string ConvertEndOfLineToLF {
get {
return ResourceManager.GetString("ConvertEndOfLineToLF", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0}(已复制到剪贴板).
/// </summary>
public static string Copied {
get {
return ResourceManager.GetString("Copied", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 文件通配符.
/// </summary>
public static string FileSearchPattern {
get {
return ResourceManager.GetString("FileSearchPattern", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 要处理的目录路径.
/// </summary>
public static string FolderPath {
get {
return ResourceManager.GetString("FolderPath", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to GUID工具.
/// </summary>
public static string GuidTool {
get {
return ResourceManager.GetString("GuidTool", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 文本编码工具.
/// </summary>
public static string HelpForText {
get {
return ResourceManager.GetString("HelpForText", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 输入文本为空.
/// </summary>
public static string InputTextIsEmpty {
get {
return ResourceManager.GetString("InputTextIsEmpty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Local clock offset.
/// </summary>
public static string LocalClockOffset {
get {
return ResourceManager.GetString("LocalClockOffset", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0}, 本机时钟偏移: {1} ms.
/// </summary>
public static string LocalTimeOffset {
get {
return ResourceManager.GetString("LocalTimeOffset", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 本机时间已同步.
/// </summary>
public static string LocalTimeSyncDone {
get {
return ResourceManager.GetString("LocalTimeSyncDone", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 没有需要处理的文件.
/// </summary>
public static string NoFileToBeProcessed {
get {
return ResourceManager.GetString("NoFileToBeProcessed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} 通信中....
/// </summary>
public static string NtpCalling {
get {
return ResourceManager.GetString("NtpCalling", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 成功 {0}/{1} , 本机时钟偏移平均值: {2} ms.
/// </summary>
public static string NtpReceiveDone {
get {
return ResourceManager.GetString("NtpReceiveDone", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0}/{1} 个 NTP 服务器.
/// </summary>
public static string NtpServerCount {
get {
return ResourceManager.GetString("NtpServerCount", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 指定的路径“{0}”不存在.
/// </summary>
public static string PathNotFound {
get {
return ResourceManager.GetString("PathNotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 按下任意键继续....
/// </summary>
public static string PressAnyKey {
get {
return ResourceManager.GetString("PressAnyKey", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to BitSet 1[0-9]2[a-z]4[A-Z]8[ascii.0x21-0x2F].
/// </summary>
public static string PwdGenerateTypes {
get {
return ResourceManager.GetString("PwdGenerateTypes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 密码长度.
/// </summary>
public static string PwdLength {
get {
return ResourceManager.GetString("PwdLength", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 随机密码生成器.
/// </summary>
public static string RandomPasswordGenerator {
get {
return ResourceManager.GetString("RandomPasswordGenerator", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 只读模式(仅做测试,不实际修改).
/// </summary>
public static string ReadOnly {
get {
return ResourceManager.GetString("ReadOnly", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 移除文件尾部换行和空格.
/// </summary>
public static string RemoveTrailingWhiteSpaces {
get {
return ResourceManager.GetString("RemoveTrailingWhiteSpaces", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 查找文件....
/// </summary>
public static string SearchingFile {
get {
return ResourceManager.GetString("SearchingFile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} 个文件.
/// </summary>
public static string SearchingFileOK {
get {
return ResourceManager.GetString("SearchingFileOK", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Server.
/// </summary>
public static string Server {
get {
return ResourceManager.GetString("Server", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 已读取:{0}/{1},处理:{2},跳过:{3}.
/// </summary>
public static string ShowMessageTemp {
get {
return ResourceManager.GetString("ShowMessageTemp", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Status.
/// </summary>
public static string Status {
get {
return ResourceManager.GetString("Status", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 同步本机时间.
/// </summary>
public static string SyncToLocalTime {
get {
return ResourceManager.GetString("SyncToLocalTime", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 要处理的文本(默认取取剪贴板值).
/// </summary>
public static string TextTobeProcessed {
get {
return ResourceManager.GetString("TextTobeProcessed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 连接NTP服务器超时时间 (毫秒).
/// </summary>
public static string TimeoutMillSecs {
get {
return ResourceManager.GetString("TimeoutMillSecs", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 移除文件的uf8 bom.
/// </summary>
public static string TrimUtf8Bom {
get {
return ResourceManager.GetString("TrimUtf8Bom", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 使用大写输出.
/// </summary>
public static string UseUppercase {
get {
return ResourceManager.GetString("UseUppercase", resourceCulture);
}
}
}
}

View File

@ -30,14 +30,11 @@
<value>The specified path "{0}" does not exist</value>
</data>
<data name="SearchingFileOK" xml:space="preserve">
<value>Find files...OK</value>
<value>{0} files</value>
</data>
<data name="ShowMessageTemp" xml:space="preserve">
<value>Read: {0}/{1}, processed: {2}, skipped: {3}</value>
</data>
<data name="HelpForText" xml:space="preserve">
<value>Text encoding tool</value>
</data>
<data name="Copied" xml:space="preserve">
<value>{0}(copied to clipboard)</value>
</data>
@ -113,4 +110,67 @@
<data name="LocalClockOffset" xml:space="preserve">
<value>Local clock offset</value>
</data>
<data name="TimeTool" xml:space="preserve">
<value>Time synchronization tool</value>
</data>
<data name="TextTool" xml:space="preserve">
<value>Text encoding tool</value>
</data>
<data name="ScreenPixelTool" xml:space="preserve">
<value>Screen coordinate color selection tool</value>
</data>
<data name="ClickCopyColor" xml:space="preserve">
<value>Click the left mouse button to copy the colors and coordinates to the clipboard</value>
</data>
<data name="PublicIP" xml:space="preserve">
<value>Public network ip: </value>
</data>
<data name="ServerTime" xml:space="preserve">
<value>Synchronize local time</value>
</data>
<data name="Ip" xml:space="preserve">
<value>IP tools</value>
</data>
<data name="KeepSession" xml:space="preserve">
<value>Keep the session after executing the command</value>
</data>
<data name="NtpServerTime" xml:space="preserve">
<value>NTP server standard clock: {0}</value>
</data>
<data name="GitTool" xml:space="preserve">
<value>Git batch operation tool</value>
</data>
<data name="GitArgs" xml:space="preserve">
<value>Parameters passed to Git</value>
</data>
<data name="Ok" xml:space="preserve">
<value>OK</value>
</data>
<data name="FindGitReps" xml:space="preserve">
<value>Find all git repository directories under "{0}"...</value>
</data>
<data name="GitOutputEncoding" xml:space="preserve">
<value>Git output encoding</value>
</data>
<data name="MaxRecursionDepth" xml:space="preserve">
<value>Directory search depth</value>
</data>
<data name="InvalidJsonString" xml:space="preserve">
<value>Clipboard does not contain correct Json string</value>
</data>
<data name="Json" xml:space="preserve">
<value>JsonTools</value>
</data>
<data name="CompressJson" xml:space="preserve">
<value>Compress Json text</value>
</data>
<data name="FormatJson" xml:space="preserve">
<value>Format JSON text</value>
</data>
<data name="GeneratorClass" xml:space="preserve">
<value>generate entity classes</value>
</data>
<data name="JsonToString" xml:space="preserve">
<value>Json text escaped into a string</value>
</data>
</root>

View File

@ -33,31 +33,58 @@
<data name="PathNotFound" xml:space="preserve">
<value>指定的路径“{0}”不存在</value>
</data>
<data name="InvalidJsonString" xml:space="preserve">
<value>剪贴板未包含正确的Json字符串</value>
</data>
<data name="SearchingFileOK" xml:space="preserve">
<value>{0} 个文件</value>
</data>
<data name="ShowMessageTemp" xml:space="preserve">
<value>已读取:{0}/{1},处理:{2},跳过:{3}</value>
</data>
<data name="HelpForText" xml:space="preserve">
<data name="TimeTool" xml:space="preserve">
<value>时间同步工具</value>
</data>
<data name="Ip" xml:space="preserve">
<value>IP工具</value>
</data>
<data name="Json" xml:space="preserve">
<value>Json工具</value>
</data>
<data name="ScreenPixelTool" xml:space="preserve">
<value>屏幕坐标颜色选取工具</value>
</data>
<data name="TextTool" xml:space="preserve">
<value>文本编码工具</value>
</data>
<data name="TextTobeProcessed" xml:space="preserve">
<value>要处理的文本(默认取取剪贴板值)</value>
</data>
<data name="Copied" xml:space="preserve">
<value>{0}(已复制到剪贴板)</value>
</data>
<data name="GitOutputEncoding" xml:space="preserve">
<value>Git输出编码</value>
</data>
<data name="MaxRecursionDepth" xml:space="preserve">
<value>目录检索深度</value>
</data>
<data name="FileSearchPattern" xml:space="preserve">
<value>文件通配符</value>
</data>
<data name="KeepSession" xml:space="preserve">
<value>执行命令后保留会话</value>
</data>
<data name="TimeoutMillSecs" xml:space="preserve">
<value>连接NTP服务器超时时间 (毫秒)</value>
</data>
<data name="SyncToLocalTime" xml:space="preserve">
<value>同步本机时间</value>
</data>
<data name="ServerTime" xml:space="preserve">
<value>同步本机时间</value>
</data>
<data name="FolderPath" xml:space="preserve">
<value>要处理的目录路径</value>
</data>
@ -67,9 +94,27 @@
<data name="GuidTool" xml:space="preserve">
<value>GUID工具</value>
</data>
<data name="GitTool" xml:space="preserve">
<value>Git批量操作工具</value>
</data>
<data name="UseUppercase" xml:space="preserve">
<value>使用大写输出</value>
</data>
<data name="GitArgs" xml:space="preserve">
<value>传递给Git的参数</value>
</data>
<data name="CompressJson" xml:space="preserve">
<value>压缩Json文本</value>
</data>
<data name="FormatJson" xml:space="preserve">
<value>格式化Json文本</value>
</data>
<data name="GeneratorClass" xml:space="preserve">
<value>生成实体类</value>
</data>
<data name="JsonToString" xml:space="preserve">
<value>Json文本转义成字符串</value>
</data>
<data name="RandomPasswordGenerator" xml:space="preserve">
<value>随机密码生成器</value>
</data>
@ -110,6 +155,9 @@
<data name="LocalTimeOffset" xml:space="preserve">
<value>{0}, 本机时钟偏移: {1} ms</value>
</data>
<data name="NtpServerTime" xml:space="preserve">
<value>NTP 服务器标准时钟: {0}</value>
</data>
<data name="LocalTimeSyncDone" xml:space="preserve">
<value>本机时间已同步</value>
</data>
@ -122,4 +170,16 @@
<data name="LocalClockOffset" xml:space="preserve">
<value>Local clock offset</value>
</data>
<data name="ClickCopyColor" xml:space="preserve">
<value>单击鼠标左键复制颜色和坐标到剪贴板</value>
</data>
<data name="PublicIP" xml:space="preserve">
<value>Public network ip... </value>
</data>
<data name="Ok" xml:space="preserve">
<value>OK</value>
</data>
<data name="FindGitReps" xml:space="preserve">
<value>查找 "{0}" 下所有git仓库目录... </value>
</data>
</root>

86
src/Lang/Str.tt Normal file
View File

@ -0,0 +1,86 @@
<#@ template language="C#" #>
<#@ assembly name="System.Xml" #>
<#@ output encoding="utf-8" extension="Designer.cs" #>
<#@ import namespace="System.Xml" #>
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Dot.Lang {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Str {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Str() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Dot.Lang.Str", typeof(Str).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
<#
var xml = new XmlDocument();
xml.Load("Str.resx");
foreach (XmlNode data in xml.SelectNodes("//root/data")) {
#>
/// <summary>
/// <#= data.SelectSingleNode("value").InnerText #>
/// </summary>
public static string <#= data.Attributes["name"].Value #> {
get {
return ResourceManager.GetString("<#= data.Attributes["name"].Value #>", resourceCulture);
}
}
<#
}
#>
}
}

View File

@ -1,251 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Dot.Lang {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Strings {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Strings() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Dot.Lang.Strings", typeof(Strings).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to 转换换行符为LF.
/// </summary>
public static string ConvertEndOfLineToLF {
get {
return ResourceManager.GetString("ConvertEndOfLineToLF", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0}(已复制到剪贴板).
/// </summary>
public static string Copied {
get {
return ResourceManager.GetString("Copied", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 文件通配符.
/// </summary>
public static string FileSearchPattern {
get {
return ResourceManager.GetString("FileSearchPattern", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 要处理的目录路径.
/// </summary>
public static string FolderPath {
get {
return ResourceManager.GetString("FolderPath", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to GUID工具.
/// </summary>
public static string GuidTool {
get {
return ResourceManager.GetString("GuidTool", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 文本编码工具.
/// </summary>
public static string HelpForText {
get {
return ResourceManager.GetString("HelpForText", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 输入文本为空.
/// </summary>
public static string InputTextIsEmpty {
get {
return ResourceManager.GetString("InputTextIsEmpty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 没有需要处理的文件.
/// </summary>
public static string NoFileToBeProcessed {
get {
return ResourceManager.GetString("NoFileToBeProcessed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 指定的路径“{0}”不存在.
/// </summary>
public static string PathNotFound {
get {
return ResourceManager.GetString("PathNotFound", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 按下任意键继续....
/// </summary>
public static string PressAnyKey {
get {
return ResourceManager.GetString("PressAnyKey", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to BitSet 1[0-9]2[a-z]4[A-Z]8[ascii.0x21-0x2F].
/// </summary>
public static string PwdGenerateTypes {
get {
return ResourceManager.GetString("PwdGenerateTypes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 密码长度.
/// </summary>
public static string PwdLength {
get {
return ResourceManager.GetString("PwdLength", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 随机密码生成器.
/// </summary>
public static string RandomPasswordGenerator {
get {
return ResourceManager.GetString("RandomPasswordGenerator", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 只读模式(仅做测试,不实际修改).
/// </summary>
public static string ReadOnly {
get {
return ResourceManager.GetString("ReadOnly", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 移除文件尾部换行和空格.
/// </summary>
public static string RemoveTrailingWhiteSpaces {
get {
return ResourceManager.GetString("RemoveTrailingWhiteSpaces", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 查找文件....
/// </summary>
public static string SearchingFile {
get {
return ResourceManager.GetString("SearchingFile", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} 个文件.
/// </summary>
public static string SearchingFileOK {
get {
return ResourceManager.GetString("SearchingFileOK", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 已读取:{0}/{1},处理:{2},跳过:{3}.
/// </summary>
public static string ShowMessageTemp {
get {
return ResourceManager.GetString("ShowMessageTemp", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 要处理的文本(默认取取剪贴板值).
/// </summary>
public static string TextTobeProcessed {
get {
return ResourceManager.GetString("TextTobeProcessed", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 移除文件的uf8 bom.
/// </summary>
public static string TrimUtf8Bom {
get {
return ResourceManager.GetString("TrimUtf8Bom", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 使用大写输出.
/// </summary>
public static string UseUppercase {
get {
return ResourceManager.GetString("UseUppercase", resourceCulture);
}
}
}
}

View File

@ -1,86 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
id="root" xmlns="">
<xsd:element name="root" msdata:IsDataSet="true"></xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="InputTextIsEmpty" xml:space="preserve">
<value>The input text is empty</value>
</data>
<data name="SearchingFile" xml:space="preserve">
<value>Find files...</value>
</data>
<data name="PathNotFound" xml:space="preserve">
<value>The specified path "{0}" does not exist</value>
</data>
<data name="SearchingFileOK" xml:space="preserve">
<value>Find files...OK</value>
</data>
<data name="ShowMessageTemp" xml:space="preserve">
<value>Read: {0}/{1}, processed: {2}, skipped: {3}</value>
</data>
<data name="HelpForText" xml:space="preserve">
<value>Text encoding tool</value>
</data>
<data name="Copied" xml:space="preserve">
<value>{0}(copied to clipboard)</value>
</data>
<data name="FileSearchPattern" xml:space="preserve">
<value>File wildcards</value>
</data>
<data name="FolderPath" xml:space="preserve">
<value>Directory path to be processed</value>
</data>
<data name="ConvertEndOfLineToLF" xml:space="preserve">
<value>Convert newline characters to LF</value>
</data>
<data name="GuidTool" xml:space="preserve">
<value>GUID tool</value>
</data>
<data name="UseUppercase" xml:space="preserve">
<value>Use uppercase output</value>
</data>
<data name="RandomPasswordGenerator" xml:space="preserve">
<value>Random password generator</value>
</data>
<data name="PwdLength" xml:space="preserve">
<value>Password length</value>
</data>
<data name="PwdGenerateTypes" xml:space="preserve">
<value>BitSet 1[0-9]2[a-z]4[A-Z]8[ascii.0x21-0x2F]</value>
</data>
<data name="RemoveTrailingWhiteSpaces" xml:space="preserve">
<value>Remove line breaks and spaces at the end of the file</value>
</data>
<data name="TrimUtf8Bom" xml:space="preserve">
<value>Remove the uf8 bom of the file</value>
</data>
<data name="TextTobeProcessed" xml:space="preserve">
<value>Text to be processed (clipboard value is taken by default)</value>
</data>
<data name="PressAnyKey" xml:space="preserve">
<value>Press any key to continue...</value>
</data>
<data name="ReadOnly" xml:space="preserve">
<value>Read-only mode (only for testing, no actual modification)</value>
</data>
<data name="NoFileToBeProcessed" xml:space="preserve">
<value>No documents to be processed</value>
</data>
</root>

View File

@ -1,94 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="InputTextIsEmpty" xml:space="preserve">
<value>输入文本为空</value>
</data>
<data name="SearchingFile" xml:space="preserve">
<value>查找文件...</value>
</data>
<data name="PathNotFound" xml:space="preserve">
<value>指定的路径“{0}”不存在</value>
</data>
<data name="SearchingFileOK" xml:space="preserve">
<value>{0} 个文件</value>
</data>
<data name="ShowMessageTemp" xml:space="preserve">
<value>已读取:{0}/{1},处理:{2},跳过:{3}</value>
</data>
<data name="HelpForText" xml:space="preserve">
<value>文本编码工具</value>
</data>
<data name="TextTobeProcessed" xml:space="preserve">
<value>要处理的文本(默认取取剪贴板值)</value>
</data>
<data name="Copied" xml:space="preserve">
<value>{0}(已复制到剪贴板)</value>
</data>
<data name="FileSearchPattern" xml:space="preserve">
<value>文件通配符</value>
</data>
<data name="FolderPath" xml:space="preserve">
<value>要处理的目录路径</value>
</data>
<data name="ConvertEndOfLineToLF" xml:space="preserve">
<value>转换换行符为LF</value>
</data>
<data name="GuidTool" xml:space="preserve">
<value>GUID工具</value>
</data>
<data name="UseUppercase" xml:space="preserve">
<value>使用大写输出</value>
</data>
<data name="RandomPasswordGenerator" xml:space="preserve">
<value>随机密码生成器</value>
</data>
<data name="PwdLength" xml:space="preserve">
<value>密码长度</value>
</data>
<data name="PwdGenerateTypes" xml:space="preserve">
<value>BitSet 1[0-9]2[a-z]4[A-Z]8[ascii.0x21-0x2F]</value>
</data>
<data name="RemoveTrailingWhiteSpaces" xml:space="preserve">
<value>移除文件尾部换行和空格</value>
</data>
<data name="TrimUtf8Bom" xml:space="preserve">
<value>移除文件的uf8 bom</value>
</data>
<data name="PressAnyKey" xml:space="preserve">
<value>按下任意键继续...</value>
</data>
<data name="ReadOnly" xml:space="preserve">
<value>只读模式(仅做测试,不实际修改)</value>
</data>
<data name="NoFileToBeProcessed" xml:space="preserve">
<value>没有需要处理的文件</value>
</data>
</root>

7
src/Option.cs Normal file
View File

@ -0,0 +1,7 @@
namespace Dot;
public abstract class OptionBase : IOption
{
[Option('k', "keep-session", HelpText = nameof(Str.KeepSession), Default = false, ResourceType = typeof(Str))]
public virtual bool KeepSession { get; set; }
}

View File

@ -1,4 +1,5 @@
using System.Reflection;
using System.Text;
using Dot;
Type[] LoadVerbs()
@ -12,13 +13,20 @@ Type[] LoadVerbs()
async Task Run(object args)
{
var tool = ToolsFactory.Create(args as IOption);
if (args is not OptionBase option) return;
var tool = ToolsFactory.Create(option);
await tool.Run();
if (option!.KeepSession) {
Console.WriteLine();
Console.WriteLine(Str.PressAnyKey);
Console.ReadKey();
}
}
//Entry Point
// Entry Point
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var types = LoadVerbs();
try {

View File

@ -3,7 +3,7 @@ using TextCopy;
namespace Dot.Pwd;
public sealed class Main : Tool<Option>
public sealed class Main : ToolBase<Option>
{
private readonly char[][] _charTable = {
"0123456789".ToCharArray() //

View File

@ -1,15 +1,15 @@
namespace Dot.Pwd;
[Verb("pwd", HelpText = nameof(Str.RandomPasswordGenerator), ResourceType = typeof(Str))]
public class Option : IOption
public class Option : OptionBase
{
[Flags]
public enum GenerateTypes
{
Number = 1
, LowerCaseLetter = 2
, UpperCaseLetter = 4
, SpecialCharacter = 8
Number = 0b0001
, LowerCaseLetter = 0b0010
, UpperCaseLetter = 0b0100
, SpecialCharacter = 0b1000
}
[Value(1, Required = true, HelpText = nameof(Str.PwdLength), ResourceType = typeof(Str))]

View File

@ -3,7 +3,7 @@ using NSExt.Extensions;
namespace Dot.RmBlank;
public sealed class Main : Tool<Option>, IDisposable
public sealed class Main : ToolBase<Option>, IDisposable
{
private int _breakCnt;
private bool _disposed;
@ -31,7 +31,7 @@ public sealed class Main : Tool<Option>, IDisposable
{
_step2Bar.Tick();
ShowMessage(1, 0, 0);
var spacesCnt = 0;
int spacesCnt;
await using var fsrw = OpenFileStream(file, FileMode.Open, FileAccess.ReadWrite);

View File

@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis;
namespace Dot.RmBom;
public sealed class Main : Tool<Option>, IDisposable
public sealed class Main : ToolBase<Option>, IDisposable
{
private int _breakCnt;
private bool _disposed;

View File

@ -5,7 +5,7 @@ using TextCopy;
namespace Dot.Text;
public sealed class Main : Tool<Option>
public sealed class Main : ToolBase<Option>
{
private ref struct Output
{
@ -66,8 +66,6 @@ public sealed class Main : Tool<Option>
private static void ParseAndShow(string text)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var ansi = BuildOutput(text, Encoding.GetEncoding("gbk"));
var utf8 = BuildOutput(text, Encoding.UTF8);
var unicodeLittleEndian = BuildOutput(text, Encoding.Unicode);
@ -108,7 +106,5 @@ html-decode: {o.HtmlDecode}
ParseAndShow(Opt.Text);
Console.Write(Str.PressAnyKey);
Console.ReadKey();
}
}

View File

@ -1,7 +1,7 @@
namespace Dot.Text;
[Verb("text", HelpText = nameof(Str.HelpForText), ResourceType = typeof(Str))]
public class Option : IOption
[Verb("text", HelpText = nameof(Str.TextTool), ResourceType = typeof(Str))]
public class Option : OptionBase
{
[Value(0, HelpText = nameof(Str.TextTobeProcessed), ResourceType = typeof(Str))]
public string Text { get; set; }

View File

@ -1,11 +1,19 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Net.Sockets;
using System.Runtime.InteropServices;
namespace Dot.Time;
public sealed class Main : Tool<Option>
public sealed class Main : ToolBase<Option>
{
private record Server
{
public int ConsoleRowIndex;
public TimeSpan Offset;
public ServerStatues Status;
}
private enum ServerStatues : byte
{
Ready
@ -27,41 +35,76 @@ public sealed class Main : Tool<Option>
[FieldOffset(0)] public ushort wYear;
}
private const int _MAX_DEGREE_OF_PARALLELISM = 10;
private const int _NTP_PORT = 123;
private readonly char[] _loading = { '-', '\\', '|', '/' };
private int _procedCnt;
private readonly int _serverCnt;
private const int _MAX_DEGREE_OF_PARALLELISM = 10;
private const int _NTP_PORT = 123;
private const string _OUTPUT_TEMP = "{0,-30} {1,20} {2,20}";
private static readonly object _lockObj = new();
private int _procedCnt;
private readonly int _serverCnt;
private readonly Dictionary<string, Server> _serverDictionary;
private readonly string[] _srvAddr = {
"ntp.ntsc.ac.cn", "cn.ntp.org.cn", "edu.ntp.org.cn", "cn.pool.ntp.org"
, "time.pool.aliyun.com", "time1.aliyun.com", "time2.aliyun.com"
, "time3.aliyun.com", "time4.aliyun.com", "time5.aliyun.com"
, "time6.aliyun.com", "time7.aliyun.com", "time1.cloud.tencent.com"
, "time2.cloud.tencent.com", "time3.cloud.tencent.com"
, "time4.cloud.tencent.com", "time5.cloud.tencent.com", "ntp.sjtu.edu.cn"
, "ntp.neu.edu.cn", "ntp.bupt.edu.cn", "ntp.shu.edu.cn", "pool.ntp.org"
, "0.pool.ntp.org", "1.pool.ntp.org", "2.pool.ntp.org", "3.pool.ntp.org"
, "asia.pool.ntp.org", "time1.google.com", "time2.google.com"
, "time3.google.com", "time4.google.com", "time.apple.com", "time1.apple.com"
, "time2.apple.com", "time3.apple.com", "time4.apple.com", "time5.apple.com"
, "time6.apple.com", "time7.apple.com", "time.windows.com", "time.nist.gov"
, "time-nw.nist.gov", "time-a.nist.gov", "time-b.nist.gov", "stdtime.gov.hk"
};
private readonly string[] _serverDomains = {
"ntp.ntsc.ac.cn", "cn.ntp.org.cn", "edu.ntp.org.cn"
, "cn.pool.ntp.org", "time.pool.aliyun.com", "time1.aliyun.com"
, "time2.aliyun.com", "time3.aliyun.com", "time4.aliyun.com"
, "time5.aliyun.com", "time6.aliyun.com", "time7.aliyun.com"
, "time1.cloud.tencent.com", "time2.cloud.tencent.com"
, "time3.cloud.tencent.com", "time4.cloud.tencent.com"
, "time5.cloud.tencent.com", "ntp.sjtu.edu.cn", "ntp.neu.edu.cn"
, "ntp.bupt.edu.cn", "ntp.shu.edu.cn", "pool.ntp.org", "0.pool.ntp.org"
, "1.pool.ntp.org", "2.pool.ntp.org", "3.pool.ntp.org"
, "asia.pool.ntp.org", "time1.google.com", "time2.google.com"
, "time3.google.com", "time4.google.com", "time.apple.com"
, "time1.apple.com", "time2.apple.com", "time3.apple.com"
, "time4.apple.com", "time5.apple.com", "time6.apple.com"
, "time7.apple.com", "time.windows.com", "time.nist.gov"
, "time-nw.nist.gov", "time-a.nist.gov", "time-b.nist.gov"
, "stdtime.gov.hk"
};
private int _successCnt;
private readonly Dictionary<string, Server> _srvStatus;
private int _successCnt;
public Main(Option opt) : base(opt)
{
_serverCnt = _serverDomains.Length;
_serverDictionary = _serverDomains.ToDictionary(x => x, _ => new Server { Status = ServerStatues.Ready });
_serverCnt = _srvAddr.Length;
var i = 0;
_srvStatus = _srvAddr.ToDictionary(
x => x, _ => new Server { Status = ServerStatues.Ready, ConsoleRowIndex = ++i });
}
private static void ChangeStatus(KeyValuePair<string, Server> server, ServerStatues status
, TimeSpan offset = default)
{
server.Value.Status = status;
server.Value.Offset = offset;
DrawTextInConsole(0, server.Value.ConsoleRowIndex
, string.Format(_OUTPUT_TEMP, server.Key, server.Value.Status
, status == ServerStatues.Succeed ? server.Value.Offset : string.Empty));
}
private async Task DrawLoading()
{
char[] loading = { '-', '\\', '|', '/' };
var loadingIndex = 0;
while (true) {
if (Volatile.Read(ref _procedCnt) == _serverCnt) break;
await Task.Delay(100);
++loadingIndex;
for (var i = 0; i != _serverCnt; ++i)
DrawTextInConsole(
34, i + 1
, _srvStatus[_srvAddr[i]].Status is ServerStatues.Succeed or ServerStatues.Failed
? " "
: loading[loadingIndex % 4].ToString());
}
Debug.WriteLine(Environment.CurrentManagedThreadId + ":" + DateTime.Now.ToString("O"));
}
private static void DrawTextInConsole(int left, int top, string text)
{
lock (_lockObj) {
Console.SetCursorPosition(left, top);
Console.Write(text);
}
}
@ -102,30 +145,35 @@ public sealed class Main : Tool<Option>
}
}
private async void Printing()
private void PrintTemplate()
{
const string outputTemp = "{0,-30}\t{1}\t{2,20}\t{3,20}";
var rolling = 0;
Console.Clear();
while (true) {
await Task.Delay(100);
Console.SetCursorPosition(0, 0);
var row = //
_serverDictionary.Select(x //
=> string.Format(outputTemp, x.Key
, x.Value.Status == ServerStatues.Connecting
? _loading[++rolling % 4]
: ' ', x.Value.Status
, x.Value.Offset == TimeSpan.Zero
? string.Empty
: x.Value.Offset));
Console.CursorVisible = false;
var row = //
_srvStatus.Select(x //
=> string.Format(_OUTPUT_TEMP, x.Key, x.Value.Status
, x.Value.Offset == TimeSpan.Zero ? string.Empty : x.Value.Offset));
Console.WriteLine(outputTemp, Str.Server, ' ', Str.Status, Str.LocalClockOffset);
Console.WriteLine(string.Join(Environment.NewLine, row));
if (_procedCnt == _serverCnt) break;
Console.WriteLine(_OUTPUT_TEMP, Str.Server, Str.Status, Str.LocalClockOffset);
Console.WriteLine(string.Join(Environment.NewLine, row));
}
private ValueTask ServerHandle(KeyValuePair<string, Server> server)
{
ChangeStatus(server, ServerStatues.Connecting);
var offset = GetNtpOffset(server.Key);
Interlocked.Increment(ref _procedCnt);
if (offset == TimeSpan.Zero) {
ChangeStatus(server, ServerStatues.Failed);
}
else {
Interlocked.Increment(ref _successCnt);
ChangeStatus(server, ServerStatues.Succeed, offset);
}
return ValueTask.CompletedTask;
}
@ -147,48 +195,46 @@ public sealed class Main : Tool<Option>
SetLocalTime(timeToSet);
}
[SuppressMessage("ReSharper", "AccessToDisposedClosure")]
public override async Task Run()
{
var tPrinting = Task.Run(Printing);
PrintTemplate();
var tLoading = DrawLoading();
await Parallel.ForEachAsync(_serverDictionary
await Parallel.ForEachAsync(_srvStatus
, new ParallelOptions { MaxDegreeOfParallelism = _MAX_DEGREE_OF_PARALLELISM }
, (server, _) => {
server.Value.Status = ServerStatues.Connecting;
var offset = GetNtpOffset(server.Key);
, (server, _) => ServerHandle(server));
Interlocked.Increment(ref _procedCnt);
await tLoading;
if (offset == TimeSpan.Zero) {
server.Value.Status = ServerStatues.Failed;
}
else {
server.Value.Status = ServerStatues.Succeed;
Interlocked.Increment(ref _successCnt);
server.Value.Offset = offset;
}
return ValueTask.CompletedTask;
});
tPrinting.Wait();
var avgOffset = TimeSpan.FromTicks((long)_serverDictionary //
var avgOffset = TimeSpan.FromTicks((long)_srvStatus //
.Where(x => x.Value.Status == ServerStatues.Succeed)
.Average(x => x.Value.Offset.Ticks));
Console.SetCursorPosition(0, _serverCnt + 1);
Console.WriteLine(Str.NtpReceiveDone, _successCnt, _serverCnt, avgOffset.TotalMilliseconds);
if (!Opt.Sync) return;
Console.WriteLine();
if (!Opt.Sync) {
if (!Opt.KeepSession) return;
var waitObj = new ManualResetEvent(false);
var _ = Task.Run(async () => {
var top = Console.GetCursorPosition().Top;
while (true) {
Console.SetCursorPosition(0, top);
Console.Write(Str.NtpServerTime, (DateTime.Now - avgOffset).ToString("O"));
waitObj.Set();
await Task.Delay(100);
}
// ReSharper disable once FunctionNeverReturns
});
waitObj.WaitOne();
return;
}
SetSysteTime(DateTime.Now - avgOffset);
Console.WriteLine(Str.LocalTimeSyncDone);
}
private record Server
{
public TimeSpan Offset;
public ServerStatues Status;
}
}

View File

@ -1,11 +1,11 @@
namespace Dot.Time;
[Verb("time", HelpText = nameof(Str.HelpForText), ResourceType = typeof(Str))]
public class Option : IOption
[Verb("time", HelpText = nameof(Str.TimeTool), ResourceType = typeof(Str))]
public class Option : OptionBase
{
[Option('s', "sync", HelpText = nameof(Str.SyncToLocalTime), Default = false, ResourceType = typeof(Str))]
public bool Sync { get; set; }
[Option('t', "timeout", HelpText = nameof(Str.TimeoutMillSecs), Default = 3000, ResourceType = typeof(Str))]
[Option('t', "timeout", HelpText = nameof(Str.TimeoutMillSecs), Default = 2000, ResourceType = typeof(Str))]
public int Timeout { get; set; }
}

View File

@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis;
namespace Dot.ToLf;
public sealed class Main : Tool<Option>, IDisposable
public sealed class Main : ToolBase<Option>, IDisposable
{
private int _breakCnt;
private bool _disposed;

View File

@ -1,7 +1,10 @@
namespace Dot;
public abstract class Tool<TOption> : ITool
public abstract class ToolBase<TOption> : ITool where TOption : OptionBase
{
// ReSharper disable once StaticMemberInGenericType
private static SpinLock _spinlock;
protected readonly ProgressBarOptions //
DefaultProgressBarOptions = new() {
MessageEncodingName = "utf-8"
@ -15,11 +18,25 @@ public abstract class Tool<TOption> : ITool
protected TOption Opt { get; }
protected Tool(TOption opt)
protected ToolBase(TOption opt)
{
Opt = opt;
}
protected static void ConcurrentWrite(int x, int y, string text)
{
var lockTaken = false;
try {
_spinlock.Enter(ref lockTaken);
Console.SetCursorPosition(x, y);
Console.Write(text);
}
finally {
if (lockTaken) _spinlock.Exit(false);
}
}
protected static IEnumerable<string> EnumerateFiles(string path, string searchPattern)
{
var fileList = Directory
@ -33,6 +50,28 @@ public abstract class Tool<TOption> : ITool
return fileList;
}
protected static Task LoadingAnimate(int x, int y, out CancellationTokenSource cts)
{
char[] animateChars = { '-', '\\', '|', '/' };
long counter = 0;
cts = new CancellationTokenSource();
var cancelToken = cts.Token;
return Task.Run(async () => {
for (;;) {
if (cancelToken.IsCancellationRequested) {
ConcurrentWrite(x, y, @" ");
return;
}
ConcurrentWrite(x, y, animateChars[counter++ % 4].ToString());
await Task.Delay(100);
}
});
}
protected static void MoveFile(string source, string dest)
{
try {
@ -65,6 +104,5 @@ public abstract class Tool<TOption> : ITool
return fsr;
}
public abstract Task Run();
}

View File

@ -14,6 +14,10 @@ public static class ToolsFactory
, Text.Option o => new Text.Main(o)
, Guid.Option o => new Guid.Main(o)
, Time.Option o => new Time.Main(o)
, Color.Option o => new Color.Main(o)
, IP.Option o => new IP.Main(o)
, Git.Option o => new Git.Main(o)
, Json.Option o => new Json.Main(o)
, _ => throw new ArgumentOutOfRangeException(nameof(option))
};
}

View File

@ -2,11 +2,12 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Dot</RootNamespace>
<AssemblyName>dot</AssemblyName>
<Version>1.1.1</Version>
<Version>1.1.5</Version>
<Authors>nsnail</Authors>
<Copyright>Copyright (c) 2022 nsnail</Copyright>
<RepositoryUrl>https://github.com/nsnail/dot.git</RepositoryUrl>
@ -29,6 +30,7 @@
<PackageReference Include="TextCopy" Version="6.2.0"/>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Lang\Str.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
@ -44,4 +46,12 @@
</Compile>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<ItemGroup Condition="!Exists('Lang\Str.Designer.cs')">
<Compile Include="Lang\Str.Designer.cs"/>
</ItemGroup>
<Exec Command="dotnet tool restore" StdOutEncoding="utf-8"/>
<Exec WorkingDirectory="$(ProjectDir)\Lang" Command="dotnet t4 Str.tt" StdOutEncoding="utf-8"/>
</Target>
</Project>