Initial commit

This commit is contained in:
SKProCH
2021-02-06 20:49:15 +03:00
commit 08ed9bdaeb
28 changed files with 1692 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
name: .NET Publish
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Build and Pack
run: |
dotnet build Material.Icons.Avalonia
dotnet pack Material.Icons.Avalonia
- name: Publish to Nuget
run: dotnet nuget push "Material.Icons.Avalonia\bin\Debug\*.nupkg" --api-key ${{secrets.NUGET_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Publish to GitHub Packages
run: dotnet nuget push "Material.Icons.Avalonia\bin\Debug\*.nupkg" --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/AvaloniaUtils/index.json --skip-duplicate
+370
View File
@@ -0,0 +1,370 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
# Created by https://www.toptal.com/developers/gitignore/api/csharp
# Edit at https://www.toptal.com/developers/gitignore?templates=csharp
### Csharp ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
!*.Meta/
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# End of https://www.toptal.com/developers/gitignore/api/csharp
/.idea/.idea.YandexMusicResolver/.idea/
/.idea/.idea.Material.Icons/.idea/
/Material.Icons.Meta.dll
/.idea/.idea.Material.Icons.Avalonia/.idea/
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 SKProCH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+337
View File
@@ -0,0 +1,337 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Visual Studio Code specific files and folder
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.jsons
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
+14
View File
@@ -0,0 +1,14 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Material.Icons.Avalonia.Demo"
x:Class="Material.Icons.Avalonia.Demo.App">
<Application.DataTemplates>
<local:ViewLocator />
</Application.DataTemplates>
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />
<StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml" />
</Application.Styles>
</Application>
+23
View File
@@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Material.Icons.Avalonia.Demo.ViewModels;
using Material.Icons.Avalonia.Demo.Views;
namespace Material.Icons.Avalonia.Demo {
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();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

@@ -0,0 +1,68 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Metadata;
namespace Material.Icons.Avalonia.Demo.Controls {
[PseudoClasses("selectednow")]
public class SelectionWrapper : UserControl {
static SelectionWrapper() {
PointerPressedEvent.Raised.Subscribe(tuple => {
if (tuple.Item1 is SelectionWrapper selectionWrapper) {
selectionWrapper.CurrentSelected = selectionWrapper.DataSource;
}
});
CurrentSelectedProperty.Changed.Subscribe(args => {
if (args.Sender is SelectionWrapper selectionWrapper) {
selectionWrapper.UpdateSelectedNow();
}
});
SelectedNowProperty.Changed.Subscribe(args => {
if (args.Sender is SelectionWrapper selectionWrapper) {
if (args.NewValue.Value) {
selectionWrapper.PseudoClasses.Add(":selectednow");
}
else {
selectionWrapper.PseudoClasses.Remove(":selectednow");
}
}
});
}
protected override void OnDataContextEndUpdate() {
base.OnDataContextEndUpdate();
UpdateSelectedNow();
}
public void UpdateSelectedNow() {
SelectedNow = DataSource != null && DataSource == CurrentSelected;
}
public static readonly StyledProperty<object> DataSourceProperty = AvaloniaProperty.Register<SelectionWrapper, object>(nameof(DataSource));
public object DataSource {
get => GetValue(DataSourceProperty);
set => SetValue(DataSourceProperty, value);
}
public static readonly StyledProperty<object> CurrentSelectedProperty = AvaloniaProperty.Register<SelectionWrapper, object>(nameof(CurrentSelected));
public object CurrentSelected {
get => GetValue(CurrentSelectedProperty);
set => SetValue(CurrentSelectedProperty, value);
}
public static readonly DirectProperty<SelectionWrapper, bool> SelectedNowProperty = AvaloniaProperty.RegisterDirect<SelectionWrapper, bool>(
nameof(SelectedNow),
wrapper => wrapper.CurrentSelected == wrapper.DataSource);
private bool _selectedNow;
public bool SelectedNow {
get => _selectedNow;
private set => SetAndRaise(SelectedNowProperty, ref _selectedNow, value);
}
}
}
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\" />
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Material.Icons.Avalonia\Material.Icons.Avalonia.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Material.Icons.Avalonia.Demo.Models {
public class PackIconKindGroup {
public PackIconKindGroup(IEnumerable<string> kinds) {
if (kinds is null) throw new ArgumentNullException(nameof(kinds));
var allValues = kinds.ToList();
if (!allValues.Any()) throw new ArgumentException($"{nameof(kinds)} must contain at least one value");
Kind = allValues.First();
Aliases = allValues
.OrderBy(x => x, StringComparer.InvariantCultureIgnoreCase)
.ToArray();
}
public string Kind { get; }
public string[] Aliases { get; }
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
using Avalonia.Data.Converters;
namespace Material.Icons.Avalonia.Demo.Models {
public class StringJoinConverter : IValueConverter {
public string? Separator { get; set; }
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
IEnumerable values = value as IEnumerable ?? Array.Empty<object>();
return string.Join(Separator ?? "", values.OfType<object>());
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
throw new NotSupportedException();
}
}
}
+19
View File
@@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.ReactiveUI;
namespace Material.Icons.Avalonia.Demo {
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<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
}
}
@@ -0,0 +1,33 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Material.Icons.Avalonia.Demo.ViewModels;
#pragma warning disable 8600
#pragma warning disable 8602
#pragma warning disable 8603
namespace Material.Icons.Avalonia.Demo {
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;
}
}
}
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls;
using DynamicData.Binding;
using Material.Icons.Avalonia.Demo.Models;
using ReactiveUI;
namespace Material.Icons.Avalonia.Demo.ViewModels {
public class MainWindowViewModel : ViewModelBase {
private readonly Lazy<IEnumerable<PackIconKindGroup>> _packIconKinds;
private IEnumerable<PackIconKindGroup>? _kinds;
private PackIconKindGroup? _group;
private string? _searchText;
public MainWindowViewModel() {
_packIconKinds = new Lazy<IEnumerable<PackIconKindGroup>>(() =>
Enum.GetNames(typeof(MaterialIconKind))
.GroupBy(k => (MaterialIconKind) Enum.Parse(typeof(MaterialIconKind), k))
.Select(g => new PackIconKindGroup(g))
.OrderBy(x => x.Kind)
.ToList());
this.WhenValueChanged(model => model.SearchText).Subscribe(DoSearch);
CopyText = this.WhenValueChanged(model => model.Group).Where(group => group != null).Select(group => $"<avalonia:PackIcon Kind=\"{group.Kind}\"/>");
}
private async void DoSearch(string text) {
if (string.IsNullOrWhiteSpace(text))
Kinds = _packIconKinds.Value;
else {
Kinds = new List<PackIconKindGroup>();
Kinds = await Task.Run(() =>
_packIconKinds.Value
.Where(x => x.Aliases.Any(a => a.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0))
.ToList());
}
}
public IEnumerable<PackIconKindGroup> Kinds {
get => _kinds ?? _packIconKinds.Value;
set => this.RaiseAndSetIfChanged(ref _kinds, value);
}
public PackIconKindGroup? Group {
get => _group;
set => this.RaiseAndSetIfChanged(ref _group, value);
}
public string? SearchText {
get => _searchText;
set => this.RaiseAndSetIfChanged(ref _searchText, value);
}
public IObservable<string> CopyText { get; set; }
}
}
@@ -0,0 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;
using ReactiveUI;
namespace Material.Icons.Avalonia.Demo.ViewModels {
public class ViewModelBase : ReactiveObject { }
}
@@ -0,0 +1,68 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:Material.Icons.Avalonia.Demo.ViewModels;assembly=Material.Icons.Avalonia.Demo"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:demo="clr-namespace:Material.Icons.Avalonia.Demo"
xmlns:system="clr-namespace:System;assembly=System.Runtime.Extensions"
xmlns:models="clr-namespace:Material.Icons.Avalonia.Demo.Controls"
xmlns:models1="clr-namespace:Material.Icons.Avalonia.Demo.Models"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
Width="800" Height="500"
x:Class="Material.Icons.Avalonia.Demo.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="Material.Icons.Avalonia.Demo">
<Window.Resources>
<models1:StringJoinConverter x:Key="StringJoinConverter" Separator="{x:Static system:Environment.NewLine}" />
</Window.Resources>
<Window.Styles>
<Style Selector="models|SelectionWrapper:selectednow > Border">
<Setter Property="Background" Value="Gray" />
</Style>
</Window.Styles>
<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>
<Grid ColumnDefinitions="*, *, Auto" RowDefinitions="*, Auto">
<ScrollViewer Grid.ColumnSpan="3" VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Disabled">
<ItemsRepeater Items="{Binding Kinds}"
HorizontalAlignment="Center">
<ItemsRepeater.Layout>
<UniformGridLayout />
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate DataType="models1:PackIconKindGroup">
<models:SelectionWrapper DataSource="{Binding .}"
CurrentSelected="{Binding $parent[ItemsRepeater].DataContext.Group, Mode=TwoWay}">
<Border Name="MainBorder">
<DockPanel Margin="2"
ToolTip.Tip="{Binding Aliases, Converter={StaticResource StringJoinConverter}}"
Width="64"
Height="64"
Background="Transparent">
<TextBlock
Text="{Binding Kind}"
DockPanel.Dock="Bottom"
FontSize="10"
HorizontalAlignment="Center" />
<avalonia:MaterialIcon
Kind="{Binding Kind}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="32"
Height="32" />
</DockPanel>
</Border>
</models:SelectionWrapper>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</ScrollViewer>
<TextBox Grid.Row="1" Grid.Column="0" Text="{Binding SearchText}" Watermark="Search" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding CopyText^}" IsReadOnly="True" />
</Grid>
</Window>
@@ -0,0 +1,18 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Diagnostics;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
namespace Material.Icons.Avalonia.Demo.Views {
public class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void InitializeComponent() {
AvaloniaXamlLoader.Load(this);
DevTools.Attach(this, KeyGesture.Parse("F12"));
}
}
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AvaloniaCI" value="https://www.myget.org/F/avalonia-ci/api/v2" />
</packageSources>
</configuration>
+22
View File
@@ -0,0 +1,22 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Material.Icons.Avalonia", "Material.Icons.Avalonia\Material.Icons.Avalonia.csproj", "{6FCAB4B3-A6F8-4243-96CD-B9DB32AF6B2F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Material.Icons.Avalonia.Demo", "Material.Icons.Avalonia.Demo\Material.Icons.Avalonia.Demo.csproj", "{BB8514A2-0293-4340-9C33-486EE9193851}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6FCAB4B3-A6F8-4243-96CD-B9DB32AF6B2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FCAB4B3-A6F8-4243-96CD-B9DB32AF6B2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FCAB4B3-A6F8-4243-96CD-B9DB32AF6B2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FCAB4B3-A6F8-4243-96CD-B9DB32AF6B2F}.Release|Any CPU.Build.0 = Release|Any CPU
{BB8514A2-0293-4340-9C33-486EE9193851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB8514A2-0293-4340-9C33-486EE9193851}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB8514A2-0293-4340-9C33-486EE9193851}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB8514A2-0293-4340-9C33-486EE9193851}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
+337
View File
@@ -0,0 +1,337 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
## Visual Studio Code specific files and folder
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.jsons
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
+5
View File
@@ -0,0 +1,5 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Material.Icons.Avalonia.App">
<StyleInclude Source="avares://Material.Icons.Avalonia/MaterialIcon.xaml" />
</Styles>
+5
View File
@@ -0,0 +1,5 @@
using Avalonia.Styling;
namespace Material.Icons.Avalonia {
public class App : Styles { }
}
@@ -0,0 +1,21 @@
using System;
using System.Globalization;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace Material.Icons.Avalonia {
public class GeometryConverter : IValueConverter {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
if (value is string s) {
return Geometry.Parse(s);
}
return BindingOperations.DoNothing;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotSupportedException();
}
}
}
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>Material.Icons.Avalonia</Title>
<Authors>SKProCH</Authors>
<Description>Avalonia control for display material icons from Material.Icons</Description>
<PackageProjectUrl>https://github.com/SKProCH/Material.Icons/</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/SKProCH/Material.Icons/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/SKProCH/Material.Icons.git</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>material icons material-design google-material avalonia</PackageTags>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.0" />
<PackageReference Include="Material.Icons" Version="1.0.2" />
</ItemGroup>
</Project>
+29
View File
@@ -0,0 +1,29 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia">
<Style Selector="avalonia|MaterialIcon">
<Style.Resources>
<avalonia:GeometryConverter x:Key="GeometryConverter"></avalonia:GeometryConverter>
</Style.Resources>
<Setter Property="Height" Value="16" />
<Setter Property="Width" Value="16" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Viewbox>
<Canvas Width="24" Height="24">
<Path Data="{Binding Data, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GeometryConverter}}"
Fill="{TemplateBinding Foreground}" />
</Canvas>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Styles>
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
namespace Material.Icons.Avalonia {
public class MaterialIcon : TemplatedControl {
private static readonly Lazy<IDictionary<MaterialIconKind, string>> _dataIndex = new(MaterialIconDataFactory.DataSetCreate);
static MaterialIcon() {
KindProperty.Changed.Subscribe(args => (args.Sender as MaterialIcon)?.UpdateData());
}
public static readonly AvaloniaProperty<MaterialIconKind> KindProperty = AvaloniaProperty.Register<MaterialIcon, MaterialIconKind>(nameof(Kind));
/// <summary>
/// Gets or sets the icon to display.
/// </summary>
public MaterialIconKind Kind {
get => (MaterialIconKind) GetValue(KindProperty);
set => SetValue(KindProperty, value);
}
private static readonly AvaloniaProperty<string?>
DataProperty = AvaloniaProperty.RegisterDirect<MaterialIcon, string?>(nameof(Data), icon => icon.Data);
private string? _data;
/// <summary>
/// Gets the icon path data for the current <see cref="Kind"/>.
/// </summary>
public string? Data {
get => _data;
private set => SetAndRaise(DataProperty, ref _data, value);
}
protected override void OnTemplateApplied(TemplateAppliedEventArgs e) {
base.OnTemplateApplied(e);
UpdateData();
}
private void UpdateData() {
string? data = null;
_dataIndex.Value?.TryGetValue(Kind, out data);
Data = data;
}
}
}
@@ -0,0 +1,34 @@
using System;
using Avalonia.Markup.Xaml;
namespace Material.Icons.Avalonia {
public class MaterialIconExt : MarkupExtension {
public MaterialIconExt() { }
public MaterialIconExt(MaterialIconKind kind) {
Kind = kind;
}
public MaterialIconExt(MaterialIconKind kind, double? size) {
Kind = kind;
Size = size;
}
[ConstructorArgument("kind")]
public MaterialIconKind Kind { get; set; }
[ConstructorArgument("size")]
public double? Size { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider) {
var result = new MaterialIcon { Kind = Kind };
if (Size.HasValue)
{
result.Height = Size.Value;
result.Width = Size.Value;
}
return result;
}
}
}
+24
View File
@@ -0,0 +1,24 @@
# Material.Icons.Avalonia
Avalonia control for display material icons from [Material.Icons](https://github.com/SKProCH/Material.Icons).
Icons list can be found on the [materialdesignicons.com](https://materialdesignicons.com/) or in the demo application.
### Getting started
Install [Material.Icons.Avalonia nuget package](https://www.nuget.org/packages/Material.Icons.Avalonia/):
```
dotnet add package Material.Icons.Avalonia
```
Include styles in `App.xaml`
```
<Application ...>
<Application.Styles>
...
<StyleInclude Source="avares://Material.Icons.Avalonia/App.xaml"></StyleInclude>
</Application.Styles>
</Application>
```
### Using
Use `MaterialIcon` control:
```
<avalonia:MaterialIcon Kind="Abacus"></avalonia:MaterialIcon>
```
The `Foreground` property controls the color of the icon.