Jump to content

Project Templates for Visual Studio


Recommended Posts

When I use the "Effect" template, and I try to edit the ConfigDialog in the Windows Forms Designer, the designer behaves very upsettingly. I'm running Windows 10 and I'm using Visual Studio 2019.

 

Specifically, when I try to drag the resizing handles for the window, besides just resizing, the window jumps to God only knows where. In this screenshot, I began clicking and holding the button:

image.png.05bec0860cd7e44553d6fc49b107ac81.png

and the moment I dragged it a pixel to the right, the dialog widget jumped out of view, and I became unable to scroll the editor window far enough in any direction to see any of it. Then I tried closing and reopening the file, and now all I see is this where the dialog used to be:

image.png.d7b5d2ba7cf5220a104c04581b03c4a9.png

...and so on. In fact, changing many of the properties, through the GUI or through the editor panel in the corner of VS, causes similar distressing behavior. What I've shown you here is actually a lot worse than it was when I first noticed that there were problems: originally, resizing the dialog would only cause it to move rapidly down and to the right, but not so rapidly as to be gone in a single update like it is now.

 

At first I thought this was the fault of the Forms Designer itself, but I don't think so anymore. I started following this official tutorial to see if these problems would occur with a simpler project. When I made a new project using the built-in Windows Forms Control Library template as the tutorial told me, I encountered no such issues. Is there a problem with something in the project files? What gives?

Edited by Modus Ponens
Link to comment
Share on other sites

20 minutes ago, Modus Ponens said:

At first I thought this was the fault of the Forms Designer itself, but I don't think so anymore. I started following this official tutorial to see if these problems would occur with a simpler project. When I made a new project using the built-in Windows Forms Control Library template as the tutorial told me, I encountered no such issues. Is there a problem with something in the project files? What gives?

 

You could have saved yourself a whole lot of time, if you had just read the previous posts in this topic.

Link to comment
Share on other sites

On 12/23/2019 at 5:51 PM, NSD said:

I was curious to see if the issue by resizing the Form was fixed

 

On 8/20/2020 at 4:06 AM, Modus Ponens said:

and the moment I dragged it a pixel to the right, the dialog widget jumped out of view

 

This will be fixed in paint.net v4.2.14. You can install an alpha build from here:

https://forums.getpaint.net/topic/116972-paintnet-4214-alpha-build-7542/

  • Like 1
  • Upvote 4
Link to comment
Share on other sites

  • 3 weeks later...

Great to see that the file types have been updated.

 

I've just been trying to compile the code with VS2017 targetting .NET 4.8. I have a couple of issues with SvgFileType.cs.

 

