Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Helpers.cs « Controls « UVtools.WPF - github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 28ec99f6f612af224e855484770bbf75a06a3b0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 *                     GNU AFFERO GENERAL PUBLIC LICENSE
 *                       Version 3, 19 November 2007
 *  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 *  Everyone is permitted to copy and distribute verbatim copies
 *  of this license document, but changing it is not allowed.
 */
using System.Collections.Generic;
using System.Linq;
using Avalonia.Controls;

namespace UVtools.WPF.Controls
{
    public static class Helpers
    {
        public static readonly List<FileDialogFilter> ImagesFileFilter = new()
        {
            new FileDialogFilter
            {
                Name = "Image Files",
                Extensions = new List<string>
                {
                    "png",
                    "bmp",
                    "jpeg",
                    "jpg",
                    "gif"
                }
            }
        };

        public static readonly List<FileDialogFilter> PngFileFilter = new List<FileDialogFilter>
        {
            new FileDialogFilter
            {
                Name = "Image Files",
                Extensions = new List<string>
                {
                    "png",
                }
            }
        };

        public static readonly List<FileDialogFilter> TxtFileFilter = new List<FileDialogFilter>
        {
            new FileDialogFilter
            {
                Name = "Text Files",
                Extensions = new List<string>
                {
                    "txt",
                }
            }
        };

        public static readonly List<FileDialogFilter> IniFileFilter = new List<FileDialogFilter>
        {
            new FileDialogFilter
            {
                Name = "Ini Files",
                Extensions = new List<string>
                {
                    "ini",
                }
            }
        };

        public static List<FileDialogFilter> ToAvaloniaFileFilter(List<KeyValuePair<string, List<string>>> data)
        {
            var result = new List<FileDialogFilter>(data.Capacity);
            result.AddRange(data.Select(kv => new FileDialogFilter {Name = kv.Key, Extensions = kv.Value}));
            return result;
        }

        public static List<FileDialogFilter> ToAvaloniaFilter(string name, string extension)
        {
            return new List<FileDialogFilter>(1)
            {
                new FileDialogFilter {Name = name, Extensions = new List<string>(1) {extension}}
            };
        }
    }
}