This repository has been archived by the owner on May 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f6ff6f
commit 421b5e6
Showing
9 changed files
with
83 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MainWindow>(); | ||
|
||
public static AppBuilder BuildAvaloniaApp() | ||
=> AppBuilder.Configure<App>() | ||
.UsePlatformDetect() | ||
.UseReactiveUI() | ||
.LogToDebug(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MainWindowViewModel> | ||
{ | ||
public MainWindow() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
this.DataContext = new MainWindowViewModel(); | ||
this.WhenActivated(disposables => { }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Uri>() | ||
Stretches = new List<Stretch> | ||
{ | ||
Stretch.None, | ||
Stretch.Fill, | ||
Stretch.Uniform, | ||
Stretch.UniformToFill | ||
}; | ||
AvailableGifs = new List<Uri> | ||
{ | ||
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<Uri> _availableGifs; | ||
public ObservableCollection<Uri> AvailableGifs | ||
private IReadOnlyList<Uri> _availableGifs; | ||
public IReadOnlyList<Uri> 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<Stretch> _stretches; | ||
public IReadOnlyList<Stretch> 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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<App>() | ||
.UsePlatformDetect() | ||
.UseReactiveUI() | ||
.LogToDebug(); | ||
} | ||
} |