Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
489 changes: 482 additions & 7 deletions .gitignore

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion AsyncImageLoader.Avalonia.Demo/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Avalonia.Markup.Xaml;
using AsyncImageLoader.Avalonia.Demo.ViewModels;
using AsyncImageLoader.Avalonia.Demo.Views;
using AsyncImageLoader.Loaders;

namespace AsyncImageLoader.Avalonia.Demo;

Expand All @@ -12,13 +13,16 @@ public override void Initialize() {
}

public override void OnFrameworkInitializationCompleted() {
ImageLoader.AsyncImageLoader = new SmartImageLoader();
ImageBrushLoader.AsyncImageLoader = ImageLoader.AsyncImageLoader;

if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
desktop.MainWindow = new MainWindow {
DataContext = new MainWindowViewModel(),
};
desktop.MainWindow.AttachDevTools();
}

base.OnFrameworkInitializationCompleted();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<PackageReference Include="Avalonia.Diagnostics" />
<PackageReference Include="Avalonia.ReactiveUI" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AsyncImageLoader.Avalonia\AsyncImageLoader.Avalonia.csproj" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Include="Assets/cat4.jpg" />
<AvaloniaResource Include="Assets/cat5.jpg" />
<EmbeddedResource Include="Assets/cat6.jpg" />
<EmbeddedResource Include="Assets/cat7.jpg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AsyncImageLoader.Avalonia\AsyncImageLoader.Avalonia.csproj" />
</ItemGroup>
</Project>
12 changes: 9 additions & 3 deletions AsyncImageLoader.Avalonia.Demo/Pages/AdvancedImagePage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</StackPanel>
<asyncImageLoader:AdvancedImage
Name="ReloadableAdvancedImage"
AutoCleanupEnabled="True"
Grid.Column="2" Grid.Row="1" Width="150" Height="150"
Source="https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat0.jpg"
Loader="{x:Static services:LongLoader.Instance}" />
Expand All @@ -40,7 +41,8 @@
Current images loaded from AvaloniaResource Source="../Assets/cat4.jpg".
</TextBlock.Text>
</TextBlock>
<asyncImageLoader:AdvancedImage Grid.Row="2" Grid.Column="2" Width="150" Height="150" Source="../Assets/cat4.jpg" />
<asyncImageLoader:AdvancedImage Grid.Row="2" Grid.Column="2" Width="150" Height="150" Source="../Assets/cat4.jpg"
AutoCleanupEnabled="True"/>
<Image Grid.Row="2" Grid.Column="3" Source="../Assets/cat4.jpg" Width="150" Height="150" />

<TextBlock Grid.Row="3" Grid.Column="0" TextWrapping="Wrap">
Expand All @@ -60,7 +62,9 @@
</TextBlock>
<asyncImageLoader:AdvancedImage Grid.Row="4" Grid.Column="2"
Width="150" Height="150" CornerRadius="5 10 15 20"
Source="/Assets/cat5.jpg" />
Source="/Assets/cat5.jpg"
AutoCleanupEnabled="True"
/>
<Border Grid.Row="4" Grid.Column="3" CornerRadius="5 10 15 20" ClipToBounds="True" Width="150" Height="150">
<Image Source="/Assets/cat5.jpg" Width="150" Height="150" />
</Border>
Expand All @@ -87,6 +91,8 @@
<asyncImageLoader:AdvancedImage Grid.Row="5" Grid.Column="2"
Name="CurrentImageExample"
Width="150" Height="150"
Source="/Assets/cat5.jpg" />
Source="/Assets/cat5.jpg"
AutoCleanupEnabled="True"
/>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging;
using Avalonia.Platform;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
xmlns:vm="clr-namespace:AsyncImageLoader.Avalonia.Demo.ViewModels"
x:Class="AsyncImageLoader.Avalonia.Demo.Pages.AdvancedImageSafeMemoryPage"
x:DataType="vm:AdvancedImageSafeMemoryViewModel">

<Grid RowDefinitions="Auto, Auto,*">

<TextBlock
FontWeight="Bold"
Text="Example demonstrating image rendering under extreme load conditions."
Margin="0,0,0,8"/>

<TextBlock
Grid.Row="1"
Text="Open AsyncImageLoader DevTools with Ctrl + I."
Margin="0,0,0,8"/>

<ItemsControl Grid.Row="1"
ItemsSource="{Binding ImageUrls}">

<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Height="700">
<asyncImageLoader:AdvancedImage
Source="{Binding}"
Height="200"
Margin="4"
AutoCleanupEnabled="True"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>

</ItemsControl>

</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using AsyncImageLoader.Avalonia.Demo.ViewModels;
using Avalonia.Controls;

namespace AsyncImageLoader.Avalonia.Demo.Pages;

public partial class AdvancedImageSafeMemoryPage : UserControl {
public AdvancedImageSafeMemoryPage() {
InitializeComponent();
DataContext = new AdvancedImageSafeMemoryViewModel();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace AsyncImageLoader.Avalonia.Demo.Pages;
Expand Down
1 change: 0 additions & 1 deletion AsyncImageLoader.Avalonia.Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.ReactiveUI;

namespace AsyncImageLoader.Avalonia.Demo;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.ObjectModel;

namespace AsyncImageLoader.Avalonia.Demo.ViewModels;

public class AdvancedImageSafeMemoryViewModel : ViewModelBase {
public ObservableCollection<string> ImageUrls { get; } =
new()
{
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat0.jpg",
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat1.jpg",
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat2.jpg",
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat3.jpg",
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat4.jpg",
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat5.jpg",
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat6.jpg",
"https://github.com/AvaloniaUtils/AsyncImageLoader.Avalonia/raw/master/AsyncImageLoader.Avalonia.Demo/Assets/cat7.jpg",
};
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace AsyncImageLoader.Avalonia.Demo.ViewModels;
namespace AsyncImageLoader.Avalonia.Demo.ViewModels;

public class MainWindowViewModel : ViewModelBase {
public string Greeting => "Welcome to Avalonia!";
Expand Down
5 changes: 1 addition & 4 deletions AsyncImageLoader.Avalonia.Demo/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using ReactiveUI;
using ReactiveUI;

namespace AsyncImageLoader.Avalonia.Demo.ViewModels;

Expand Down
3 changes: 3 additions & 0 deletions AsyncImageLoader.Avalonia.Demo/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
<TabItem Header="AdvancedImage control">
<pages:AdvancedImagePage />
</TabItem>
<TabItem Header="Stress Test">
<pages:AdvancedImageSafeMemoryPage />
</TabItem>
</controls:HamburgerMenu>
</Window>
9 changes: 4 additions & 5 deletions AsyncImageLoader.Avalonia.Demo/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

using AsyncImageLoader.DevTools.Extensions;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace AsyncImageLoader.Avalonia.Demo.Views;

public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();

this.AttachDevTools();
}

private void InitializeComponent() {
AvaloniaXamlLoader.Load(this);
this.AttachDevToolsBitmapInspector();
}
}
Loading