Compare commits

...

10 Commits

Author SHA1 Message Date
xu
fdfe4ccb56 新换电脑安装最新vs2022后框架更新为4.8 2024-04-08 19:39:23 +08:00
40e6fe1b9e 更改到vs2022 2024-01-08 20:40:29 +08:00
a9fcf7d4b3 修改日期格式 2023-05-01 13:56:09 +08:00
xu
ae690cc341 修改名字 2020-09-20 11:42:25 +08:00
xu
314a77bfd7 增加状态消息 2020-01-30 20:32:24 +08:00
zxd
ab5611f15d 修改消息提示
添加ini文件读写
2018-11-03 10:27:25 +08:00
zxd
5e5817b8a4 使用通信模块前的提交
修改读取日志
2018-08-11 12:13:56 +08:00
zxd
c37f276314 添加了读日志 2018-08-03 11:43:16 +08:00
4469ebe8f4 加入注释 2018-05-12 23:16:57 +08:00
40b2351be0 更新依赖包以支持release编译 2017-08-18 12:16:42 +08:00
12 changed files with 211 additions and 91 deletions

View File

@ -44,11 +44,19 @@ 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)
{
lock (_logLock)
{
// TODO: 林俊清20150605应改为不使用 AppendAllText提高性能。
// TODO: 王海20150605应改为不使用 AppendAllText提高性能。
for (int i = 0; i < 5; i++)
{
try

View File

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

View File

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

View File

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

View File

@ -8,15 +8,38 @@ namespace Plane.Windows.Messages
public static class Message
{
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)
{
ShowAction = showAction;
}
public static void ConfigureStatus(Action<string> showAction)
{
StatusAction = showAction;
}
public static void Show(string message)
{
ShowAction?.Invoke(message);
ShowAction?.Invoke(DateTime.Now.ToString("HH:mm:ss ")+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,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Plane.Windows.Messages</RootNamespace>
<AssemblyName>Plane.Windows.Messages</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -20,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -28,10 +30,11 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\..\Plane.FormationCreator\packages\MahApps.Metro.1.5.0\lib\net40\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
@ -40,7 +43,7 @@
<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>
<HintPath>..\..\Plane.FormationCreator\packages\MahApps.Metro.1.5.0\lib\net40\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xaml" />
@ -71,9 +74,7 @@
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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"?>
<packages>
<package id="MahApps.Metro" version="1.2.2.0" targetFramework="net40" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net40" requireReinstallation="true" />
</packages>

View File

@ -0,0 +1,58 @@
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,77 +1,81 @@
<?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>
-->
<?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.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</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>
<Prefer32Bit>false</Prefer32Bit>
</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>
<Prefer32Bit>false</Prefer32Bit>
</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="IniHelper\IniFiles.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>

View File

@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
namespace Plane.Logging
{
@ -14,7 +15,13 @@ namespace Plane.Logging
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,5 +18,7 @@ namespace Plane.Logging
/// <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);
string ReadLog();
}
}

View File

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