Seite 1 von 1

Paint.NET Addon erstellen

Verfasst: 28.10.2011 12:14
von Makke
Hallo zusammen,

ich habe mal ein paar Fragen bezüglich der Addon-Erstellung für das freie Grafikprogramm Paint.NET. In den Foren dazu ist ein Template zur Erstellung eines Addons in Visual-C# zu finden (hänge ich unten an), meine Frage ist, kann ich das mit Purebasic ebenfalls bewerkstelligen ?

Ich habe mich noch nicht so sehr mit OOP Programmierung befasst, jedoch folgendes aus dem Template Code herausgelesen:

- in der Datei "PaintDotNet.Effects.dll" im Installationsordner von Paint.NET sind die Klassen (PaintDotNet.Effects.Effect, PaintDotNet.Effects.EffectConfigToken, PaintDotNet.Effects.EffectConfigDialog) definiert
- diese müsste ich importieren um sie ansprechen/benutzen zu können

Jetzt zu meinen Fragen:

- geht das überhaupt ?
- wie kann ich die Klassen aus der DLL importieren ?

Vielleicht hat jemand Lust mir da auf die Sprünge zu helfen.

Hier noch der C#-Code:
EffectPlugin.cs

Code: Alles auswählen

using System;
using System.Collections;
using System.Drawing;
using PaintDotNet;
using PaintDotNet.Effects;

namespace $safeprojectname$
{
    public class EffectPlugin
        : PaintDotNet.Effects.Effect
    {
        public static string StaticName
        {
            get
            {
                return "Effect Plugin";
            }
        }

        public static Bitmap StaticIcon
        {
            get
            {
                return new Bitmap(typeof(EffectPlugin), "EffectPluginIcon.png");
            }
        }

        public static string StaticSubMenuName
        {
            get
            {
                return null; // Use for no submenu
                // return "My SubMenu"; // Use for custom submenu
            }
        }

        public EffectPlugin()
            : base(EffectPlugin.StaticName, EffectPlugin.StaticIcon, EffectPlugin.StaticSubMenuName, true)
        {

        }

        public override EffectConfigDialog CreateConfigDialog()
        {
            return new EffectPluginConfigDialog();
        }

        public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length)
        {
            PdnRegion selectionRegion = EnvironmentParameters.GetSelection(srcArgs.Bounds);

            for (int i = startIndex; i < startIndex + length; ++i)
            {
                Rectangle rect = rois[i];

                for (int y = rect.Top; y < rect.Bottom; ++y)
                {
                    for (int x = rect.Left; x < rect.Right; ++x)
                    {
                        // Render Code Here
                    }
                }
            }
        }
    }
}
EffectPluginToken.cs

Code: Alles auswählen

using System;

namespace $safeprojectname$
{
    public class EffectPluginConfigToken : PaintDotNet.Effects.EffectConfigToken
    {
        // Declare variables here
        // Using getters/setters, you can manipulate the "value" before assigning it to your private variable.

        // Example using getters/setters:
        //----------------------------------------
        // private double variable;
        // public double Variable
        // {
        //     get { return variable; }
        //     set { this.variable = value; }
        // }

        // Example not using getters/setters:
        //----------------------------------------
        // public double variable;

        public EffectPluginConfigToken()
            : base()
        {
            // Set default variables here
            // this.variable = 0.0;
        }

        protected EffectPluginConfigToken(EffectPluginConfigToken copyMe)
            : base(copyMe)
        {
            // this.variable = copyMe.variable;
        }

        public override object Clone()
        {
            return new EffectPluginConfigToken(this);
        }
    }
}
EffectPluginConfigDialog.cs

Code: Alles auswählen

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using PaintDotNet.Effects;
using PaintDotNet;

namespace $safeprojectname$
{
    public class EffectPluginConfigDialog : PaintDotNet.Effects.EffectConfigDialog
    {
        private Button buttonOK;
        private Button buttonCancel;

        public EffectPluginConfigDialog()
        {
            InitializeComponent();
        }

        protected override void InitialInitToken()
        {
            theEffectToken = new EffectPluginConfigToken();
        }

        protected override void InitTokenFromDialog()
        {
            // ((EffectPluginConfigToken)EffectToken).variable = dialogVariable;
        }

        protected override void InitDialogFromToken(EffectConfigToken effectToken)
        {
            // EffectPluginConfigToken token = (EffectPluginConfigToken)effectToken;
            // dialogVariable = token.variable;
        }

        private void InitializeComponent()
        {
            this.buttonCancel = new System.Windows.Forms.Button();
            this.buttonOK = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // buttonCancel
            // 
            this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.buttonCancel.Location = new System.Drawing.Point(195, 218);
            this.buttonCancel.Name = "buttonCancel";
            this.buttonCancel.Size = new System.Drawing.Size(75, 23);
            this.buttonCancel.TabIndex = 1;
            this.buttonCancel.Text = "Cancel";
            this.buttonCancel.UseVisualStyleBackColor = true;
            this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
            // 
            // buttonOK
            // 
            this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.buttonOK.Location = new System.Drawing.Point(114, 218);
            this.buttonOK.Name = "buttonOK";
            this.buttonOK.Size = new System.Drawing.Size(75, 23);
            this.buttonOK.TabIndex = 2;
            this.buttonOK.Text = "OK";
            this.buttonOK.UseVisualStyleBackColor = true;
            this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
            // 
            // EffectPluginConfigDialog
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.ClientSize = new System.Drawing.Size(282, 253);
            this.Controls.Add(this.buttonOK);
            this.Controls.Add(this.buttonCancel);
            this.Location = new System.Drawing.Point(0, 0);
            this.Name = "EffectPluginConfigDialog";
            this.Controls.SetChildIndex(this.buttonCancel, 0);
            this.Controls.SetChildIndex(this.buttonOK, 0);
            this.ResumeLayout(false);

        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            FinishTokenUpdate();
            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

Re: Paint.NET Addon erstellen

Verfasst: 28.10.2011 13:12
von Rings
kurzum:

Nein, man kann mir Purebasic keine .NET Programme erstellen.

Re: Paint.NET Addon erstellen

Verfasst: 28.10.2011 15:44
von Ramihyn_
Du könntest aber eine PureBasic DLL erstellen die dann per DLLImport in das EffectPlugin.cs eingebunden und genutzt wird. Damit wäre die ganze Effektprogrammierung in PureBasic und ein kleiner C# Wrapper würde die Anbindung erledigen.