From fe46c308ef3eb1be3c39eca680e9b01b6b749336 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 1 Feb 2021 01:05:42 -0500 Subject: Added project files --- .gitignore | 8 ++++++++ Alee Audio Player.csproj | 17 +++++++++++++++++ App.axaml | 12 ++++++++++++ App.axaml.cs | 29 +++++++++++++++++++++++++++++ Assets/avalonia-logo.ico | Bin 0 -> 176111 bytes Program.cs | 23 +++++++++++++++++++++++ ViewLocator.cs | 32 ++++++++++++++++++++++++++++++++ ViewModels/MainWindowViewModel.cs | 11 +++++++++++ ViewModels/ViewModelBase.cs | 11 +++++++++++ Views/MainWindow.axaml | 17 +++++++++++++++++ Views/MainWindow.axaml.cs | 22 ++++++++++++++++++++++ 11 files changed, 182 insertions(+) create mode 100644 .gitignore create mode 100644 Alee Audio Player.csproj create mode 100644 App.axaml create mode 100644 App.axaml.cs create mode 100644 Assets/avalonia-logo.ico create mode 100644 Program.cs create mode 100644 ViewLocator.cs create mode 100644 ViewModels/MainWindowViewModel.cs create mode 100644 ViewModels/ViewModelBase.cs create mode 100644 Views/MainWindow.axaml create mode 100644 Views/MainWindow.axaml.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d007509 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.idea/ +.vscode/ +.vs/ + +bin/ +obj/ + +*.user \ No newline at end of file diff --git a/Alee Audio Player.csproj b/Alee Audio Player.csproj new file mode 100644 index 0000000..92eef67 --- /dev/null +++ b/Alee Audio Player.csproj @@ -0,0 +1,17 @@ + + + WinExe + net5.0 + enable + + + + + + + + + + + + diff --git a/App.axaml b/App.axaml new file mode 100644 index 0000000..ddd8046 --- /dev/null +++ b/App.axaml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/App.axaml.cs b/App.axaml.cs new file mode 100644 index 0000000..0ddebe2 --- /dev/null +++ b/App.axaml.cs @@ -0,0 +1,29 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using Alee_Audio_Player.ViewModels; +using Alee_Audio_Player.Views; + +namespace Alee_Audio_Player +{ + public 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/Assets/avalonia-logo.ico b/Assets/avalonia-logo.ico new file mode 100644 index 0000000..da8d49f Binary files /dev/null and b/Assets/avalonia-logo.ico differ diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..ef72448 --- /dev/null +++ b/Program.cs @@ -0,0 +1,23 @@ +using System; +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.ReactiveUI; + +namespace Alee_Audio_Player +{ + 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. + 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() + .LogToTrace() + .UseReactiveUI(); + } +} diff --git a/ViewLocator.cs b/ViewLocator.cs new file mode 100644 index 0000000..ded617c --- /dev/null +++ b/ViewLocator.cs @@ -0,0 +1,32 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Alee_Audio_Player.ViewModels; + +namespace Alee_Audio_Player +{ + public class ViewLocator : IDataTemplate + { + public bool SupportsRecycling => false; + + public IControl Build(object data) + { + var name = data.GetType().FullName!.Replace("ViewModel", "View"); + var type = Type.GetType(name); + + if (type != null) + { + return (Control)Activator.CreateInstance(type)!; + } + else + { + 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/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..e0d82ae --- /dev/null +++ b/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Alee_Audio_Player.ViewModels +{ + public class MainWindowViewModel : ViewModelBase + { + public string Greeting => "Welcome to Avalonia!"; + } +} diff --git a/ViewModels/ViewModelBase.cs b/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..b28eeb1 --- /dev/null +++ b/ViewModels/ViewModelBase.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ReactiveUI; + +namespace Alee_Audio_Player.ViewModels +{ + public class ViewModelBase : ReactiveObject + { + } +} diff --git a/Views/MainWindow.axaml b/Views/MainWindow.axaml new file mode 100644 index 0000000..a3d8dfb --- /dev/null +++ b/Views/MainWindow.axaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/Views/MainWindow.axaml.cs b/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..81f1a2c --- /dev/null +++ b/Views/MainWindow.axaml.cs @@ -0,0 +1,22 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Alee_Audio_Player.Views +{ + public class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} \ No newline at end of file -- cgit v1.2.3