Compare commits

..

No commits in common. "fdfe4ccb5664c1d7be3a8fff7914806c73a1a542" and "a4ad241de0598a23b6ff02c2510635692f20fbd0" have entirely different histories.

12 changed files with 91 additions and 211 deletions

View File

@ -44,19 +44,11 @@ namespace Plane.Logging
} }
} }
public override string ReadLog()
{
string text = "";
if (File.Exists(LogFilePath))
text = File.ReadAllText(LogFilePath);
return text;
}
protected override void LogCore(string message, Category category, Priority priority) protected override void LogCore(string message, Category category, Priority priority)
{ {
lock (_logLock) lock (_logLock)
{ {
// TODO: 王海20150605应改为不使用 AppendAllText提高性能。 // TODO: 林俊清20150605应改为不使用 AppendAllText提高性能。
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
try try

View File

@ -9,9 +9,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plane.Logging</RootNamespace> <RootNamespace>Plane.Logging</RootNamespace>
<AssemblyName>Plane.Logging</AssemblyName> <AssemblyName>Plane.Logging</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -21,7 +20,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -30,7 +28,6 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

View File

@ -9,9 +9,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plane.Reflection</RootNamespace> <RootNamespace>Plane.Reflection</RootNamespace>
<AssemblyName>Plane.Reflection</AssemblyName> <AssemblyName>Plane.Reflection</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -21,7 +20,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -30,7 +28,6 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />

View File

@ -29,15 +29,7 @@ namespace Plane.Windows.Messages
{ {
if (Dispatcher.CheckAccess()) if (Dispatcher.CheckAccess())
{ {
try return func();
{
return func();
}
catch (Exception ex)
{
return 0;
}
} }
else else
{ {

View File

@ -8,38 +8,15 @@ namespace Plane.Windows.Messages
public static class Message public static class Message
{ {
private static Action<string> ShowAction { get; set; } private static Action<string> ShowAction { get; set; }
private static Action<bool> ConnectAction { get; set; }
private static Action<string> StatusAction { get; set; }
public static void Configure(Action<string> showAction) public static void Configure(Action<string> showAction)
{ {
ShowAction = showAction; ShowAction = showAction;
} }
public static void ConfigureStatus(Action<string> showAction)
{
StatusAction = showAction;
}
public static void Show(string message) public static void Show(string message)
{ {
ShowAction?.Invoke(DateTime.Now.ToString("HH:mm:ss ")+message); ShowAction?.Invoke(message);
}
public static void ShowStatus(string message)
{
StatusAction?.Invoke(message);
}
public static void Configure(Action<bool> connectAction)
{
ConnectAction = connectAction;
}
public static void Connect(bool isConnected)
{
ConnectAction?.Invoke(isConnected);
} }
} }
} }

View File

@ -9,9 +9,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plane.Windows.Messages</RootNamespace> <RootNamespace>Plane.Windows.Messages</RootNamespace>
<AssemblyName>Plane.Windows.Messages</AssemblyName> <AssemblyName>Plane.Windows.Messages</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -21,7 +20,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@ -30,11 +28,10 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL"> <Reference Include="MahApps.Metro, Version=1.2.2.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\..\Plane.FormationCreator\packages\MahApps.Metro.1.5.0\lib\net40\MahApps.Metro.dll</HintPath> <HintPath>..\..\EHang.FormationCreator\packages\MahApps.Metro.1.2.2.0\lib\net40\MahApps.Metro.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
@ -43,7 +40,7 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\Plane.FormationCreator\packages\MahApps.Metro.1.5.0\lib\net40\System.Windows.Interactivity.dll</HintPath> <HintPath>..\..\EHang.FormationCreator\packages\MahApps.Metro.1.2.2.0\lib\net40\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System.Xaml" /> <Reference Include="System.Xaml" />
@ -74,7 +71,9 @@
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MahApps.Metro" version="1.5.0" targetFramework="net40" requireReinstallation="true" /> <package id="MahApps.Metro" version="1.2.2.0" targetFramework="net40" />
</packages> </packages>

View File

@ -1,58 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Plane.Windows.IniHelper
{
/// <summary>
/// IniFiles 的摘要说明。
/// 示例文件路径C:\file.ini
/// [Server] //[*] 表示缓存区
/// name=localhost //name 表示主键localhost 表示值
/// </summary>
public class IniFiles
{
public string path;
[DllImport("kernel32")] //返回0表示失败非0为成功
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport("kernel32")] //返回取得字符串缓冲区的长度
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
/// <summary>
/// 保存ini文件的路径
/// 调用示例var ini = IniFiles("C:\file.ini");
/// </summary>
/// <param name="INIPath"></param>
public IniFiles()
{
this.path = Environment.CurrentDirectory + @"\Config.ini";
}
/// <summary>
/// 写Ini文件
/// 调用示例ini.IniWritevalue("Server","name","localhost");
/// </summary>
/// <param name="Section">[缓冲区]</param>
/// <param name="Key">键</param>
/// <param name="value">值</param>
public void IniWritevalue(string Section, string Key, string value)
{
WritePrivateProfileString(Section, Key, value, this.path);
}
/// <summary>
/// 读Ini文件
/// 调用示例ini.IniWritevalue("Server","name");
/// </summary>
/// <param name="Section">[缓冲区]</param>
/// <param name="Key">键</param>
/// <returns>值</returns>
public string IniReadvalue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
return temp.ToString();
}
}
}

View File

@ -1,81 +1,77 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{06848293-9B17-4068-9B35-44D0ED713CD4}</ProjectGuid> <ProjectGuid>{06848293-9B17-4068-9B35-44D0ED713CD4}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plane.Windows</RootNamespace> <RootNamespace>Plane.Windows</RootNamespace>
<AssemblyName>Plane.Windows</AssemblyName> <AssemblyName>Plane.Windows</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> </PropertyGroup>
</PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols>
<DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType>
<DebugType>full</DebugType> <Optimize>false</Optimize>
<Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath>
<OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport>
<ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel>
<WarningLevel>4</WarningLevel> </PropertyGroup>
<Prefer32Bit>false</Prefer32Bit> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup> <DebugType>pdbonly</DebugType>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <Optimize>true</Optimize>
<DebugType>pdbonly</DebugType> <OutputPath>bin\Release\</OutputPath>
<Optimize>true</Optimize> <DefineConstants>TRACE</DefineConstants>
<OutputPath>bin\Release\</OutputPath> <ErrorReport>prompt</ErrorReport>
<DefineConstants>TRACE</DefineConstants> <WarningLevel>4</WarningLevel>
<ErrorReport>prompt</ErrorReport> </PropertyGroup>
<WarningLevel>4</WarningLevel> <ItemGroup>
<Prefer32Bit>false</Prefer32Bit> <Reference Include="PresentationCore" />
</PropertyGroup> <Reference Include="PresentationFramework" />
<ItemGroup> <Reference Include="System" />
<Reference Include="PresentationCore" /> <Reference Include="System.Core" />
<Reference Include="PresentationFramework" /> <Reference Include="System.Xaml" />
<Reference Include="System" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Core" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="WindowsBase" />
<Reference Include="System.Data" /> </ItemGroup>
<Reference Include="System.Xml" /> <ItemGroup>
<Reference Include="WindowsBase" /> <Compile Include="Controls\ProgressButton.cs" />
</ItemGroup> <Compile Include="Converters\BooleanToResourceConverter.cs" />
<ItemGroup> <Compile Include="Converters\BooleanToStringConverter.cs" />
<Compile Include="Controls\ProgressButton.cs" /> <Compile Include="Converters\BooleanToVisibilityConverter.cs" />
<Compile Include="Converters\BooleanToResourceConverter.cs" /> <Compile Include="Converters\NullableBooleanConverter.cs" />
<Compile Include="Converters\BooleanToStringConverter.cs" /> <Compile Include="Converters\BooleanConverter.cs" />
<Compile Include="Converters\BooleanToVisibilityConverter.cs" /> <Compile Include="Converters\InverseBooleanConverter.cs" />
<Compile Include="Converters\NullableBooleanConverter.cs" /> <Compile Include="Converters\NullableBooleanToVisibilityConverter.cs" />
<Compile Include="Converters\BooleanConverter.cs" /> <Compile Include="UpdateChecker.cs" />
<Compile Include="Converters\InverseBooleanConverter.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Converters\NullableBooleanToVisibilityConverter.cs" /> </ItemGroup>
<Compile Include="IniHelper\IniFiles.cs" /> <ItemGroup>
<Compile Include="UpdateChecker.cs" /> <Page Include="Assets\ListBox.xaml">
<Compile Include="Properties\AssemblyInfo.cs" /> <Generator>MSBuild:Compile</Generator>
</ItemGroup> <SubType>Designer</SubType>
<ItemGroup> </Page>
<Page Include="Assets\ListBox.xaml"> </ItemGroup>
<Generator>MSBuild:Compile</Generator> <ItemGroup>
<SubType>Designer</SubType> <ProjectReference Include="..\Plane\Plane.csproj">
</Page> <Project>{6cce2aeb-3b38-4c00-b32d-433a990ae2ad}</Project>
</ItemGroup> <Name>Plane</Name>
<ItemGroup> </ProjectReference>
<ProjectReference Include="..\Plane\Plane.csproj"> </ItemGroup>
<Project>{6cce2aeb-3b38-4c00-b32d-433a990ae2ad}</Project> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Name>Plane</Name> <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
</ProjectReference> Other similar extension points exist, see Microsoft.Common.targets.
</ItemGroup> <Target Name="BeforeBuild">
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <Target Name="AfterBuild">
Other similar extension points exist, see Microsoft.Common.targets. </Target>
<Target Name="BeforeBuild"> -->
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project> </Project>

View File

@ -1,5 +1,4 @@
using System; using System.Diagnostics;
using System.Diagnostics;
namespace Plane.Logging namespace Plane.Logging
{ {
@ -15,13 +14,7 @@ namespace Plane.Logging
protected override void LogCore(string message, Category category, Priority priority) protected override void LogCore(string message, Category category, Priority priority)
{ {
Debug.WriteLine(BuildStandardLogEntry(message, category, priority)); //写入日志 Debug.WriteLine(BuildStandardLogEntry(message, category, priority));
} }
public override string ReadLog()
{
return "";
}
} }
} }

View File

@ -18,7 +18,5 @@ namespace Plane.Logging
/// <param name="category">Category of the entry.</param> /// <param name="category">Category of the entry.</param>
/// <param name="priority">The priority 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); void Log(string message, Category category = Category.Info, Priority priority = Priority.None);
string ReadLog();
} }
} }

View File

@ -26,9 +26,6 @@ namespace Plane.Logging
LogCore(message, category, priority); LogCore(message, category, priority);
} }
public abstract string ReadLog();
protected static string BuildStandardLogEntry(string message, Category category, Priority 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}"; 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}";