Jump to content

Need help moving to Visual Studio


Recommended Posts

Hello,

I've been following the CodeLab tutorials, and they are awesome! I'm currently at the 'Moving beyond CodeLab to Visual Studio' tutorial, but I'm currently stuck at generating the DLL file. Basically, I am able to build the program without an errors, but when I check my /bin/debug/ folder, there's no DLL file that is generated.

 

This is the source code that I get when I check the 'View Source' box in CodeLab:

// Compiler options:  /unsafe /optimize /res:"C:\Users\william.huang\Documents\Paint.NET Plugins\Tutorial\ColorBalanceOld.png","MyScriptEffect.ColorBalanceOld.png"  /debug- /target:library /out:"C:\Users\william.huang\Desktop\MyScript.dll"
using System;
using System.IO;
using System.Linq;
using System.Drawing;
using System.Threading;
using System.Reflection;
using System.Drawing.Text;
using System.Windows.Forms;
using System.IO.Compression;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
using Registry = Microsoft.Win32.Registry;
using RegistryKey = Microsoft.Win32.RegistryKey;
using PaintDotNet;
using PaintDotNet.Effects;
using PaintDotNet.AppModel;
using PaintDotNet.IndirectUI;
using PaintDotNet.Collections;
using PaintDotNet.PropertySystem;
using IntSliderControl = System.Int32;
using CheckboxControl = System.Boolean;
using ColorWheelControl = PaintDotNet.ColorBgra;
using AngleControl = System.Double;
using PanSliderControl = PaintDotNet.Pair<double,double>;
using TextboxControl = System.String;
using DoubleSliderControl = System.Double;
using ListBoxControl = System.Byte;
using RadioButtonControl = System.Byte;
using ReseedButtonControl = System.Byte;
using MultiLineTextboxControl = System.String;
using RollControl = System.Tuple<double, double, double>;

[assembly: AssemblyTitle("MyScript Plugin for Paint.NET")]
[assembly: AssemblyDescription("MyScript selected pixels")]
[assembly: AssemblyConfiguration("myscript")]
[assembly: AssemblyCompany("William")]
[assembly: AssemblyProduct("MyScript")]
[assembly: AssemblyCopyright("Copyright © William")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.0.*")]

namespace MyScriptEffect
{
    public class PluginSupportInfo : IPluginSupportInfo
    {
        public string Author
        {
            get
            {
                return ((AssemblyCopyrightAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]).Copyright;
            }
        }
        public string Copyright
        {
            get
            {
                return ((AssemblyDescriptionAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]).Description;
            }
        }

        public string DisplayName
        {
            get
            {
                return ((AssemblyProductAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0]).Product;
            }
        }

        public Version Version
        {
            get
            {
                return base.GetType().Assembly.GetName().Version;
            }
        }

        public Uri WebsiteUri
        {
            get
            {
                return new Uri("http://www.getpaint.net/redirect/plugins.html");
            }
        }
    }

    [PluginSupportInfo(typeof(PluginSupportInfo), DisplayName = "My effect")]
    public class MyScriptEffectPlugin : PropertyBasedEffect
    {
        public static string StaticName
        {
            get
            {
                return "My effect";
            }
        }

        public static Image StaticIcon
        {
            get
            {
                return new Bitmap(typeof(MyScriptEffectPlugin), "ColorBalanceOld.png");
            }
        }

        public static string SubmenuName
        {
            get
            {
                return SubmenuNames.Artistic;
            }
        }

        public MyScriptEffectPlugin()
            : base(StaticName, StaticIcon, SubmenuName, EffectFlags.Configurable)
        {
        }

        private void OnWindowHelpButtonClicked(IWin32Window owner, string helpContent)
        {
            if (helpContent.ToLower().StartsWith("http://") || helpContent.ToLower().StartsWith("https://"))
            {
                PaintDotNet.ServiceProviderExtensions.GetService<IShellService>(Services).LaunchUrl(null, helpContent);
            }
        }

        public enum PropertyNames
        {
            Amount1,
            Amount2,
            Amount3
        }


        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Amount1, 0,-100,100));
            props.Add(new Int32Property(PropertyNames.Amount2, 0,-100,100));
            props.Add(new Int32Property(PropertyNames.Amount3, 0,-100,100));

            return new PropertyCollection(props);
        }

        protected override ControlInfo OnCreateConfigUI(PropertyCollection props)
        {
            ControlInfo configUI = CreateDefaultConfigUI(props);

            configUI.SetPropertyControlValue(PropertyNames.Amount1, ControlInfoPropertyNames.DisplayName, "Cyan - Red");
            configUI.SetPropertyControlValue(PropertyNames.Amount2, ControlInfoPropertyNames.DisplayName, "Magenta - Green");
            configUI.SetPropertyControlValue(PropertyNames.Amount3, ControlInfoPropertyNames.DisplayName, "Yellow - Blue");

            return configUI;
        }

        protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            Amount1 = newToken.GetProperty<Int32Property>(PropertyNames.Amount1).Value;
            Amount2 = newToken.GetProperty<Int32Property>(PropertyNames.Amount2).Value;
            Amount3 = newToken.GetProperty<Int32Property>(PropertyNames.Amount3).Value;

            base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
        }

        protected override void OnCustomizeConfigUIWindowProperties(PropertyCollection props)
        {
            // Add help button to effect UI
            props[ControlInfoPropertyNames.WindowHelpContentType].Value = WindowHelpContentType.CustomViaCallback;
            props[ControlInfoPropertyNames.WindowHelpContent].Value = "http://www.getpaint.net/redirect/plugins.html";
            base.OnCustomizeConfigUIWindowProperties(props);
        }

        protected override unsafe void OnRender(Rectangle[] rois, int startIndex, int length)
        {
            if (length == 0) return;
            for (int i = startIndex; i < startIndex + length; ++i)
            {
                Render(DstArgs.Surface,SrcArgs.Surface,rois[i]);
            }
        }

        #region User Entered Code
        #region UICode
        int Amount1=0;   //[-100,100]Cyan - Red
        int Amount2=0;   //[-100,100]Magenta - Green
        int Amount3=0;   //[-100,100]Yellow - Blue
        #endregion
        
        private byte Clamp2Byte(int iValue)
        {
            if (iValue<0) return 0;
            if (iValue>255) return 255;
            return (byte)iValue;
        }
        
        void Render(Surface dst, Surface src, Rectangle rect) 
        { 
            ColorBgra CurrentPixel; 
            int R, G, B;
            for(int y = rect.Top; y < rect.Bottom; y++) 
            { 
                for (int x = rect.Left; x < rect.Right; x++) 
                { 
                    CurrentPixel = src[x,y]; 
                    R = (int)CurrentPixel.R;
                    G = (int)CurrentPixel.G;
                    B = (int)CurrentPixel.B;
                    // Cyan - Red adjustment
                    R = R + Amount1;
                    G = G - (Amount1 / 2);
                    B = B - (Amount1 / 2);
                    // Magenta - Green adjustment
                    G = G + Amount2;
                    R = R - (Amount2 / 2);
                    B = B - (Amount2 / 2);
                    // Yellow - Blue adjustment
                    B = B + Amount3;
                    R = R - (Amount3 / 2);
                    G = G - (Amount3 / 2);
                    // Reassemble the color from R, G, and B
                    CurrentPixel = ColorBgra.FromBgra(Clamp2Byte(B),Clamp2Byte(G),Clamp2Byte(R),CurrentPixel.A);
                    dst[x,y] = CurrentPixel; 
                } 
            } 
        }
        
        #endregion
    }
}

 

And I am using Visual Studio 2017.

  • Upvote 1
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...