├── .editorconfig
├── .github
└── workflows
│ └── dotnetcore.yml
├── .gitignore
├── 2020-09-17_15h22_46.png
├── LICENSE
├── README.md
├── avalonia_iconpacks_preview010.gif
├── global.json
└── src
├── .idea
└── .idea.AvaloniaIconPacks.TestApp
│ └── .idea
│ ├── .gitignore
│ ├── .name
│ ├── indexLayout.xml
│ └── misc.xml
├── AvaloniaApp
├── App.axaml
├── App.axaml.cs
├── AvaloniaApp.csproj
├── EnumsExtension.cs
├── MainWindow.axaml
├── MainWindow.axaml.cs
├── Program.cs
└── app.manifest
├── AvaloniaIconPacks.TestApp.sln
├── IconPacks.Avalonia.BoxIcons
├── BoxIcons.xaml
├── Converter
│ └── PackIconBoxIconsKindToImageConverter.cs
├── IconPacks.Avalonia.BoxIcons.csproj
├── PackIconBoxIcons.cs
├── PackIconBoxIcons.xaml
├── PackIconBoxIconsExtension.cs
├── PackIconBoxIconsImageExtension.cs
├── PackIconBoxIconsKind.cs
└── Properties
│ └── AssemblyInfo.cs
├── IconPacks.Avalonia.Core
├── Attributes
│ └── MetaDataAttribute.cs
├── Converter
│ ├── MarkupConverter.cs
│ └── PackIconKindToImageConverterBase.cs
├── IconPacks.Avalonia.Core.csproj
├── PackIcon.xaml
├── PackIconBase.cs
├── PackIconControlBase.cs
├── PackIconControlBase.xaml
├── PackIconDataFactory.cs
├── PackIconExtension.cs
├── PackIconFlipOrientation.cs
├── PackIconImageExtension.cs
└── Properties
│ └── AssemblyInfo.cs
├── IconPacks.Avalonia
├── Converter
│ └── PackIconKindToImageConverter.cs
├── IconPacks.Avalonia.csproj
├── Icons.xaml
├── PackIconControl.cs
├── PackIconControl.xaml
├── PackIconControlDataFactory.cs
├── PackIconExtension.cs
├── PackIconImageExtension.cs
└── Properties
│ └── AssemblyInfo.cs
└── Icons
└── BoxIcons
└── Icons.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | ; Top-most http://editorconfig.org/ file
2 | root = true
3 |
4 | [*]
5 | end_of_line = crlf
6 | indent_style = space
7 | max_line_length = 190
8 |
9 | ; 4-column tab indentation
10 | [*.{cs,csproj,xaml,xml,props,targets,nuspec}]
11 | indent_size = 4
12 |
13 | [*.{yml,json}]
14 | indent_size = 2
15 | max_line_length = off
16 |
17 | [*.md]
18 | indent_size = 2
19 | max_line_length = off
20 | trim_trailing_whitespace = false
21 |
--------------------------------------------------------------------------------
/.github/workflows/dotnetcore.yml:
--------------------------------------------------------------------------------
1 | name: Build with .NET Core
2 |
3 | on: [push]
4 |
5 | jobs:
6 | publishlinux:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - uses: actions/checkout@v4
11 | with:
12 | fetch-depth: 0
13 | - name: Setup .NET Core
14 | uses: actions/setup-dotnet@v4
15 | with:
16 | dotnet-version: |
17 | 6.x
18 | 8.x
19 | - name: Publish with dotnet
20 | run: dotnet publish ./src/AvaloniaApp/AvaloniaApp.csproj -r linux-x64 -c Release -f net6.0
21 | - name: Archive publish artifacts
22 | uses: actions/upload-artifact@v4
23 | with:
24 | name: AvaloniaApp_net60_linux-x64
25 | path: src/AvaloniaApp/bin/Release/net6.0/linux-x64/publish
26 |
27 | publishwin:
28 | runs-on: windows-latest
29 |
30 | steps:
31 | - uses: actions/checkout@v4
32 | with:
33 | fetch-depth: 0
34 | - name: Setup .NET Core
35 | uses: actions/setup-dotnet@v4
36 | with:
37 | dotnet-version: |
38 | 6.x
39 | 8.x
40 | - name: Publish with dotnet
41 | run: dotnet publish ./src/AvaloniaApp/AvaloniaApp.csproj -r win-x64 -c Release -f net6.0
42 | - name: Archive publish artifacts
43 | uses: actions/upload-artifact@v4
44 | with:
45 | name: AvaloniaApp_net60_winx64
46 | path: src/AvaloniaApp/bin/Release/net6.0/win-x64/publish
47 |
48 | publishmac:
49 | runs-on: macos-latest
50 |
51 | steps:
52 | - uses: actions/checkout@v4
53 | with:
54 | fetch-depth: 0
55 | - name: Setup .NET Core
56 | uses: actions/setup-dotnet@v4
57 | with:
58 | dotnet-version: |
59 | 6.x
60 | 8.x
61 | - name: Publish with dotnet
62 | run: dotnet publish ./src/AvaloniaApp/AvaloniaApp.csproj -r osx-x64 -c Release -f net6.0
63 | - name: Archive publish artifacts
64 | uses: actions/upload-artifact@v4
65 | with:
66 | name: AvaloniaApp_net60_osx
67 | path: src/AvaloniaApp/bin/Release/net6.0/osx-x64/publish
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/2020-09-17_15h22_46.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/punker76/MahApps.Avalonia.IconPacks.Testbed/ea758248f4b5b11b4fe519dcb9ef9632b9c83f7f/2020-09-17_15h22_46.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Jan Karger ツ ☀
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IconPacks.Avalonia
2 |
3 | Testbed for planned IconPacks.Avalonia library.
4 |
5 | Inspired by [MahApps.Metro.IconPacks](https://github.com/MahApps/MahApps.Metro.IconPacks)
6 |
7 | https://github.com/user-attachments/assets/196d46bf-98bf-4326-a186-4699ccf8c841
8 |
--------------------------------------------------------------------------------
/avalonia_iconpacks_preview010.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/punker76/MahApps.Avalonia.IconPacks.Testbed/ea758248f4b5b11b4fe519dcb9ef9632b9c83f7f/avalonia_iconpacks_preview010.gif
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "8.0.403",
4 | "rollForward": "feature",
5 | "allowPrerelease": false
6 | }
7 | }
--------------------------------------------------------------------------------
/src/.idea/.idea.AvaloniaIconPacks.TestApp/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /.idea.AvaloniaIconPacks.TestApp.iml
6 | /modules.xml
7 | /projectSettingsUpdater.xml
8 | /contentModel.xml
9 | # Datasource local storage ignored files
10 | /../../../../../../../../../:\Users\jkarger\OneDrive\DevTalks\tests\.idea\.idea.AvaloniaIconPacks.TestApp\.idea/dataSources/
11 | /dataSources.local.xml
12 | # Editor-based HTTP Client requests
13 | /httpRequests/
14 |
--------------------------------------------------------------------------------
/src/.idea/.idea.AvaloniaIconPacks.TestApp/.idea/.name:
--------------------------------------------------------------------------------
1 | AvaloniaIconPacks.TestApp
--------------------------------------------------------------------------------
/src/.idea/.idea.AvaloniaIconPacks.TestApp/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/.idea/.idea.AvaloniaIconPacks.TestApp/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/AvaloniaApp/App.axaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/AvaloniaApp/App.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.Markup.Xaml;
4 |
5 | namespace AvaloniaApp
6 | {
7 | public partial class App : Application
8 | {
9 | public override void Initialize()
10 | {
11 | AvaloniaXamlLoader.Load(this);
12 | }
13 |
14 | public override void OnFrameworkInitializationCompleted()
15 | {
16 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
17 | {
18 | desktop.MainWindow = new MainWindow();
19 | }
20 |
21 | base.OnFrameworkInitializationCompleted();
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/AvaloniaApp/AvaloniaApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0;net6.0
6 | enable
7 | true
8 | app.manifest
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/AvaloniaApp/EnumsExtension.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Data;
2 | using Avalonia.Markup.Xaml.MarkupExtensions;
3 | using Avalonia.Markup.Xaml;
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace AvaloniaApp
8 | {
9 | public class EnumsExtension : MarkupExtension
10 | {
11 | private readonly Type _type;
12 |
13 | public EnumsExtension(Type type) => _type = type;
14 |
15 | public override object ProvideValue(IServiceProvider serviceProvider)
16 | {
17 | var binding = new CompiledBindingExtension()
18 | {
19 | Mode = BindingMode.OneTime,
20 | DataType = typeof(IEnumerable<>).MakeGenericType(_type),
21 | Source = Enum.GetValues(_type)
22 | };
23 | return binding;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/AvaloniaApp/MainWindow.axaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
30 |
31 |
32 |
35 |
36 |
37 |
40 |
41 |
42 |
45 |
46 |
47 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | Horizontal
62 | Vertical
63 | Both
64 | Normal
65 |
66 |
67 |
70 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
104 |
105 |
106 |
116 |
117 |
118 |
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/src/AvaloniaApp/MainWindow.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 |
4 | namespace AvaloniaApp
5 | {
6 | public partial class MainWindow : Window
7 | {
8 | public MainWindow()
9 | {
10 | InitializeComponent();
11 | #if DEBUG
12 | this.AttachDevTools();
13 | #endif
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/AvaloniaApp/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using System;
3 |
4 | namespace AvaloniaApp
5 | {
6 | internal class Program
7 | {
8 | // Initialization code. Don't use any Avalonia, third-party APIs or any
9 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
10 | // yet and stuff might break.
11 | [STAThread]
12 | public static void Main(string[] args) => BuildAvaloniaApp()
13 | .StartWithClassicDesktopLifetime(args);
14 |
15 | // Avalonia configuration, don't remove; also used by visual designer.
16 | public static AppBuilder BuildAvaloniaApp()
17 | => AppBuilder.Configure()
18 | .UsePlatformDetect()
19 | .WithInterFont()
20 | .LogToTrace();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/AvaloniaApp/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/AvaloniaIconPacks.TestApp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.10.34916.146
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaApp", "AvaloniaApp\AvaloniaApp.csproj", "{3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IconPacks.Avalonia.Core", "IconPacks.Avalonia.Core\IconPacks.Avalonia.Core.csproj", "{870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8AA3A5E7-A687-4781-9416-E96489E4C781}"
11 | ProjectSection(SolutionItems) = preProject
12 | ..\.editorconfig = ..\.editorconfig
13 | EndProjectSection
14 | EndProject
15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IconPacks.Avalonia.BoxIcons", "IconPacks.Avalonia.BoxIcons\IconPacks.Avalonia.BoxIcons.csproj", "{0159372E-46AA-4886-B346-4AA74B26D613}"
16 | EndProject
17 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IconPacks.Avalonia", "IconPacks.Avalonia\IconPacks.Avalonia.csproj", "{49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}"
18 | EndProject
19 | Global
20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
21 | Debug|Any CPU = Debug|Any CPU
22 | Debug|x64 = Debug|x64
23 | Debug|x86 = Debug|x86
24 | Release|Any CPU = Release|Any CPU
25 | Release|x64 = Release|x64
26 | Release|x86 = Release|x86
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x64.ActiveCfg = Debug|Any CPU
32 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x64.Build.0 = Debug|Any CPU
33 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x86.ActiveCfg = Debug|Any CPU
34 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Debug|x86.Build.0 = Debug|Any CPU
35 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x64.ActiveCfg = Release|Any CPU
38 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x64.Build.0 = Release|Any CPU
39 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x86.ActiveCfg = Release|Any CPU
40 | {3D1F4877-0B9D-4D2E-BA55-2527FB5F6552}.Release|x86.Build.0 = Release|Any CPU
41 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Debug|x64.ActiveCfg = Debug|Any CPU
44 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Debug|x64.Build.0 = Debug|Any CPU
45 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Debug|x86.ActiveCfg = Debug|Any CPU
46 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Debug|x86.Build.0 = Debug|Any CPU
47 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Release|Any CPU.ActiveCfg = Release|Any CPU
48 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Release|Any CPU.Build.0 = Release|Any CPU
49 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Release|x64.ActiveCfg = Release|Any CPU
50 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Release|x64.Build.0 = Release|Any CPU
51 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Release|x86.ActiveCfg = Release|Any CPU
52 | {870C9AFF-CB82-4A6B-BB0B-7AE19B43A766}.Release|x86.Build.0 = Release|Any CPU
53 | {0159372E-46AA-4886-B346-4AA74B26D613}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {0159372E-46AA-4886-B346-4AA74B26D613}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {0159372E-46AA-4886-B346-4AA74B26D613}.Debug|x64.ActiveCfg = Debug|Any CPU
56 | {0159372E-46AA-4886-B346-4AA74B26D613}.Debug|x64.Build.0 = Debug|Any CPU
57 | {0159372E-46AA-4886-B346-4AA74B26D613}.Debug|x86.ActiveCfg = Debug|Any CPU
58 | {0159372E-46AA-4886-B346-4AA74B26D613}.Debug|x86.Build.0 = Debug|Any CPU
59 | {0159372E-46AA-4886-B346-4AA74B26D613}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 | {0159372E-46AA-4886-B346-4AA74B26D613}.Release|Any CPU.Build.0 = Release|Any CPU
61 | {0159372E-46AA-4886-B346-4AA74B26D613}.Release|x64.ActiveCfg = Release|Any CPU
62 | {0159372E-46AA-4886-B346-4AA74B26D613}.Release|x64.Build.0 = Release|Any CPU
63 | {0159372E-46AA-4886-B346-4AA74B26D613}.Release|x86.ActiveCfg = Release|Any CPU
64 | {0159372E-46AA-4886-B346-4AA74B26D613}.Release|x86.Build.0 = Release|Any CPU
65 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Debug|Any CPU.Build.0 = Debug|Any CPU
67 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Debug|x64.ActiveCfg = Debug|Any CPU
68 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Debug|x64.Build.0 = Debug|Any CPU
69 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Debug|x86.ActiveCfg = Debug|Any CPU
70 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Debug|x86.Build.0 = Debug|Any CPU
71 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Release|Any CPU.ActiveCfg = Release|Any CPU
72 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Release|Any CPU.Build.0 = Release|Any CPU
73 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Release|x64.ActiveCfg = Release|Any CPU
74 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Release|x64.Build.0 = Release|Any CPU
75 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Release|x86.ActiveCfg = Release|Any CPU
76 | {49ECE319-789D-4A0C-9CAF-D79CF6BFEB48}.Release|x86.Build.0 = Release|Any CPU
77 | EndGlobalSection
78 | GlobalSection(SolutionProperties) = preSolution
79 | HideSolutionNode = FALSE
80 | EndGlobalSection
81 | GlobalSection(ExtensibilityGlobals) = postSolution
82 | SolutionGuid = {E6ECA210-1B2F-4011-A34A-7E9D2CC4721F}
83 | EndGlobalSection
84 | EndGlobal
85 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/BoxIcons.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/Converter/PackIconBoxIconsKindToImageConverter.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Media;
2 |
3 | namespace IconPacks.Avalonia.Converter
4 | {
5 | public class PackIconBoxIconsKindToImageConverter : PackIconKindToImageConverterBase
6 | {
7 | ///
8 | protected override string GetPathData(object iconKind)
9 | {
10 | string data = null;
11 | if (iconKind is PackIconBoxIconsKind kind)
12 | {
13 | PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
14 | }
15 |
16 | return data;
17 | }
18 |
19 | ///
20 | protected override ScaleTransform GetScaleTransform(object iconKind)
21 | {
22 | return new ScaleTransform(1, -1);
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/IconPacks.Avalonia.BoxIcons.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0;net6.0;netstandard2.0
5 | $(DefineConstants);AVALONIA
6 | latest
7 | latest
8 | true
9 | disable
10 | true
11 |
12 |
13 |
14 | $(DefineConstants);BOXICONS
15 | BoxIcons
16 | IconPacks.Avalonia.BoxIcons
17 | IconPacks.Avalonia.BoxIcons
18 | IconPacks.Avalonia
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Resources\%(RecursiveDir)%(FileName)%(Extension)
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/PackIconBoxIcons.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Media;
3 | using IconPacks.Avalonia.Attributes;
4 |
5 | namespace IconPacks.Avalonia
6 | {
7 | ///
8 | /// BoxIcons licensed under [SIL OFL 1.1](http://scripts.sil.org/OFL)
9 | /// Contributions, corrections and requests can be made on GitHub https://github.com/atisawd/boxicons.
10 | ///
11 | [MetaData("Boxicons", "https://boxicons.com/", "https://boxicons.com/usage/#license")]
12 | public class PackIconBoxIcons : PackIconControlBase
13 | {
14 | public PackIconBoxIcons()
15 | {
16 | base.UpdateIconPseudoClasses(true, false, true);
17 | }
18 |
19 | public static readonly StyledProperty KindProperty
20 | = AvaloniaProperty.Register(nameof(Kind));
21 |
22 | ///
23 | /// Gets or sets the icon to display.
24 | ///
25 | public PackIconBoxIconsKind Kind
26 | {
27 | get { return GetValue(KindProperty); }
28 | set { SetValue(KindProperty, value); }
29 | }
30 |
31 | // We override OnPropertyChanged of the base class. That way we can react on property changes
32 | protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
33 | {
34 | base.OnPropertyChanged(change);
35 |
36 | // if the changed property is the KindProperty, we need to update the stars
37 | if (change.Property == KindProperty)
38 | {
39 | UpdateData();
40 | }
41 | }
42 |
43 | protected override void SetKind(TKind iconKind)
44 | {
45 | this.SetCurrentValue(KindProperty, iconKind);
46 | }
47 |
48 | protected override void UpdateData()
49 | {
50 | if (Kind != default)
51 | {
52 | string data = null;
53 | PackIconDataFactory.DataIndex.Value?.TryGetValue(Kind, out data);
54 | this.Data = data != null ? StreamGeometry.Parse(data) : null;
55 | }
56 | else
57 | {
58 | this.Data = null;
59 | }
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/PackIconBoxIcons.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
17 |
18 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/PackIconBoxIconsExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace IconPacks.Avalonia
5 | {
6 | public class BoxIconsExtension : BasePackIconExtension
7 | {
8 | public BoxIconsExtension()
9 | {
10 | }
11 |
12 | public BoxIconsExtension(PackIconBoxIconsKind kind)
13 | {
14 | this.Kind = kind;
15 | }
16 |
17 | [ConstructorArgument("kind")] public PackIconBoxIconsKind Kind { get; set; }
18 |
19 | public override object ProvideValue(IServiceProvider serviceProvider)
20 | {
21 | return this.GetPackIcon(this.Kind);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/PackIconBoxIconsImageExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Markup.Xaml;
3 | using Avalonia.Media;
4 |
5 | namespace IconPacks.Avalonia
6 | {
7 | public class BoxIconsImageExtension : BasePackIconImageExtension
8 | {
9 | public BoxIconsImageExtension()
10 | {
11 | }
12 |
13 | public BoxIconsImageExtension(PackIconBoxIconsKind kind)
14 | {
15 | this.Kind = kind;
16 | }
17 |
18 | [ConstructorArgument("kind")] public PackIconBoxIconsKind Kind { get; set; }
19 |
20 | public override object ProvideValue(IServiceProvider serviceProvider)
21 | {
22 | return CreateImageSource(this.Kind, this.Brush ?? Brushes.Black);
23 | }
24 |
25 | ///
26 | protected override string GetPathData(object iconKind)
27 | {
28 | string data = null;
29 | if (iconKind is PackIconBoxIconsKind kind)
30 | {
31 | PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
32 | }
33 |
34 | return data;
35 | }
36 |
37 | ///
38 | protected override ScaleTransform GetScaleTransform(object iconKind)
39 | {
40 | return new ScaleTransform(1, -1);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.BoxIcons/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using Avalonia.Metadata;
3 |
4 | [assembly: XmlnsPrefix("urn:iconpacks-avalonia", "iconPacks")]
5 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks")]
6 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks.Avalonia")]
7 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks.Avalonia.Converter")]
8 |
9 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/Attributes/MetaDataAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace IconPacks.Avalonia.Attributes
4 | {
5 | ///
6 | /// Specifies meta data for a class.
7 | ///
8 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
9 | public sealed class MetaDataAttribute : Attribute
10 | {
11 | public MetaDataAttribute()
12 | {
13 | }
14 |
15 | public MetaDataAttribute(string name, string projectUrl, string licenseUrl)
16 | {
17 | Name = name;
18 | ProjectUrl = projectUrl;
19 | LicenseUrl = licenseUrl;
20 | }
21 |
22 | public string Name { get; }
23 |
24 | public string ProjectUrl { get; }
25 |
26 | public string LicenseUrl { get; }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/Converter/MarkupConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Data.Converters;
3 | using Avalonia.Markup.Xaml;
4 | using System.Globalization;
5 | using Avalonia.Data;
6 |
7 | namespace IconPacks.Avalonia.Converter
8 | {
9 | ///
10 | /// MarkupConverter is a MarkupExtension which can be used for IValueConverter.
11 | ///
12 | public abstract class MarkupConverter : MarkupExtension, IValueConverter
13 | {
14 | ///
15 | public override object ProvideValue(IServiceProvider serviceProvider)
16 | {
17 | return this;
18 | }
19 |
20 | ///
21 | /// Converts a value.
22 | ///
23 | /// The value to convert.
24 | /// The type of the target.
25 | /// A user-defined parameter.
26 | /// The culture to use.
27 | /// The converted value.
28 | ///
29 | /// This method should not throw exceptions. If the value is not convertible, return
30 | /// a in an error state. Any exceptions thrown will be
31 | /// treated as an application exception.
32 | ///
33 | protected abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);
34 |
35 | ///
36 | /// Converts a value.
37 | ///
38 | /// The value to convert.
39 | /// The type of the target.
40 | /// A user-defined parameter.
41 | /// The culture to use.
42 | /// The converted value.
43 | ///
44 | /// This method should not throw exceptions. If the value is not convertible, return
45 | /// a in an error state. Any exceptions thrown will be
46 | /// treated as an application exception.
47 | ///
48 | protected abstract object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);
49 |
50 | ///
51 | object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
52 | {
53 | try
54 | {
55 | return Convert(value, targetType, parameter, culture);
56 | }
57 | catch
58 | {
59 | return BindingOperations.DoNothing;
60 | }
61 | }
62 |
63 | ///
64 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
65 | {
66 | try
67 | {
68 | return ConvertBack(value, targetType, parameter, culture);
69 | }
70 | catch
71 | {
72 | return BindingOperations.DoNothing;
73 | }
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/Converter/PackIconKindToImageConverterBase.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Media;
2 | using System.Globalization;
3 | using System;
4 | using Avalonia.Data;
5 |
6 | namespace IconPacks.Avalonia.Converter
7 | {
8 | public abstract class PackIconKindToImageConverterBase : MarkupConverter
9 | {
10 | ///
11 | /// Gets or sets the brush to draw the icon.
12 | ///
13 | public IBrush Brush { get; set; } = Brushes.Black;
14 |
15 | ///
16 | /// Gets or sets the flip orientation for the icon.
17 | ///
18 | public PackIconFlipOrientation Flip { get; set; } = PackIconFlipOrientation.Normal;
19 |
20 | ///
21 | /// Gets or sets the rotation (angle) for the icon.
22 | ///
23 | public double RotationAngle { get; set; } = 0d;
24 |
25 | ///
26 | /// Gets the path data for the given kind.
27 | ///
28 | protected abstract string GetPathData(object iconKind);
29 |
30 | ///
31 | /// Gets the ScaleTransform for the given kind.
32 | ///
33 | /// The icon kind to draw.
34 | protected virtual ScaleTransform GetScaleTransform(object iconKind)
35 | {
36 | return new ScaleTransform(1, 1);
37 | }
38 |
39 | ///
40 | /// Gets the for the .
41 | ///
42 | /// The icon kind to draw.
43 | protected Transform GetTransformGroup(object iconKind)
44 | {
45 | var transformGroup = new TransformGroup();
46 | transformGroup.Children.Add(this.GetScaleTransform(iconKind)); // scale
47 | transformGroup.Children.Add(new ScaleTransform(
48 | this.Flip is PackIconFlipOrientation.Horizontal or PackIconFlipOrientation.Both ? -1 : 1,
49 | this.Flip is PackIconFlipOrientation.Vertical or PackIconFlipOrientation.Both ? -1 : 1
50 | )); // flip
51 | transformGroup.Children.Add(new RotateTransform(this.RotationAngle)); // rotate
52 |
53 | return transformGroup;
54 | }
55 |
56 | ///
57 | /// Gets the object that will be used for the .
58 | ///
59 | protected virtual DrawingGroup GetDrawingGroup(object iconKind, IBrush foregroundBrush, string path)
60 | {
61 | var geometryDrawing = new GeometryDrawing
62 | {
63 | Geometry = StreamGeometry.Parse(path),
64 | Brush = foregroundBrush
65 | };
66 |
67 | var drawingGroup = new DrawingGroup
68 | {
69 | Children = { geometryDrawing },
70 | Transform = this.GetTransformGroup(iconKind)
71 | };
72 |
73 | return drawingGroup;
74 | }
75 |
76 | ///
77 | /// Gets the ImageSource for the given kind.
78 | ///
79 | protected IImage CreateImageSource(object iconKind, IBrush foregroundBrush)
80 | {
81 | var path = this.GetPathData(iconKind);
82 |
83 | if (string.IsNullOrEmpty(path))
84 | {
85 | return null;
86 | }
87 |
88 | var drawingImage = new DrawingImage(GetDrawingGroup(iconKind, foregroundBrush, path));
89 | return drawingImage;
90 | }
91 |
92 | ///
93 | protected override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
94 | {
95 | return value is not Enum
96 | ? null
97 | : CreateImageSource(value, parameter as IBrush ?? this.Brush ?? Brushes.Black);
98 | }
99 |
100 | ///
101 | protected override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
102 | {
103 | throw new NotSupportedException("Two way bindings are not supported with an image");
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0;net6.0;netstandard2.0
5 | $(DefineConstants);AVALONIA
6 | latest
7 | latest
8 | true
9 | disable
10 | true
11 |
12 |
13 |
14 | IconPacks.Avalonia.Core
15 | IconPacks.Avalonia.Core
16 | IconPacks.Avalonia
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIcon.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIconBase.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace IconPacks.Avalonia
4 | {
5 | public abstract class PackIconBase : PathIcon
6 | {
7 | protected internal abstract void SetKind(TKind iconKind);
8 | protected abstract void UpdateData();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIconControlBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Avalonia;
4 | using Avalonia.Animation;
5 | using Avalonia.Animation.Easings;
6 | using Avalonia.Controls;
7 | using Avalonia.Controls.Metadata;
8 | using Avalonia.Controls.Primitives;
9 | using Avalonia.Data;
10 | using Avalonia.Media;
11 | using Avalonia.Styling;
12 |
13 | namespace IconPacks.Avalonia
14 | {
15 | ///
16 | /// Class PackIconControlBase which is the base class for any PackIcon control.
17 | ///
18 | [PseudoClasses(IconDataFlippedVerticallyPseudoClass)]
19 | [PseudoClasses(IconFilledPseudoClass)]
20 | [PseudoClasses(IconOutlinedPseudoClass)]
21 | public abstract class PackIconControlBase : PackIconBase
22 | {
23 | ///
24 | /// A string representing the pseudo-class when the icon data is flipped vertically
25 | ///
26 | /// ":icon-data-flipped-vertically"
27 | public const string IconDataFlippedVerticallyPseudoClass = ":icon-data-flipped-vertically";
28 |
29 | ///
30 | /// A string representing the pseudo-class when the icon data is drawn filled
31 | ///
32 | /// ":icon-filled"
33 | public const string IconFilledPseudoClass = ":icon-filled";
34 |
35 | ///
36 | /// A string representing the pseudo-class when the icon data is drawn outlined
37 | ///
38 | /// ":icon-outlined"
39 | public const string IconOutlinedPseudoClass = ":icon-outlined";
40 |
41 | protected PackIconControlBase()
42 | {
43 | AffectsRender(SpinProperty, SpinDurationProperty, OpacityProperty, SpinEasingFunctionProperty, FlipProperty, RotationAngleProperty);
44 | }
45 |
46 | private bool CanSpin()
47 | {
48 | return this.Spin
49 | && this.IsVisible
50 | && this.SpinDuration > 0
51 | && this.Opacity > 0
52 | && this.SpinEasingFunction != null;
53 | }
54 |
55 | private Grid innerGrid;
56 | private ScaleTransform scaleTransform;
57 | private RotateTransform rotateTransform;
58 |
59 | ///
60 | protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
61 | {
62 | base.OnApplyTemplate(e);
63 |
64 | this.innerGrid = e.NameScope.Find("PART_InnerGrid");
65 |
66 | if (this.innerGrid != null)
67 | {
68 | var transformGroup = new TransformGroup();
69 | this.scaleTransform = new ScaleTransform();
70 | this.rotateTransform = new RotateTransform();
71 | transformGroup.Children.Add(scaleTransform);
72 | transformGroup.Children.Add(rotateTransform);
73 | this.innerGrid.RenderTransform = transformGroup;
74 | }
75 |
76 | this.UpdateScaleTransformation(this.Flip);
77 | this.UpdateRotateTransformation(this.RotationAngle);
78 | this.UpdateData();
79 |
80 | var spin = CanSpin();
81 | if (spin)
82 | {
83 | this.StopSpinAnimation();
84 | this.BeginSpinAnimation();
85 | }
86 | }
87 |
88 | protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
89 | {
90 | base.OnPropertyChanged(change);
91 |
92 | if (change.Property == FlipProperty)
93 | {
94 | if (change.NewValue != null && change.NewValue != change.OldValue)
95 | {
96 | this.UpdateScaleTransformation(change.GetNewValue());
97 | }
98 | }
99 | else if (change.Property == RotationAngleProperty)
100 | {
101 | if (change.NewValue != null && change.NewValue != change.OldValue)
102 | {
103 | this.UpdateRotateTransformation(change.GetNewValue());
104 | }
105 | }
106 |
107 | // Update Spin-Animation as needed
108 | if (change.Property == SpinProperty
109 | || change.Property == IsVisibleProperty
110 | || change.Property == SpinDurationProperty
111 | || change.Property == OpacityProperty
112 | || change.Property == SpinEasingFunctionProperty)
113 | {
114 | this.StopSpinAnimation();
115 |
116 | if (this.CanSpin())
117 | {
118 | this.BeginSpinAnimation();
119 | }
120 | }
121 | }
122 |
123 | private void UpdateScaleTransformation(PackIconFlipOrientation flipOrientation)
124 | {
125 | if (this.scaleTransform != null)
126 | {
127 | var scaleX = flipOrientation is PackIconFlipOrientation.Horizontal or PackIconFlipOrientation.Both
128 | ? -1
129 | : 1;
130 | var scaleY = flipOrientation is PackIconFlipOrientation.Vertical or PackIconFlipOrientation.Both
131 | ? -1
132 | : 1;
133 | this.scaleTransform.ScaleX = scaleX;
134 | this.scaleTransform.ScaleY = scaleY;
135 | }
136 | }
137 |
138 | private void UpdateRotateTransformation(double angle)
139 | {
140 | if (this.rotateTransform != null)
141 | {
142 | this.rotateTransform.Angle = angle;
143 | }
144 | }
145 |
146 | ///
147 | /// Identifies the Flip dependency property.
148 | ///
149 | public static readonly StyledProperty FlipProperty
150 | = AvaloniaProperty.Register(nameof(Flip));
151 |
152 | ///
153 | /// Gets or sets the flip orientation.
154 | ///
155 | public PackIconFlipOrientation Flip
156 | {
157 | get { return this.GetValue(FlipProperty); }
158 | set { this.SetValue(FlipProperty, value); }
159 | }
160 |
161 | ///
162 | /// Identifies the RotationAngle dependency property.
163 | ///
164 | public static readonly StyledProperty RotationAngleProperty
165 | = AvaloniaProperty.Register(
166 | nameof(RotationAngle),
167 | 0d,
168 | false,
169 | BindingMode.OneWay,
170 | null,
171 | (packIcon, value) =>
172 | {
173 | if (value < 0)
174 | {
175 | return 0d;
176 | }
177 |
178 | return value > 360 ? 360d : value;
179 | });
180 |
181 | ///
182 | /// Gets or sets the rotation (angle).
183 | ///
184 | /// The rotation.
185 | public double RotationAngle
186 | {
187 | get { return this.GetValue(RotationAngleProperty); }
188 | set { this.SetValue(RotationAngleProperty, value); }
189 | }
190 |
191 | ///
192 | /// Identifies the Spin dependency property.
193 | ///
194 | public static readonly StyledProperty SpinProperty
195 | = AvaloniaProperty.Register(nameof(Spin));
196 |
197 | ///
198 | /// Gets or sets a value indicating whether the inner icon is spinning.
199 | ///
200 | /// true if spin; otherwise, false.
201 | public bool Spin
202 | {
203 | get { return this.GetValue(SpinProperty); }
204 | set { this.SetValue(SpinProperty, value); }
205 | }
206 |
207 | private Animation spinAnimation = null;
208 | private Task spinAnimationTask = null;
209 |
210 | private void BeginSpinAnimation()
211 | {
212 | if (this.innerGrid is null)
213 | {
214 | return;
215 | }
216 |
217 | var animation = spinAnimation ?? new Animation
218 | {
219 | Children =
220 | {
221 | new KeyFrame()
222 | {
223 | Cue = new Cue(0),
224 | Setters = { new Setter(RotateTransform.AngleProperty, 0d) }
225 | },
226 | new KeyFrame()
227 | {
228 | Cue = new Cue(1),
229 | Setters = { new Setter(RotateTransform.AngleProperty, 360d) }
230 | }
231 | }
232 | };
233 |
234 | animation.Duration = TimeSpan.FromSeconds(this.SpinDuration);
235 | animation.Easing = this.SpinEasingFunction;
236 | animation.IterationCount = IterationCount.Infinite;
237 | this.spinAnimation = animation;
238 | this.spinAnimationTask = animation.RunAsync(this.innerGrid);
239 | }
240 |
241 | private void StopSpinAnimation()
242 | {
243 | if (this.spinAnimation != null)
244 | {
245 | this.spinAnimation.IterationCount = new IterationCount(0);
246 | this.spinAnimationTask?.Dispose();
247 | this.spinAnimationTask = null;
248 | }
249 | }
250 |
251 | ///
252 | /// Identifies the SpinDuration dependency property.
253 | ///
254 | public static readonly StyledProperty SpinDurationProperty
255 | = AvaloniaProperty.Register(
256 | nameof(SpinDuration),
257 | 1d,
258 | false,
259 | BindingMode.OneWay,
260 | null,
261 | (iconPack, value) => value < 0 ? 0d : value);
262 |
263 | ///
264 | /// Gets or sets the duration of the spinning animation (in seconds). This will also restart the spin animation.
265 | ///
266 | /// The duration of the spin in seconds.
267 | public double SpinDuration
268 | {
269 | get { return this.GetValue(SpinDurationProperty); }
270 | set { this.SetValue(SpinDurationProperty, value); }
271 | }
272 |
273 | ///
274 | /// Identifies the SpinEasingFunction dependency property.
275 | ///
276 | public static readonly StyledProperty SpinEasingFunctionProperty
277 | = AvaloniaProperty.Register(
278 | nameof(SpinEasingFunction),
279 | new LinearEasing());
280 |
281 | ///
282 | /// Gets or sets the EasingFunction of the spinning animation. This will also restart the spin animation.
283 | ///
284 | /// The spin easing function.
285 | public Easing SpinEasingFunction
286 | {
287 | get { return this.GetValue(SpinEasingFunctionProperty); }
288 | set { this.SetValue(SpinEasingFunctionProperty, value); }
289 | }
290 |
291 | public static readonly StyledProperty SpinAutoReverseProperty
292 | = AvaloniaProperty.Register(nameof(SpinAutoReverse));
293 |
294 | ///
295 | /// Gets or sets the AutoReverse of the spinning animation. This will also restart the spin animation.
296 | ///
297 | /// true if [spin automatic reverse]; otherwise, false.
298 | public bool SpinAutoReverse
299 | {
300 | get { return this.GetValue(SpinAutoReverseProperty); }
301 | set { this.SetValue(SpinAutoReverseProperty, value); }
302 | }
303 |
304 | protected void UpdateIconPseudoClasses(bool filled, bool outlined, bool flipped)
305 | {
306 | PseudoClasses.Set(IconFilledPseudoClass, filled);
307 | PseudoClasses.Set(IconOutlinedPseudoClass, outlined);
308 | PseudoClasses.Set(IconDataFlippedVerticallyPseudoClass, flipped);
309 | }
310 | }
311 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIconControlBase.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
13 |
14 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
40 |
41 |
42 |
50 |
51 |
52 |
55 |
56 |
57 |
60 |
61 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIconDataFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using Avalonia.Platform;
5 |
6 | namespace IconPacks.Avalonia
7 | {
8 | public static class PackIconDataFactory where TEnum : struct, Enum
9 | {
10 | public static Lazy> DataIndex { get; }
11 |
12 | static PackIconDataFactory()
13 | {
14 | DataIndex = new Lazy>(Create);
15 | }
16 |
17 | public static IDictionary Create()
18 | {
19 | using var iconJsonStream = AssetLoader.Open(new Uri($"avares://{typeof(TEnum).Assembly.GetName().Name}/Resources/Icons.json"));
20 | #pragma warning disable IL2026
21 | return new ReadOnlyDictionary(System.Text.Json.JsonSerializer.Deserialize>(iconJsonStream) ?? new Dictionary());
22 | #pragma warning restore IL2026
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIconExtension.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Animation.Easings;
2 | using System;
3 | using Avalonia.Markup.Xaml;
4 |
5 | namespace IconPacks.Avalonia
6 | {
7 | public interface IPackIconExtension
8 | {
9 | double Width { get; set; }
10 | double Height { get; set; }
11 | PackIconFlipOrientation Flip { get; set; }
12 | double RotationAngle { get; set; }
13 | bool Spin { get; set; }
14 | bool SpinAutoReverse { get; set; }
15 | Easing SpinEasingFunction { get; set; }
16 | double SpinDuration { get; set; }
17 | }
18 |
19 | public static class PackIconExtensionHelper
20 | {
21 | public static PackIconControlBase GetPackIcon(this IPackIconExtension packIconExtension, TKind kind) where TPack : PackIconControlBase, new()
22 | {
23 | var packIcon = new TPack();
24 | packIcon.SetKind(kind);
25 |
26 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.Width))
27 | {
28 | packIcon.Width = packIconExtension.Width;
29 | }
30 |
31 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.Height))
32 | {
33 | packIcon.Height = packIconExtension.Height;
34 | }
35 |
36 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.Flip))
37 | {
38 | packIcon.Flip = packIconExtension.Flip;
39 | }
40 |
41 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.RotationAngle))
42 | {
43 | packIcon.RotationAngle = packIconExtension.RotationAngle;
44 | }
45 |
46 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.Spin))
47 | {
48 | packIcon.Spin = packIconExtension.Spin;
49 | }
50 |
51 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.SpinAutoReverse))
52 | {
53 | packIcon.SpinAutoReverse = packIconExtension.SpinAutoReverse;
54 | }
55 |
56 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.SpinEasingFunction))
57 | {
58 | packIcon.SpinEasingFunction = packIconExtension.SpinEasingFunction;
59 | }
60 |
61 | if (((BasePackIconExtension)packIconExtension).IsFieldChanged(BasePackIconExtension.ChangedFieldFlags.SpinDuration))
62 | {
63 | packIcon.SpinDuration = packIconExtension.SpinDuration;
64 | }
65 |
66 | return packIcon;
67 | }
68 | }
69 |
70 | public abstract class BasePackIconExtension : MarkupExtension, IPackIconExtension
71 | {
72 | private double _width = 20d;
73 |
74 | public double Width
75 | {
76 | get => _width;
77 | set
78 | {
79 | if (Equals(_width, value))
80 | {
81 | return;
82 | }
83 |
84 | _width = value;
85 | WriteFieldChangedFlag(ChangedFieldFlags.Width, true);
86 | }
87 | }
88 |
89 | private double _height = 20d;
90 |
91 | public double Height
92 | {
93 | get => _height;
94 | set
95 | {
96 | if (Equals(_height, value))
97 | {
98 | return;
99 | }
100 |
101 | _height = value;
102 | WriteFieldChangedFlag(ChangedFieldFlags.Height, true);
103 | }
104 | }
105 |
106 | private PackIconFlipOrientation _flip = PackIconFlipOrientation.Normal;
107 |
108 | public PackIconFlipOrientation Flip
109 | {
110 | get => _flip;
111 | set
112 | {
113 | if (Equals(_flip, value))
114 | {
115 | return;
116 | }
117 |
118 | _flip = value;
119 | WriteFieldChangedFlag(ChangedFieldFlags.Flip, true);
120 | }
121 | }
122 |
123 | private double _rotationAngle = 0d;
124 |
125 | public double RotationAngle
126 | {
127 | get => _rotationAngle;
128 | set
129 | {
130 | if (Equals(_rotationAngle, value))
131 | {
132 | return;
133 | }
134 |
135 | _rotationAngle = value;
136 | WriteFieldChangedFlag(ChangedFieldFlags.RotationAngle, true);
137 | }
138 | }
139 |
140 | private bool _spin;
141 |
142 | public bool Spin
143 | {
144 | get => _spin;
145 | set
146 | {
147 | if (Equals(_spin, value))
148 | {
149 | return;
150 | }
151 |
152 | _spin = value;
153 | WriteFieldChangedFlag(ChangedFieldFlags.Spin, true);
154 | }
155 | }
156 |
157 | private bool _spinAutoReverse;
158 |
159 | public bool SpinAutoReverse
160 | {
161 | get => _spinAutoReverse;
162 | set
163 | {
164 | if (Equals(_spinAutoReverse, value))
165 | {
166 | return;
167 | }
168 |
169 | _spinAutoReverse = value;
170 | WriteFieldChangedFlag(ChangedFieldFlags.SpinAutoReverse, true);
171 | }
172 | }
173 |
174 | private Easing _spinEasingFunction = null;
175 |
176 | public Easing SpinEasingFunction
177 | {
178 | get => _spinEasingFunction;
179 | set
180 | {
181 | if (Equals(_spinEasingFunction, value))
182 | {
183 | return;
184 | }
185 |
186 | _spinEasingFunction = value;
187 | WriteFieldChangedFlag(ChangedFieldFlags.SpinEasingFunction, true);
188 | }
189 | }
190 |
191 | private double _spinDuration = 1d;
192 |
193 | public double SpinDuration
194 | {
195 | get => _spinDuration;
196 | set
197 | {
198 | if (Equals(_spinDuration, value))
199 | {
200 | return;
201 | }
202 |
203 | _spinDuration = value;
204 | WriteFieldChangedFlag(ChangedFieldFlags.SpinDuration, true);
205 | }
206 | }
207 |
208 | internal ChangedFieldFlags changedField; // Cache changed field bits
209 |
210 | internal bool IsFieldChanged(ChangedFieldFlags reqFlag)
211 | {
212 | return (changedField & reqFlag) != 0;
213 | }
214 |
215 | internal void WriteFieldChangedFlag(ChangedFieldFlags reqFlag, bool set)
216 | {
217 | if (set)
218 | {
219 | changedField |= reqFlag;
220 | }
221 | else
222 | {
223 | changedField &= (~reqFlag);
224 | }
225 | }
226 |
227 | [Flags]
228 | internal enum ChangedFieldFlags : ushort
229 | {
230 | Width = 0x0001,
231 | Height = 0x0002,
232 | Flip = 0x0004,
233 | RotationAngle = 0x0008,
234 | Spin = 0x0010,
235 | SpinAutoReverse = 0x0020,
236 | SpinEasingFunction = 0x0040,
237 | SpinDuration = 0x0080
238 | }
239 | }
240 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIconFlipOrientation.cs:
--------------------------------------------------------------------------------
1 | namespace IconPacks.Avalonia
2 | {
3 | ///
4 | /// Enum PackIconFlipOrientation for the Flip property of any PackIcon control.
5 | ///
6 | public enum PackIconFlipOrientation
7 | {
8 | ///
9 | /// No flip
10 | ///
11 | Normal,
12 |
13 | ///
14 | /// Flip the icon horizontal
15 | ///
16 | Horizontal,
17 |
18 | ///
19 | /// Flip the icon vertical
20 | ///
21 | Vertical,
22 |
23 | ///
24 | /// Flip the icon vertical and horizontal
25 | ///
26 | Both
27 | }
28 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/PackIconImageExtension.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Markup.Xaml;
2 | using Avalonia.Media;
3 |
4 | namespace IconPacks.Avalonia
5 | {
6 | public abstract class BasePackIconImageExtension : MarkupExtension
7 | {
8 | ///
9 | /// Gets or sets the brush to draw the icon.
10 | ///
11 | public IBrush Brush { get; set; } = Brushes.Black;
12 |
13 | ///
14 | /// Gets or sets the flip orientation for the icon.
15 | ///
16 | public PackIconFlipOrientation Flip { get; set; } = PackIconFlipOrientation.Normal;
17 |
18 | ///
19 | /// Gets or sets the rotation (angle) for the icon.
20 | ///
21 | public double RotationAngle { get; set; } = 0d;
22 |
23 | ///
24 | /// Gets the path data for the given kind.
25 | ///
26 | protected abstract string GetPathData(object iconKind);
27 |
28 | ///
29 | /// Gets the ScaleTransform for the given kind.
30 | ///
31 | /// The icon kind to draw.
32 | protected virtual ScaleTransform GetScaleTransform(object iconKind)
33 | {
34 | return new ScaleTransform(1, 1);
35 | }
36 |
37 | ///
38 | /// Gets the for the .
39 | ///
40 | /// The icon kind to draw.
41 | protected Transform GetTransformGroup(object iconKind)
42 | {
43 | var transformGroup = new TransformGroup();
44 | transformGroup.Children.Add(this.GetScaleTransform(iconKind)); // scale
45 | transformGroup.Children.Add(new ScaleTransform(
46 | this.Flip is PackIconFlipOrientation.Horizontal or PackIconFlipOrientation.Both ? -1 : 1,
47 | this.Flip is PackIconFlipOrientation.Vertical or PackIconFlipOrientation.Both ? -1 : 1
48 | )); // flip
49 | transformGroup.Children.Add(new RotateTransform(this.RotationAngle)); // rotate
50 |
51 | return transformGroup;
52 | }
53 |
54 | ///
55 | /// Gets the object that will be used for the .
56 | ///
57 | protected virtual DrawingGroup GetDrawingGroup(object iconKind, IBrush foregroundBrush, string path)
58 | {
59 | var geometryDrawing = new GeometryDrawing
60 | {
61 | Geometry = StreamGeometry.Parse(path),
62 | Brush = foregroundBrush
63 | };
64 |
65 | var drawingGroup = new DrawingGroup
66 | {
67 | Children = { geometryDrawing },
68 | Transform = this.GetTransformGroup(iconKind)
69 | };
70 |
71 | return drawingGroup;
72 | }
73 |
74 | ///
75 | /// Gets the ImageSource for the given kind.
76 | ///
77 | protected IImage CreateImageSource(object iconKind, IBrush foregroundBrush)
78 | {
79 | var path = this.GetPathData(iconKind);
80 |
81 | if (string.IsNullOrEmpty(path))
82 | {
83 | return null;
84 | }
85 |
86 | var drawingImage = new DrawingImage(GetDrawingGroup(iconKind, foregroundBrush, path));
87 | return drawingImage;
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using Avalonia.Metadata;
3 |
4 | [assembly: XmlnsPrefix("urn:iconpacks-avalonia", "iconPacks")]
5 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks")]
6 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks.Avalonia")]
7 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks.Avalonia.Attributes")]
8 |
9 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/Converter/PackIconKindToImageConverter.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Media;
2 |
3 | namespace IconPacks.Avalonia.Converter
4 | {
5 | public class PackIconKindToImageConverter : PackIconKindToImageConverterBase
6 | {
7 | ///
8 | protected override string GetPathData(object iconKind)
9 | {
10 | string data = null;
11 | switch (iconKind)
12 | {
13 | // case PackIconBootstrapIconsKind kind:
14 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
15 | // return data;
16 | case PackIconBoxIconsKind kind:
17 | PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
18 | return data;
19 | // case PackIconCircumIconsKind kind:
20 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
21 | // return data;
22 | // case PackIconCodiconsKind kind:
23 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
24 | // return data;
25 | // case PackIconCooliconsKind kind:
26 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
27 | // return data;
28 | // case PackIconEntypoKind kind:
29 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
30 | // return data;
31 | // case PackIconEvaIconsKind kind:
32 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
33 | // return data;
34 | // case PackIconFeatherIconsKind kind:
35 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
36 | // return data;
37 | // case PackIconFileIconsKind kind:
38 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
39 | // return data;
40 | // case PackIconFontaudioKind kind:
41 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
42 | // return data;
43 | // case PackIconFontAwesomeKind kind:
44 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
45 | // return data;
46 | // case PackIconFontistoKind kind:
47 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
48 | // return data;
49 | // case PackIconForkAwesomeKind kind:
50 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
51 | // return data;
52 | // case PackIconGameIconsKind kind:
53 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
54 | // return data;
55 | // case PackIconIoniconsKind kind:
56 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
57 | // return data;
58 | // case PackIconJamIconsKind kind:
59 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
60 | // return data;
61 | // case PackIconLucideKind kind:
62 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
63 | // return data;
64 | // case PackIconMaterialKind kind:
65 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
66 | // return data;
67 | // case PackIconMaterialLightKind kind:
68 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
69 | // return data;
70 | // case PackIconMaterialDesignKind kind:
71 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
72 | // return data;
73 | // case PackIconMemoryIconsKind kind:
74 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
75 | // return data;
76 | // case PackIconMicronsKind kind:
77 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
78 | // return data;
79 | // case PackIconModernKind kind:
80 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
81 | // return data;
82 | // case PackIconOcticonsKind kind:
83 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
84 | // return data;
85 | // case PackIconPhosphorIconsKind kind:
86 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
87 | // return data;
88 | // case PackIconPicolIconsKind kind:
89 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
90 | // return data;
91 | // case PackIconPixelartIconsKind kind:
92 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
93 | // return data;
94 | // case PackIconRadixIconsKind kind:
95 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
96 | // return data;
97 | // case PackIconRemixIconKind kind:
98 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
99 | // return data;
100 | // case PackIconRPGAwesomeKind kind:
101 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
102 | // return data;
103 | // case PackIconSimpleIconsKind kind:
104 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
105 | // return data;
106 | // case PackIconTypiconsKind kind:
107 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
108 | // return data;
109 | // case PackIconUniconsKind kind:
110 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
111 | // return data;
112 | // case PackIconVaadinIconsKind kind:
113 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
114 | // return data;
115 | // case PackIconWeatherIconsKind kind:
116 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
117 | // return data;
118 | // case PackIconZondiconsKind kind:
119 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
120 | // return data;
121 | default:
122 | return null;
123 | }
124 | }
125 |
126 | ///
127 | protected override ScaleTransform GetScaleTransform(object iconKind)
128 | {
129 | switch (iconKind)
130 | {
131 | // case PackIconBootstrapIconsKind _:
132 | case PackIconBoxIconsKind _:
133 | // case PackIconCodiconsKind _:
134 | // case PackIconCooliconsKind _:
135 | // case PackIconEvaIconsKind _:
136 | // case PackIconFileIconsKind _:
137 | // case PackIconFontaudioKind _:
138 | // case PackIconFontistoKind _:
139 | // case PackIconForkAwesomeKind _:
140 | // case PackIconJamIconsKind _:
141 | // case PackIconLucideKind _:
142 | // case PackIconRPGAwesomeKind _:
143 | // case PackIconTypiconsKind _:
144 | // case PackIconVaadinIconsKind _:
145 | return new ScaleTransform(1, -1);
146 | default:
147 | return new ScaleTransform(1, 1);
148 | }
149 | }
150 |
151 | ///
152 | protected override DrawingGroup GetDrawingGroup(object iconKind, IBrush foregroundBrush, string path)
153 | {
154 | var geometryDrawing = new GeometryDrawing
155 | {
156 | Geometry = StreamGeometry.Parse(path)
157 | };
158 |
159 | // if (iconKind is PackIconFeatherIconsKind)
160 | // {
161 | // var pen = new Pen(foregroundBrush, 2d)
162 | // {
163 | // StartLineCap = PenLineCap.Round,
164 | // EndLineCap = PenLineCap.Round,
165 | // LineJoin = PenLineJoin.Round
166 | // };
167 | // geometryDrawing.Pen = pen;
168 | // }
169 | // else
170 | {
171 | geometryDrawing.Brush = foregroundBrush;
172 | }
173 |
174 | var drawingGroup = new DrawingGroup
175 | {
176 | Children = { geometryDrawing },
177 | Transform = this.GetTransformGroup(iconKind)
178 | };
179 |
180 | return drawingGroup;
181 | }
182 | }
183 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/IconPacks.Avalonia.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0;net6.0;netstandard2.0
5 | $(DefineConstants);AVALONIA
6 | latest
7 | latest
8 | true
9 | disable
10 | true
11 |
12 |
13 |
14 | $(DefineConstants);ALL
15 | IconPacks.Avalonia
16 | IconPacks.Avalonia
17 | IconPacks.Avalonia
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/Icons.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/PackIconControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using Avalonia;
4 | using Avalonia.Controls;
5 | using Avalonia.Controls.Metadata;
6 | using Avalonia.Media;
7 | using IconPacks.Avalonia;
8 |
9 | namespace IconPacks.Avalonia
10 | {
11 | ///
12 | ///
13 | public class PackIconControl : PackIconControlBase
14 | {
15 |
16 | public static readonly StyledProperty KindProperty
17 | = AvaloniaProperty.Register(nameof(Kind));
18 |
19 | ///
20 | /// Gets or sets the icon to display.
21 | ///
22 | public Enum Kind
23 | {
24 | get { return GetValue(KindProperty); }
25 | set { SetValue(KindProperty, value); }
26 | }
27 |
28 | // We override OnPropertyChanged of the base class. That way we can react on property changes
29 | protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
30 | {
31 | base.OnPropertyChanged(change);
32 |
33 | // if the changed property is the KindProperty, we need to update the stars
34 | if (change.Property == KindProperty)
35 | {
36 | UpdateData();
37 | }
38 | }
39 |
40 | protected override void SetKind(TKind iconKind)
41 | {
42 | this.SetCurrentValue(KindProperty, iconKind);
43 | }
44 |
45 | protected override void UpdateData()
46 | {
47 | switch(Kind)
48 | {
49 | case PackIconBoxIconsKind:
50 | UpdateIconPseudoClasses(true, false, true);
51 | break;
52 |
53 | default:
54 | UpdateIconPseudoClasses(true, false, false);
55 | break;
56 | }
57 |
58 | if (Kind != default(Enum))
59 | {
60 | string data = null;
61 | PackIconControlDataFactory.DataIndex.Value?.TryGetValue(Kind, out data);
62 | this.Data = data != null ? StreamGeometry.Parse(data) : null;
63 | }
64 | else
65 | {
66 | this.Data = null;
67 | }
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/PackIconControl.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
17 |
18 |
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/PackIconControlDataFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace IconPacks.Avalonia
5 | {
6 | /// ******************************************
7 | /// This code is auto generated. Do not amend.
8 | /// ******************************************
9 | public static class PackIconControlDataFactory
10 | {
11 | public static Lazy> DataIndex { get; }
12 |
13 | static PackIconControlDataFactory()
14 | {
15 | DataIndex = new Lazy>(Create);
16 | }
17 |
18 | internal static IDictionary Create()
19 | {
20 | var dictionary = new Dictionary();
21 | // foreach (var packIcon in PackIconDataFactory.Create())
22 | // {
23 | // dictionary.Add(packIcon.Key, packIcon.Value);
24 | // }
25 | foreach (var packIcon in PackIconDataFactory.Create())
26 | {
27 | dictionary.Add(packIcon.Key, packIcon.Value);
28 | }
29 |
30 | // foreach (var packIcon in PackIconDataFactory.Create())
31 | // {
32 | // dictionary.Add(packIcon.Key, packIcon.Value);
33 | // }
34 | // foreach (var packIcon in PackIconDataFactory.Create())
35 | // {
36 | // dictionary.Add(packIcon.Key, packIcon.Value);
37 | // }
38 | // foreach (var packIcon in PackIconDataFactory.Create())
39 | // {
40 | // dictionary.Add(packIcon.Key, packIcon.Value);
41 | // }
42 | // foreach (var packIcon in PackIconDataFactory.Create())
43 | // {
44 | // dictionary.Add(packIcon.Key, packIcon.Value);
45 | // }
46 | // foreach (var packIcon in PackIconDataFactory.Create())
47 | // {
48 | // dictionary.Add(packIcon.Key, packIcon.Value);
49 | // }
50 | // foreach (var packIcon in PackIconDataFactory.Create())
51 | // {
52 | // dictionary.Add(packIcon.Key, packIcon.Value);
53 | // }
54 | // foreach (var packIcon in PackIconDataFactory.Create())
55 | // {
56 | // dictionary.Add(packIcon.Key, packIcon.Value);
57 | // }
58 | // foreach (var packIcon in PackIconDataFactory.Create())
59 | // {
60 | // dictionary.Add(packIcon.Key, packIcon.Value);
61 | // }
62 | // foreach (var packIcon in PackIconDataFactory.Create())
63 | // {
64 | // dictionary.Add(packIcon.Key, packIcon.Value);
65 | // }
66 | // foreach (var packIcon in PackIconDataFactory.Create())
67 | // {
68 | // dictionary.Add(packIcon.Key, packIcon.Value);
69 | // }
70 | // foreach (var packIcon in PackIconDataFactory.Create())
71 | // {
72 | // dictionary.Add(packIcon.Key, packIcon.Value);
73 | // }
74 | // foreach (var packIcon in PackIconDataFactory.Create())
75 | // {
76 | // dictionary.Add(packIcon.Key, packIcon.Value);
77 | // }
78 | // foreach (var packIcon in PackIconDataFactory.Create())
79 | // {
80 | // dictionary.Add(packIcon.Key, packIcon.Value);
81 | // }
82 | // foreach (var packIcon in PackIconDataFactory.Create())
83 | // {
84 | // dictionary.Add(packIcon.Key, packIcon.Value);
85 | // }
86 | // foreach (var packIcon in PackIconDataFactory.Create())
87 | // {
88 | // dictionary.Add(packIcon.Key, packIcon.Value);
89 | // }
90 | // foreach (var packIcon in PackIconDataFactory.Create())
91 | // {
92 | // dictionary.Add(packIcon.Key, packIcon.Value);
93 | // }
94 | // foreach (var packIcon in PackIconDataFactory.Create())
95 | // {
96 | // dictionary.Add(packIcon.Key, packIcon.Value);
97 | // }
98 | // foreach (var packIcon in PackIconDataFactory.Create())
99 | // {
100 | // dictionary.Add(packIcon.Key, packIcon.Value);
101 | // }
102 | // foreach (var packIcon in PackIconDataFactory.Create())
103 | // {
104 | // dictionary.Add(packIcon.Key, packIcon.Value);
105 | // }
106 | // foreach (var packIcon in PackIconDataFactory.Create())
107 | // {
108 | // dictionary.Add(packIcon.Key, packIcon.Value);
109 | // }
110 | // foreach (var packIcon in PackIconDataFactory.Create())
111 | // {
112 | // dictionary.Add(packIcon.Key, packIcon.Value);
113 | // }
114 | // foreach (var packIcon in PackIconDataFactory.Create())
115 | // {
116 | // dictionary.Add(packIcon.Key, packIcon.Value);
117 | // }
118 | // foreach (var packIcon in PackIconDataFactory.Create())
119 | // {
120 | // dictionary.Add(packIcon.Key, packIcon.Value);
121 | // }
122 | // foreach (var packIcon in PackIconDataFactory.Create())
123 | // {
124 | // dictionary.Add(packIcon.Key, packIcon.Value);
125 | // }
126 | // foreach (var packIcon in PackIconDataFactory.Create())
127 | // {
128 | // dictionary.Add(packIcon.Key, packIcon.Value);
129 | // }
130 | // foreach (var packIcon in PackIconDataFactory.Create())
131 | // {
132 | // dictionary.Add(packIcon.Key, packIcon.Value);
133 | // }
134 | // foreach (var packIcon in PackIconDataFactory.Create())
135 | // {
136 | // dictionary.Add(packIcon.Key, packIcon.Value);
137 | // }
138 | // foreach (var packIcon in PackIconDataFactory.Create())
139 | // {
140 | // dictionary.Add(packIcon.Key, packIcon.Value);
141 | // }
142 | // foreach (var packIcon in PackIconDataFactory.Create())
143 | // {
144 | // dictionary.Add(packIcon.Key, packIcon.Value);
145 | // }
146 | // foreach (var packIcon in PackIconDataFactory.Create())
147 | // {
148 | // dictionary.Add(packIcon.Key, packIcon.Value);
149 | // }
150 | // foreach (var packIcon in PackIconDataFactory.Create())
151 | // {
152 | // dictionary.Add(packIcon.Key, packIcon.Value);
153 | // }
154 | // foreach (var packIcon in PackIconDataFactory.Create())
155 | // {
156 | // dictionary.Add(packIcon.Key, packIcon.Value);
157 | // }
158 | // foreach (var packIcon in PackIconDataFactory.Create())
159 | // {
160 | // dictionary.Add(packIcon.Key, packIcon.Value);
161 | // }
162 | // foreach (var packIcon in PackIconDataFactory.Create())
163 | // {
164 | // dictionary.Add(packIcon.Key, packIcon.Value);
165 | // }
166 | return dictionary;
167 | }
168 | }
169 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/PackIconExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Data;
3 | using Avalonia.Markup.Xaml;
4 |
5 | namespace IconPacks.Avalonia
6 | {
7 | public class PackIconExtension : BasePackIconExtension
8 | {
9 | public PackIconExtension()
10 | {
11 | }
12 |
13 | public PackIconExtension(Enum kind)
14 | {
15 | this.Kind = kind;
16 | }
17 |
18 | [ConstructorArgument("kind")] public Enum Kind { get; set; }
19 |
20 | public override object ProvideValue(IServiceProvider serviceProvider)
21 | {
22 | // if (this.Kind is PackIconBootstrapIconsKind)
23 | // {
24 | // return this.GetPackIcon((PackIconBootstrapIconsKind) this.Kind);
25 | // }
26 | if (this.Kind is PackIconBoxIconsKind)
27 | {
28 | return this.GetPackIcon((PackIconBoxIconsKind)this.Kind);
29 | }
30 |
31 | // if (this.Kind is PackIconCircumIconsKind)
32 | // {
33 | // return this.GetPackIcon((PackIconCircumIconsKind) this.Kind);
34 | // }
35 | // if (this.Kind is PackIconCodiconsKind)
36 | // {
37 | // return this.GetPackIcon((PackIconCodiconsKind) this.Kind);
38 | // }
39 | // if (this.Kind is PackIconCooliconsKind)
40 | // {
41 | // return this.GetPackIcon((PackIconCooliconsKind) this.Kind);
42 | // }
43 | // if (this.Kind is PackIconEntypoKind)
44 | // {
45 | // return this.GetPackIcon((PackIconEntypoKind) this.Kind);
46 | // }
47 | // if (this.Kind is PackIconEvaIconsKind)
48 | // {
49 | // return this.GetPackIcon((PackIconEvaIconsKind) this.Kind);
50 | // }
51 | // if (this.Kind is PackIconFeatherIconsKind)
52 | // {
53 | // return this.GetPackIcon((PackIconFeatherIconsKind) this.Kind);
54 | // }
55 | // if (this.Kind is PackIconFileIconsKind)
56 | // {
57 | // return this.GetPackIcon((PackIconFileIconsKind) this.Kind);
58 | // }
59 | // if (this.Kind is PackIconFontaudioKind)
60 | // {
61 | // return this.GetPackIcon((PackIconFontaudioKind) this.Kind);
62 | // }
63 | // if (this.Kind is PackIconFontAwesomeKind)
64 | // {
65 | // return this.GetPackIcon((PackIconFontAwesomeKind) this.Kind);
66 | // }
67 | // if (this.Kind is PackIconFontistoKind)
68 | // {
69 | // return this.GetPackIcon((PackIconFontistoKind) this.Kind);
70 | // }
71 | // if (this.Kind is PackIconForkAwesomeKind)
72 | // {
73 | // return this.GetPackIcon((PackIconForkAwesomeKind) this.Kind);
74 | // }
75 | // if (this.Kind is PackIconGameIconsKind)
76 | // {
77 | // return this.GetPackIcon((PackIconGameIconsKind) this.Kind);
78 | // }
79 | // if (this.Kind is PackIconIoniconsKind)
80 | // {
81 | // return this.GetPackIcon((PackIconIoniconsKind) this.Kind);
82 | // }
83 | // if (this.Kind is PackIconJamIconsKind)
84 | // {
85 | // return this.GetPackIcon((PackIconJamIconsKind) this.Kind);
86 | // }
87 | // if (this.Kind is PackIconLucideKind)
88 | // {
89 | // return this.GetPackIcon((PackIconLucideKind) this.Kind);
90 | // }
91 | // if (this.Kind is PackIconMaterialKind)
92 | // {
93 | // return this.GetPackIcon((PackIconMaterialKind) this.Kind);
94 | // }
95 | // if (this.Kind is PackIconMaterialLightKind)
96 | // {
97 | // return this.GetPackIcon((PackIconMaterialLightKind) this.Kind);
98 | // }
99 | // if (this.Kind is PackIconMaterialDesignKind)
100 | // {
101 | // return this.GetPackIcon((PackIconMaterialDesignKind) this.Kind);
102 | // }
103 | // if (this.Kind is PackIconMemoryIconsKind)
104 | // {
105 | // return this.GetPackIcon((PackIconMemoryIconsKind) this.Kind);
106 | // }
107 | // if (this.Kind is PackIconMicronsKind)
108 | // {
109 | // return this.GetPackIcon((PackIconMicronsKind) this.Kind);
110 | // }
111 | // if (this.Kind is PackIconModernKind)
112 | // {
113 | // return this.GetPackIcon((PackIconModernKind) this.Kind);
114 | // }
115 | // if (this.Kind is PackIconOcticonsKind)
116 | // {
117 | // return this.GetPackIcon((PackIconOcticonsKind) this.Kind);
118 | // }
119 | // if (this.Kind is PackIconPhosphorIconsKind)
120 | // {
121 | // return this.GetPackIcon((PackIconPhosphorIconsKind) this.Kind);
122 | // }
123 | // if (this.Kind is PackIconPicolIconsKind)
124 | // {
125 | // return this.GetPackIcon((PackIconPicolIconsKind) this.Kind);
126 | // }
127 | // if (this.Kind is PackIconPixelartIconsKind)
128 | // {
129 | // return this.GetPackIcon((PackIconPixelartIconsKind) this.Kind);
130 | // }
131 | // if (this.Kind is PackIconRadixIconsKind)
132 | // {
133 | // return this.GetPackIcon((PackIconRadixIconsKind) this.Kind);
134 | // }
135 | // if (this.Kind is PackIconRemixIconKind)
136 | // {
137 | // return this.GetPackIcon((PackIconRemixIconKind) this.Kind);
138 | // }
139 | // if (this.Kind is PackIconRPGAwesomeKind)
140 | // {
141 | // return this.GetPackIcon((PackIconRPGAwesomeKind) this.Kind);
142 | // }
143 | // if (this.Kind is PackIconSimpleIconsKind)
144 | // {
145 | // return this.GetPackIcon((PackIconSimpleIconsKind) this.Kind);
146 | // }
147 | // if (this.Kind is PackIconTypiconsKind)
148 | // {
149 | // return this.GetPackIcon((PackIconTypiconsKind) this.Kind);
150 | // }
151 | // if (this.Kind is PackIconUniconsKind)
152 | // {
153 | // return this.GetPackIcon((PackIconUniconsKind) this.Kind);
154 | // }
155 | // if (this.Kind is PackIconVaadinIconsKind)
156 | // {
157 | // return this.GetPackIcon((PackIconVaadinIconsKind) this.Kind);
158 | // }
159 | // if (this.Kind is PackIconWeatherIconsKind)
160 | // {
161 | // return this.GetPackIcon((PackIconWeatherIconsKind) this.Kind);
162 | // }
163 | // if (this.Kind is PackIconZondiconsKind)
164 | // {
165 | // return this.GetPackIcon((PackIconZondiconsKind) this.Kind);
166 | // }
167 | //return null;
168 | return BindingNotification.UnsetValue;
169 | }
170 | }
171 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/PackIconImageExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Avalonia.Markup.Xaml;
3 | using Avalonia.Media;
4 |
5 | namespace IconPacks.Avalonia
6 | {
7 | public class PackIconImageExtension : BasePackIconImageExtension
8 | {
9 | public PackIconImageExtension()
10 | {
11 | }
12 |
13 | public PackIconImageExtension(Enum kind)
14 | {
15 | this.Kind = kind;
16 | }
17 |
18 | [ConstructorArgument("kind")] public Enum Kind { get; set; }
19 |
20 | public override object ProvideValue(IServiceProvider serviceProvider)
21 | {
22 | return CreateImageSource(this.Kind, this.Brush ?? Brushes.Black);
23 | }
24 |
25 | ///
26 | protected override string GetPathData(object iconKind)
27 | {
28 | string data = null;
29 | switch (iconKind)
30 | {
31 | // case PackIconBootstrapIconsKind kind:
32 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
33 | // return data;
34 | case PackIconBoxIconsKind kind:
35 | PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
36 | return data;
37 | // case PackIconCircumIconsKind kind:
38 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
39 | // return data;
40 | // case PackIconCodiconsKind kind:
41 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
42 | // return data;
43 | // case PackIconCooliconsKind kind:
44 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
45 | // return data;
46 | // case PackIconEntypoKind kind:
47 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
48 | // return data;
49 | // case PackIconEvaIconsKind kind:
50 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
51 | // return data;
52 | // case PackIconFeatherIconsKind kind:
53 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
54 | // return data;
55 | // case PackIconFileIconsKind kind:
56 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
57 | // return data;
58 | // case PackIconFontaudioKind kind:
59 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
60 | // return data;
61 | // case PackIconFontAwesomeKind kind:
62 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
63 | // return data;
64 | // case PackIconFontistoKind kind:
65 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
66 | // return data;
67 | // case PackIconForkAwesomeKind kind:
68 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
69 | // return data;
70 | // case PackIconGameIconsKind kind:
71 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
72 | // return data;
73 | // case PackIconIoniconsKind kind:
74 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
75 | // return data;
76 | // case PackIconJamIconsKind kind:
77 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
78 | // return data;
79 | // case PackIconLucideKind kind:
80 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
81 | // return data;
82 | // case PackIconMaterialKind kind:
83 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
84 | // return data;
85 | // case PackIconMaterialLightKind kind:
86 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
87 | // return data;
88 | // case PackIconMaterialDesignKind kind:
89 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
90 | // return data;
91 | // case PackIconMemoryIconsKind kind:
92 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
93 | // return data;
94 | // case PackIconMicronsKind kind:
95 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
96 | // return data;
97 | // case PackIconModernKind kind:
98 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
99 | // return data;
100 | // case PackIconOcticonsKind kind:
101 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
102 | // return data;
103 | // case PackIconPhosphorIconsKind kind:
104 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
105 | // return data;
106 | // case PackIconPicolIconsKind kind:
107 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
108 | // return data;
109 | // case PackIconPixelartIconsKind kind:
110 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
111 | // return data;
112 | // case PackIconRadixIconsKind kind:
113 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
114 | // return data;
115 | // case PackIconRemixIconKind kind:
116 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
117 | // return data;
118 | // case PackIconRPGAwesomeKind kind:
119 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
120 | // return data;
121 | // case PackIconSimpleIconsKind kind:
122 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
123 | // return data;
124 | // case PackIconTypiconsKind kind:
125 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
126 | // return data;
127 | // case PackIconUniconsKind kind:
128 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
129 | // return data;
130 | // case PackIconVaadinIconsKind kind:
131 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
132 | // return data;
133 | // case PackIconWeatherIconsKind kind:
134 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
135 | // return data;
136 | // case PackIconZondiconsKind kind:
137 | // PackIconDataFactory.DataIndex.Value?.TryGetValue(kind, out data);
138 | // return data;
139 | default:
140 | return null;
141 | }
142 | }
143 |
144 | ///
145 | protected override ScaleTransform GetScaleTransform(object iconKind)
146 | {
147 | switch (iconKind)
148 | {
149 | // case PackIconBootstrapIconsKind _:
150 | case PackIconBoxIconsKind _:
151 | // case PackIconCodiconsKind _:
152 | // case PackIconCooliconsKind _:
153 | // case PackIconEvaIconsKind _:
154 | // case PackIconFileIconsKind _:
155 | // case PackIconFontaudioKind _:
156 | // case PackIconFontistoKind _:
157 | // case PackIconForkAwesomeKind _:
158 | // case PackIconJamIconsKind _:
159 | // case PackIconLucideKind _:
160 | // case PackIconRPGAwesomeKind _:
161 | // case PackIconTypiconsKind _:
162 | // case PackIconVaadinIconsKind _:
163 | return new ScaleTransform(1, -1);
164 | default:
165 | return new ScaleTransform(1, 1);
166 | }
167 | }
168 |
169 | ///
170 | protected override DrawingGroup GetDrawingGroup(object iconKind, IBrush foregroundBrush, string path)
171 | {
172 | var geometryDrawing = new GeometryDrawing
173 | {
174 | Geometry = StreamGeometry.Parse(path)
175 | };
176 |
177 | // if (iconKind is PackIconFeatherIconsKind)
178 | // {
179 | // var pen = new Pen(foregroundBrush, 2d)
180 | // {
181 | // StartLineCap = PenLineCap.Round,
182 | // EndLineCap = PenLineCap.Round,
183 | // LineJoin = PenLineJoin.Round
184 | // };
185 | // geometryDrawing.Pen = pen;
186 | // }
187 | // else
188 | {
189 | geometryDrawing.Brush = foregroundBrush;
190 | }
191 |
192 | var drawingGroup = new DrawingGroup
193 | {
194 | Children = { geometryDrawing },
195 | Transform = this.GetScaleTransform(iconKind)
196 | };
197 |
198 | return drawingGroup;
199 | }
200 | }
201 | }
--------------------------------------------------------------------------------
/src/IconPacks.Avalonia/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using Avalonia.Metadata;
3 |
4 | [assembly: XmlnsPrefix("urn:iconpacks-avalonia", "iconPacks")]
5 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks")]
6 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks.Avalonia")]
7 | [assembly: XmlnsDefinition("urn:iconpacks-avalonia", "IconPacks.Avalonia.Converter")]
8 |
9 | [assembly: ComVisible(false)]
10 |
--------------------------------------------------------------------------------