11 changed files with 490 additions and 135 deletions
@ -0,0 +1,43 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio Version 16 |
|||
VisualStudioVersion = 16.0.35325.158 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apewer", "Apewer\Apewer.csproj", "{7C47A362-78F9-4EC2-86F1-B442658D2466}" |
|||
EndProject |
|||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apewer.Source", "Apewer.Source\Apewer.Source.csproj", "{AFF499E2-10D0-406B-A563-CE3327D57962}" |
|||
EndProject |
|||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apewer.Web", "Apewer.Web\Apewer.Web.csproj", "{0C9CD2F9-E0C2-4BAC-84C1-33A57798D6CC}" |
|||
EndProject |
|||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apewer.Windows", "Apewer.Windows\Apewer.Windows.csproj", "{5FB935E5-01E8-4CA7-9157-DC58BD731408}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{7C47A362-78F9-4EC2-86F1-B442658D2466}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{7C47A362-78F9-4EC2-86F1-B442658D2466}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{7C47A362-78F9-4EC2-86F1-B442658D2466}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{7C47A362-78F9-4EC2-86F1-B442658D2466}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{AFF499E2-10D0-406B-A563-CE3327D57962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{AFF499E2-10D0-406B-A563-CE3327D57962}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{AFF499E2-10D0-406B-A563-CE3327D57962}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{AFF499E2-10D0-406B-A563-CE3327D57962}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{0C9CD2F9-E0C2-4BAC-84C1-33A57798D6CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{0C9CD2F9-E0C2-4BAC-84C1-33A57798D6CC}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{0C9CD2F9-E0C2-4BAC-84C1-33A57798D6CC}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{0C9CD2F9-E0C2-4BAC-84C1-33A57798D6CC}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{5FB935E5-01E8-4CA7-9157-DC58BD731408}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{5FB935E5-01E8-4CA7-9157-DC58BD731408}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{5FB935E5-01E8-4CA7-9157-DC58BD731408}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{5FB935E5-01E8-4CA7-9157-DC58BD731408}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {7A4C1E3C-8A0A-4128-A143-627A9F76EF02} |
|||
EndGlobalSection |
|||
EndGlobal |
@ -1,29 +1,29 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\Apewer\Apewer.props" /> |
|||
<Import Project="..\Apewer\Apewer.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<DefineConstants>SOURCE;$(DefineConstants);</DefineConstants> |
|||
<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">MYSQL_6_10;$(DefineConstants);</DefineConstants> |
|||
<DefineConstants Condition="'$(TargetFramework)'=='net40'">MYSQL_6_9;$(DefineConstants);</DefineConstants> |
|||
<TargetFrameworks>netstandard2.0;net40;net20</TargetFrameworks> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<DefineConstants>SOURCE;$(DefineConstants);</DefineConstants> |
|||
<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">MYSQL_6_10;$(DefineConstants);</DefineConstants> |
|||
<DefineConstants Condition="'$(TargetFramework)'=='net40'">MYSQL_6_9;$(DefineConstants);</DefineConstants> |
|||
<TargetFrameworks>netstandard2.0;net40;net20</TargetFrameworks> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Apewer\Apewer.csproj" /> |
|||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.110" PrivateAssets="all" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Apewer\Apewer.csproj" /> |
|||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.110" PrivateAssets="all" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'"> |
|||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" /> |
|||
<PackageReference Include="System.Data.SqlClient" Version="4.4.3" /> |
|||
<PackageReference Include="System.Security.Permissions" Version="4.4.1" /> |
|||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'"> |
|||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" /> |
|||
<PackageReference Include="System.Data.SqlClient" Version="4.4.3" /> |
|||
<PackageReference Include="System.Security.Permissions" Version="4.4.1" /> |
|||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup Condition="'$(TargetFramework)'=='net40'"> |
|||
<Reference Include="System.Configuration" /> |
|||
<Reference Include="System.Transactions" /> |
|||
</ItemGroup> |
|||
<ItemGroup Condition="'$(TargetFramework)'=='net40'"> |
|||
<Reference Include="System.Configuration" /> |
|||
<Reference Include="System.Transactions" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
@ -1,25 +1,25 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\Apewer\Apewer.props" /> |
|||
<Import Project="..\Apewer\Apewer.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<DefineConstants>WEB;$(DefineConstants);</DefineConstants> |
|||
<TargetFrameworks>netcoreapp3.1;net40;net20</TargetFrameworks> |
|||
</PropertyGroup> |
|||
<PropertyGroup> |
|||
<DefineConstants>WEB;$(DefineConstants);</DefineConstants> |
|||
<TargetFrameworks>netcoreapp3.1;net40;net20</TargetFrameworks> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="FavIcon.ico" /> |
|||
<EmbeddedResource Include="WebConfig40.xml" /> |
|||
<EmbeddedResource Include="WebConfigStd.xml" /> |
|||
<EmbeddedResource Include="WebConfig461.xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<EmbeddedResource Include="FavIcon.ico" /> |
|||
<EmbeddedResource Include="WebConfig40.xml" /> |
|||
<EmbeddedResource Include="WebConfigStd.xml" /> |
|||
<EmbeddedResource Include="WebConfig461.xml" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Apewer\Apewer.csproj" /> |
|||
<FrameworkReference Condition="'$(TargetFramework)' == 'netcoreapp3.1'" Include="Microsoft.AspNetCore.App" /> |
|||
<Reference Condition="'$(TargetFramework)' == 'net461'" Include="System.Web" /> |
|||
<Reference Condition="'$(TargetFramework)' == 'net40'" Include="System.Web" /> |
|||
<Reference Condition="'$(TargetFramework)' == 'net20'" Include="System.Web" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Apewer\Apewer.csproj" /> |
|||
<FrameworkReference Condition="'$(TargetFramework)' == 'netcoreapp3.1'" Include="Microsoft.AspNetCore.App" /> |
|||
<Reference Condition="'$(TargetFramework)' == 'net461'" Include="System.Web" /> |
|||
<Reference Condition="'$(TargetFramework)' == 'net40'" Include="System.Web" /> |
|||
<Reference Condition="'$(TargetFramework)' == 'net20'" Include="System.Web" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
|
@ -0,0 +1,123 @@ |
|||
using System; |
|||
|
|||
namespace Apewer.WinForm |
|||
{ |
|||
|
|||
/// <summary>修饰键。</summary>
|
|||
public struct ModifierKey : IEquatable<ModifierKey> |
|||
{ |
|||
|
|||
byte _value; |
|||
bool _alt; |
|||
bool _ctrl; |
|||
bool _shift; |
|||
bool _win; |
|||
|
|||
/// <summary>包含 ALT 键。</summary>
|
|||
public bool WithALT { get => _alt; } |
|||
|
|||
/// <summary>包含 CTRL 键。</summary>
|
|||
public bool WithCTRL { get => _ctrl; } |
|||
|
|||
/// <summary>包含 SHIFT 键。</summary>
|
|||
public bool WithSHIFT { get => _shift; } |
|||
|
|||
/// <summary>包含 WIN 键。</summary>
|
|||
public bool WithWIN { get => _win; } |
|||
|
|||
/// <summary>修饰键组合的值。</summary>
|
|||
public byte Value { get => _value; } |
|||
|
|||
/// <exception cref="OverflowException"></exception>
|
|||
private ModifierKey(byte value) |
|||
{ |
|||
_alt = value << 7 >> 7 == 1; |
|||
_ctrl = value << 6 >> 7 == 1; |
|||
_shift = value << 5 >> 7 == 1; |
|||
_win = value << 4 >> 7 == 1; |
|||
_value = Convert.ToByte(value); |
|||
if (_value != value) throw new OverflowException($"参数【{value}】含有无效的键。"); |
|||
} |
|||
|
|||
private ModifierKey(bool alt, bool ctrl, bool shift, bool win) |
|||
{ |
|||
_alt = alt; |
|||
_ctrl = ctrl; |
|||
_shift = shift; |
|||
_win = win; |
|||
|
|||
var value = 0; |
|||
if (alt) value += 0x01; |
|||
if (ctrl) value += 0x02; |
|||
if (shift) value += 0x04; |
|||
if (win) value += 0x05; |
|||
_value = Convert.ToByte(value); |
|||
} |
|||
|
|||
/// <summary></summary>
|
|||
public override int GetHashCode() => _value; |
|||
|
|||
/// <summary></summary>
|
|||
public override bool Equals(object obj) |
|||
{ |
|||
if (obj is ModifierKey b) return _value == b._value; |
|||
return false; |
|||
} |
|||
|
|||
/// <summary></summary>
|
|||
public bool Equals(ModifierKey another) => _value == another._value; |
|||
|
|||
/// <summary></summary>
|
|||
public static implicit operator byte(ModifierKey instance) => instance._value; |
|||
|
|||
/// <summary></summary>
|
|||
/// <exception cref="OverflowException"></exception>
|
|||
public static implicit operator ModifierKey(byte value) => new ModifierKey(value); |
|||
|
|||
/// <summary></summary>
|
|||
/// <exception cref="ArgumentException" />
|
|||
public static ModifierKey operator +(ModifierKey a, ModifierKey b) |
|||
{ |
|||
if (a._alt && b._alt) throw new ArgumentException("相加的两个组合键共同包含了 ALT 键。"); |
|||
if (a._ctrl && b._ctrl) throw new ArgumentException("相加的两个组合键共同包含了 CTRL 键。"); |
|||
if (a._shift && b._shift) throw new ArgumentException("相加的两个组合键共同包含了 SHIFT 键。"); |
|||
if (a._win && b._win) throw new ArgumentException("相加的两个组合键共同包含了 WIN 键。"); |
|||
|
|||
var alt = a._alt || b._alt; |
|||
var ctrl = a._ctrl || b._ctrl; |
|||
var shift = a._shift || b._shift; |
|||
var win = a._win || b._win; |
|||
return new ModifierKey(alt, ctrl, shift, win); |
|||
} |
|||
|
|||
/// <summary></summary>
|
|||
public static ModifierKey operator -(ModifierKey a, ModifierKey b) |
|||
{ |
|||
var alt = a._alt; |
|||
var ctrl = a._ctrl; |
|||
var shift = a._shift; |
|||
var win = a._win; |
|||
|
|||
if (b._alt) alt = false; |
|||
if (b._ctrl) ctrl = false; |
|||
if (b._shift) shift = false; |
|||
if (b._win) win = false; |
|||
|
|||
return new ModifierKey(alt, ctrl, shift, win); |
|||
} |
|||
|
|||
/// <summary>表示 ALT 修饰键。</summary>
|
|||
public static ModifierKey ALT { get; } = new ModifierKey(0x01); |
|||
|
|||
/// <summary>表示 CTRL 修饰键。</summary>
|
|||
public static ModifierKey CTRL { get; } = new ModifierKey(0x02); |
|||
|
|||
/// <summary>表示 SHIFT 修饰键。</summary>
|
|||
public static ModifierKey SHIFT { get; } = new ModifierKey(0x04); |
|||
|
|||
/// <summary>表示 WIN 修饰键。</summary>
|
|||
public static ModifierKey WIN { get; } = new ModifierKey(0x08); |
|||
|
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue