原始导入
This commit is contained in:
commit
a4ad241de0
6
Plane.ConsoleTests/App.config
Normal file
6
Plane.ConsoleTests/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="LogEntry" value="ConsoleTests" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
64
Plane.ConsoleTests/Plane.ConsoleTests.csproj
Normal file
64
Plane.ConsoleTests/Plane.ConsoleTests.csproj
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{595FE1F1-BEAF-4021-907A-0219B65F1487}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.ConsoleTests</RootNamespace>
|
||||
<AssemblyName>Plane.ConsoleTests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Plane\Plane.csproj">
|
||||
<Project>{6cce2aeb-3b38-4c00-b32d-433a990ae2ad}</Project>
|
||||
<Name>Plane</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
28
Plane.ConsoleTests/Program.cs
Normal file
28
Plane.ConsoleTests/Program.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Plane.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Plane.ConsoleTests
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
Foo(null);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//Logger.Instance.Log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
static void Foo(string kk)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(kk));
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Plane.ConsoleTests/Properties/AssemblyInfo.cs
Normal file
35
Plane.ConsoleTests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.ConsoleTests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.ConsoleTests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("595fe1f1-beaf-4021-907a-0219b65f1487")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
238
Plane.Libraries.sln
Normal file
238
Plane.Libraries.sln
Normal file
@ -0,0 +1,238 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Tests", "Plane.Tests\Plane.Tests.csproj", "{5B2EF077-5714-4371-973B-2831C2E1D148}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.ConsoleTests", "Plane.ConsoleTests\Plane.ConsoleTests.csproj", "{595FE1F1-BEAF-4021-907A-0219B65F1487}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Windows", "Plane.Windows\Plane.Windows.csproj", "{06848293-9B17-4068-9B35-44D0ED713CD4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Reflection", "Plane.Reflection\Plane.Reflection.csproj", "{98755514-C2E9-4ABE-8A25-007804577558}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Net", "Plane.Net\Plane.Net.csproj", "{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "PLClass", "..\myPLClass\ClassLibrary2\PLClass.vbproj", "{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Windows.Messages", "Plane.Windows.Messages\Plane.Windows.Messages.csproj", "{413C18E2-235F-4E15-B5C1-633657DE5D7A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Windows.Maps", "Plane.Windows.Maps\Plane.Windows.Maps.csproj", "{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.WpfTests", "Plane.WpfTests\Plane.WpfTests.csproj", "{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Maps.ChinaOffset", "Plane.Maps.ChinaOffset\Plane.Maps.ChinaOffset.csproj", "{4D25C082-A829-47B2-9E0E-584A687D3DE4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane.Logging", "Plane.Logging\Plane.Logging.csproj", "{9C2CAFDA-CF1D-4565-B797-398376FCD346}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plane", "Plane\Plane.csproj", "{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|x64.Build.0 = Release|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{5B2EF077-5714-4371-973B-2831C2E1D148}.Release|x86.Build.0 = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|x64.Build.0 = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{595FE1F1-BEAF-4021-907A-0219B65F1487}.Release|x86.Build.0 = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|x64.Build.0 = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{06848293-9B17-4068-9B35-44D0ED713CD4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|x64.Build.0 = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{98755514-C2E9-4ABE-8A25-007804577558}.Release|x86.Build.0 = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}.Release|x86.Build.0 = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|x64.Build.0 = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{92E63872-4938-4F0C-9FD8-BDFE3388EEB3}.Release|x86.Build.0 = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|x64.Build.0 = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{413C18E2-235F-4E15-B5C1-633657DE5D7A}.Release|x86.Build.0 = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|x64.Build.0 = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}.Release|x86.Build.0 = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4D25C082-A829-47B2-9E0E-584A687D3DE4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|x64.Build.0 = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{9C2CAFDA-CF1D-4565-B797-398376FCD346}.Release|x86.Build.0 = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
68
Plane.Logging/LocalFileLogger.cs
Normal file
68
Plane.Logging/LocalFileLogger.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace Plane.Logging
|
||||
{
|
||||
public class LocalFileLogger : Logger
|
||||
{
|
||||
private string _logDirPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"Plane",
|
||||
ConfigurationManager.AppSettings["LogEntry"] ?? AppDomain.CurrentDomain.FriendlyName,
|
||||
"Logs"
|
||||
);
|
||||
|
||||
private object _logLock = new object();
|
||||
|
||||
public LocalFileLogger()
|
||||
{
|
||||
}
|
||||
|
||||
public LocalFileLogger(ILogger loggerToDecorate) : base(loggerToDecorate)
|
||||
{
|
||||
}
|
||||
|
||||
private string LogDirPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Directory.Exists(_logDirPath))
|
||||
{
|
||||
Directory.CreateDirectory(_logDirPath);
|
||||
}
|
||||
return _logDirPath;
|
||||
}
|
||||
}
|
||||
|
||||
private string LogFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(LogDirPath, DateTime.Today.ToString("yyyyMMdd") + ".log");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LogCore(string message, Category category, Priority priority)
|
||||
{
|
||||
lock (_logLock)
|
||||
{
|
||||
// TODO: 林俊清,20150605,应改为不使用 AppendAllText,提高性能。
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.AppendAllText(LogFilePath,
|
||||
BuildStandardLogEntry(message, category, priority));
|
||||
break;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
60
Plane.Logging/Plane.Logging.csproj
Normal file
60
Plane.Logging/Plane.Logging.csproj
Normal file
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{9C2CAFDA-CF1D-4565-B797-398376FCD346}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Logging</RootNamespace>
|
||||
<AssemblyName>Plane.Logging</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LocalFileLogger.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Plane\Plane.csproj">
|
||||
<Project>{6cce2aeb-3b38-4c00-b32d-433a990ae2ad}</Project>
|
||||
<Name>Plane</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
36
Plane.Logging/Properties/AssemblyInfo.cs
Normal file
36
Plane.Logging/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Plane.Logging")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Logging")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//将 ComVisible 设置为 false 将使此程序集中的类型
|
||||
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("9c2cafda-cf1d-4565-b797-398376fcd346")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
47
Plane.Maps.ChinaOffset/ChinaMapOffsetResolver.cs
Normal file
47
Plane.Maps.ChinaOffset/ChinaMapOffsetResolver.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane.Maps.ChinaOffset
|
||||
{
|
||||
public sealed class ChinaMapOffsetResolver
|
||||
{
|
||||
private static ChinaMapOffsetResolver _Instance;
|
||||
public static ChinaMapOffsetResolver Instance
|
||||
{
|
||||
get { return _Instance ?? (_Instance = new ChinaMapOffsetResolver()); }
|
||||
}
|
||||
|
||||
private ChinaMapOffsetResolver() { }
|
||||
|
||||
private ChinaOffsetMap _CM;
|
||||
private ChinaOffsetMap CM { get { return _CM ?? (_CM = new ChinaOffsetMap(LoadResource("chinaoffset"))); } }
|
||||
|
||||
private ChinaOffsetMap _Acm;
|
||||
private ChinaOffsetMap Acm { get { return _Acm ?? (_Acm = new ChinaOffsetMap(LoadResource("antichinaoffset"))); } }
|
||||
|
||||
public LatLng StandardToChinaMap(double lat, double lng)
|
||||
{
|
||||
var dxyRetLngLat = new double[2];
|
||||
this.CM.GetLonLatAfterOffset(lng, lat, dxyRetLngLat);
|
||||
return new LatLng(dxyRetLngLat[1], dxyRetLngLat[0]);
|
||||
}
|
||||
|
||||
public LatLng ChinaMapToStandard(double lat, double lng)
|
||||
{
|
||||
var dxyRetLngLat = new double[2];
|
||||
this.Acm.GetLonLatAfterOffset(lng, lat, dxyRetLngLat);
|
||||
return new LatLng(dxyRetLngLat[1], dxyRetLngLat[0]);
|
||||
}
|
||||
|
||||
private Stream LoadResource(string simpleName)
|
||||
{
|
||||
String resourceName = this.GetType().Namespace + ".Resources." + simpleName + ".dat";
|
||||
return typeof(ChinaMapOffsetResolver).GetTypeInfo().Assembly.GetManifestResourceStream(resourceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
444
Plane.Maps.ChinaOffset/ChinaOffsetMap.cs
Normal file
444
Plane.Maps.ChinaOffset/ChinaOffsetMap.cs
Normal file
@ -0,0 +1,444 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane.Maps.ChinaOffset
|
||||
{
|
||||
internal class ChinaOffsetMap
|
||||
{
|
||||
private byte[] gbuffer;
|
||||
//private byte[] gbuffer1;
|
||||
//FileInputStream file;
|
||||
SOffsetMapFileHeader header;
|
||||
String filename;
|
||||
Stream pFileIn;
|
||||
private int ixFromX;
|
||||
private int iyFromY;
|
||||
|
||||
internal ChinaOffsetMap(Stream FileIn)
|
||||
{
|
||||
//RandomAccessFile a=new Ra;
|
||||
|
||||
//FileIn.reset();
|
||||
pFileIn = FileIn;
|
||||
byte[] bb = new byte[1];
|
||||
ixFromX = -1;
|
||||
iyFromY = -1;
|
||||
|
||||
//FileInputStream file = new FileInputStream();
|
||||
//bs = new BufferedInputStream(FileIn);
|
||||
//ds = new DataInputStream(bs);
|
||||
|
||||
header = new SOffsetMapFileHeader();
|
||||
int a, b, c, d;
|
||||
|
||||
a = pFileIn.ReadByte();
|
||||
b = pFileIn.ReadByte();
|
||||
c = pFileIn.ReadByte();
|
||||
d = pFileIn.ReadByte();
|
||||
header.ixFromLng = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
//header.ixFromLng = pFileIn.read();
|
||||
|
||||
//a = ds.readByte();
|
||||
//b = ds.readByte();
|
||||
//c = ds.readByte();
|
||||
//d = ds.readByte();
|
||||
|
||||
|
||||
a = pFileIn.ReadByte();
|
||||
b = pFileIn.ReadByte();
|
||||
c = pFileIn.ReadByte();
|
||||
d = pFileIn.ReadByte();
|
||||
header.ixToLng = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
//header.ixToLng = pFileIn.read();
|
||||
|
||||
// a = ds.readByte();
|
||||
// b = ds.readByte();
|
||||
// c = ds.readByte();
|
||||
// d = ds.readByte();
|
||||
|
||||
a = pFileIn.ReadByte();
|
||||
b = pFileIn.ReadByte();
|
||||
c = pFileIn.ReadByte();
|
||||
d = pFileIn.ReadByte();
|
||||
header.iyFromLat = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
//header.iyFromLat = pFileIn.read();
|
||||
|
||||
// a = ds.readByte();
|
||||
// b = ds.readByte();
|
||||
// c = ds.readByte();
|
||||
// d = ds.readByte();
|
||||
|
||||
a = pFileIn.ReadByte();
|
||||
b = pFileIn.ReadByte();
|
||||
c = pFileIn.ReadByte();
|
||||
d = pFileIn.ReadByte();
|
||||
header.iyToLat = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
//header.iyToLat = pFileIn.read();
|
||||
|
||||
gbuffer = new byte[101 * 101 * 4];
|
||||
}
|
||||
|
||||
private class SOffsetMapFileHeader
|
||||
{
|
||||
public int ixFromLng;
|
||||
public int ixToLng;
|
||||
public int iyFromLat;
|
||||
public int iyToLat;
|
||||
};
|
||||
|
||||
private class SOffsetXY
|
||||
{
|
||||
public short sXOffset;
|
||||
public short sYOffset;
|
||||
};
|
||||
|
||||
private class SRealOffsetXY
|
||||
{
|
||||
public double dXOffset;
|
||||
public double dYOffset;
|
||||
};
|
||||
|
||||
public void LonLat2GMAbsPt(int iLevel, double dxLon, double dyLat, int[] ixy)
|
||||
{
|
||||
int ulPixCnt = 1;
|
||||
for (int i = 0; i < iLevel; i++)
|
||||
ulPixCnt *= 2;
|
||||
ulPixCnt *= 256; //得到象素点的数目<E695B0><E79BAE>??/2
|
||||
|
||||
dxLon += (double)180;
|
||||
|
||||
ixy[0] = (int)((double)ulPixCnt * dxLon / 360.0);
|
||||
|
||||
if (dyLat > 0)//北纬
|
||||
{
|
||||
double dtmp = Math.Tan((dyLat + 90.0) * Math.PI / 360.0);
|
||||
double dy = Math.Log(dtmp) / Math.PI;
|
||||
ixy[1] = (int)((1 - dy) * ulPixCnt / 2);
|
||||
}
|
||||
else//南纬
|
||||
{
|
||||
double dtmp = Math.Tan((dyLat + 90) * Math.PI / 360.0);
|
||||
double dy = Math.Log(dtmp) / Math.PI;
|
||||
ixy[1] = (int)((1 - dy) * ulPixCnt / 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void GMAbsPt2LonLat(int iLevel, int ix, int iy, double[] dxyLonLat)
|
||||
{
|
||||
double dTemp;
|
||||
int ulPixCnt = 1;
|
||||
for (int i = 0; i < iLevel; i++)
|
||||
ulPixCnt *= 2;
|
||||
ulPixCnt *= 128; //得到象素点的数目<E695B0><E79BAE>??/2
|
||||
|
||||
dTemp = ix + 0.5;
|
||||
// dTemp = ix;
|
||||
dxyLonLat[0] = 180.0 * dTemp / ((double)ulPixCnt) - 180.0; //计算经度
|
||||
if (dxyLonLat[0] > 180.0)
|
||||
dxyLonLat[0] = dxyLonLat[0] - 360.0;
|
||||
|
||||
dxyLonLat[1] = 0.0;
|
||||
if (iy < ulPixCnt) //计算纬度(unsigned long)
|
||||
{
|
||||
//北纬,大于零
|
||||
dTemp = 1.0 - ((double)(iy + 0.5)) / (double)ulPixCnt;
|
||||
dTemp = Math.Exp(Math.PI * dTemp);
|
||||
dxyLonLat[1] = 360 * Math.Atan(dTemp) / Math.PI - 90.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//南纬,小于零
|
||||
dTemp = ((double)(iy + 0.5)) / (double)ulPixCnt - 1;
|
||||
dTemp = Math.Exp(Math.PI * dTemp);
|
||||
dxyLonLat[1] = 360.0 * Math.Atan(dTemp) / Math.PI - 90.0;
|
||||
dxyLonLat[1] = -dxyLonLat[1];
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadOffsetFromFile(String FilePath)
|
||||
{
|
||||
filename = FilePath;
|
||||
|
||||
using (var fs = File.OpenRead(FilePath))
|
||||
{
|
||||
|
||||
header = new SOffsetMapFileHeader();
|
||||
int a, b, c, d;
|
||||
|
||||
a = fs.ReadByte();
|
||||
b = fs.ReadByte();
|
||||
c = fs.ReadByte();
|
||||
d = fs.ReadByte();
|
||||
header.ixFromLng = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
|
||||
a = fs.ReadByte();
|
||||
b = fs.ReadByte();
|
||||
c = fs.ReadByte();
|
||||
d = fs.ReadByte();
|
||||
header.ixToLng = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
|
||||
a = fs.ReadByte();
|
||||
b = fs.ReadByte();
|
||||
c = fs.ReadByte();
|
||||
d = fs.ReadByte();
|
||||
header.iyFromLat = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
|
||||
a = fs.ReadByte();
|
||||
b = fs.ReadByte();
|
||||
c = fs.ReadByte();
|
||||
d = fs.ReadByte();
|
||||
header.iyToLat = (((d & 0xff) << 24) | ((c & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
public interface LoadProgress
|
||||
{
|
||||
void LoadPrs(int progress, int total);
|
||||
}
|
||||
|
||||
LoadProgress loadProgress;
|
||||
public void SetOnLoadProgress(LoadProgress loadPrs)
|
||||
{
|
||||
loadProgress = loadPrs;
|
||||
}
|
||||
|
||||
private bool GetOffset(int ixPos, int iyPos, SOffsetXY rXY)
|
||||
{
|
||||
rXY.sXOffset = rXY.sYOffset = 0;
|
||||
|
||||
int MapWidth = header.ixToLng - header.ixFromLng;
|
||||
int MapHeight = header.iyToLat - header.iyFromLat;
|
||||
|
||||
if (ixPos < 0 || ixPos >= MapWidth || iyPos < 0 || iyPos >= MapHeight)
|
||||
return false;
|
||||
|
||||
if ((ixFromX < 0) || (iyFromY < 0) || (ixFromX != (ixPos / 100) * 100) || (iyFromY != (iyPos / 100) * 100))
|
||||
{
|
||||
ixFromX = (ixPos / 100) * 100;
|
||||
iyFromY = (iyPos / 100) * 100;
|
||||
|
||||
pFileIn.Position = 0;
|
||||
int lastFilePos = 0;
|
||||
int filePos;
|
||||
int readsize = 0;
|
||||
byte[] lnbuffer = new byte[101 * 4];
|
||||
for (int j = 0; j < 101; j++)
|
||||
{
|
||||
filePos = (iyFromY + j) * MapWidth * 4 + ixFromX * 4 + 16;
|
||||
pFileIn.Seek(filePos - lastFilePos - readsize, SeekOrigin.Current);
|
||||
lastFilePos = filePos;
|
||||
if (pFileIn.Length - pFileIn.Position - 1 >= lnbuffer.Length)
|
||||
{
|
||||
pFileIn.Read(lnbuffer, 0, lnbuffer.Length);
|
||||
readsize = 404;
|
||||
}
|
||||
else
|
||||
{
|
||||
readsize = (int)(pFileIn.Length - pFileIn.Position - 1);
|
||||
pFileIn.Read(lnbuffer, 0, readsize);
|
||||
}
|
||||
Array.Copy(lnbuffer, 0, gbuffer, j * 101 * 4, 101 * 4);
|
||||
//loadProgress.LoadPrs(j, 100);
|
||||
}
|
||||
}
|
||||
|
||||
int iPixInx = (iyPos % 100) * 101 + (ixPos % 100);
|
||||
int iFilePos = iPixInx * 4;
|
||||
|
||||
short a, b;
|
||||
|
||||
a = gbuffer[iFilePos];
|
||||
b = gbuffer[iFilePos + 1];
|
||||
rXY.sXOffset = (short)(((b & 0xff) << 8) | (a & 0xff));
|
||||
|
||||
a = gbuffer[iFilePos + 2];
|
||||
b = gbuffer[iFilePos + 3];
|
||||
rXY.sYOffset = (short)(((b & 0xff) << 8) | (a & 0xff));
|
||||
return true;
|
||||
|
||||
/*rXY.sXOffset = rXY.sYOffset = 0;
|
||||
int MapWidth = header.ixToLng - header.ixFromLng;
|
||||
int MapHeight = header.iyToLat - header.iyFromLat;
|
||||
|
||||
if (ixPos < 0 || ixPos >= MapWidth || iyPos < 0 || iyPos >= MapHeight)
|
||||
return false;
|
||||
|
||||
int iPixInx = iyPos * MapWidth + ixPos;
|
||||
int iFilePos = iPixInx*4;
|
||||
try {
|
||||
if (iFilePos >= MinID && iFilePos <= MaxID) {
|
||||
|
||||
}else{
|
||||
pFileIn.reset();
|
||||
// ds.mark(0);
|
||||
// ds.reset();
|
||||
|
||||
if (iFilePos - 50000 >= 0){
|
||||
MinID = iFilePos - 50000;
|
||||
}else{
|
||||
MinID = 0;
|
||||
}
|
||||
if (iFilePos + 50000 <= pFileIn.available()){
|
||||
MaxID = iFilePos + 50000;
|
||||
}else{
|
||||
MaxID = pFileIn.available();
|
||||
}
|
||||
|
||||
pFileIn.skip(MinID+16);
|
||||
pFileIn.read(gbuffer,0,(MaxID - MinID));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//ds.read(gbuffer1,0,ds.available());
|
||||
//ds.close();
|
||||
//bs.close();
|
||||
//file.skip(iFilePos);
|
||||
//RandomAccessFile randomFile = new RandomAccessFile(filename, "r");
|
||||
//randomFile.seek(iFilePos);
|
||||
// DataInputStream ds = new DataInputStream(pFileIn);
|
||||
// pFileIn.reset();
|
||||
// pFileIn.skip(iFilePos);
|
||||
//BufferedInputStream bs = new BufferedInputStream(randomFile);
|
||||
//DataInputStream ds = new DataInputStream(bs);
|
||||
|
||||
short a,b;
|
||||
|
||||
a = gbuffer[iFilePos-MinID];
|
||||
b = gbuffer[iFilePos-MinID+1];
|
||||
rXY.sXOffset = (short) (((b & 0xff) << 8) | (a & 0xff));
|
||||
|
||||
a = gbuffer[iFilePos-MinID+2];
|
||||
b = gbuffer[iFilePos-MinID+3];
|
||||
rXY.sYOffset = (short) (((b & 0xff) << 8) | (a & 0xff));
|
||||
|
||||
return true;*/
|
||||
}
|
||||
|
||||
private bool GetRealOffset(double dxRefLng, double dyRefLat, SRealOffsetXY rXY)
|
||||
{
|
||||
double dyPos = (dyRefLat - header.iyFromLat / 100.0) * 100.0;
|
||||
double dxPos = (dxRefLng - header.ixFromLng / 100.0) * 100.0;
|
||||
|
||||
int ixPos = (int)dxPos;
|
||||
int iyPos = (int)dyPos;
|
||||
SOffsetXY[] ofsXY = new SOffsetXY[4];
|
||||
|
||||
ofsXY[0] = new SOffsetXY();
|
||||
ofsXY[1] = new SOffsetXY();
|
||||
ofsXY[2] = new SOffsetXY();
|
||||
ofsXY[3] = new SOffsetXY();
|
||||
|
||||
bool[] bRet = new bool[4];
|
||||
int iTmpCnt = 0;
|
||||
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
bRet[k] = GetOffset(ixPos + k % 2, iyPos + k / 2, ofsXY[k]);
|
||||
if (bRet[k])
|
||||
iTmpCnt++;
|
||||
}
|
||||
|
||||
if (iTmpCnt == 0)
|
||||
return false;
|
||||
|
||||
SRealOffsetXY rfsXY_Up = new SRealOffsetXY();
|
||||
SRealOffsetXY rfsXY_Down = new SRealOffsetXY();
|
||||
bool bUpValid = false, bDownValid = false;
|
||||
if (bRet[0] || bRet[1])
|
||||
{
|
||||
if (bRet[0] == false)
|
||||
{
|
||||
rfsXY_Up.dXOffset = (double)ofsXY[1].sXOffset;
|
||||
rfsXY_Up.dYOffset = (double)ofsXY[1].sYOffset;
|
||||
}
|
||||
else if (bRet[1] == false)
|
||||
{
|
||||
rfsXY_Up.dXOffset = (double)ofsXY[0].sXOffset;
|
||||
rfsXY_Up.dYOffset = (double)ofsXY[0].sYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
rfsXY_Up.dXOffset = (double)ofsXY[0].sXOffset * ((double)(ixPos) + 1.0 - dxPos) +
|
||||
(double)ofsXY[1].sXOffset * (dxPos - (double)(ixPos));
|
||||
rfsXY_Up.dYOffset = (double)ofsXY[0].sYOffset * ((double)(ixPos) + 1.0 - dxPos) +
|
||||
(double)ofsXY[1].sYOffset * (dxPos - (double)(ixPos));
|
||||
}
|
||||
bUpValid = true;
|
||||
}
|
||||
|
||||
if (bRet[2] || bRet[3])
|
||||
{
|
||||
if (bRet[2] == false)
|
||||
{
|
||||
rfsXY_Down.dXOffset = (double)ofsXY[3].sXOffset;
|
||||
rfsXY_Down.dYOffset = (double)ofsXY[3].sYOffset;
|
||||
}
|
||||
else if (bRet[3] == false)
|
||||
{
|
||||
rfsXY_Down.dXOffset = (double)ofsXY[2].sXOffset;
|
||||
rfsXY_Down.dYOffset = (double)ofsXY[2].sYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
rfsXY_Down.dXOffset = (double)ofsXY[2].sXOffset * ((double)(ixPos) + 1.0 - dxPos) +
|
||||
(double)ofsXY[3].sXOffset * (dxPos - (double)(ixPos));
|
||||
rfsXY_Down.dYOffset = (double)ofsXY[2].sYOffset * ((double)(ixPos) + 1.0 - dxPos) +
|
||||
(double)ofsXY[3].sYOffset * (dxPos - (double)(ixPos));
|
||||
}
|
||||
bDownValid = true;
|
||||
}
|
||||
|
||||
if (!bUpValid)
|
||||
{
|
||||
rXY.dXOffset = rfsXY_Down.dXOffset;
|
||||
rXY.dYOffset = rfsXY_Down.dYOffset;
|
||||
}
|
||||
else if (!bDownValid)
|
||||
{
|
||||
rXY.dXOffset = rfsXY_Up.dXOffset;
|
||||
rXY.dYOffset = rfsXY_Up.dYOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
rXY.dXOffset = rfsXY_Up.dXOffset * ((double)(iyPos) + 1.0 - dyPos) +
|
||||
rfsXY_Down.dXOffset * (dyPos - (double)(iyPos));
|
||||
rXY.dYOffset = rfsXY_Up.dYOffset * ((double)(iyPos) + 1.0 - dyPos) +
|
||||
rfsXY_Down.dYOffset * (dyPos - (double)(iyPos));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void GetLonLatAfterOffset(double dxRefLng, double dyRefLat, double[] dxyRetLngLat)
|
||||
{
|
||||
int[] ixyAbs = new int[2];
|
||||
|
||||
if ((dxRefLng < header.ixFromLng / 100.0) || (dxRefLng > header.ixToLng / 100.0) ||
|
||||
(dyRefLat < header.iyFromLat / 100.0) || (dyRefLat > header.iyToLat / 100.0))
|
||||
{
|
||||
dxyRetLngLat[0] = dxRefLng;
|
||||
dxyRetLngLat[1] = dyRefLat;
|
||||
return;
|
||||
}
|
||||
|
||||
SRealOffsetXY rXY = new SRealOffsetXY();
|
||||
if (GetRealOffset(dxRefLng, dyRefLat, rXY) == false)
|
||||
{
|
||||
dxyRetLngLat[0] = dxRefLng;
|
||||
dxyRetLngLat[1] = dyRefLat;
|
||||
return;
|
||||
}
|
||||
|
||||
LonLat2GMAbsPt(18, dxRefLng, dyRefLat, ixyAbs);
|
||||
ixyAbs[0] += (int)rXY.dXOffset;
|
||||
ixyAbs[1] += (int)rXY.dYOffset;
|
||||
|
||||
GMAbsPt2LonLat(18, ixyAbs[0], ixyAbs[1], dxyRetLngLat);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Plane.Maps.ChinaOffset/LatLng.cs
Normal file
20
Plane.Maps.ChinaOffset/LatLng.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Plane.Maps.ChinaOffset
|
||||
{
|
||||
public struct LatLng
|
||||
{
|
||||
public LatLng(double latitude, double longitude)
|
||||
{
|
||||
this.Latitude = latitude;
|
||||
this.Longitude = longitude;
|
||||
}
|
||||
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
}
|
||||
}
|
||||
57
Plane.Maps.ChinaOffset/Plane.Maps.ChinaOffset.csproj
Normal file
57
Plane.Maps.ChinaOffset/Plane.Maps.ChinaOffset.csproj
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4D25C082-A829-47B2-9E0E-584A687D3DE4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Maps.ChinaOffset</RootNamespace>
|
||||
<AssemblyName>Plane.Maps.ChinaOffset</AssemblyName>
|
||||
<DefaultLanguage>zh-CN</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="project.json" />
|
||||
<EmbeddedResource Include="Resources\antichinaoffset.dat" />
|
||||
<EmbeddedResource Include="Resources\chinaoffset.dat" />
|
||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ChinaMapOffsetResolver.cs" />
|
||||
<Compile Include="ChinaOffsetMap.cs" />
|
||||
<Compile Include="LatLng.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
30
Plane.Maps.ChinaOffset/Properties/AssemblyInfo.cs
Normal file
30
Plane.Maps.ChinaOffset/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Plane.Maps.ChinaOffset")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Maps.ChinaOffset")]
|
||||
[assembly: AssemblyCopyright("版权所有(C) 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("zh-Hans")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
BIN
Plane.Maps.ChinaOffset/Resources/antichinaoffset.dat
Normal file
BIN
Plane.Maps.ChinaOffset/Resources/antichinaoffset.dat
Normal file
Binary file not shown.
BIN
Plane.Maps.ChinaOffset/Resources/chinaoffset.dat
Normal file
BIN
Plane.Maps.ChinaOffset/Resources/chinaoffset.dat
Normal file
Binary file not shown.
16
Plane.Maps.ChinaOffset/project.json
Normal file
16
Plane.Maps.ChinaOffset/project.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"supports": {
|
||||
"net46.app": {},
|
||||
"uwp.10.0.app": {},
|
||||
"dnxcore50.app": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore": "5.0.0",
|
||||
"Microsoft.NETCore.Portable.Compatibility": "1.0.0"
|
||||
},
|
||||
"frameworks": {
|
||||
"dotnet": {
|
||||
"imports": "portable-net452+win81"
|
||||
}
|
||||
}
|
||||
}
|
||||
18555
Plane.Maps.ChinaOffset/project.lock.json
Normal file
18555
Plane.Maps.ChinaOffset/project.lock.json
Normal file
File diff suppressed because it is too large
Load Diff
9
Plane.Net/GpsTrackEndedEventArgs.cs
Normal file
9
Plane.Net/GpsTrackEndedEventArgs.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace Plane.Net
|
||||
{
|
||||
public class GpsTrackEndedEventArgs : EventArgs
|
||||
{
|
||||
public string Id { get; set; }
|
||||
}
|
||||
}
|
||||
153
Plane.Net/PLNet.cs
Normal file
153
Plane.Net/PLNet.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace Plane.Net
|
||||
{
|
||||
public class PLNet : PLClass.PLNet
|
||||
{
|
||||
public PLNet(AsyncOperation asyncOperation) : base(asyncOperation)
|
||||
{
|
||||
}
|
||||
|
||||
public event EventHandler<PositionEventArgs> GetUserLocation2;
|
||||
|
||||
public event EventHandler<GpsTrackEndedEventArgs> GpsTrackEnded;
|
||||
|
||||
public event EventHandler<PositionEventArgs> mynet_GPSTrackArrival2;
|
||||
|
||||
/// <summary>
|
||||
/// 取轨迹。
|
||||
/// </summary>
|
||||
/// <param name="id">用户 ID。</param>
|
||||
/// <param name="date">日期字符串,"20150416"。</param>
|
||||
/// <param name="period">时间段,"145740-150306"。</param>
|
||||
public void GetGPSTrack2(string id, string date, string period)
|
||||
{
|
||||
SendCmd($"~{id}|{date}|{period.Replace('-', '|')}|0|1");
|
||||
}
|
||||
|
||||
public override bool ProcessData(byte[] data)
|
||||
{
|
||||
switch ((char)data[0])
|
||||
{
|
||||
case 'G':
|
||||
ProcessUserLocationMessage(data);
|
||||
break;
|
||||
|
||||
case '^':
|
||||
ProcessGpsTrackMessage(data);
|
||||
break;
|
||||
|
||||
default:
|
||||
return base.ProcessData(data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询哪天有轨迹。
|
||||
/// </summary>
|
||||
/// <param name="id">用户 ID。</param>
|
||||
/// <param name="startDate">起始日期,"yyyyMMdd"。</param>
|
||||
/// <param name="endDate">结束日期,"yyyyMMdd"。</param>
|
||||
public void QueryTrackDays(string id, string startDate, string endDate)
|
||||
{
|
||||
var cmd = $"DD{id}|{startDate}|{endDate}|1";
|
||||
SendCmd(cmd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询某天哪些时间段有轨迹。
|
||||
/// </summary>
|
||||
/// <param name="id">用户 ID。</param>
|
||||
/// <param name="date">日期字符串,格式为 "yyyyMMdd"。</param>
|
||||
public void QueryTrackPeriods(string id, string date)
|
||||
{
|
||||
var cmd = $"DT{id}|{date}|1";
|
||||
SendCmd(cmd);
|
||||
}
|
||||
|
||||
private PositionEventArgs GetPositionEventArgs(byte[] data)
|
||||
{
|
||||
var getUserLocation2EventArgs = new PositionEventArgs();
|
||||
|
||||
getUserLocation2EventArgs.Ident = (char)data[1];
|
||||
|
||||
byte[] buffer = new byte[16];
|
||||
|
||||
Array.Copy(data, 2, buffer, 0, 16);
|
||||
getUserLocation2EventArgs.Id = Encoding.GetEncoding("GBK").GetString(buffer).TrimEnd('\0');
|
||||
|
||||
//buffer = new byte[4];
|
||||
Array.Copy(data, 23, buffer, 0, 4);
|
||||
getUserLocation2EventArgs.Longitude = BitConverter.ToSingle(buffer, 0);
|
||||
|
||||
Array.Copy(data, 27, buffer, 0, 4);
|
||||
getUserLocation2EventArgs.Latitude = BitConverter.ToSingle(buffer, 0);
|
||||
|
||||
Array.Copy(data, 33, buffer, 0, 4);
|
||||
getUserLocation2EventArgs.Roll = BitConverter.ToSingle(buffer, 0);
|
||||
|
||||
Array.Copy(data, 37, buffer, 0, 4);
|
||||
getUserLocation2EventArgs.Pitch = BitConverter.ToSingle(buffer, 0);
|
||||
|
||||
Array.Copy(data, 41, buffer, 0, 4);
|
||||
getUserLocation2EventArgs.Yaw = BitConverter.ToSingle(buffer, 0);
|
||||
|
||||
getUserLocation2EventArgs.Mode = data[45];
|
||||
getUserLocation2EventArgs.Speed = data[46];
|
||||
getUserLocation2EventArgs.Satellite = data[47];
|
||||
getUserLocation2EventArgs.Battery = data[48];
|
||||
|
||||
//buffer = new byte[2];
|
||||
|
||||
//高度
|
||||
Array.Copy(data, 31, buffer, 0, 2);
|
||||
getUserLocation2EventArgs.Altitude = BitConverter.ToInt16(buffer, 0);
|
||||
|
||||
Array.Copy(data, 49, buffer, 0, 2);
|
||||
getUserLocation2EventArgs.Distance = BitConverter.ToUInt16(buffer, 0);
|
||||
|
||||
Array.Copy(data, 51, buffer, 0, 2);
|
||||
getUserLocation2EventArgs.FlySecond = BitConverter.ToUInt16(buffer, 0);
|
||||
|
||||
//buffer = new byte[8];
|
||||
|
||||
Array.Copy(data, 53, buffer, 0, 8);
|
||||
double r_time = BitConverter.ToDouble(buffer, 0);
|
||||
getUserLocation2EventArgs.RecordTime = (
|
||||
new DateTime(1899, 12, 30, 0, 0, 0, DateTimeKind.Utc) + TimeSpan.FromDays(r_time)
|
||||
).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
//new DateTime(
|
||||
// TimeSpan.FromMilliseconds(((r_time - 25569.0) * 86400000.0 - 28800000.0)).Ticks,
|
||||
// DateTimeKind.Utc
|
||||
// ).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
return getUserLocation2EventArgs;
|
||||
}
|
||||
|
||||
private void ProcessGpsTrackMessage(byte[] data)
|
||||
{
|
||||
int commandLength = data.Length - 1;
|
||||
if (commandLength < 18)
|
||||
{
|
||||
GpsTrackEnded?.Invoke(this, new GpsTrackEndedEventArgs
|
||||
{
|
||||
Id = Encoding.GetEncoding("GBK").GetString(data, 1, data.Length - 1)
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var positionEventArgs = GetPositionEventArgs(data);
|
||||
mynet_GPSTrackArrival2?.Invoke(this, positionEventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessUserLocationMessage(byte[] data)
|
||||
{
|
||||
var positionEventArgs = GetPositionEventArgs(data);
|
||||
GetUserLocation2?.Invoke(this, positionEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
Plane.Net/Plane.Net.csproj
Normal file
61
Plane.Net/Plane.Net.csproj
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6E87B399-637D-4FAA-A833-BA5A3CA6BE8B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Net</RootNamespace>
|
||||
<AssemblyName>Plane.Net</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="PLNet.cs" />
|
||||
<Compile Include="GpsTrackEndedEventArgs.cs" />
|
||||
<Compile Include="PositionEventArgs.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\myPLClass\ClassLibrary2\PLClass.vbproj">
|
||||
<Project>{92e63872-4938-4f0c-9fd8-bdfe3388eeb3}</Project>
|
||||
<Name>EhClass</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
23
Plane.Net/PositionEventArgs.cs
Normal file
23
Plane.Net/PositionEventArgs.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace Plane.Net
|
||||
{
|
||||
public class PositionEventArgs : EventArgs
|
||||
{
|
||||
public short Altitude { get; set; }
|
||||
public byte Battery { get; set; }
|
||||
public ushort Distance { get; set; }
|
||||
public ushort FlySecond { get; set; }
|
||||
public string Id { get; set; }
|
||||
public char Ident { get; set; }
|
||||
public float Latitude { get; set; }
|
||||
public float Longitude { get; set; }
|
||||
public byte Mode { get; set; }
|
||||
public float Pitch { get; set; }
|
||||
public string RecordTime { get; set; }
|
||||
public float Roll { get; set; }
|
||||
public byte Satellite { get; set; }
|
||||
public byte Speed { get; set; }
|
||||
public float Yaw { get; set; }
|
||||
}
|
||||
}
|
||||
36
Plane.Net/Properties/AssemblyInfo.cs
Normal file
36
Plane.Net/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.Net")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Net")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("6e87b399-637d-4faa-a833-ba5a3ca6be8b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
53
Plane.Reflection/Plane.Reflection.csproj
Normal file
53
Plane.Reflection/Plane.Reflection.csproj
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{98755514-C2E9-4ABE-8A25-007804577558}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Reflection</RootNamespace>
|
||||
<AssemblyName>Plane.Reflection</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
36
Plane.Reflection/Properties/AssemblyInfo.cs
Normal file
36
Plane.Reflection/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.Reflection")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Reflection")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("98755514-c2e9-4abe-8a25-007804577558")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
38
Plane.Reflection/Utils.cs
Normal file
38
Plane.Reflection/Utils.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
|
||||
namespace Plane.Reflection
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static Dictionary<string, Stream> GetResourcesUnder(string dir)
|
||||
{
|
||||
dir = dir.ToLower();
|
||||
if (!dir.EndsWith("/"))
|
||||
{
|
||||
dir += "/";
|
||||
}
|
||||
|
||||
var assembly = Assembly.GetCallingAssembly();
|
||||
var resourcesName = assembly.GetName().Name + ".g.resources";
|
||||
var stream = assembly.GetManifestResourceStream(resourcesName);
|
||||
var resourceReader = new ResourceReader(stream);
|
||||
|
||||
return
|
||||
(from p in resourceReader.OfType<DictionaryEntry>()
|
||||
let theme = (string)p.Key
|
||||
where theme.StartsWith(dir)
|
||||
select new
|
||||
{
|
||||
Key = theme.Substring(dir.Length),
|
||||
Value = p.Value as Stream
|
||||
}).ToDictionary(i => i.Key, i => i.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Plane.Tests/Collections/IEnumerableExtensionsTests.cs
Normal file
19
Plane.Tests/Collections/IEnumerableExtensionsTests.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Plane.Collections;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Linq;
|
||||
|
||||
namespace Plane.Tests.Collections
|
||||
{
|
||||
[TestClass]
|
||||
public class IEnumerableExtensionsTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void ForEach_OK()
|
||||
{
|
||||
var items = new[] { 1, 2, 8, 9 };
|
||||
var sum = 0;
|
||||
items.ForEach(i => sum += i);
|
||||
Assert.AreEqual(sum, items.Sum());
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Plane.Tests/Plane.Tests.csproj
Normal file
92
Plane.Tests/Plane.Tests.csproj
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5B2EF077-5714-4371-973B-2831C2E1D148}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Tests</RootNamespace>
|
||||
<AssemblyName>Plane.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
||||
<IsCodedUITest>False</IsCodedUITest>
|
||||
<TestProjectType>UnitTest</TestProjectType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
<ItemGroup>
|
||||
<Compile Include="Collections\IEnumerableExtensionsTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Plane\Plane.csproj">
|
||||
<Project>{6cce2aeb-3b38-4c00-b32d-433a990ae2ad}</Project>
|
||||
<Name>Plane</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
35
Plane.Tests/Properties/AssemblyInfo.cs
Normal file
35
Plane.Tests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5b2ef077-5714-4371-973b-2831c2e1d148")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
11
Plane.Windows.Maps/MapView.xaml
Normal file
11
Plane.Windows.Maps/MapView.xaml
Normal file
@ -0,0 +1,11 @@
|
||||
<UserControl x:Class="Plane.Windows.Maps.MapView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<WebBrowser x:Name="browser"
|
||||
Source="http://www.baidu.com/" />
|
||||
</UserControl>
|
||||
24
Plane.Windows.Maps/MapView.xaml.cs
Normal file
24
Plane.Windows.Maps/MapView.xaml.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Plane.Windows.Maps
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MapView.xaml
|
||||
/// </summary>
|
||||
public partial class MapView : UserControl
|
||||
{
|
||||
public MapView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
65
Plane.Windows.Maps/Plane.Windows.Maps.csproj
Normal file
65
Plane.Windows.Maps/Plane.Windows.Maps.csproj
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{10EECB08-D899-4A5A-9F72-F99AF7AC82A4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Windows.Maps</RootNamespace>
|
||||
<AssemblyName>Plane.Windows.Maps</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MapView.xaml.cs">
|
||||
<DependentUpon>MapView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="MapView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
36
Plane.Windows.Maps/Properties/AssemblyInfo.cs
Normal file
36
Plane.Windows.Maps/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.Windows.Maps")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Windows.Maps")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("10eecb08-d899-4a5a-9f72-f99af7ac82a4")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
373
Plane.Windows.Messages/Alert.cs
Normal file
373
Plane.Windows.Messages/Alert.cs
Normal file
@ -0,0 +1,373 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="MessageBox.cs">
|
||||
// TODO: Update copyright text.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace Plane.Windows.Messages
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box.
|
||||
/// </summary>
|
||||
public static class Alert
|
||||
{
|
||||
private static Dispatcher _Dispatcher;
|
||||
private static Dispatcher Dispatcher
|
||||
{
|
||||
get { return _Dispatcher ?? (_Dispatcher = Application.Current.Dispatcher); }
|
||||
}
|
||||
|
||||
private static MessageBoxResult RunOnUIThread(Func<MessageBoxResult> func)
|
||||
{
|
||||
if (Dispatcher.CheckAccess())
|
||||
{
|
||||
return func();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (MessageBoxResult)Dispatcher.Invoke(func);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message and returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(string messageBoxText)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText);
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message and a title bar caption; and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(string messageBoxText, string caption)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption);
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box in front of the specified window. The message box displays a message and returns a result.
|
||||
/// </summary>
|
||||
/// <param name="owner">A System.Windows.Window that represents the owner window of the message box.</param>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(Window owner, string messageBoxText)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText);
|
||||
msg.Owner = owner;
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box in front of the specified window. The message box displays a message and title bar caption; and it returns a result.
|
||||
/// </summary>
|
||||
/// <param name="owner">A System.Windows.Window that represents the owner window of the message box.</param>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption);
|
||||
msg.Owner = owner;
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, title bar caption, and button; and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, button);
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, title bar caption, button, and icon; and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, button, icon);
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, title bar caption, and OK button with a custom System.String value for the button's text; and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="okButtonText">A System.String that specifies the text to display within the OK button.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowOK(string messageBoxText, string caption, string okButtonText)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.OK);
|
||||
msg.OkButtonText = okButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, title bar caption, OK button with a custom System.String value for the button's text, and icon; and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="okButtonText">A System.String that specifies the text to display within the OK button.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowOK(string messageBoxText, string caption, string okButtonText, MessageBoxImage icon)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.OK, icon);
|
||||
msg.OkButtonText = okButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, and OK/Cancel buttons with custom System.String values for the buttons' text;
|
||||
/// and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="okButtonText">A System.String that specifies the text to display within the OK button.</param>
|
||||
/// <param name="cancelButtonText">A System.String that specifies the text to display within the Cancel button.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowOKCancel(string messageBoxText, string caption, string okButtonText, string cancelButtonText)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.OKCancel);
|
||||
msg.OkButtonText = okButtonText;
|
||||
msg.CancelButtonText = cancelButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, OK/Cancel buttons with custom System.String values for the buttons' text, and icon;
|
||||
/// and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="okButtonText">A System.String that specifies the text to display within the OK button.</param>
|
||||
/// <param name="cancelButtonText">A System.String that specifies the text to display within the Cancel button.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowOKCancel(string messageBoxText, string caption, string okButtonText, string cancelButtonText, MessageBoxImage icon)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.OKCancel, icon);
|
||||
msg.OkButtonText = okButtonText;
|
||||
msg.CancelButtonText = cancelButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, and Yes/No buttons with custom System.String values for the buttons' text;
|
||||
/// and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="yesButtonText">A System.String that specifies the text to display within the Yes button.</param>
|
||||
/// <param name="noButtonText">A System.String that specifies the text to display within the No button.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowYesNo(string messageBoxText, string caption, string yesButtonText, string noButtonText)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.YesNo);
|
||||
msg.YesButtonText = yesButtonText;
|
||||
msg.NoButtonText = noButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, Yes/No buttons with custom System.String values for the buttons' text, and icon;
|
||||
/// and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="yesButtonText">A System.String that specifies the text to display within the Yes button.</param>
|
||||
/// <param name="noButtonText">A System.String that specifies the text to display within the No button.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowYesNo(string messageBoxText, string caption, string yesButtonText, string noButtonText, MessageBoxImage icon)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.YesNo, icon);
|
||||
msg.YesButtonText = yesButtonText;
|
||||
msg.NoButtonText = noButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, and Yes/No/Cancel buttons with custom System.String values for the buttons' text;
|
||||
/// and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="yesButtonText">A System.String that specifies the text to display within the Yes button.</param>
|
||||
/// <param name="noButtonText">A System.String that specifies the text to display within the No button.</param>
|
||||
/// <param name="cancelButtonText">A System.String that specifies the text to display within the Cancel button.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowYesNoCancel(string messageBoxText, string caption, string yesButtonText, string noButtonText, string cancelButtonText)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.YesNoCancel);
|
||||
msg.YesButtonText = yesButtonText;
|
||||
msg.NoButtonText = noButtonText;
|
||||
msg.CancelButtonText = cancelButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a message box that has a message, caption, Yes/No/Cancel buttons with custom System.String values for the buttons' text, and icon;
|
||||
/// and that returns a result.
|
||||
/// </summary>
|
||||
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
|
||||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
/// <param name="yesButtonText">A System.String that specifies the text to display within the Yes button.</param>
|
||||
/// <param name="noButtonText">A System.String that specifies the text to display within the No button.</param>
|
||||
/// <param name="cancelButtonText">A System.String that specifies the text to display within the Cancel button.</param>
|
||||
/// <param name="icon">A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
public static MessageBoxResult ShowYesNoCancel(string messageBoxText, string caption, string yesButtonText, string noButtonText, string cancelButtonText, MessageBoxImage icon)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
AlertWindow msg = new AlertWindow(messageBoxText, caption, MessageBoxButton.YesNoCancel, icon);
|
||||
msg.YesButtonText = yesButtonText;
|
||||
msg.NoButtonText = noButtonText;
|
||||
msg.CancelButtonText = cancelButtonText;
|
||||
|
||||
msg.ShowDialog();
|
||||
|
||||
return msg.Result;
|
||||
});
|
||||
}
|
||||
|
||||
public static MessageBoxResult ShowProgressAutoClose(string loadingText, Func<bool> completedChecker, Func<bool> cancelledChecker)
|
||||
{
|
||||
return ShowProgressCore(loadingText, msgWindow => msgWindow.Close(), completedChecker, cancelledChecker);
|
||||
}
|
||||
|
||||
public static MessageBoxResult ShowProgress(string loadingText, string completedText, Func<bool> completedChecker, Func<bool> cancelledChecker)
|
||||
{
|
||||
return ShowProgressCore(loadingText, msgWindow => msgWindow.CompleteProgress(completedText), completedChecker, cancelledChecker);
|
||||
}
|
||||
|
||||
private static MessageBoxResult ShowProgressCore(string loadingText, Action<AlertWindow> completedHandler, Func<bool> completedChecker, Func<bool> cancelledChecker)
|
||||
{
|
||||
return RunOnUIThread(() =>
|
||||
{
|
||||
var msgWindow = AlertWindow.CreateProgressWindow(loadingText);
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (completedChecker())
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(new Action(() => completedHandler(msgWindow)));
|
||||
break;
|
||||
}
|
||||
else if (cancelledChecker != null && cancelledChecker())
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(new Action(() => msgWindow.Close()));
|
||||
break;
|
||||
};
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
});
|
||||
if (!completedChecker())
|
||||
{
|
||||
msgWindow.ShowDialog();
|
||||
}
|
||||
return msgWindow.Result;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
140
Plane.Windows.Messages/AlertWindow.xaml
Normal file
140
Plane.Windows.Messages/AlertWindow.xaml
Normal file
@ -0,0 +1,140 @@
|
||||
<Controls:MetroWindow x:Class="Plane.Windows.Messages.AlertWindow"
|
||||
x:ClassModifier="internal"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ShowCloseButton="False"
|
||||
MinWidth="700"
|
||||
MinHeight="200"
|
||||
ShowInTaskbar="False"
|
||||
Topmost="True"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="WidthAndHeight"
|
||||
TextOptions.TextFormattingMode="Display"
|
||||
TextOptions.TextRenderingMode="ClearType"
|
||||
UseLayoutRounding="True">
|
||||
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Colors.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/VS/Styles.xaml" />
|
||||
<ResourceDictionary Source="Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
<Window.Style>
|
||||
<StaticResource ResourceKey="AlertWindowStyle" />
|
||||
</Window.Style>
|
||||
|
||||
<!-- todo: The TextOptions properties above fix a minor blurry image issue, but are only compatible with >= .NET 4.0 -->
|
||||
<Grid MaxWidth="600">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0"
|
||||
MinHeight="69">
|
||||
<DockPanel>
|
||||
<Image Name="Image_MessageBox"
|
||||
Width="32"
|
||||
Height="32"
|
||||
HorizontalAlignment="Left"
|
||||
DockPanel.Dock="Left"
|
||||
Margin="30,0,0,0"
|
||||
Visibility="Collapsed" />
|
||||
<TextBlock Name="TextBlock_Message"
|
||||
TextWrapping="Wrap"
|
||||
MaxWidth="500"
|
||||
Width="Auto"
|
||||
VerticalAlignment="Center"
|
||||
Margin="12,20,41,15"
|
||||
FontSize="16" />
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Controls:MetroProgressBar Name="progressBar"
|
||||
IsIndeterminate="True"
|
||||
Visibility="Hidden"
|
||||
Foreground="{DynamicResource ProgressBarFillBrush}" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="2"
|
||||
MinHeight="49"
|
||||
Margin="0,0,0,30">
|
||||
<DockPanel Margin="5,0">
|
||||
|
||||
<!-- Cancel Button -->
|
||||
<Button Name="Button_Cancel"
|
||||
MinWidth="88"
|
||||
MaxWidth="160"
|
||||
Height="26"
|
||||
Margin="5,0"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="Collapsed"
|
||||
IsCancel="True"
|
||||
DockPanel.Dock="Right"
|
||||
Click="Button_Cancel_Click">
|
||||
<Label Name="Label_Cancel"
|
||||
Padding="0"
|
||||
Margin="10,0">_Cancel</Label>
|
||||
</Button>
|
||||
<!-- End Cancel Button -->
|
||||
|
||||
<!-- No Button -->
|
||||
<Button Name="Button_No"
|
||||
MinWidth="88"
|
||||
MaxWidth="160"
|
||||
Height="26"
|
||||
Margin="5,0"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="Collapsed"
|
||||
DockPanel.Dock="Right"
|
||||
Click="Button_No_Click">
|
||||
<Label Name="Label_No"
|
||||
Padding="0"
|
||||
Margin="10,0">_No</Label>
|
||||
</Button>
|
||||
<!-- End No Button -->
|
||||
|
||||
<!-- Yes Button -->
|
||||
<Button Name="Button_Yes"
|
||||
MinWidth="88"
|
||||
MaxWidth="160"
|
||||
Height="26"
|
||||
Margin="35,0,5,0"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="Collapsed"
|
||||
DockPanel.Dock="Right"
|
||||
Click="Button_Yes_Click">
|
||||
<Label Name="Label_Yes"
|
||||
Padding="0"
|
||||
Margin="10,0">_Yes</Label>
|
||||
</Button>
|
||||
<!-- End Yes Button -->
|
||||
|
||||
<!-- OK Button -->
|
||||
<Button Name="Button_OK"
|
||||
MinWidth="88"
|
||||
MaxWidth="160"
|
||||
Margin="35,0,5,0"
|
||||
HorizontalAlignment="Right"
|
||||
Height="26"
|
||||
Click="Button_OK_Click">
|
||||
<Label Name="Label_Ok"
|
||||
Padding="0"
|
||||
Margin="10,0">_OK</Label>
|
||||
</Button>
|
||||
<!-- End OK Button -->
|
||||
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Controls:MetroWindow>
|
||||
259
Plane.Windows.Messages/AlertWindow.xaml.cs
Normal file
259
Plane.Windows.Messages/AlertWindow.xaml.cs
Normal file
@ -0,0 +1,259 @@
|
||||
using MahApps.Metro.Controls;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
|
||||
namespace Plane.Windows.Messages
|
||||
{
|
||||
internal partial class AlertWindow : MetroWindow
|
||||
{
|
||||
internal string Caption
|
||||
{
|
||||
get
|
||||
{
|
||||
return Title;
|
||||
}
|
||||
set
|
||||
{
|
||||
Title = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return TextBlock_Message.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
TextBlock_Message.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal string OkButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Label_Ok.Content.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
Label_Ok.Content = value.TryAddKeyboardAccellerator();
|
||||
}
|
||||
}
|
||||
|
||||
internal string CancelButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Label_Cancel.Content.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
Label_Cancel.Content = value.TryAddKeyboardAccellerator();
|
||||
}
|
||||
}
|
||||
|
||||
internal string YesButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Label_Yes.Content.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
Label_Yes.Content = value.TryAddKeyboardAccellerator();
|
||||
}
|
||||
}
|
||||
|
||||
internal string NoButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Label_No.Content.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
Label_No.Content = value.TryAddKeyboardAccellerator();
|
||||
}
|
||||
}
|
||||
|
||||
public MessageBoxResult Result { get; set; }
|
||||
|
||||
private AlertWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
internal AlertWindow(string message)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Message = message;
|
||||
Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed;
|
||||
DisplayButtons(MessageBoxButton.OK);
|
||||
}
|
||||
|
||||
internal AlertWindow(string message, string caption)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Message = message;
|
||||
Caption = caption;
|
||||
Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed;
|
||||
DisplayButtons(MessageBoxButton.OK);
|
||||
}
|
||||
|
||||
internal AlertWindow(string message, string caption, MessageBoxButton button)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Message = message;
|
||||
Caption = caption;
|
||||
Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed;
|
||||
|
||||
DisplayButtons(button);
|
||||
}
|
||||
|
||||
internal AlertWindow(string message, string caption, MessageBoxImage image)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Message = message;
|
||||
Caption = caption;
|
||||
DisplayImage(image);
|
||||
DisplayButtons(MessageBoxButton.OK);
|
||||
}
|
||||
|
||||
internal AlertWindow(string message, string caption, MessageBoxButton button, MessageBoxImage image)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Message = message;
|
||||
Caption = caption;
|
||||
Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed;
|
||||
|
||||
DisplayButtons(button);
|
||||
DisplayImage(image);
|
||||
}
|
||||
|
||||
internal static AlertWindow CreateProgressWindow(string loadingText)
|
||||
{
|
||||
var window = new AlertWindow();
|
||||
window.Message = loadingText;
|
||||
window.progressBar.Visibility = Visibility.Visible;
|
||||
window.Image_MessageBox.Visibility = System.Windows.Visibility.Collapsed;
|
||||
window.Button_OK.Visibility = System.Windows.Visibility.Collapsed;
|
||||
window.Button_Yes.Visibility = System.Windows.Visibility.Collapsed;
|
||||
window.Button_No.Visibility = System.Windows.Visibility.Collapsed;
|
||||
window.Button_Cancel.Visibility = System.Windows.Visibility.Collapsed;
|
||||
return window;
|
||||
}
|
||||
|
||||
internal void CompleteProgress(string completedText)
|
||||
{
|
||||
this.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
Message = completedText;
|
||||
progressBar.Visibility = Visibility.Hidden;
|
||||
Button_OK.Visibility = Visibility.Visible;
|
||||
Button_OK.Focus();
|
||||
}));
|
||||
}
|
||||
|
||||
private void DisplayButtons(MessageBoxButton button)
|
||||
{
|
||||
switch (button)
|
||||
{
|
||||
case MessageBoxButton.OKCancel:
|
||||
// Hide all but OK, Cancel
|
||||
Button_OK.Visibility = System.Windows.Visibility.Visible;
|
||||
Button_OK.Focus();
|
||||
Button_Cancel.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
Button_Yes.Visibility = System.Windows.Visibility.Collapsed;
|
||||
Button_No.Visibility = System.Windows.Visibility.Collapsed;
|
||||
break;
|
||||
case MessageBoxButton.YesNo:
|
||||
// Hide all but Yes, No
|
||||
Button_Yes.Visibility = System.Windows.Visibility.Visible;
|
||||
Button_Yes.Focus();
|
||||
Button_No.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
Button_OK.Visibility = System.Windows.Visibility.Collapsed;
|
||||
Button_Cancel.Visibility = System.Windows.Visibility.Collapsed;
|
||||
break;
|
||||
case MessageBoxButton.YesNoCancel:
|
||||
// Hide only OK
|
||||
Button_Yes.Visibility = System.Windows.Visibility.Visible;
|
||||
Button_Yes.Focus();
|
||||
Button_No.Visibility = System.Windows.Visibility.Visible;
|
||||
Button_Cancel.Visibility = System.Windows.Visibility.Visible;
|
||||
|
||||
Button_OK.Visibility = System.Windows.Visibility.Collapsed;
|
||||
break;
|
||||
default:
|
||||
// Hide all but OK
|
||||
Button_OK.Visibility = System.Windows.Visibility.Visible;
|
||||
Button_OK.Focus();
|
||||
|
||||
Button_Yes.Visibility = System.Windows.Visibility.Collapsed;
|
||||
Button_No.Visibility = System.Windows.Visibility.Collapsed;
|
||||
Button_Cancel.Visibility = System.Windows.Visibility.Collapsed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayImage(MessageBoxImage image)
|
||||
{
|
||||
Icon icon;
|
||||
|
||||
switch (image)
|
||||
{
|
||||
case MessageBoxImage.Exclamation: // Enumeration value 48 - also covers "Warning"
|
||||
icon = SystemIcons.Exclamation;
|
||||
break;
|
||||
case MessageBoxImage.Error: // Enumeration value 16, also covers "Hand" and "Stop"
|
||||
icon = SystemIcons.Hand;
|
||||
break;
|
||||
case MessageBoxImage.Information: // Enumeration value 64 - also covers "Asterisk"
|
||||
icon = SystemIcons.Information;
|
||||
break;
|
||||
case MessageBoxImage.Question:
|
||||
icon = SystemIcons.Question;
|
||||
break;
|
||||
default:
|
||||
icon = SystemIcons.Information;
|
||||
break;
|
||||
}
|
||||
|
||||
Image_MessageBox.Source = icon.ToImageSource();
|
||||
Image_MessageBox.Visibility = System.Windows.Visibility.Visible;
|
||||
}
|
||||
|
||||
private void Button_OK_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Cancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_Yes_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.Yes;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Button_No_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.No;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Plane.Windows.Messages/Message.cs
Normal file
22
Plane.Windows.Messages/Message.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Plane.Windows.Messages
|
||||
{
|
||||
public static class Message
|
||||
{
|
||||
private static Action<string> ShowAction { get; set; }
|
||||
|
||||
public static void Configure(Action<string> showAction)
|
||||
{
|
||||
ShowAction = showAction;
|
||||
}
|
||||
|
||||
public static void Show(string message)
|
||||
{
|
||||
ShowAction?.Invoke(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
86
Plane.Windows.Messages/Plane.Windows.Messages.csproj
Normal file
86
Plane.Windows.Messages/Plane.Windows.Messages.csproj
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{413C18E2-235F-4E15-B5C1-633657DE5D7A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Windows.Messages</RootNamespace>
|
||||
<AssemblyName>Plane.Windows.Messages</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MahApps.Metro, Version=1.2.2.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\EHang.FormationCreator\packages\MahApps.Metro.1.2.2.0\lib\net40\MahApps.Metro.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\EHang.FormationCreator\packages\MahApps.Metro.1.2.2.0\lib\net40\System.Windows.Interactivity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Alert.cs" />
|
||||
<Compile Include="AlertWindow.xaml.cs">
|
||||
<DependentUpon>AlertWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Message.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="AlertWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
36
Plane.Windows.Messages/Properties/AssemblyInfo.cs
Normal file
36
Plane.Windows.Messages/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.Windows.Messages")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Windows.Messages")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("46fd6371-c845-4b8b-be41-f9f574da8f16")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
24
Plane.Windows.Messages/Styles.xaml
Normal file
24
Plane.Windows.Messages/Styles.xaml
Normal file
@ -0,0 +1,24 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:c="http://metro.mahapps.com/winfx/xaml/controls">
|
||||
|
||||
<FontFamily x:Key="AlertFontFamily">Microsoft YaHei</FontFamily>
|
||||
|
||||
<SolidColorBrush x:Key="ProgressBarFillBrush"
|
||||
Color="{DynamicResource HighlightColor}" />
|
||||
|
||||
<SolidColorBrush x:Key="WindowGlowBrush"
|
||||
Color="{DynamicResource HighlightColor}" />
|
||||
|
||||
<Style TargetType="c:MetroWindow"
|
||||
x:Key="AlertWindowStyle"
|
||||
BasedOn="{StaticResource {x:Type c:MetroWindow}}">
|
||||
<Setter Property="NonActiveWindowTitleBrush"
|
||||
Value="Transparent" />
|
||||
<Setter Property="FontFamily"
|
||||
Value="{DynamicResource AlertFontFamily}" />
|
||||
<Setter Property="GlowBrush"
|
||||
Value="{DynamicResource WindowGlowBrush}" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
50
Plane.Windows.Messages/Util.cs
Normal file
50
Plane.Windows.Messages/Util.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// <copyright file="Util.cs">
|
||||
// TODO: Update copyright text.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace Plane.Windows.Messages
|
||||
{
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
/// <summary>
|
||||
/// TODO: Update summary.
|
||||
/// </summary>
|
||||
internal static class Util
|
||||
{
|
||||
internal static ImageSource ToImageSource(this Icon icon)
|
||||
{
|
||||
ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
|
||||
icon.Handle,
|
||||
Int32Rect.Empty,
|
||||
BitmapSizeOptions.FromEmptyOptions());
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keyboard Accellerators are used in Windows to allow easy shortcuts to controls like Buttons and
|
||||
/// MenuItems. These allow users to press the Alt key, and a shortcut key will be highlighted on the
|
||||
/// control. If the user presses that key, that control will be activated.
|
||||
/// This method checks a string if it contains a keyboard accellerator. If it doesn't, it adds one to the
|
||||
/// beginning of the string. If there are two strings with the same accellerator, Windows handles it.
|
||||
/// The keyboard accellerator character for WPF is underscore (_). It will not be visible.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
internal static string TryAddKeyboardAccellerator(this string input)
|
||||
{
|
||||
const string accellerator = "_"; // This is the default WPF accellerator symbol - used to be & in WinForms
|
||||
|
||||
// If it already contains an accellerator, do nothing
|
||||
if (input.Contains(accellerator)) return input;
|
||||
|
||||
return accellerator + input;
|
||||
}
|
||||
}
|
||||
}
|
||||
4
Plane.Windows.Messages/packages.config
Normal file
4
Plane.Windows.Messages/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MahApps.Metro" version="1.2.2.0" targetFramework="net40" />
|
||||
</packages>
|
||||
41
Plane.Windows/Assets/ListBox.xaml
Normal file
41
Plane.Windows/Assets/ListBox.xaml
Normal file
@ -0,0 +1,41 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="RadioButtonListBoxStyle"
|
||||
TargetType="ListBox">
|
||||
<Setter Property="Background"
|
||||
Value="Transparent" />
|
||||
<Setter Property="BorderThickness"
|
||||
Value="0" />
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel KeyboardNavigation.DirectionalNavigation="Cycle" />
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="ItemContainerStyle">
|
||||
<Setter.Value>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Margin"
|
||||
Value="0,0,5,0" />
|
||||
<Setter Property="SnapsToDevicePixels"
|
||||
Value="true" />
|
||||
<Setter Property="OverridesDefaultStyle"
|
||||
Value="true" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<RadioButton IsTabStop="False"
|
||||
GroupName=""
|
||||
IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Content="{TemplateBinding Content}" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
23
Plane.Windows/Controls/ProgressButton.cs
Normal file
23
Plane.Windows/Controls/ProgressButton.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Plane.Windows.Controls
|
||||
{
|
||||
public class ProgressButton : Button
|
||||
{
|
||||
// Using a DependencyProperty as the backing store for IsProcessing. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty IsProcessingProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsProcessing",
|
||||
typeof(bool),
|
||||
typeof(ProgressButton),
|
||||
new PropertyMetadata(defaultValue: false)
|
||||
);
|
||||
|
||||
public bool IsProcessing
|
||||
{
|
||||
get { return (bool)GetValue(IsProcessingProperty); }
|
||||
set { SetValue(IsProcessingProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Plane.Windows/Converters/BooleanConverter.cs
Normal file
30
Plane.Windows/Converters/BooleanConverter.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Plane.Windows.Converters
|
||||
{
|
||||
public class BooleanConverter<T> : IValueConverter
|
||||
{
|
||||
public BooleanConverter(T trueValue, T falseValue)
|
||||
{
|
||||
True = trueValue;
|
||||
False = falseValue;
|
||||
}
|
||||
|
||||
public virtual T False { get; set; }
|
||||
|
||||
public virtual T True { get; set; }
|
||||
|
||||
public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is bool && ((bool)value) ? True : False;
|
||||
}
|
||||
|
||||
public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is T && EqualityComparer<T>.Default.Equals((T)value, True);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Plane.Windows/Converters/BooleanToResourceConverter.cs
Normal file
31
Plane.Windows/Converters/BooleanToResourceConverter.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Plane.Windows.Converters
|
||||
{
|
||||
public class BooleanToResourceConverter : BooleanConverter<object>
|
||||
{
|
||||
public BooleanToResourceConverter() : base(null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public override object False
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.Current.TryFindResource(FalseKey);
|
||||
}
|
||||
}
|
||||
|
||||
public object FalseKey { get; set; }
|
||||
|
||||
public override object True
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.Current.TryFindResource(TrueKey);
|
||||
}
|
||||
}
|
||||
|
||||
public object TrueKey { get; set; }
|
||||
}
|
||||
}
|
||||
9
Plane.Windows/Converters/BooleanToStringConverter.cs
Normal file
9
Plane.Windows/Converters/BooleanToStringConverter.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Plane.Windows.Converters
|
||||
{
|
||||
public sealed class BooleanToStringConverter : BooleanConverter<string>
|
||||
{
|
||||
public BooleanToStringConverter() :
|
||||
base("True", "False")
|
||||
{ }
|
||||
}
|
||||
}
|
||||
15
Plane.Windows/Converters/BooleanToVisibilityConverter.cs
Normal file
15
Plane.Windows/Converters/BooleanToVisibilityConverter.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Plane.Windows.Converters
|
||||
{
|
||||
public sealed class BooleanToVisibilityConverter : BooleanConverter<Visibility>
|
||||
{
|
||||
public BooleanToVisibilityConverter() :
|
||||
base(Visibility.Visible, Visibility.Collapsed)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
31
Plane.Windows/Converters/InverseBooleanConverter.cs
Normal file
31
Plane.Windows/Converters/InverseBooleanConverter.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Plane.Windows.Converters
|
||||
{
|
||||
[ValueConversion(typeof(bool), typeof(bool))]
|
||||
public class InverseBooleanConverter : IValueConverter
|
||||
{
|
||||
#region IValueConverter Members
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter,
|
||||
System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (targetType != typeof(bool))
|
||||
throw new InvalidOperationException("The target must be a boolean");
|
||||
|
||||
return !(bool)value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter,
|
||||
System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
51
Plane.Windows/Converters/NullableBooleanConverter.cs
Normal file
51
Plane.Windows/Converters/NullableBooleanConverter.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Plane.Windows.Converters
|
||||
{
|
||||
public class NullableBooleanConverter<T> : IValueConverter
|
||||
{
|
||||
public NullableBooleanConverter(T trueValue, T falseValue, T nullValue)
|
||||
{
|
||||
True = trueValue;
|
||||
False = falseValue;
|
||||
Null = nullValue;
|
||||
}
|
||||
|
||||
public T True { get; set; }
|
||||
public T False { get; set; }
|
||||
public T Null { get; set; }
|
||||
|
||||
public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value != null && !(value is bool?))
|
||||
throw new InvalidOperationException("The target must be a Nullable<bool>");
|
||||
var val = (bool?)value;
|
||||
return
|
||||
val == null
|
||||
? Null
|
||||
: val.Value
|
||||
? True
|
||||
: False;
|
||||
}
|
||||
|
||||
public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is T))
|
||||
throw new InvalidOperationException($"The target must be a {typeof(T).Name}");
|
||||
var comparer = EqualityComparer<T>.Default;
|
||||
var val = (T)value;
|
||||
return
|
||||
comparer.Equals(val, True)
|
||||
? true
|
||||
: comparer.Equals(val, False)
|
||||
? false
|
||||
: (bool?)null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Plane.Windows.Converters
|
||||
{
|
||||
public sealed class NullableBooleanToVisibilityConverter : NullableBooleanConverter<Visibility>
|
||||
{
|
||||
public NullableBooleanToVisibilityConverter() :
|
||||
base(Visibility.Visible, Visibility.Collapsed, Visibility.Collapsed)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
77
Plane.Windows/Plane.Windows.csproj
Normal file
77
Plane.Windows/Plane.Windows.csproj
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{06848293-9B17-4068-9B35-44D0ED713CD4}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.Windows</RootNamespace>
|
||||
<AssemblyName>Plane.Windows</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ProgressButton.cs" />
|
||||
<Compile Include="Converters\BooleanToResourceConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToStringConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
|
||||
<Compile Include="Converters\NullableBooleanConverter.cs" />
|
||||
<Compile Include="Converters\BooleanConverter.cs" />
|
||||
<Compile Include="Converters\InverseBooleanConverter.cs" />
|
||||
<Compile Include="Converters\NullableBooleanToVisibilityConverter.cs" />
|
||||
<Compile Include="UpdateChecker.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Assets\ListBox.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Plane\Plane.csproj">
|
||||
<Project>{6cce2aeb-3b38-4c00-b32d-433a990ae2ad}</Project>
|
||||
<Name>Plane</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
36
Plane.Windows/Properties/AssemblyInfo.cs
Normal file
36
Plane.Windows/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.Windows")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.Windows")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("06848293-9b17-4068-9b35-44d0ed713cd4")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
46
Plane.Windows/UpdateChecker.cs
Normal file
46
Plane.Windows/UpdateChecker.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Plane.Logging;
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace Plane.Windows
|
||||
{
|
||||
public class UpdateChecker
|
||||
{
|
||||
private ILogger _logger;
|
||||
|
||||
public UpdateChecker(string urlToCheckUpdate, ILogger logger)
|
||||
{
|
||||
this.Url = urlToCheckUpdate;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Version LatestVersion { get; set; }
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
public void CheckAsync(Action<Version> completedCallback)
|
||||
{
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
client.DownloadStringCompleted += (s, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Result.Length > 128)
|
||||
{
|
||||
// 这么长,肯定是假的。
|
||||
return;
|
||||
}
|
||||
LatestVersion = Version.Parse(e.Result.Split('_')[0]);
|
||||
completedCallback?.Invoke(LatestVersion);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Log(ex);
|
||||
}
|
||||
};
|
||||
client.DownloadStringAsync(new Uri(Url));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Plane.WpfTests/App.xaml
Normal file
9
Plane.WpfTests/App.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<Application x:Class="Plane.WpfTests.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Plane.WpfTests"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
16
Plane.WpfTests/App.xaml.cs
Normal file
16
Plane.WpfTests/App.xaml.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace Plane.WpfTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
29
Plane.WpfTests/MainWindow.xaml
Normal file
29
Plane.WpfTests/MainWindow.xaml
Normal file
@ -0,0 +1,29 @@
|
||||
<Window x:Class="Plane.WpfTests.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Plane.WpfTests"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow"
|
||||
Height="350"
|
||||
Width="525">
|
||||
<WrapPanel>
|
||||
<WrapPanel.Resources>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="HorizontalAlignment"
|
||||
Value="Center" />
|
||||
<Setter Property="Margin"
|
||||
Value="5" />
|
||||
<Setter Property="Padding"
|
||||
Value="10,3" />
|
||||
</Style>
|
||||
</WrapPanel.Resources>
|
||||
<Button x:Name="btnTestAlert"
|
||||
Content="Alert"
|
||||
Click="btnTestAlert_Click" />
|
||||
<Button x:Name="btnTestAlert2"
|
||||
Content="Alert2"
|
||||
Click="btnTestAlert2_Click" />
|
||||
</WrapPanel>
|
||||
</Window>
|
||||
38
Plane.WpfTests/MainWindow.xaml.cs
Normal file
38
Plane.WpfTests/MainWindow.xaml.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using Plane.Windows.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Plane.WpfTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnTestAlert_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Alert.Show("Hello 大家好,我是林俊清。");
|
||||
}
|
||||
|
||||
private void btnTestAlert2_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Alert.ShowOKCancel("啦啦啦。。。!!!,,,|||---+++===#%&……¥……##¥##@%#$@%#, I have a table in my little bedroom.", "Title 标题", "确定(_O)", "取消(_C)");
|
||||
}
|
||||
}
|
||||
}
|
||||
107
Plane.WpfTests/Plane.WpfTests.csproj
Normal file
107
Plane.WpfTests/Plane.WpfTests.csproj
Normal file
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B0B29B9D-3972-48CB-B74D-98E69FEE6DAA}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane.WpfTests</RootNamespace>
|
||||
<AssemblyName>Plane.WpfTests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Plane.Windows.Messages\Plane.Windows.Messages.csproj">
|
||||
<Project>{413c18e2-235f-4e15-b5c1-633657de5d7a}</Project>
|
||||
<Name>Plane.Windows.Messages</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
55
Plane.WpfTests/Properties/AssemblyInfo.cs
Normal file
55
Plane.WpfTests/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Plane.WpfTests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane.WpfTests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
//the line below to match the UICulture setting in the project file.
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
63
Plane.WpfTests/Properties/Resources.Designer.cs
generated
Normal file
63
Plane.WpfTests/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Plane.WpfTests.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Plane.WpfTests.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Plane.WpfTests/Properties/Resources.resx
Normal file
117
Plane.WpfTests/Properties/Resources.resx
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</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>
|
||||
</root>
|
||||
26
Plane.WpfTests/Properties/Settings.Designer.cs
generated
Normal file
26
Plane.WpfTests/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Plane.WpfTests.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Plane.WpfTests/Properties/Settings.settings
Normal file
7
Plane.WpfTests/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
48
Plane/Collections/CollectionExtensions.cs
Normal file
48
Plane/Collections/CollectionExtensions.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Plane.Collections
|
||||
{
|
||||
public static class CollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Calls ICollection<T>.Add internally, but returns the original collection for chain programming.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The item type.</typeparam>
|
||||
/// <param name="origin">The original collection.</param>
|
||||
/// <param name="itemToAdd">The item to add.</param>
|
||||
/// <returns>The original collection.</returns>
|
||||
public static ICollection<T> AddEx<T>(this ICollection<T> origin, T itemToAdd)
|
||||
{
|
||||
origin.Add(itemToAdd);
|
||||
return origin;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add items to the collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The item type.</typeparam>
|
||||
/// <param name="origin">The original collection.</param>
|
||||
/// <param name="itemToAdd">The items to add.</param>
|
||||
/// <returns>The original collection.</returns>
|
||||
public static ICollection<T> AddEx<T>(this ICollection<T> origin, IEnumerable<T> itemsToAdd)
|
||||
{
|
||||
foreach (var item in itemsToAdd)
|
||||
{
|
||||
origin.Add(item);
|
||||
}
|
||||
return origin;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls ICollection<T>.Clear internally, but returns the original collection for chain programming.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The item type.</typeparam>
|
||||
/// <param name="origin">The original collection.</param>
|
||||
/// <returns>The original collection.</returns>
|
||||
public static ICollection<T> ClearEx<T>(this ICollection<T> origin)
|
||||
{
|
||||
origin.Clear();
|
||||
return origin;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Plane/Collections/DictionaryExtensions.cs
Normal file
23
Plane/Collections/DictionaryExtensions.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Plane.Collections
|
||||
{
|
||||
public static class DictionaryExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 尝试返回字典中与指定的键对应的值,若此键不存在则返回指定的默认值。
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">键的类型。</typeparam>
|
||||
/// <typeparam name="TValue">值的类型。</typeparam>
|
||||
/// <param name="dictionary">源字典。</param>
|
||||
/// <param name="key">键。</param>
|
||||
/// <param name="defaultValue">默认值。</param>
|
||||
/// <returns>若字典中包含指定的键,返回其对应的值;否则返回指定的默认值。</returns>
|
||||
public static TValue GetValue<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue = default(TValue))
|
||||
{
|
||||
var value = defaultValue;
|
||||
dictionary.TryGetValue(key, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
59
Plane/Collections/EnumerableExtensions.cs
Normal file
59
Plane/Collections/EnumerableExtensions.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Plane.Collections
|
||||
{
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public static void ForEach<T>(this IEnumerable items, Action<T> action)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(items));
|
||||
}
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
foreach (T item in items)
|
||||
{
|
||||
action(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(items));
|
||||
}
|
||||
if (action == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
foreach (var item in items)
|
||||
{
|
||||
action(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static string JoinToString(this IEnumerable<string> items, string separator)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(items));
|
||||
}
|
||||
return string.Join(separator, items);
|
||||
}
|
||||
|
||||
public static string JoinToString<T>(this IEnumerable<T> items, string separator)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(items));
|
||||
}
|
||||
return string.Join(separator, items);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Plane/Globalization/CultureInfoUtils.cs
Normal file
22
Plane/Globalization/CultureInfoUtils.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
namespace Plane.Globalization
|
||||
{
|
||||
public static class CultureInfoUtils
|
||||
{
|
||||
public static event EventHandler UICultureChanged;
|
||||
|
||||
public static IEnumerable<CultureInfo> GetCultures(params string[] names)
|
||||
{
|
||||
return names.Select(name => new CultureInfo(name));
|
||||
}
|
||||
|
||||
public static void RaiseUICultureChanged()
|
||||
{
|
||||
UICultureChanged?.Invoke(null, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Plane/Logging/Categary.cs
Normal file
10
Plane/Logging/Categary.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Plane.Logging
|
||||
{
|
||||
public enum Category
|
||||
{
|
||||
Debug = 0,
|
||||
Exception = 1,
|
||||
Info = 2,
|
||||
Warn = 3
|
||||
}
|
||||
}
|
||||
20
Plane/Logging/DebugLogger.cs
Normal file
20
Plane/Logging/DebugLogger.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Plane.Logging
|
||||
{
|
||||
public class DebugLogger : Logger
|
||||
{
|
||||
public DebugLogger()
|
||||
{
|
||||
}
|
||||
|
||||
public DebugLogger(ILogger loggerToDecorate) : base(loggerToDecorate)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LogCore(string message, Category category, Priority priority)
|
||||
{
|
||||
Debug.WriteLine(BuildStandardLogEntry(message, category, priority));
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Plane/Logging/ILogger.cs
Normal file
22
Plane/Logging/ILogger.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Plane.Logging
|
||||
{
|
||||
public interface ILogger
|
||||
{
|
||||
/// <summary>
|
||||
/// Write a new log entry about the specified exception with the specified priority.
|
||||
/// </summary>
|
||||
/// <param name="ex">Exception instance to log.</param>
|
||||
/// <param name="priority">The priority of the entry.</param>
|
||||
void Log(Exception ex, Priority priority = Priority.High);
|
||||
|
||||
/// <summary>
|
||||
/// Write a new log entry with the specified category and priority.
|
||||
/// </summary>
|
||||
/// <param name="message">Message body to log.</param>
|
||||
/// <param name="category">Category of the entry.</param>
|
||||
/// <param name="priority">The priority of the entry.</param>
|
||||
void Log(string message, Category category = Category.Info, Priority priority = Priority.None);
|
||||
}
|
||||
}
|
||||
36
Plane/Logging/Logger.cs
Normal file
36
Plane/Logging/Logger.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
|
||||
namespace Plane.Logging
|
||||
{
|
||||
public abstract class Logger : ILogger
|
||||
{
|
||||
private ILogger _loggerToDecorate;
|
||||
|
||||
public Logger()
|
||||
{
|
||||
}
|
||||
|
||||
public Logger(ILogger loggerToDecorate)
|
||||
{
|
||||
_loggerToDecorate = loggerToDecorate;
|
||||
}
|
||||
|
||||
public void Log(Exception ex, Priority priority = Priority.High)
|
||||
{
|
||||
Log(ex.ToString(), Category.Exception, priority);
|
||||
}
|
||||
|
||||
public void Log(string message, Category category = Category.Info, Priority priority = Priority.None)
|
||||
{
|
||||
_loggerToDecorate?.Log(message, category, priority);
|
||||
LogCore(message, category, priority);
|
||||
}
|
||||
|
||||
protected static string BuildStandardLogEntry(string message, Category category, Priority priority)
|
||||
{
|
||||
return $"--{category}-{priority}-{DateTime.Now.ToString("yyyyMMdd HH:mm:ss.fff")}--------------------{Environment.NewLine}{Environment.NewLine}{message}{Environment.NewLine}{Environment.NewLine}--<END>--{Environment.NewLine}{Environment.NewLine}";
|
||||
}
|
||||
|
||||
protected abstract void LogCore(string message, Category category, Priority priority);
|
||||
}
|
||||
}
|
||||
10
Plane/Logging/Priority.cs
Normal file
10
Plane/Logging/Priority.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Plane.Logging
|
||||
{
|
||||
public enum Priority
|
||||
{
|
||||
None = 0,
|
||||
High = 1,
|
||||
Medium = 2,
|
||||
Low = 3
|
||||
}
|
||||
}
|
||||
32
Plane/MathUtils.cs
Normal file
32
Plane/MathUtils.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace Plane
|
||||
{
|
||||
public static class MathUtils
|
||||
{
|
||||
public static void Constrain<T>(ref T value, T min, T max) where T : struct, IComparable<T>
|
||||
{
|
||||
if (min.CompareTo(max) > 0)
|
||||
{
|
||||
throw new ArgumentException($"Argument {nameof(max)} ({max}) must be greater than argument {nameof(min)} ({min}). ", nameof(max));
|
||||
}
|
||||
if (value.CompareTo(min) < 0)
|
||||
{
|
||||
value = min;
|
||||
}
|
||||
if (value.CompareTo(max) > 0)
|
||||
{
|
||||
value = max;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsInRange<T>(this T value, T min, T max) where T : struct, IComparable<T>
|
||||
{
|
||||
if (min.CompareTo(max) > 0)
|
||||
{
|
||||
throw new ArgumentException($"Argument {nameof(max)} ({max}) must be greater than argument {nameof(min)} ({min}). ", nameof(max));
|
||||
}
|
||||
return value.CompareTo(min) >= 0 && value.CompareTo(max) <= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
61
Plane/Plane.csproj
Normal file
61
Plane/Plane.csproj
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6CCE2AEB-3B38-4C00-B32D-433A990AE2AD}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Plane</RootNamespace>
|
||||
<AssemblyName>Plane</AssemblyName>
|
||||
<DefaultLanguage>zh-CN</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<TargetFrameworkProfile>Profile5</TargetFrameworkProfile>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Collections\CollectionExtensions.cs" />
|
||||
<Compile Include="Collections\DictionaryExtensions.cs" />
|
||||
<Compile Include="Collections\EnumerableExtensions.cs" />
|
||||
<Compile Include="Globalization\CultureInfoUtils.cs" />
|
||||
<Compile Include="Logging\Categary.cs" />
|
||||
<Compile Include="Logging\DebugLogger.cs" />
|
||||
<Compile Include="Logging\ILogger.cs" />
|
||||
<Compile Include="Logging\Logger.cs" />
|
||||
<Compile Include="Logging\Priority.cs" />
|
||||
<Compile Include="MathUtils.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="StringExtensions.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
30
Plane/Properties/AssemblyInfo.cs
Normal file
30
Plane/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Plane")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Plane")]
|
||||
[assembly: AssemblyCopyright("版权所有(C) 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("zh-Hans")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
37
Plane/StringExtensions.cs
Normal file
37
Plane/StringExtensions.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace Plane
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 把字符串转换成其表示的日期。
|
||||
/// </summary>
|
||||
/// <param name="value">形如 yyyyMMdd 或 yyyyMMddHHmmss 的字符串。</param>
|
||||
/// <returns>指定的字符串表示的日期。</returns>
|
||||
public static DateTime ToDateTime(this string value)
|
||||
{
|
||||
if (value == null) throw new ArgumentNullException(nameof(value));
|
||||
if (value.Length == 8)
|
||||
{
|
||||
return new DateTime(
|
||||
Convert.ToInt32(value.Substring(0, 4)),
|
||||
Convert.ToInt32(value.Substring(4, 2)),
|
||||
Convert.ToInt32(value.Substring(6, 2))
|
||||
);
|
||||
}
|
||||
else if (value.Length == 14)
|
||||
{
|
||||
return new DateTime(
|
||||
Convert.ToInt32(value.Substring(0, 4)),
|
||||
Convert.ToInt32(value.Substring(4, 2)),
|
||||
Convert.ToInt32(value.Substring(6, 2)),
|
||||
Convert.ToInt32(value.Substring(8, 2)),
|
||||
Convert.ToInt32(value.Substring(10, 2)),
|
||||
Convert.ToInt32(value.Substring(12, 2))
|
||||
);
|
||||
}
|
||||
throw new InvalidOperationException("String.ToDateTime 扩展方法只支持 yyyyMMdd 和 yyyyMMddHHmmss 两种形式的字符串!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user