Firstly, the obsolete constructor. Have I fixed it correctly?

 

    public class SvgFileType : FileType
    {
        //
        // Obsolete.
        //
        //public SvgFileType()
        //    : base(
        //        "Scalable Vector Graphics",       // name
        //        FileTypeFlags.SupportsLoading,    // flags
        //        new[] {".svg", ".svgz"})          // extensions
        //{
        //}

        //
        // New and improved.
        //
        public SvgFileType()
            : base
            (
                "Scalable Vector Graphics",         // name
                new FileTypeOptions                 // options
                {
                    LoadExtensions = new string[] { ".svg", ".svgx" }
                }
            )
        {
            //this.Options.LoadExtensions = new List<string> { ".svg", ".svgx" };
            //this.Options.LoadExtensions = new string[] { ".svg", ".svgx" };
            //FileTypeOptions fto = new FileTypeOptions
            //{
            //    LoadExtensions = new List<string> { ".svg", ".svgx" }
            //};
        }

 

 

Secondly, I get 4 compile errors with SvgVisualElement.Visible being read only, e.g.:

 

Quote

Error    CS0200    Property or indexer 'SvgVisualElement.Visible' cannot be assigned to -- it is read only    SvgFileTypePlugin    C:\Users\me\Dowloads\Scalable-Vector-Graphics-Plugin-for-Paint.NET-0.3-alpha\Scalable-Vector-Graphics-Plugin-for-Paint.NET-0.3-alpha\SvgFileType\SvgFileType.cs

 

Would it be OK to comment these out. or is there a new equivalent?

Link to comment
Share on other sites

3 hours ago, Tim! said:

Firstly, the obsolete constructor. Have I fixed it correctly?

 

That looks okay to me.

 

3 hours ago, Tim! said:

Secondly, I get 4 compile errors with SvgVisualElement.Visible being read only, e.g.:

 

Would it be OK to comment these out. or is there a new equivalent?

 

You have to ask the people developing the SVG plugin.

Link to comment
Share on other sites

  • 4 weeks later...

I just want to mention that in Project Template - Effect the slider has a minimum value equal to 0 which leads to crash due to division by zero in the following line:

CurrentPixel = (y% amount1 == 0)? ...


Also, SubmenuName is Blur although I think it should be null to be easily found by the user.

The plugin below was created just to test some things. It doesn't do anything special, it just draws lines and a circle.

The color control is based on the control in the CodeLab source code and is quite similar.

h0G6rJh.png

Here is the source code:
http://www.mediafire.com/file/9f9gz612mmmlldu/VSpdnProject.zip/file
 

  • Upvote 1
Link to comment
Share on other sites

1 hour ago, NSD said:

I just want to mention that in Project Template - Effect the slider has a minimum value equal to 0 which leads to crash due to division by zero in the following line:


CurrentPixel = (y% amount1 == 0)? ...


Also, SubmenuName is Blur although I think it should be null to be easily found by the user.

 

People aren't meant to run the example code, but if it bothers you, submit a Pull request on the Github project.

Link to comment
Share on other sites

  • 9 months later...

Unfortunately, these templates use the .NET Framework. The newest Paint.NET alpha (which I wish to target with my plugin, for reasons of having the newest C# 9 features) uses .NET 5. If I do what these templates do (which is target the Paint.NET DLLs, copy plugin dll to FileTypes/Effects folder at post build, then start Paint.NET as the debug action) with the new SDK csproj format as well as targeting `net5.0-windows`, it'll complain of DLL conflicts due to different versions that the plugin is using compared to Paint.NET. Do you plan on fixing these templates for .NET 5?
EDIT:
After some messing around, I did get it to compile. Although, it would be nice to have these templates updated...


New csproj format properties:

Spoiler

 

  <PropertyGroup>
    <OutputType>Library</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>


Paint.NET DLL references:

Spoiler

 

  <ItemGroup>
    <Reference Include="PaintDotNet.Base">
      <HintPath>C:\Program Files\paint.net\PaintDotNet.Base.dll</HintPath>
    </Reference>
    <Reference Include="PaintDotNet.Core">
      <HintPath>C:\Program Files\paint.net\PaintDotNet.Core.dll</HintPath>
    </Reference>
    <Reference Include="PaintDotNet.Data">
      <HintPath>C:\Program Files\paint.net\PaintDotNet.Data.dll</HintPath>
    </Reference>
  </ItemGroup>


 
PostBuild event (new csproj format):

Spoiler

 

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="if exist &quot;$(TargetPath)&quot; (&#xD;&#xA;  copy &quot;$(TargetPath)&quot; &quot;C:\Program Files\paint.net\FileTypes\&quot;&#xD;&#xA;) else (&#xD;&#xA;  echo ERROR: Failed to copy plugin! Check if the build failed.&#xD;&#xA;  exit(1)&#xD;&#xA;)" />
  </Target>



Then add this to the end of your AssemblyInfo.cs:

Spoiler

 

[assembly: SupportedOSPlatform("windows")]


 

And finally, debugging paint.net at start debug:

Spoiler

 

image.thumb.png.39d37cbb97270a49c5dd86087d84d53c.png

Edited by xchellx
Figured out how to build plugin with .NET 5; explanation
Link to comment
Share on other sites

3 hours ago, xchellx said:

After some messing around, I did get it to compile. Although, it would be nice to have these templates updated...

 

Okay, if you've already made the effort to get it working, then go submit a pull request on Github.

Keep in mind I won't publish an update until Paint.NET v4.3 is released.

 

 

 

Existing plugin codebases can just use the try-convert tool to automatically migrate solutions/projects to .NET 5.

https://github.com/dotnet/try-convert

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Configuration Manager in Visual Studio 2019?

I attempted to make the changes in the previous post to update the template for Core 5.0. No easy task. I tried editing the code with Visual Studio Code but when I opened the Project in Visual Studio it prompted me to open the Configuration Manager. Microsoft Docs describes how to activate Configuration Manager but my installation is missing the described menu entry.  "Show advanced build configurations" does not exist. I did try another approach by building the template from a new project, but when copying the code into the new project, there were too many errors generated (not because of lack of references). Seems Core 5.0 is a whole new language.

Signature2018.png

 

Link to comment
Share on other sites

@AndrewDavid sounds like you keep biting off more than you can chew.

 

If you're trying to compile the template files, that will never work. The templates have a bunch of none-code within them.

What you want to build is the VSIX package.  Hint: You need the 'Visual Studio SDK' installed. You can find an option for it in the Visual Studio Installer.

 

I have no idea what you're talking about with the Configuration Manager.  Sounds like Visual Studio is just confused, because you're missing that SDK.

Link to comment
Share on other sites

It does say create addons and extensions (which I have no plans on doing) which is why it wasn't installed. Once installed, still no config manager.  I'll just continue downloading until I get it.

 

40 minutes ago, toe_head2001 said:

sounds like you keep biting off more than you can chew.

I have time to learn.

 

41 minutes ago, toe_head2001 said:

I have no idea what you're talking about with the Configuration Manager.

Do you see it? I may have to build it as a custom tool.

Signature2018.png

 

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...