Jump to content

Gradient Control w/ Top + Bottom Colors?


APShredder

Recommended Posts

As I've been trying to make my latest plugin, I decided to add some Gradient controls to it. But the thing is, every time I go to build it I get error saying:

'PaintDotNet.ColorGradientControl.BottomColor' is obsolete: 'Use MinColor property instead'

'PaintDotNet.ColorGradientControl.TopColor' is obsolete: 'Use MaxColor property instead'

So usually I just go and comment those lines and then I can successful build the plugin. The problem with that though, is every time I change something in the ConfigDialog, they become uncommented. And it's really annoying to have to go back, find the lines that I need, and comment them every time I change anything I the ConfigDialog.

So I guess my question is, is there a better way to stop those error messages from showing up in the first place?

Thanks in advance. :D

Link to comment
Share on other sites

You shouldn't be manually editing code in InitializeComponent() if you're using the Visual Studio form designer unless you really know what you're doing. Otherwise, your changes will likely either break the designer or end up getting reverted by VS's code generation.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

Sorry if this seems patronising:

1. Create a custom control, Visual C# has an item template for them.

2. Override the OnLoad method in the new class.

3. Create a new instance of the gradient control with your needed properties (some obviously added to the custom control manually), fill dock it in the control and add it to the control using this.Controls.Add(gradientControlBuilder).

KaHuc.png
Link to comment
Share on other sites

Ok, so I'm farther along then before, but I'm stuck again.

Here's where I am so far:

using System;
using System.Collections.Generic;
using PaintDotNet;
using System.Text;

namespace ExtractColor
{
   private override class gradientControlBuilder
   {
       private ColorGradientControl CGC = new ColorGradientControl();

   }
}

Where should I go from here?

Link to comment
Share on other sites

Note that it is a method that should be overridden, not the class. Sample code:

   using System;
   using System.Collections.Generic;
   using PaintDotNet;
   using System.Text;

   namespace ExtractColor
   {
       internal class GradientControlWrapper : UserControl 
       {
           ColorGradientControl colorGradientControl;

           protected override void OnLoad()
           {
              colorGradientControl = new ColorGradientControl();
              colorGradientControl.Dock = DockStyle.Fill;

              this.Controls.Add(colorGradientControl);
           }
       }
   }

Edit: Replaced private with internal.

Edit2: Derived from UserControl.

KaHuc.png
Link to comment
Share on other sites

Ok I think I got it, but I'm still getting an error message saying:

'ExtractColor.GradientControlWrapper' does not contain a definition for 'Controls' and no extension method 'Controls' accepting a first argument of type 'ExtractColor.GradientControlWrapper' could be found (are you missing a using directive or an assembly reference?)

My code matches yours exactly so I don't know what the problem is.

Link to comment
Share on other sites

Yep. I even tried recopying it.

Here's my code:

using System;
using System.Collections.Generic;
using PaintDotNet;
using System.Text;

namespace ExtractColor
{
   internal class GradientControlWrapper : UserControl
   {
       ColorGradientControl colorGradientControl;

       protected override void OnLoad()
       {
           colorGradientControl = new ColorGradientControl();
           colorGradientControl.Dock = System.Windows.Forms.DockStyle.Fill;

           this.Controls.Add(colorGradientControl);
       }
   }
}

Link to comment
Share on other sites

Sorry, I was writing it from memory and forgot that OnLoad takes an EventArgs parameter. Try this:

   using System;
   using System.Collections.Generic;
   using PaintDotNet;
   using System.Text;

   namespace ExtractColor
   {
       internal class GradientControlWrapper : UserControl
       {
           ColorGradientControl colorGradientControl;

           protected override void OnLoad(EventArgs e)
           {
               colorGradientControl = new ColorGradientControl();
               colorGradientControl.Dock = System.Windows.Forms.DockStyle.Fill;

               this.Controls.Add(colorGradientControl);
           }
       }
   }

KaHuc.png
Link to comment
Share on other sites

If you build the project, it should show-up in the toolbox. Alternatively, if you want to replace the current gradient controls with the wrapper, backup the project and change the type names in the InitializeComponent() method to the wrapper. If any exceptions come-up with non-referenced properties, simply add getters and setters to the wrapper for those properties which proxy those properties in the wrapper's gradient box control.

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

×
×
  • Create New...