From 4d6087e1bd00b4880cd83790ca7fc71f34986bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Thu, 2 Feb 2023 10:12:54 +0100 Subject: [PATCH] chore: add packetlogger folder structure --- NosTale-PacketLogger.sln | 14 +++++++ NosTale-PacketLogger.sln.DotSettings.user | 14 +++---- src/PacketLogger/App.axaml | 13 +++++++ src/PacketLogger/App.axaml.cs | 38 ++++++++++++++++++ src/PacketLogger/PacketLogger.csproj | 37 ++++++++++++++++++ src/PacketLogger/Program.cs | 41 ++++++++++++++++++++ src/PacketLogger/Roots.xml | 5 +++ src/PacketLogger/ViewLocator.cs | 41 ++++++++++++++++++++ src/PacketLogger/ViewModels/ViewModelBase.cs | 15 +++++++ src/PacketLogger/app.manifest | 18 +++++++++ 10 files changed, 229 insertions(+), 7 deletions(-) create mode 100644 src/PacketLogger/App.axaml create mode 100644 src/PacketLogger/App.axaml.cs create mode 100644 src/PacketLogger/PacketLogger.csproj create mode 100644 src/PacketLogger/Program.cs create mode 100644 src/PacketLogger/Roots.xml create mode 100644 src/PacketLogger/ViewLocator.cs create mode 100644 src/PacketLogger/ViewModels/ViewModelBase.cs create mode 100644 src/PacketLogger/app.manifest diff --git a/NosTale-PacketLogger.sln b/NosTale-PacketLogger.sln index 85a1ac2..a7435e4 100644 --- a/NosTale-PacketLogger.sln +++ b/NosTale-PacketLogger.sln @@ -1,8 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PacketLogger.PacketAnalyzer", "src\PacketLogger.PacketAnalyzer\PacketLogger.PacketAnalyzer.csproj", "{4DDFB174-CF6F-41D1-8E94-8D54F10F7177}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PacketLogger", "src\PacketLogger\PacketLogger.csproj", "{ED52AE11-3808-4D50-93DA-888F231F5207}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4DDFB174-CF6F-41D1-8E94-8D54F10F7177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4DDFB174-CF6F-41D1-8E94-8D54F10F7177}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4DDFB174-CF6F-41D1-8E94-8D54F10F7177}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4DDFB174-CF6F-41D1-8E94-8D54F10F7177}.Release|Any CPU.Build.0 = Release|Any CPU + {ED52AE11-3808-4D50-93DA-888F231F5207}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED52AE11-3808-4D50-93DA-888F231F5207}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED52AE11-3808-4D50-93DA-888F231F5207}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED52AE11-3808-4D50-93DA-888F231F5207}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection EndGlobal diff --git a/NosTale-PacketLogger.sln.DotSettings.user b/NosTale-PacketLogger.sln.DotSettings.user index 98e4f9f..33c7176 100644 --- a/NosTale-PacketLogger.sln.DotSettings.user +++ b/NosTale-PacketLogger.sln.DotSettings.user @@ -4,14 +4,14 @@ </AssemblyExplorer> C:\Program Files\dotnet\sdk\7.0.101\MSBuild.dll 1114112 - <SessionState ContinuousTestingMode="0" Name="PacketFcTestSubpackets" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <TestAncestor> - <TestId>xUnit::9BC56B40-64E3-4A8F-AD49-C52857A35026::net6.0::NosSmooth.Packets.Tests.Converters.Packets.InPacketConverterTests.DeserializesPlayerInCorrectly</TestId> - <TestId>xUnit::9BC56B40-64E3-4A8F-AD49-C52857A35026::net6.0::NosSmooth.Packets.Tests.Converters.Packets.InPacketConverterTests.SerializesPlayerInCorrectly</TestId> - </TestAncestor> + <SessionState ContinuousTestingMode="0" Name="PacketFcTestSubpackets" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <TestAncestor> + <TestId>xUnit::9BC56B40-64E3-4A8F-AD49-C52857A35026::net6.0::NosSmooth.Packets.Tests.Converters.Packets.InPacketConverterTests.DeserializesPlayerInCorrectly</TestId> + <TestId>xUnit::9BC56B40-64E3-4A8F-AD49-C52857A35026::net6.0::NosSmooth.Packets.Tests.Converters.Packets.InPacketConverterTests.SerializesPlayerInCorrectly</TestId> + </TestAncestor> </SessionState> - <SessionState ContinuousTestingMode="0" IsActive="True" Name="PacketFcTestSubpackets #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <Project Location="D:\Shared\Documents\my_projects\NosSmooth" Presentation="&lt;Tests&gt;" /> + <SessionState ContinuousTestingMode="0" IsActive="True" Name="PacketFcTestSubpackets #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Project Location="D:\Shared\Documents\my_projects\NosSmooth" Presentation="&lt;Tests&gt;" /> </SessionState> True diff --git a/src/PacketLogger/App.axaml b/src/PacketLogger/App.axaml new file mode 100644 index 0000000..82da4bf --- /dev/null +++ b/src/PacketLogger/App.axaml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/PacketLogger/App.axaml.cs b/src/PacketLogger/App.axaml.cs new file mode 100644 index 0000000..f9833fd --- /dev/null +++ b/src/PacketLogger/App.axaml.cs @@ -0,0 +1,38 @@ +// +// App.axaml.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using PacketLogger.ViewModels; +using PacketLogger.Views; +using PropertyChanged; + +namespace PacketLogger; + +[DoNotNotify] +public partial class App : Application +{ + /// + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } + + /// + public override void OnFrameworkInitializationCompleted() + { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new MainWindow + { + DataContext = new MainWindowViewModel(), + }; + } + + base.OnFrameworkInitializationCompleted(); + } +} \ No newline at end of file diff --git a/src/PacketLogger/PacketLogger.csproj b/src/PacketLogger/PacketLogger.csproj new file mode 100644 index 0000000..dde61b1 --- /dev/null +++ b/src/PacketLogger/PacketLogger.csproj @@ -0,0 +1,37 @@ + + + WinExe + net7.0 + enable + true + app.manifest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PacketLogger/Program.cs b/src/PacketLogger/Program.cs new file mode 100644 index 0000000..596f253 --- /dev/null +++ b/src/PacketLogger/Program.cs @@ -0,0 +1,41 @@ +// +// Program.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using Avalonia; +using Avalonia.Media; +using Avalonia.ReactiveUI; +using Projektanker.Icons.Avalonia; +using Projektanker.Icons.Avalonia.MaterialDesign; + +namespace PacketLogger; + +/// +/// Application entrypoint class. +/// +public class Program +{ + /// + /// Application entrypoint. + /// + /// The CLI arguments. + [STAThread] + public static void Main(string[] args) + => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + /// + /// Build the Avalonia app. + /// + /// The app builder. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .LogToTrace() + .UseReactiveUI() + .WithIcons(c => c.Register()) + .With(new FontManagerOptions() { DefaultFamilyName = "Arial" }); +} \ No newline at end of file diff --git a/src/PacketLogger/Roots.xml b/src/PacketLogger/Roots.xml new file mode 100644 index 0000000..4b17bc8 --- /dev/null +++ b/src/PacketLogger/Roots.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/PacketLogger/ViewLocator.cs b/src/PacketLogger/ViewLocator.cs new file mode 100644 index 0000000..a1c6a48 --- /dev/null +++ b/src/PacketLogger/ViewLocator.cs @@ -0,0 +1,41 @@ +// +// ViewLocator.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using PacketLogger.ViewModels; + +namespace PacketLogger; + +/// +public class ViewLocator : IDataTemplate +{ + /// + public IControl Build(object? data) + { + if (data is null) + { + return new TextBlock { Text = "View not selected." }; + } + + var name = data.GetType().FullName!.Replace("ViewModel", "View"); + var type = Type.GetType(name); + + if (type != null) + { + return (Control)Activator.CreateInstance(type)!; + } + + return new TextBlock { Text = "Not Found: " + name }; + } + + /// + public bool Match(object? data) + { + return data is ViewModelBase; + } +} \ No newline at end of file diff --git a/src/PacketLogger/ViewModels/ViewModelBase.cs b/src/PacketLogger/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..24064f8 --- /dev/null +++ b/src/PacketLogger/ViewModels/ViewModelBase.cs @@ -0,0 +1,15 @@ +// +// ViewModelBase.cs +// +// Copyright (c) František Boháček. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.ComponentModel; +using ReactiveUI; + +namespace PacketLogger.ViewModels; + +/// +public class ViewModelBase : ReactiveObject, INotifyPropertyChanged +{ +} diff --git a/src/PacketLogger/app.manifest b/src/PacketLogger/app.manifest new file mode 100644 index 0000000..e0ce8d0 --- /dev/null +++ b/src/PacketLogger/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + -- 2.48.1