mirror of
https://github.com/nsnail/dot.git
synced 2025-06-17 13:03:22 +08:00
<adjust> * 多平台支持
This commit is contained in:
parent
ea75f46af3
commit
f4b7c5d0ad
@ -1,3 +1,4 @@
|
||||
dotnet build
|
||||
dotnet publish -c Release -r win-x64 --sc -p:"PublishSingleFile=true" -o ./build/win-x64
|
||||
dotnet publish -f net7.0-windows -c Release -r win-x64 --sc -p:"PublishSingleFile=true" -o ./build/win-x64
|
||||
dotnet publish -f net7.0 -c Release -r linux-x64 --sc -p:"PublishSingleFile=true" -o ./build/linux-x64
|
||||
Remove-Item -r ./build/temp
|
@ -1,3 +1,4 @@
|
||||
#if NET7_0_WINDOWS
|
||||
namespace Dot.Color;
|
||||
|
||||
public sealed class Main : ToolBase<Option>
|
||||
@ -10,4 +11,6 @@ public sealed class Main : ToolBase<Option>
|
||||
Application.Run(new WinMain());
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,3 +1,4 @@
|
||||
#if NET7_0_WINDOWS
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@ -72,4 +73,5 @@ public class MouseHook : IDisposable
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,3 +1,4 @@
|
||||
#if NET7_0_WINDOWS
|
||||
using System.Drawing.Drawing2D;
|
||||
using Size = System.Drawing.Size;
|
||||
|
||||
@ -81,4 +82,5 @@ public class WinInfo : Form
|
||||
// 触发重绘
|
||||
_pbox.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,3 +1,4 @@
|
||||
#if NET7_0_WINDOWS
|
||||
using TextCopy;
|
||||
|
||||
namespace Dot.Color;
|
||||
@ -53,8 +54,7 @@ public class WinMain : Form
|
||||
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})");
|
||||
ClipboardService.SetText($"{e.X},{e.Y} #{color.R:X2}{color.G:X2}{color.B:X2}({color.R},{color.G},{color.B})");
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
@ -69,4 +69,6 @@ public class WinMain : Form
|
||||
e.Graphics.DrawImage(_bmp, 0, 0);
|
||||
Opacity = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,4 +1,6 @@
|
||||
#if NET7_0_WINDOWS
|
||||
using TextCopy;
|
||||
#endif
|
||||
|
||||
namespace Dot.Guid;
|
||||
|
||||
@ -11,8 +13,10 @@ public sealed class Main : ToolBase<Option>
|
||||
{
|
||||
var guid = System.Guid.NewGuid().ToString();
|
||||
if (Opt.Upper) guid = guid.ToUpper();
|
||||
ClipboardService.SetText(guid);
|
||||
Console.WriteLine(Str.Copied, guid);
|
||||
#if NET7_0_WINDOWS
|
||||
ClipboardService.SetText(guid);
|
||||
#endif
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
using System.Text.Json;
|
||||
using NSExt.Extensions;
|
||||
#if NET7_0_WINDOWS
|
||||
using TextCopy;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Dot.Json;
|
||||
|
||||
@ -10,7 +13,11 @@ public class Main : ToolBase<Option>
|
||||
|
||||
public Main(Option opt) : base(opt)
|
||||
{
|
||||
var inputText = ClipboardService.GetText();
|
||||
var inputText = Opt.InputText;
|
||||
|
||||
#if NET7_0_WINDOWS
|
||||
if (inputText.NullOrWhiteSpace()) inputText = ClipboardService.GetText();
|
||||
#endif
|
||||
if (inputText.NullOrWhiteSpace()) throw new ArgumentException(Str.InputTextIsEmpty);
|
||||
|
||||
try {
|
||||
@ -63,6 +70,8 @@ public class Main : ToolBase<Option>
|
||||
else if (Opt.Format) result = await JsonFormat();
|
||||
|
||||
if (result.NullOrWhiteSpace()) return;
|
||||
#if NET7_0_WINDOWS
|
||||
await ClipboardService.SetTextAsync(result!);
|
||||
#endif
|
||||
}
|
||||
}
|
@ -12,4 +12,7 @@ public class Option : OptionBase
|
||||
|
||||
[Option('f', "format", HelpText = nameof(Str.FormatJson), Default = true, ResourceType = typeof(Str))]
|
||||
public bool Format { get; set; }
|
||||
|
||||
[Value(0, HelpText = nameof(Str.TextTobeProcessed), ResourceType = typeof(Str))]
|
||||
public string InputText { get; set; }
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
using NSExt.Extensions;
|
||||
#if NET7_0_WINDOWS
|
||||
using TextCopy;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Dot.Pwd;
|
||||
|
||||
@ -46,8 +49,10 @@ public sealed class Main : ToolBase<Option>
|
||||
*(pDest + i) = *(pSource + randScope.Rand());
|
||||
|
||||
var result = new string(pDest, 0, Opt.Length);
|
||||
ClipboardService.SetText(result);
|
||||
Console.WriteLine(Str.Copied, result);
|
||||
#if NET7_0_WINDOWS
|
||||
ClipboardService.SetText(result);
|
||||
#endif
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
@ -1,8 +1,10 @@
|
||||
using System.Diagnostics;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using NSExt.Extensions;
|
||||
#if NET7_0_WINDOWS
|
||||
using TextCopy;
|
||||
using System.Diagnostics;
|
||||
#endif
|
||||
|
||||
namespace Dot.Text;
|
||||
|
||||
@ -98,14 +100,18 @@ html-encode: {o.HtmlEncode}
|
||||
html-decode: {o.HtmlDecode}
|
||||
""";
|
||||
Console.WriteLine(outputTemp);
|
||||
#if NET7_0_WINDOWS
|
||||
var file = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.html");
|
||||
File.WriteAllText(file, outputTemp.Text2Html());
|
||||
Process.Start("explorer", file);
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override async Task Core()
|
||||
{
|
||||
#if NET7_0_WINDOWS
|
||||
if (Opt.Text.NullOrEmpty()) Opt.Text = await ClipboardService.GetTextAsync();
|
||||
#endif
|
||||
if (Opt.Text.NullOrEmpty()) throw new ArgumentException(Str.InputTextIsEmpty);
|
||||
|
||||
|
||||
|
@ -14,11 +14,13 @@ 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))
|
||||
#if NET7_0_WINDOWS
|
||||
, Color.Option o => new Color.Main(o)
|
||||
#endif
|
||||
, 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))
|
||||
};
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<TargetFrameworks>net7.0-windows;net7.0</TargetFrameworks>
|
||||
<UseWindowsForms Condition="'$(TargetFramework)' == 'net7.0-windows'">true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>Dot</RootNamespace>
|
||||
<AssemblyName>dot</AssemblyName>
|
||||
@ -13,6 +13,9 @@
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<AssemblyTitle>功能全面的实用工具 - 程序员的瑞士军刀</AssemblyTitle>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net7.0-windows'">
|
||||
<DefineConstants>$(DefineConstants);NET7_0_WINDOWS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
@ -23,7 +26,7 @@
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
|
||||
<PackageReference Include="NSExt" Version="1.0.8"/>
|
||||
<PackageReference Include="Spectre.Console" Version="0.45.1-preview.0.46"/>
|
||||
<PackageReference Include="TextCopy" Version="6.2.0"/>
|
||||
<PackageReference Condition="'$(TargetFramework)' == 'net7.0-windows'" Include="TextCopy" Version="6.2.0"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Lang\Str.resx">
|
||||
|
Loading…
x
Reference in New Issue
Block a user