forked from 0xC0000054/pdn-photoshop-brush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbrFileType.cs
74 lines (63 loc) · 2.79 KB
/
AbrFileType.cs
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
/////////////////////////////////////////////////////////////////////////////////
//
// ABR FileType Plugin for Paint.NET
//
// This software is provided under the MIT License:
// Copyright (c) 2012-2017 Nicholas Hayes
//
// See LICENSE.txt for complete licensing and attribution information.
//
/////////////////////////////////////////////////////////////////////////////////
using PaintDotNet;
using PaintDotNet.IndirectUI;
using PaintDotNet.PropertySystem;
using System.Collections.Generic;
using System.IO;
namespace AbrFileTypePlugin
{
[PluginSupportInfo(typeof(PluginSupportInfo))]
public sealed class AbrFileType : PropertyBasedFileType
{
public static string StaticName
{
get
{
return "Photoshop Brush";
}
}
public AbrFileType() : base(
StaticName,
FileTypeFlags.SupportsLoading | FileTypeFlags.SupportsSaving | FileTypeFlags.SupportsLayers | FileTypeFlags.SavesWithProgress,
new string[] {".abr"})
{
}
protected override Document OnLoad(Stream input)
{
return AbrLoad.Load(input);
}
public override PropertyCollection OnCreateSavePropertyCollection()
{
List<Property> props = new List<Property>
{
StaticListChoiceProperty.CreateForEnum(PropertyNames.FileVersion, AbrFileVersion.Version2, false),
new BooleanProperty(PropertyNames.RLE, true)
};
return new PropertyCollection(props);
}
public override ControlInfo OnCreateSaveConfigUI(PropertyCollection props)
{
ControlInfo info = CreateDefaultSaveConfigUI(props);
info.SetPropertyControlValue(PropertyNames.FileVersion, ControlInfoPropertyNames.DisplayName, Properties.Resources.FileVersionHeader);
info.FindControlForPropertyName(PropertyNames.FileVersion).SetValueDisplayName(AbrFileVersion.Version1, Properties.Resources.FileVersion1);
info.FindControlForPropertyName(PropertyNames.FileVersion).SetValueDisplayName(AbrFileVersion.Version2, Properties.Resources.FileVersion2);
info.SetPropertyControlType(PropertyNames.FileVersion, PropertyControlType.RadioButton);
info.SetPropertyControlValue(PropertyNames.RLE, ControlInfoPropertyNames.DisplayName, string.Empty);
info.SetPropertyControlValue(PropertyNames.RLE, ControlInfoPropertyNames.Description, Properties.Resources.RLECompression);
return info;
}
protected override void OnSaveT(Document input, Stream output, PropertyBasedSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback)
{
AbrSave.Save(input, output, token, progressCallback);
}
}
}