I am new to developing plugins for Paint.Net, so it I suspect I am missing something simple.
Below is the fledgling plugin that seems to correctly provide properties for save dialog ("save Configuration"). But after the hitting OK on it I get another popuup "Save Configuration" dialog with a cycling dialog bar and the word "finishing" above the progress control. The problem is it never goes away. Pretty much requires I terminate Paint.Net.
Attached debugger and didn't see any exceptions being fired. My OnSaveT is empty.
I am using the latest version 4.0.9.
using System;
using System.IO;
using System.Collections.Generic;
using PaintDotNet;
using PaintDotNet.IndirectUI;
using PaintDotNet.PropertySystem;
using System.Drawing;
namespace ArduinoProgmemNeoPixel
{
internal class ArduinoProgmemNeoPixelFileType : PropertyBasedFileType
{
// Names of the properties
private enum PropertyNames
{
VariableName,
ColorOrder,
ColorValueBase
}
private enum ColorOrder
{
RGB,
GRB,
BRG,
RBG,
RGBW,
GRBW,
BRGW,
RBGW
}
private enum ColorValueBase
{
Decimal,
Hexadecimal,
Octal,
Binary
}
// Defaults
const String defaultVariableNameFormat = "Bitmap{0:x}";
// ----------------------------------------------------------------------
/// <summary>
/// Constructs a ArduinoProgmemNeoPixelFileType instance
/// </summary>
internal ArduinoProgmemNeoPixelFileType()
: base( "Arduino Source File",
//FileTypeFlags.SupportsLayers |
//FileTypeFlags.SavesWithProgress |
FileTypeFlags.SupportsSaving,
new[] { ".cpp", ".c", ".h" })
{
}
// ----------------------------------------------------------------------
/// <summary>
/// Add properties to the dialog
/// </summary>
public override PropertyCollection OnCreateSavePropertyCollection()
{
List<Property> props = new List<Property>();
string defaultVariableName = string.Format(defaultVariableNameFormat, this.GetHashCode());
props.Add(new StringProperty(PropertyNames.VariableName, defaultVariableName, 60));
props.Add(StaticListChoiceProperty.CreateForEnum<ColorOrder>(PropertyNames.ColorOrder, 0, false));
props.Add(StaticListChoiceProperty.CreateForEnum<ColorValueBase>(PropertyNames.ColorValueBase, 0, false));
List<PropertyCollectionRule> propRules = new List<PropertyCollectionRule>();
return new PropertyCollection(props, propRules);
}
// ----------------------------------------------------------------------
/// <summary>
/// Adapt properties in the dialog (DisplayName, ...)
/// </summary>
public override ControlInfo OnCreateSaveConfigUI(PropertyCollection props)
{
ControlInfo configUI = CreateDefaultSaveConfigUI(props);
configUI.SetPropertyControlValue(PropertyNames.VariableName, ControlInfoPropertyNames.DisplayName, "Variable Name");
configUI.SetPropertyControlValue(PropertyNames.VariableName, ControlInfoPropertyNames.Description, "The name of the variable in the created file. You can always edit the name latter.");
configUI.SetPropertyControlValue(PropertyNames.ColorOrder, ControlInfoPropertyNames.DisplayName, "Color element order");
configUI.SetPropertyControlValue(PropertyNames.ColorOrder, ControlInfoPropertyNames.Description, "Select the native color element order of your NeoPixels.");
configUI.SetPropertyControlValue(PropertyNames.ColorValueBase, ControlInfoPropertyNames.DisplayName, "Color value base");
configUI.SetPropertyControlValue(PropertyNames.ColorValueBase, ControlInfoPropertyNames.Description, "What numerical base do you want the values to be written out as.");
return configUI;
}
// ----------------------------------------------------------------------
/// <summary>
/// Saves a document to a stream respecting the properties
/// </summary>
protected override void OnSaveT(Document input,
Stream output,
PropertyBasedSaveConfigToken token,
Surface scratchSurface,
ProgressEventHandler progressCallback)
{
// input.Flatten(scratchSurface);
//using (StreamWriter writer = new StreamWriter(output))
{
}
}
// ----------------------------------------------------------------------
/// <summary>
/// Creates a document from a stream
/// </summary>
protected override Document OnLoad(Stream input)
{
// add some code here ...
return null;
}
}
}