diff --git a/AvaloniaGif.Demo/App.xaml.cs b/AvaloniaGif.Demo/App.xaml.cs index 7eded71..a40dad3 100644 --- a/AvaloniaGif.Demo/App.xaml.cs +++ b/AvaloniaGif.Demo/App.xaml.cs @@ -1,25 +1,21 @@ using Avalonia; -using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; -using Avalonia.ReactiveUI; namespace AvaloniaGif.Demo { public class App : Application { - public override void Initialize() + public override void Initialize() => AvaloniaXamlLoader.Load(this); + + public override void OnFrameworkInitializationCompleted() { - AvaloniaXamlLoader.Load(this); + var window = new MainWindow + { + DataContext = new MainWindowViewModel() + }; + + window.Show(); + base.OnFrameworkInitializationCompleted(); } - - static void Main(string[] args) - => BuildAvaloniaApp() - .Start(); - - public static AppBuilder BuildAvaloniaApp() - => AppBuilder.Configure() - .UsePlatformDetect() - .UseReactiveUI() - .LogToDebug(); } } \ No newline at end of file diff --git a/AvaloniaGif.Demo/AvaloniaGif.Demo.csproj b/AvaloniaGif.Demo/AvaloniaGif.Demo.csproj index acb5b41..62dda02 100644 --- a/AvaloniaGif.Demo/AvaloniaGif.Demo.csproj +++ b/AvaloniaGif.Demo/AvaloniaGif.Demo.csproj @@ -11,13 +11,13 @@ Designer - + - + \ No newline at end of file diff --git a/AvaloniaGif.Demo/Images/c-loader.gif b/AvaloniaGif.Demo/Images/c-loader.gif new file mode 100644 index 0000000..d290bdd Binary files /dev/null and b/AvaloniaGif.Demo/Images/c-loader.gif differ diff --git a/AvaloniaGif.Demo/Images/evitare-loader.gif b/AvaloniaGif.Demo/Images/evitare-loader.gif new file mode 100644 index 0000000..4961f56 Binary files /dev/null and b/AvaloniaGif.Demo/Images/evitare-loader.gif differ diff --git a/AvaloniaGif.Demo/Images/loader.gif b/AvaloniaGif.Demo/Images/loader.gif new file mode 100644 index 0000000..afaaffd Binary files /dev/null and b/AvaloniaGif.Demo/Images/loader.gif differ diff --git a/AvaloniaGif.Demo/MainWindow.xaml b/AvaloniaGif.Demo/MainWindow.xaml index 8852646..ea9ea62 100644 --- a/AvaloniaGif.Demo/MainWindow.xaml +++ b/AvaloniaGif.Demo/MainWindow.xaml @@ -5,8 +5,19 @@ Title="GIFs on Avalonia!" Height="480" Width="680" Background="White"> - - - - + + + + + + + + + + + diff --git a/AvaloniaGif.Demo/MainWindow.xaml.cs b/AvaloniaGif.Demo/MainWindow.xaml.cs index c7f75a4..cf491d2 100644 --- a/AvaloniaGif.Demo/MainWindow.xaml.cs +++ b/AvaloniaGif.Demo/MainWindow.xaml.cs @@ -1,15 +1,15 @@ -using Avalonia.Controls; -using Avalonia.Markup.Xaml; -using Avalonia; +using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; +using ReactiveUI; namespace AvaloniaGif.Demo { - public class MainWindow : Window + public class MainWindow : ReactiveWindow { public MainWindow() { AvaloniaXamlLoader.Load(this); - this.DataContext = new MainWindowViewModel(); + this.WhenActivated(disposables => { }); } } } \ No newline at end of file diff --git a/AvaloniaGif.Demo/MainWindowViewModel.cs b/AvaloniaGif.Demo/MainWindowViewModel.cs index 1b8a6f3..98dae29 100644 --- a/AvaloniaGif.Demo/MainWindowViewModel.cs +++ b/AvaloniaGif.Demo/MainWindowViewModel.cs @@ -1,64 +1,62 @@ -using System.Collections.ObjectModel; using System; -using System.ComponentModel; +using System.Collections.Generic; +using Avalonia.Media; +using ReactiveUI; namespace AvaloniaGif.Demo { - public class MainWindowViewModel : INotifyPropertyChanged + public class MainWindowViewModel : ReactiveObject { - public event PropertyChangedEventHandler PropertyChanged; - private void OnPropertyChanged(string v) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(v)); - } - public MainWindowViewModel() { - this.AvailableGifs = new ObservableCollection() + Stretches = new List + { + Stretch.None, + Stretch.Fill, + Stretch.Uniform, + Stretch.UniformToFill + }; + AvailableGifs = new List { new Uri("resm:AvaloniaGif.Demo.Images.laundry.gif"), new Uri("resm:AvaloniaGif.Demo.Images.earth.gif"), new Uri("resm:AvaloniaGif.Demo.Images.rainbow.gif"), - new Uri("resm:AvaloniaGif.Demo.Images.newton-cradle.gif"), + new Uri("resm:AvaloniaGif.Demo.Images.newton-cradle.gif"), + + // Great shots by Vitaly Silkin, free to use: + // https://dribbble.com/colder/projects/219798-Loaders + new Uri("resm:AvaloniaGif.Demo.Images.loader.gif"), + new Uri("resm:AvaloniaGif.Demo.Images.evitare-loader.gif"), + new Uri("resm:AvaloniaGif.Demo.Images.c-loader.gif") }; } - public void DisplaySelectedGif() - { - CurrentGif = SelectedGif; - } - - private ObservableCollection _availableGifs; - public ObservableCollection AvailableGifs + private IReadOnlyList _availableGifs; + public IReadOnlyList AvailableGifs { get => _availableGifs; - set - { - _availableGifs = value; - OnPropertyChanged(nameof(AvailableGifs)); - } + set => this.RaiseAndSetIfChanged(ref _availableGifs, value); } private Uri _selectedGif; public Uri SelectedGif { get => _selectedGif; - set - { - _selectedGif = value; - OnPropertyChanged(nameof(SelectedGif)); - } + set => this.RaiseAndSetIfChanged(ref _selectedGif, value); } - private Uri _currentGif; - public Uri CurrentGif + private IReadOnlyList _stretches; + public IReadOnlyList Stretches { - get => _currentGif; - set - { - _currentGif = value; - OnPropertyChanged(nameof(CurrentGif)); - } + get => _stretches; + set => this.RaiseAndSetIfChanged(ref _stretches, value); + } + + private Stretch _stretch = Stretch.None; + public Stretch Stretch + { + get => _stretch; + set => this.RaiseAndSetIfChanged(ref _stretch, value); } } } diff --git a/AvaloniaGif.Demo/Program.cs b/AvaloniaGif.Demo/Program.cs new file mode 100644 index 0000000..9d715ce --- /dev/null +++ b/AvaloniaGif.Demo/Program.cs @@ -0,0 +1,17 @@ +using Avalonia; +using Avalonia.Logging.Serilog; +using Avalonia.ReactiveUI; + +namespace AvaloniaGif.Demo +{ + public static class Program + { + public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); + + public static AppBuilder BuildAvaloniaApp() + => AppBuilder.Configure() + .UsePlatformDetect() + .UseReactiveUI() + .LogToDebug(); + } +} \ No newline at end of file