-Mari- Posted August 5, 2019 Share Posted August 5, 2019 I am trying to change the output of the CopySelectionCoords plugin from left, top, width, height to { "X": left, "Y": top, "Width": width, "Height": height } I've come across a few issues, but most of it boils down to me not knowing how to properly convert EffectFlags to EffectOptions. I've read this thread and downloaded and looked through OptionBasedLibrary v0.7.9. I've read through all the CodeLab tutorials and searched through the forum using GetPaint's custom search page. I'm a C# novice and I'm trying to use Visual Studio 2019 to edit this plugin for my own use; I've tried using CodeLab, but I'm not sure how to use it to get the output I need. I would greatly appreciate some help since I'm obviously in over my head. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted August 5, 2019 Share Posted August 5, 2019 : base(StaticName, StaticIcon, SubmenuName, EffectFlags.None) To: : base(StaticName, StaticIcon, SubmenuName, new EffectOptions { Flags = EffectFlags.None }) Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
toe_head2001 Posted August 5, 2019 Share Posted August 5, 2019 For the output string change: string selectionCoords = $"{selection.Left}, {selection.Top}, {selection.Width}, {selection.Height}"; To: string selectionCoords = $"X: {selection.Left}, Y: {selection.Top}, Width: {selection.Width}, Height: {selection.Height}"; Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
toe_head2001 Posted August 5, 2019 Share Posted August 5, 2019 If you want to switch to CodeLab, all you need is this: void PreRender(Surface dst, Surface src) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); string selectionCoords = "X: " + selection.Left + ", Y: " + selection.Top + ", Width: " + selection.Width + ", Height: " + selection.Height; Services.GetService<IClipboardService>().SetText(selectionCoords); } void Render(Surface dst, Surface src, Rectangle rect) { dst.CopySurface(src, rect.Location, rect); } Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
-Mari- Posted August 5, 2019 Author Share Posted August 5, 2019 Thank you! I tried your first solution, but I thought I'd done something incorrectly. After looking at your original plugin, I think that I must've misunderstood what its purpose was. I was trying to make a selection and have the (x,y) of the top left corner of that selection and the width and height of the selection shown in the output. I appreciate your time. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted August 5, 2019 Share Posted August 5, 2019 3 minutes ago, -Mari- said: I was trying to make a selection and have the (x,y) of the top left corner of that selection and the width and height of the selection shown in the output. Um, that's exactly what the plugin does. Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
-Mari- Posted August 5, 2019 Author Share Posted August 5, 2019 I thought so, too, but maybe I'm doing something else incorrectly. No matter what selection I make it only outputs 0, 0, 800, 600. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted August 5, 2019 Share Posted August 5, 2019 And you're using the code from here? Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
-Mari- Posted August 5, 2019 Author Share Posted August 5, 2019 All my selections still come out to X: 0, Y: 0, Width: 800, Height: 600. I'm not sure why. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted August 5, 2019 Share Posted August 5, 2019 Can you post a screenshot of paint.net showing your selection? Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
-Mari- Posted August 5, 2019 Author Share Posted August 5, 2019 Quote Link to comment Share on other sites More sharing options...
-Mari- Posted August 5, 2019 Author Share Posted August 5, 2019 I figured out what I was messing up. I was selecting the effect then making my selection instead of making my selection and then choosing the effect. Selection -> Copy Selection. I don't know what I was thinking. Thank you so much for your help and for writing the original plugin. Quote 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.