diff --git a/ZonyLrcTools.sln b/ZonyLrcTools.sln index 09bb7fc..40da903 100644 --- a/ZonyLrcTools.sln +++ b/ZonyLrcTools.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZonyLrcTools.LocalServer", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZonyLrcTools.Common", "src\ZonyLrcTools.Common\ZonyLrcTools.Common.csproj", "{9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZonyLrcTools.Desktop", "src\ZonyLrcTools.Desktop\ZonyLrcTools.Desktop.csproj", "{DC92902B-4303-4E43-AFB3-3F93FD3986AD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -37,6 +39,10 @@ Global {9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}.Debug|Any CPU.Build.0 = Debug|Any CPU {9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B42E4CA-61AA-4798-8D2B-2D8A7035EB67}.Release|Any CPU.Build.0 = Release|Any CPU + {DC92902B-4303-4E43-AFB3-3F93FD3986AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC92902B-4303-4E43-AFB3-3F93FD3986AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC92902B-4303-4E43-AFB3-3F93FD3986AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC92902B-4303-4E43-AFB3-3F93FD3986AD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -49,5 +55,6 @@ Global {FFBD3200-568F-455B-8390-5E76C51D522C} = {AF8ADB2F-E46C-4DEE-8316-652D9FE1A69B} {2875A08A-FFD6-4863-B815-5384DCFE88FC} = {C29FB05C-54B1-4020-94D2-87E192EB2F98} {9B42E4CA-61AA-4798-8D2B-2D8A7035EB67} = {C29FB05C-54B1-4020-94D2-87E192EB2F98} + {DC92902B-4303-4E43-AFB3-3F93FD3986AD} = {C29FB05C-54B1-4020-94D2-87E192EB2F98} EndGlobalSection EndGlobal diff --git a/src/ZonyLrcTools.Desktop/App.axaml b/src/ZonyLrcTools.Desktop/App.axaml new file mode 100644 index 0000000..850f55e --- /dev/null +++ b/src/ZonyLrcTools.Desktop/App.axaml @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/ZonyLrcTools.Desktop/App.axaml.cs b/src/ZonyLrcTools.Desktop/App.axaml.cs new file mode 100644 index 0000000..90f68ff --- /dev/null +++ b/src/ZonyLrcTools.Desktop/App.axaml.cs @@ -0,0 +1,28 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using ZonyLrcTools.Desktop.ViewModels; +using ZonyLrcTools.Desktop.Views; + +namespace ZonyLrcTools.Desktop; + +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/ZonyLrcTools.Desktop/Assets/avalonia-logo.ico b/src/ZonyLrcTools.Desktop/Assets/avalonia-logo.ico new file mode 100644 index 0000000..da8d49f Binary files /dev/null and b/src/ZonyLrcTools.Desktop/Assets/avalonia-logo.ico differ diff --git a/src/ZonyLrcTools.Desktop/Program.cs b/src/ZonyLrcTools.Desktop/Program.cs new file mode 100644 index 0000000..068c279 --- /dev/null +++ b/src/ZonyLrcTools.Desktop/Program.cs @@ -0,0 +1,23 @@ +using Avalonia; +using Avalonia.ReactiveUI; +using System; + +namespace ZonyLrcTools.Desktop; + +class Program +{ + // Initialization code. Don't use any Avalonia, third-party APIs or any + // SynchronizationContext-reliant code before AppMain is called: things aren't initialized + // yet and stuff might break. + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + + // Avalonia configuration, don't remove; also used by visual designer. + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .WithInterFont() + .LogToTrace() + .UseReactiveUI(); +} \ No newline at end of file diff --git a/src/ZonyLrcTools.Desktop/ViewLocator.cs b/src/ZonyLrcTools.Desktop/ViewLocator.cs new file mode 100644 index 0000000..0f9e6c8 --- /dev/null +++ b/src/ZonyLrcTools.Desktop/ViewLocator.cs @@ -0,0 +1,27 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using ZonyLrcTools.Desktop.ViewModels; + +namespace ZonyLrcTools.Desktop; + +public class ViewLocator : IDataTemplate +{ + public Control Build(object data) + { + 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/ZonyLrcTools.Desktop/ViewModels/MainWindowViewModel.cs b/src/ZonyLrcTools.Desktop/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..920d009 --- /dev/null +++ b/src/ZonyLrcTools.Desktop/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,6 @@ +namespace ZonyLrcTools.Desktop.ViewModels; + +public class MainWindowViewModel : ViewModelBase +{ + public string Greeting => "Welcome to Avalonia!"; +} \ No newline at end of file diff --git a/src/ZonyLrcTools.Desktop/ViewModels/ViewModelBase.cs b/src/ZonyLrcTools.Desktop/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..4d094d7 --- /dev/null +++ b/src/ZonyLrcTools.Desktop/ViewModels/ViewModelBase.cs @@ -0,0 +1,7 @@ +using ReactiveUI; + +namespace ZonyLrcTools.Desktop.ViewModels; + +public class ViewModelBase : ReactiveObject +{ +} \ No newline at end of file diff --git a/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml b/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml new file mode 100644 index 0000000..1215f04 --- /dev/null +++ b/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml @@ -0,0 +1,20 @@ + + + + + + + + + + diff --git a/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml.cs b/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..fa81cf5 --- /dev/null +++ b/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace ZonyLrcTools.Desktop.Views; + +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/src/ZonyLrcTools.Desktop/ZonyLrcTools.Desktop.csproj b/src/ZonyLrcTools.Desktop/ZonyLrcTools.Desktop.csproj new file mode 100644 index 0000000..b37075d --- /dev/null +++ b/src/ZonyLrcTools.Desktop/ZonyLrcTools.Desktop.csproj @@ -0,0 +1,26 @@ + + + WinExe + net7.0 + enable + true + app.manifest + true + + + + + + + + + + + + + + + + + + diff --git a/src/ZonyLrcTools.Desktop/app.manifest b/src/ZonyLrcTools.Desktop/app.manifest new file mode 100644 index 0000000..873f011 --- /dev/null +++ b/src/ZonyLrcTools.Desktop/app.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + + +