BoltBait Posted December 31, 2014 Share Posted December 31, 2014 The IndirectUI double slider control has an issue where the up arrow can not increase beyond certain values. For example, if you create a control min: 0, max: 15, default: 8, step: .01, you can not press the control's up arrow beyond 8.03 when starting from the default position of 8. Here is a CodeLab script to demonstrate the issue: #region UICode double Amount1 = 8; // [0,15] Control Description #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; dst[x,y] = CurrentPixel; } } } CodeLab then builds the following code from that script: Hidden Content: using System; using System.Linq; using System.Text; using System.Windows; using System.Drawing; using Microsoft.Win32; using System.Reflection; using System.Drawing.Text; using System.Windows.Forms; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using PaintDotNet; using PaintDotNet.Effects; using PaintDotNet.AppModel; using PaintDotNet.IndirectUI; using PaintDotNet.Collections; using PaintDotNet.PropertySystem; [assembly: AssemblyTitle("DoubleSlider Plugin for Paint.NET")] [assembly: AssemblyDescription("DoubleSlider selected pixels")] [assembly: AssemblyConfiguration("doubleslider")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DoubleSlider")] [assembly: AssemblyCopyright("Copyright © ")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: AssemblyVersion("1.0.*")] namespace DoubleSliderEffect { public class PluginSupportInfo : IPluginSupportInfo { public string Author { get { return ((AssemblyCopyrightAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0]).Copyright; } } public string Copyright { get { return ((AssemblyDescriptionAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0]).Description; } } public string DisplayName { get { return ((AssemblyProductAttribute)base.GetType().Assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0]).Product; } } public Version Version { get { return base.GetType().Assembly.GetName().Version; } } public Uri WebsiteUri { get { return new Uri("http://www.getpaint.net/redirect/plugins.html"); } } } [PluginSupportInfo(typeof(PluginSupportInfo), DisplayName = "DoubleSlider")] public class DoubleSliderEffectPlugin : PropertyBasedEffect { public static string StaticName { get { return "DoubleSlider"; } } public static Image StaticIcon { get { return null; } } public static string SubmenuName { get { return null; // Programmer's chosen default } } public DoubleSliderEffectPlugin() : base(StaticName, StaticIcon, SubmenuName, EffectFlags.Configurable) { } public enum PropertyNames { Amount1 } protected override PropertyCollection OnCreatePropertyCollection() { List<Property> props = new List<Property>(); props.Add(new DoubleProperty(PropertyNames.Amount1, 8, 0, 15)); return new PropertyCollection(props); } protected override ControlInfo OnCreateConfigUI(PropertyCollection props) { ControlInfo configUI = CreateDefaultConfigUI(props); configUI.SetPropertyControlValue(PropertyNames.Amount1, ControlInfoPropertyNames.DisplayName, "Control Description"); configUI.SetPropertyControlValue(PropertyNames.Amount1, ControlInfoPropertyNames.SliderLargeChange, 0.25); configUI.SetPropertyControlValue(PropertyNames.Amount1, ControlInfoPropertyNames.SliderSmallChange, 0.05); configUI.SetPropertyControlValue(PropertyNames.Amount1, ControlInfoPropertyNames.UpDownIncrement, 0.01); return configUI; } protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { this.Amount1 = newToken.GetProperty<DoubleProperty>(PropertyNames.Amount1).Value; base.OnSetRenderInfo(newToken, dstArgs, srcArgs); } protected override unsafe void OnRender(Rectangle[] rois, int startIndex, int length) { if (length == 0) return; for (int i = startIndex; i < startIndex + length; ++i) { Render(DstArgs.Surface,SrcArgs.Surface,rois[i]); } } #region User Entered Code #region UICode double Amount1 = 8; // [0,15] Control Description #endregion void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; dst[x,y] = CurrentPixel; } } } #endregion } } To view the issue, you must build the script to a DLL and install it. When you run the effect from within paint.net, try pressing the up arrow on the control. It will stop at 8.03. At this point, if you type in 8.04 tab, it will reset back to 8.03. Or, if you type 8.05 tab, then press the up arrow again it will stop at 8.28. It appears that some values simply are not allowed in the control. Using the down arrow jumps over these "broken" values (8.04, 8.29, etc.) but does not stop the UI. EDIT: Interestingly, the built-in Effects > Noise > Add Noise effect does not show this issue with the coverage slider. I'm able to enter 8.04 and 8.29 directly into the control. HOWEVER, the built-in effect Effects > Render > Julia Fractal DOES show the problem with the Factor slider. You can not enter 8.04 or 8.29 into the amount. It appears that the maximum amount of the slider makes a difference. I think this shows that it is NOT a CodeLab issue. This issue was originally reported by user TechnoRobbo. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
ReMake Posted December 31, 2014 Share Posted December 31, 2014 This error is shown only in the range from 8.04 to 10.04 (PDN 3.5.11 & CodeLab 1.8). 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.