Ego Eram Reputo Posted August 23, 2018 Share Posted August 23, 2018 Nice start! Feel free to post your code if you want help. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
xod Posted September 3, 2018 Author Share Posted September 3, 2018 I try to use OptionBasedLibrary but i can't figure out how to get the parameter Bold or Italic or both. enum OptionNames { myFontStyle, ... } enum FontStyleEnum { Bold, Italic } protected override OptionControlList OnSetupOptions(OptionContext optContext) { return new OptionControlList { new OptionEnumCheckBoxes<FontStyleEnum>(OptionNames.myFontStyle, optContext) { }, ... protected override void OnSetRenderInfo(OptionBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { FontStyle myStyle = OptionEnumCheckBoxes<FontStyleEnum>.GetOptionChecked(OptionNames.myFontStyle, newToken.Items); ... Error: There is no argument given to corresponds to the required formal parameter 'values' of ... Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 3, 2018 Share Posted September 3, 2018 33 minutes ago, xod said: I try to use OptionBasedLibrary but i can't figure out how to get the parameter Bold or Italic or both. Replace FontStyle with FontStyleEnum. FontStyleEnum myStyle = OptionEnumCheckBoxes<FontStyleEnum>.GetOptionChecked(OptionNames.myFontStyle, newToken.Items); 2 Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
xod Posted September 8, 2018 Author Share Posted September 8, 2018 Is there a way to make the VectorPan control background to have the color of the canvas?(OptionBasedLibrary) Spoiler new OptionDoubleVectorPan(OptionNames.VectorPan, optContext, 0, -1, 1, 0, -1, 1, false)//true = deactivate control { DisplayName = "Position",//the control name displayed on the UI StaticBitmapUnderlay = new Bitmap(80,60),//an image can be used here: new Bitmap(Image,80,60), Indent = 0,//Indenting to the left of the window //NumericUnitX = new NumericUnit("%"), //NumericUnitY = new NumericUnit("%"), UpDownIncrementX = 0.01, UpDownIncrementY = 0.01, ShowLineToCenter = true, ViewOffset = 0, ViewFactor = 1, DecimalPlaces = 3, ShowResetButton = true, SliderShowTickMarks = false, SliderSmallChangeX = 0.01, SliderSmallChangeY = 0.01, SliderLargeChangeX = 0.25, SliderLargeChangeY = 0.25, //Description = "Control Description", GadgetScale = 1.5, //Label = "Label:\nsome text\nhere" } Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 8, 2018 Share Posted September 8, 2018 52 minutes ago, xod said: Is there a way to make the VectorPan control background to have the color of the canvas?(OptionBasedLibrary) StaticBitmapUnderlay = this.EnvironmentParameters.SourceSurface.CreateAliasedBitmap(selection); Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
xod Posted September 8, 2018 Author Share Posted September 8, 2018 (edited) Thanks TH. Edited September 9, 2018 by xod Quote Link to comment Share on other sites More sharing options...
xod Posted September 9, 2018 Author Share Posted September 9, 2018 How to add list of installed font in a drop down? new OptionEnumDropDown<FontFamily>(OptionNames.Test, optContext) This does not work: The type 'FontFamily' must be a non-nullabe value... Quote Link to comment Share on other sites More sharing options...
Mallaboro Posted September 9, 2018 Share Posted September 9, 2018 Nearly finished my plugin. ? As a long-time user of paint.net I must say I'm quite proud. 1 Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted September 9, 2018 Share Posted September 9, 2018 Top effort! I'm impressed. 2 Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 12, 2018 Share Posted September 12, 2018 On 9/9/2018 at 6:59 PM, xod said: How to add list of installed font in a drop down? An OptionBasedEffect requires the DropDown items to be defined in an enum. However, you can't dynamically create an enum from a list of fonts. IndirectUI is more flexible in this regard, since the items can be defined in an array of any type, or an enum. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
xod Posted September 12, 2018 Author Share Posted September 12, 2018 Thanks for the reply. So there is no simple solution? Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 12, 2018 Share Posted September 12, 2018 1 minute ago, xod said: So there is no simple solution? Correct. Midora (Martin Osieka) hasn't been around for more than 18 months, but you could try to send him a PM with the feature request. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
MJW Posted September 12, 2018 Share Posted September 12, 2018 3 hours ago, toe_head2001 said: IndirectUI is more flexible in this regard, since the items can be defined in an array of any type, or an enum. Perhaps I'm missing something, having never used the OptionBased library, but that doesn't really seem like much of a limitation. Can't the integer returned by the control be used to index into an array of fonts? Returning anything but an index from a list control never struck me as that great of an advantage. It may save a few steps, but they're pretty simple steps. 1 Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 12, 2018 Share Posted September 12, 2018 1 minute ago, MJW said: Perhaps I'm missing something, having never used the OptionBased library, but that doesn't really seem like much of a limitation. Can't the integer returned by the control be used to index into an array of fonts? Returning anything but an index from a list control never struck me as that much of an advantage The issue is not about the return value, but simply populating the DropDown. You have to have an enum with all the DropDown items. ie. enum Fonts { Arial, Consolas, Times New Roman, ... } Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
MJW Posted September 12, 2018 Share Posted September 12, 2018 I see the problem. If the OptionBased library accepts only enums for the list values, that seems like a rather poor design choice, since it doesn't easily allow for any variable-length lists. There's no option to simply return the integer index of the selection? If the length of the list can be specified independently of the number of enum entries, then the problem can be solved (simply, if not elegantly) by using an enum with the maximum number of entries. I expect it can't, though. Quote Link to comment Share on other sites More sharing options...
xod Posted September 13, 2018 Author Share Posted September 13, 2018 I looked at the PrintIt effect and it seems that OptionBased can display the list of installed fonts, but I don't know how ... Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 13, 2018 Share Posted September 13, 2018 34 minutes ago, xod said: I looked at the PrintIt effect and it seems that OptionBased can display the list of installed fonts, but I don't know how ... The implementation for the OptionFontName control is within PrintIt itself, and therefore can't be used by other plugins. You could try to recreate it though. An OptionControl works like a UserControl. ie: A control that houses a group of child controls. Create a class that derives from OptionControl, and add the controls you need. class MyCustomOptionControl : OptionControl { ComboBox myDropDown = new ComboBox(); TextBox myTextBox = new TextBox(); CheckBox myCheckBox = new TextBox(); MyCustomOptionControl() { } } Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
null54 Posted September 13, 2018 Share Posted September 13, 2018 36 minutes ago, xod said: I looked at the PrintIt effect and it seems that OptionBased can display the list of installed fonts, but I don't know how ... That control is part of PrintIt, not the OptionBased library. 1 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait Link to comment Share on other sites More sharing options...
xod Posted September 13, 2018 Author Share Posted September 13, 2018 OK, thank you for the answers. Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 13, 2018 Share Posted September 13, 2018 (edited) @xod, I got a proof-of-concept working: Spoiler Add this class to your project. internal class OptionFontDropDown : OptionControl { private readonly ComboBox fontDropDown; private readonly int defaultIndex; internal OptionFontDropDown(Enum optId, OptionContext optContext) : this(optId, optContext, "Arial") { } internal OptionFontDropDown(Enum optId, OptionContext optContext, string defaultFont) : base(optId, optContext) { this.fontDropDown = new ComboBox(); this.defaultIndex = FontUtil.FindFontIndex(defaultFont); this.fontDropDown.Items.AddRange(FontUtil.FontNames); this.fontDropDown.SelectedIndex = this.defaultIndex; this.fontDropDown.SelectedIndexChanged += (sender, e) => OnValueChanged(); this.Controls.Add(fontDropDown); } public override void OptionDefaultToValues(OptionDictionary values) { values[this.Id] = FontUtil.FontNames[this.defaultIndex]; } public override void OptionToValues(OptionDictionary values) { values[this.Id] = FontUtil.FontNames[this.fontDropDown.SelectedIndex]; } public override void ValuesToOption(OptionDictionary values) { string fontName = (string)values[this.Id]; fontDropDown.SelectedIndex = FontUtil.FindFontIndex(fontName); } protected override void OnReset() { fontDropDown.SelectedIndex = this.defaultIndex; } public static string GetOptionValue(Enum optId, OptionDictionary values) { return (string)values[optId.ToString()]; } protected override void OnLayout(LayoutEventArgs e) { this.SetBounds( 0, 0, this.Parent?.Width ?? this.fontDropDown.Width + this.fontDropDown.Margin.Horizontal, this.fontDropDown.Height + this.fontDropDown.Margin.Vertical); base.OnLayout(e); } private static class FontUtil { internal static readonly string[] FontNames; internal static int FindFontIndex(string familyName) { for (int i = 0; i < FontNames.Length; i++) { if (FontNames[i].Equals(familyName, StringComparison.OrdinalIgnoreCase)) { return i; } } return 0; } static FontUtil() { List<string> usableFonts = new List<string>(); using (InstalledFontCollection intstalledFonts = new InstalledFontCollection()) { foreach (FontFamily font in intstalledFonts.Families) { usableFonts.Add(font.Name); } } FontNames = usableFonts.ToArray(); } } } Edited September 13, 2018 by toe_head2001 1 2 Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
xod Posted September 14, 2018 Author Share Posted September 14, 2018 Thank you very much! Quote Link to comment Share on other sites More sharing options...
xod Posted September 17, 2018 Author Share Posted September 17, 2018 (edited) It is the same plugin made with the OptionBased library. 1. I can't figure out how to disable 'Inner circle', 'Outer circle' and 'Pen width' when I uncheck 'Draw the circles'. 2. If I modify the Alpha channel for any Colors tab and then run the Pan or Rotator controls (not the sliders) the canvas is not updated with the chosen color. Download Edited October 26, 2018 by xod 1 Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted September 17, 2018 Share Posted September 17, 2018 16 minutes ago, xod said: 1. I can't figure out how to disable 'Inner circle', 'Outer circle' and 'Pen width' when I uncheck 'Draw the circles'. Did you take a look at the example in my 'Graph Paper' plugin? https://github.com/toehead2001/pdn-graph-paper/blob/master/GraphPaper/GraphPaper.cs#L204 19 minutes ago, xod said: 2. If I modify the Alpha channel for any Colors tab and then run the Pan or Rotator controls (not the sliders) the canvas is not updated with the chosen color. I'm guessing the Effect Token only gets updated when Focus leaves the Alpha textbox. When you click on the Pan or the Rotator, the Focus remains in the textbox (as evidenced by the blinking text caret). You might be able to create a work-around, but I'd have to take a close look at it to be sure. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
xod Posted September 30, 2018 Author Share Posted September 30, 2018 I'm trying to translate my plugins into my language and everything goes right except for the title in the window that remains unchanged. Is there a trick I should know? Spoiler public string DisplayName => LangStrings.EffectName; using System.Globalization; namespace TestEffect { internal static class LangStrings { private static readonly string UICulture = CultureInfo.CurrentUICulture.Name; internal static string EffectName { get { switch (UICulture) { case "ro": return "The effect name in my language"; default: return "The effect name in english"; } } } ... Quote Link to comment Share on other sites More sharing options...
ReMake Posted September 30, 2018 Share Posted September 30, 2018 Try Spoiler using System.Globalization; namespace TestEffect { public class PluginSupportInfo : IPluginSupportInfo { public string DisplayName => LangStrings.EffectName; } internal static class LangStrings { private static readonly string UICulture = CultureInfo.CurrentUICulture.Name; internal static string EffectName { get { switch (UICulture) { case "ro": return "The effect name in my language"; default: return "The effect name in english"; } } } ... 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.