Skip to content

Commit

Permalink
Merge pull request #188 from Insire/dev
Browse files Browse the repository at this point in the history
merge changes from dev
  • Loading branch information
Insire authored Nov 20, 2021
2 parents c58b208 + 7f1ffc3 commit 01381f0
Show file tree
Hide file tree
Showing 54 changed files with 221 additions and 290 deletions.
4 changes: 1 addition & 3 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

<PropertyGroup>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
</PropertyGroup>

<PropertyGroup>
<LangVersion>9.0</LangVersion>
<CodeAnalysisRuleSet>..\..\MvvmScarletToolkit.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<OutputType>Library</OutputType>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<Description>MvvmScarletToolkit.Abstractions is part of the MvvmScarletToolkit framework, containing interfaces and extensions used by the rest of the framework.</Description>
<PackageTags>MvvmScarletToolkit,MVVM,C#,Toolkit,Scarlet,Library,.NET,OSS,OpenSource</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.240">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void Command_PropertyChanged(object sender, PropertyChangedEventArgs e)
}

[DebuggerStepThrough]
public sealed override async void Execute(object parameter)
public override sealed async void Execute(object parameter)
{
await ExecuteAsync(parameter)
.ConfigureAwait(true); // return to UI thread here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace MvvmScarletToolkit.Commands
public abstract class GenericConcurrentCommandBase : ConcurrentCommandBase
{
[Bindable(true, BindingDirection.OneWay)]
public sealed override Task Completion => Execution.TaskCompletion;
public override sealed Task Completion => Execution.TaskCompletion;

private NotifyTaskCompletion _execution;
[Bindable(true, BindingDirection.OneWay)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<OutputType>Library</OutputType>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<Description>MvvmScarletToolkit.Commands is part of the MvvmScarletToolkit framework, containing asynchrnous and synchronous implementations of the ICommand interface for .NET.</Description>
<PackageTags>MvvmScarletToolkit,MVVM,C#,Toolkit,Scarlet,Library,.NET,OSS,OpenSource</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.1" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />

<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.240">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp3.1;net5.0-windows;net6.0-windows</TargetFrameworks>
<OutputType>Library</OutputType>
<UseWPF>true</UseWPF>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DynamicData" Version="7.4.1" />
<PackageReference Include="DynamicData" Version="7.4.3" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.37" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 5 additions & 1 deletion src/MvvmScarletToolkit.Incubator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.InteropServices;

#if NET5_0_OR_GREATER
[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<OutputType>Library</OutputType>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<Description>MvvmScarletToolkit.Observables is part of the MvvmScarletToolkit framework, containing opinionated base classes for viewmodels of the MVVM pattern.</Description>
<PackageTags>MvvmScarletToolkit,MVVM,C#,Toolkit,Scarlet,Library,.NET,OSS,OpenSource</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.1" />
<PackageReference Include="DynamicData" Version="7.4.1" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="DynamicData" Version="7.4.3" />

<PackageReference Include="Roslynator.Analyzers" Version="3.2.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.240">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using DynamicData;
using DynamicData.Binding;
using System;
using System.Linq;
using System.Reactive.Linq;
using DynamicData;
using DynamicData.Binding;

namespace MvvmScarletToolkit
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:MvvmScarletToolkit.Wpf.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mvvm="clr-namespace:MvvmScarletToolkit;assembly=MvvmScarletToolkit.Wpf"
xmlns:mvvm="http://SoftThorn.MvvmScarletToolkit.com/winfx/xaml/shared"
d:DataContext="{d:DesignInstance Type=local:ProcessingImagesViewModel,
IsDesignTimeCreatable=False}"
mc:Ignorable="d">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using MvvmScarletToolkit.Observables;
using System.Windows.Media;

namespace MvvmScarletToolkit.Wpf.Samples
Expand Down
35 changes: 21 additions & 14 deletions src/MvvmScarletToolkit.Wpf.Samples/Features/Image/Image.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MvvmScarletToolkit.Observables;
using System.IO;
using System;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
Expand All @@ -9,6 +10,8 @@ namespace MvvmScarletToolkit.Wpf.Samples
{
public sealed class Image : ViewModelBase
{
private readonly Assembly _assembly;

private string _displayName;
public string DisplayName
{
Expand Down Expand Up @@ -38,6 +41,7 @@ public int Sequence
}

private BitmapSource _source;

public BitmapSource Source
{
get { return _source; }
Expand All @@ -46,17 +50,19 @@ public BitmapSource Source

public ICommand LoadCommand { get; }

public Image(IScarletCommandBuilder commandBuilder)
public Image(IScarletCommandBuilder commandBuilder, Assembly assembly)
: base(commandBuilder)
{
LoadCommand = commandBuilder.Create(Load, () => true)
.WithSingleExecution()
.Build();

_assembly = assembly ?? throw new ArgumentNullException(nameof(assembly));
}

private async Task Load(CancellationToken token)
{
if (!File.Exists(_path) || _source != null)
if (string.IsNullOrEmpty(_path) || _source != null)
{
return;
}
Expand All @@ -65,20 +71,21 @@ private async Task Load(CancellationToken token)
await Dispatcher.Invoke(() => Source = image).ConfigureAwait(false);
}

private static BitmapSource GetImage(string path)
private BitmapSource GetImage(string resourceName)
{
using var stream = File.OpenRead(path);

var img = new BitmapImage();
img.BeginInit();
img.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
img.CacheOption = BitmapCacheOption.OnLoad;
img.StreamSource = stream;
img.EndInit();
using (var stream = _assembly.GetManifestResourceStream(resourceName))
{
var img = new BitmapImage();
img.BeginInit();
img.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
img.CacheOption = BitmapCacheOption.OnLoad;
img.StreamSource = stream;
img.EndInit();

img.Freeze();
img.Freeze();

return img;
return img;
}
}
}
}
64 changes: 16 additions & 48 deletions src/MvvmScarletToolkit.Wpf.Samples/Features/Image/ImageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,24 @@ public ImageFactory(IScarletCommandBuilder commandBuilder)

public IEnumerable<Image> GetImageList()
{
var absolutePath = Path.GetFullPath(".");
const string resourcesFolder = "Resources";
var assembly = typeof(ImageFactory).Assembly;

yield return new Image(_commandBuilder)
var index = 0;
foreach (var name in assembly.GetManifestResourceNames())
{
IsSelected = true,
DisplayName = "Valley",
Path = Path.Combine(absolutePath, resourcesFolder, "wallhaven-75354.jpg"),
Sequence = 0,
};

yield return new Image(_commandBuilder)
{
IsSelected = false,
DisplayName = "Jungle",
Path = Path.Combine(absolutePath, resourcesFolder, "wallhaven-245035.jpg"),
Sequence = 1,
};

yield return new Image(_commandBuilder)
{
IsSelected = false,
DisplayName = "Winter",
Path = Path.Combine(absolutePath, resourcesFolder, "wallhaven-319605.jpg"),
Sequence = 2,
};

yield return new Image(_commandBuilder)
{
IsSelected = false,
DisplayName = "Night",
Path = Path.Combine(absolutePath, resourcesFolder, "wallhaven-401406.jpg"),
Sequence = 3,
};

yield return new Image(_commandBuilder)
{
IsSelected = false,
DisplayName = "Moon",
Path = Path.Combine(absolutePath, resourcesFolder, "Moon_Color_Hypersaturated_Stars_900.jpg"),
Sequence = 4,
};

yield return new Image(_commandBuilder)
{
IsSelected = false,
DisplayName = "Road",
Path = Path.Combine(absolutePath, resourcesFolder, "Death_to_Stock_Photography_RideorDie_8.jpg"),
Sequence = 5,
};
if (name.EndsWith(".jpg"))
{
yield return new Image(_commandBuilder, assembly)
{
IsSelected = index == 0,
DisplayName = Path.GetFileName(name),
Path = name,
Sequence = index,
};

index++;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

namespace MvvmScarletToolkit.Wpf.Samples
{
#if NET5_0_OR_GREATER

[System.Runtime.Versioning.SupportedOSPlatform("windows7.0")]
#endif
public sealed class NavigationViewModel : Scenes
{
public NavigationViewModel(SynchronizationContext synchronizationContext, IScarletCommandBuilder commandBuilder, LocalizationsViewModel localizationsViewModel)
Expand Down
Loading

0 comments on commit 01381f0

Please sign in to comment.