From c7428fab1c38d29bcc50ee263678504e34d01318 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 1 Feb 2021 22:13:46 -0500 Subject: Moved project files --- Erable/App.axaml | 12 +++++++++++ Erable/App.axaml.cs | 29 +++++++++++++++++++++++++ Erable/Assets/avalonia-logo.ico | Bin 0 -> 176111 bytes Erable/Erable.csproj | 19 ++++++++++++++++ Erable/Program.cs | 23 ++++++++++++++++++++ Erable/ViewLocator.cs | 32 +++++++++++++++++++++++++++ Erable/ViewModels/MainWindowViewModel.cs | 36 +++++++++++++++++++++++++++++++ Erable/ViewModels/ViewModelBase.cs | 11 ++++++++++ Erable/Views/MainWindow.axaml | 20 +++++++++++++++++ Erable/Views/MainWindow.axaml.cs | 22 +++++++++++++++++++ 10 files changed, 204 insertions(+) create mode 100644 Erable/App.axaml create mode 100644 Erable/App.axaml.cs create mode 100644 Erable/Assets/avalonia-logo.ico create mode 100644 Erable/Erable.csproj create mode 100644 Erable/Program.cs create mode 100644 Erable/ViewLocator.cs create mode 100644 Erable/ViewModels/MainWindowViewModel.cs create mode 100644 Erable/ViewModels/ViewModelBase.cs create mode 100644 Erable/Views/MainWindow.axaml create mode 100644 Erable/Views/MainWindow.axaml.cs (limited to 'Erable') diff --git a/Erable/App.axaml b/Erable/App.axaml new file mode 100644 index 0000000..992dbfb --- /dev/null +++ b/Erable/App.axaml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/Erable/App.axaml.cs b/Erable/App.axaml.cs new file mode 100644 index 0000000..addd072 --- /dev/null +++ b/Erable/App.axaml.cs @@ -0,0 +1,29 @@ +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Markup.Xaml; +using Erable.ViewModels; +using Erable.Views; + +namespace Erable +{ + 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/Erable/Assets/avalonia-logo.ico b/Erable/Assets/avalonia-logo.ico new file mode 100644 index 0000000..da8d49f Binary files /dev/null and b/Erable/Assets/avalonia-logo.ico differ diff --git a/Erable/Erable.csproj b/Erable/Erable.csproj new file mode 100644 index 0000000..b10f530 --- /dev/null +++ b/Erable/Erable.csproj @@ -0,0 +1,19 @@ + + + WinExe + net5.0 + enable + Erable + + + + + + + + + + + + + diff --git a/Erable/Program.cs b/Erable/Program.cs new file mode 100644 index 0000000..312bbb4 --- /dev/null +++ b/Erable/Program.cs @@ -0,0 +1,23 @@ +using System; +using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.ReactiveUI; + +namespace Erable +{ + 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/Erable/ViewLocator.cs b/Erable/ViewLocator.cs new file mode 100644 index 0000000..0a6eb01 --- /dev/null +++ b/Erable/ViewLocator.cs @@ -0,0 +1,32 @@ +using System; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Erable.ViewModels; + +namespace Erable +{ + 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/Erable/ViewModels/MainWindowViewModel.cs b/Erable/ViewModels/MainWindowViewModel.cs new file mode 100644 index 0000000..0c51fbd --- /dev/null +++ b/Erable/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Avalonia.Controls; +using Gst; + +namespace Erable.ViewModels +{ + public class MainWindowViewModel : ViewModelBase + { + public string Greeting => "Welcome to Erable Audio Player!"; + + public void PlayFunction(string[] args) + { + Application.Init(ref args); + // Build the pipeline + var pipeline = Parse.Launch("playbin uri=file:///home/andrew/Music/4616-werq-by-kevin-macleod.mp3"); + + // Start playing + pipeline.SetState(State.Playing); + + // Wait until error or EOS + var bus = pipeline.Bus; + var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Eos | MessageType.Error); + + // Free resources + //pipeline.SetState (State.Null); + } + + public void BrowseFunction() + { + //OpenFileDialog dialog = new OpenFileDialog(); + //dialog.Filters.Add(new FileDialogFilter() {Name = "Audio Files", Extensions = {"mp3"}}); + } + } +} diff --git a/Erable/ViewModels/ViewModelBase.cs b/Erable/ViewModels/ViewModelBase.cs new file mode 100644 index 0000000..6ab8d21 --- /dev/null +++ b/Erable/ViewModels/ViewModelBase.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ReactiveUI; + +namespace Erable.ViewModels +{ + public class ViewModelBase : ReactiveObject + { + } +} diff --git a/Erable/Views/MainWindow.axaml b/Erable/Views/MainWindow.axaml new file mode 100644 index 0000000..6bb4cd1 --- /dev/null +++ b/Erable/Views/MainWindow.axaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/Erable/Views/MainWindow.axaml.cs b/Erable/Views/MainWindow.axaml.cs new file mode 100644 index 0000000..814bc0f --- /dev/null +++ b/Erable/Views/MainWindow.axaml.cs @@ -0,0 +1,22 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Erable.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