Jump to content

Writing a PropertyBasedFileType plugin and I get infinite "Finishing" progress dialog


Makuna
 Share

Recommended Posts

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;
        }


    }
}
Link to comment
Share on other sites

This might help explain some of the details...   http://forums.getpaint.net/index.php?/topic/31645-paintnet-filetype-plugins/?p=424863

 

Something Midora suggested a while back when I was developing a filetype plugin: http://forums.getpaint.net/index.php?/topic/31674-csv-comma-separated-values-filetype/?p=425159I'm not sure if he got around to adding it to the template.

Link to comment
Share on other sites

This might help explain some of the details...   http://forums.getpaint.net/index.php?/topic/31645-paintnet-filetype-plugins/?p=424863

 

Something Midora suggested a while back when I was developing a filetype plugin: http://forums.getpaint.net/index.php?/topic/31674-csv-comma-separated-values-filetype/?p=425159I'm not sure if he got around to adding it to the template.

 

THANKS!  The IsReflexive override was the needed part to allow it to finish.

Link to comment
Share on other sites

Pleased to hear that. Good luck with the plugin!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...