APShredder Posted September 22, 2009 Share Posted September 22, 2009 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. Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
pyrochild Posted September 22, 2009 Share Posted September 22, 2009 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. Quote ambigram signature by Kemaru [i write plugins and stuff] If you like a post, upvote it! Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 Normally I won't be editing the code in there, except that if I don't, I wouldn't be able to build my plugin. So either way it's kinda of a lose-lose situation. Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
pyrochild Posted September 22, 2009 Share Posted September 22, 2009 You can move the code into your own initializer (what I do) or you can simply not use the form designer (what Rick does). Quote ambigram signature by Kemaru [i write plugins and stuff] If you like a post, upvote it! Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 Sorry for being such a noob, but I don't know how to do either of those. Help please? Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 I'm not 100% sure what the gradient control even is, but one way would be to create a wrapper control and create and dock-fill the gradient control inside it in the Load() event handler OnLoad() override. Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 <-- Those are gradient controls. As for all the other stuff you said... well I don't understand any of it. Like I said before, I'm pretty much a total noob, so you're going to have to kind be pretty basic with me. Sorry. :oops: Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 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). Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 Are you sure there's a template for it? All I have is: Windows Form Application, Class Library, WPF Application, WPF Browser Application, Console Application, and Empty Project. Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 It's an item template: Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 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? Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 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. Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 Did you copy the version with two edits? Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 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); } } } Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 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); } } } Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 Well I tried using that code, but I'm still getting the same error message. Any ideas? Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 Add a using for System.Windows.Forms. Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 22, 2009 Author Share Posted September 22, 2009 Ok, now that class works, but my gradient controls are in a groupbox, so how do I add the class to my plugin? Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 23, 2009 Author Share Posted September 23, 2009 If I try to build it, it brings me back to my original problem. I have to go and comment all those lines that were giving me errors, which kind of makes the whole process pointless. Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 23, 2009 Share Posted September 23, 2009 The point of the wrapper method was that you could avoid adding property wrappers for those you don't want the designer touching, remove them from the code and thus have the designer ignore them. Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 23, 2009 Author Share Posted September 23, 2009 Ok, now I'm just totally lost. Maybe it would be easier just to do what I was doing before. Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Simon Brown Posted September 23, 2009 Share Posted September 23, 2009 If you send it to me I could try to fix it. Quote Link to comment Share on other sites More sharing options...
APShredder Posted September 23, 2009 Author Share Posted September 23, 2009 Ok here you go. Extract Color Source Quote BlendModes Plus | Dissolve | Extract Color Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.