Skip to content

Commit a399f0b

Browse files
punker76timunie
authored andcommitted
add paginator until we got a virtualized wrappanel
1 parent 70294ea commit a399f0b

File tree

5 files changed

+316
-231
lines changed

5 files changed

+316
-231
lines changed

src/MahApps.IconPacksBrowser.Avalonia/MahApps.IconPacksBrowser.Avalonia/ViewModels/IconPackViewModel.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43
using System.Collections.ObjectModel;
5-
using System.Globalization;
64
using System.Linq;
75
using System.Threading.Tasks;
8-
using System.Windows.Input;
96
using AsyncAwaitBestPractices;
10-
using Avalonia;
11-
using Avalonia.Controls;
12-
using Avalonia.Media;
13-
using Avalonia.Media.Imaging;
14-
using Avalonia.Platform;
157
using CommunityToolkit.Mvvm.ComponentModel;
16-
using CommunityToolkit.Mvvm.Input;
17-
using FluentAvalonia.UI.Data;
18-
using IconPacks.Avalonia;
198
using IconPacks.Avalonia.Attributes;
20-
using MahApps.IconPacksBrowser.Avalonia.Helper;
219

2210
namespace MahApps.IconPacksBrowser.Avalonia.ViewModels;
2311

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,86 @@
1-
using System;
2-
using System.ComponentModel;
3-
using System.Linq;
4-
using IconPacks.Avalonia;
5-
using IconPacks.Avalonia.Attributes;
6-
using MahApps.IconPacksBrowser.Avalonia.Helper;
7-
8-
namespace MahApps.IconPacksBrowser.Avalonia.ViewModels;
9-
10-
public interface IIconViewModel
11-
{
12-
/// <summary>
13-
/// Gets the unique identifier by returning "IcoNPackName|Name" combination
14-
/// </summary>
15-
string Identifier => $"{IconPackName}|{Name}";
16-
17-
string Name { get; set; }
18-
string IconPackName { get; }
19-
string Description { get; set; }
20-
Type IconPackType { get; set; }
21-
Type IconType { get; set; }
22-
object Value { get; set; }
23-
MetaDataAttribute MetaData { get; set; }
24-
string? CopyToClipboardText { get; }
25-
string? CopyToClipboardWpfGeometry { get; }
26-
string? CopyToClipboardAsContentText { get; }
27-
string? CopyToClipboardAsPathIconText { get; }
28-
string? CopyToClipboardAsGeometryText { get; }
29-
}
30-
31-
public class IconViewModel : ViewModelBase, IIconViewModel
32-
{
33-
public IconViewModel(Type enumType, Type packType, Enum k, MetaDataAttribute metaData)
34-
{
35-
Name = k.ToString();
36-
Description = GetDescription(k);
37-
IconPackType = packType;
38-
IconType = enumType;
39-
Value = k;
40-
MetaData = metaData;
41-
}
42-
43-
public string? CopyToClipboardText => ExportHelper.FillTemplate(ExportHelper.ClipboardWpf, new ExportParameters(this)); // $"<iconPacks:{IconPackType.Name} Kind=\"{Name}\" />";
44-
45-
public string? CopyToClipboardWpfGeometry =>
46-
ExportHelper.FillTemplate(ExportHelper.ClipboardWpfGeometry, new ExportParameters(this)); // $"<iconPacks:{IconPackType.Name} Kind=\"{Name}\" />";
47-
48-
public string? CopyToClipboardAsContentText =>
49-
ExportHelper.FillTemplate(ExportHelper.ClipboardContent, new ExportParameters(this)); // $"{{iconPacks:{IconPackType.Name.Replace("PackIcon", "")} Kind={Name}}}";
50-
51-
public string? CopyToClipboardAsPathIconText =>
52-
ExportHelper.FillTemplate(ExportHelper.ClipboardUwp, new ExportParameters(this)); // $"<iconPacks:{IconPackType.Name.Replace("PackIcon", "PathIcon")} Kind=\"{Name}\" />";
53-
54-
public string? CopyToClipboardAsGeometryText => ExportHelper.FillTemplate(ExportHelper.ClipboardData, new ExportParameters(this)); // GetPackIconControlBase().Data;
55-
56-
public string Name { get; set; }
57-
58-
public string IconPackName => IconPackType.Name.Replace("PackIcon", "");
59-
60-
public string Description { get; set; }
61-
62-
public Type IconPackType { get; set; }
63-
64-
public Type IconType { get; set; }
65-
66-
public object Value { get; set; }
67-
68-
public MetaDataAttribute MetaData { get; set; }
69-
70-
internal PackIconControlBase? GetPackIconControlBase()
71-
{
72-
if (Activator.CreateInstance(IconPackType) is not PackIconControlBase iconPack) return null;
73-
74-
var kindProperty = IconPackType.GetProperty("Kind");
75-
if (kindProperty == null) return null;
76-
kindProperty.SetValue(iconPack, Value);
77-
78-
return iconPack;
79-
}
80-
81-
internal static string GetDescription(Enum value)
82-
{
83-
var fieldInfo = value.GetType().GetField(value.ToString());
84-
return fieldInfo?.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() is DescriptionAttribute attribute ? attribute.Description : value.ToString();
85-
}
1+
using System;
2+
using System.ComponentModel;
3+
using System.Linq;
4+
using IconPacks.Avalonia;
5+
using IconPacks.Avalonia.Attributes;
6+
using MahApps.IconPacksBrowser.Avalonia.Helper;
7+
8+
namespace MahApps.IconPacksBrowser.Avalonia.ViewModels;
9+
10+
public interface IIconViewModel
11+
{
12+
/// <summary>
13+
/// Gets the unique identifier by returning "IconPackName|Name" combination
14+
/// </summary>
15+
string Identifier => $"{IconPackName}|{Name}";
16+
17+
string Name { get; set; }
18+
string IconPackName { get; }
19+
string Description { get; set; }
20+
Type IconPackType { get; set; }
21+
Type IconType { get; set; }
22+
object Value { get; set; }
23+
MetaDataAttribute MetaData { get; set; }
24+
string? CopyToClipboardText { get; }
25+
string? CopyToClipboardWpfGeometry { get; }
26+
string? CopyToClipboardAsContentText { get; }
27+
string? CopyToClipboardAsPathIconText { get; }
28+
string? CopyToClipboardAsGeometryText { get; }
29+
}
30+
31+
public class IconViewModel : ViewModelBase, IIconViewModel
32+
{
33+
public IconViewModel(Type enumType, Type packType, Enum k, MetaDataAttribute metaData)
34+
{
35+
Name = k.ToString();
36+
Description = GetDescription(k);
37+
IconPackType = packType;
38+
IconType = enumType;
39+
Value = k;
40+
MetaData = metaData;
41+
}
42+
43+
public string? CopyToClipboardText => ExportHelper.FillTemplate(ExportHelper.ClipboardWpf, new ExportParameters(this)); // $"<iconPacks:{IconPackType.Name} Kind=\"{Name}\" />";
44+
45+
public string? CopyToClipboardWpfGeometry =>
46+
ExportHelper.FillTemplate(ExportHelper.ClipboardWpfGeometry, new ExportParameters(this)); // $"<iconPacks:{IconPackType.Name} Kind=\"{Name}\" />";
47+
48+
public string? CopyToClipboardAsContentText =>
49+
ExportHelper.FillTemplate(ExportHelper.ClipboardContent, new ExportParameters(this)); // $"{{iconPacks:{IconPackType.Name.Replace("PackIcon", "")} Kind={Name}}}";
50+
51+
public string? CopyToClipboardAsPathIconText =>
52+
ExportHelper.FillTemplate(ExportHelper.ClipboardUwp, new ExportParameters(this)); // $"<iconPacks:{IconPackType.Name.Replace("PackIcon", "PathIcon")} Kind=\"{Name}\" />";
53+
54+
public string? CopyToClipboardAsGeometryText => ExportHelper.FillTemplate(ExportHelper.ClipboardData, new ExportParameters(this)); // GetPackIconControlBase().Data;
55+
56+
public string Name { get; set; }
57+
58+
public string IconPackName => IconPackType.Name.Replace("PackIcon", "");
59+
60+
public string Description { get; set; }
61+
62+
public Type IconPackType { get; set; }
63+
64+
public Type IconType { get; set; }
65+
66+
public object Value { get; set; }
67+
68+
public MetaDataAttribute MetaData { get; set; }
69+
70+
internal PackIconControlBase? GetPackIconControlBase()
71+
{
72+
if (Activator.CreateInstance(IconPackType) is not PackIconControlBase iconPack) return null;
73+
74+
var kindProperty = IconPackType.GetProperty("Kind");
75+
if (kindProperty == null) return null;
76+
kindProperty.SetValue(iconPack, Value);
77+
78+
return iconPack;
79+
}
80+
81+
internal static string GetDescription(Enum value)
82+
{
83+
var fieldInfo = value.GetType().GetField(value.ToString());
84+
return fieldInfo?.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() is DescriptionAttribute attribute ? attribute.Description : value.ToString();
85+
}
8686
}

0 commit comments

Comments
 (0)