From 534b5496449ddce3fe5b8732d170dbbe9fddb028 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 22 Jun 2026 18:39:37 +0100 Subject: [PATCH 1/5] Add KryptonCircularProgressBar + animation lib Add a new KryptonCircularProgressBar control with full Krypton palette integration, animation support, marquee mode, superscript/subscript text and tri-state threshold compatibility. Includes: - Control implementation (KryptonKryptonCircularProgressBar.cs) and ValueChangedEventArgs - Embedded WinFormAnimation library (Animator, Path, Timer, easing functions, helpers) - README, toolbox bitmap and test harness (CircularProgressBarTest form + designer + resx) - TestForm StartScreen entry and changelog entry - Small project/global-using updates and resource designer tweaks This brings the circular progress control into Krypton.Toolkit.Utilities and adds a demo for manual verification. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Documents/Changelog/Changelog.md | 2 + .../KryptonKryptonCircularProgressBar.cs | 925 ++++++++++++++++++ .../General/ValueChangedEventArgs.cs | 67 ++ .../KryptonCircularProgressBar.bmp | Bin 0 -> 380 bytes .../SearchBoxImageResources.Designer.cs | 4 +- .../Global/Globals.cs | 2 + .../Krypton.Toolkit.Utilities/GlobalUsings.cs | 3 +- .../Krypton.Toolkit.Utilities.csproj | 1 + .../General/AnimationFunctions.cs | 681 +++++++++++++ .../WinFormAnimatiion/General/Animator.cs | 481 +++++++++ .../WinFormAnimatiion/General/Animator2D.cs | 470 +++++++++ .../WinFormAnimatiion/General/Animator3D.cs | 504 ++++++++++ .../WinFormAnimatiion/General/Definitions.cs | 283 ++++++ .../WinFormAnimatiion/General/Float2D.cs | 640 ++++++++++++ .../WinFormAnimatiion/General/Float3D.cs | 509 ++++++++++ .../General/FloatExtensions.cs | 68 ++ .../WinFormAnimatiion/General/IAnimator.cs | 119 +++ .../WinFormAnimatiion/General/Icon.png | Bin 0 -> 12792 bytes .../WinFormAnimatiion/General/Path.cs | 176 ++++ .../WinFormAnimatiion/General/Path2D.cs | 321 ++++++ .../General/Path2DExtensions.cs | 294 ++++++ .../WinFormAnimatiion/General/Path3D.cs | 376 +++++++ .../General/Path3DExtensions.cs | 305 ++++++ .../General/PathExtensions.cs | 174 ++++ .../WinFormAnimatiion/General/SafeInvoker.cs | 166 ++++ .../General/SafeInvoker`1.cs | 66 ++ .../WinFormAnimatiion/General/Timer.cs | 187 ++++ .../Controls Toolkit/KryptonProgressBar.cs | 29 + .../AboutToolkitImageResources.Designer.cs | 2 +- .../Buttons/ButtonImageResources.Designer.cs | 2 +- .../CommandLinkImageResources.Designer.cs | 2 +- .../OutlookGridImageResources.Designer.cs | 2 +- .../OutlookGridStringResources.Designer.cs | 2 +- .../PaletteSchemaResources.Designer.cs | 2 +- .../Sort/SortingImageResources.Designer.cs | 2 +- .../ToolkitLogoResources.Designer.cs | 2 +- ...ndows10UACShieldImageResources.Designer.cs | 2 +- ...ndows11UACShieldImageResources.Designer.cs | 2 +- ...s7And8xUACShieldImageResources.Designer.cs | 2 +- ...wsVistaUACShieldImageResources.Designer.cs | 2 +- .../WindowsLogoImageResources.Designer.cs | 2 +- .../CircularProgressBarTest.Designer.cs | 806 +++++++++++++++ .../TestForm/CircularProgressBarTest.cs | 259 +++++ .../TestForm/CircularProgressBarTest.resx | 61 ++ .../TestForm/StartScreen.cs | 1 + 45 files changed, 7990 insertions(+), 16 deletions(-) create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonKryptonCircularProgressBar.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/General/ValueChangedEventArgs.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ToolboxBitmaps/KryptonCircularProgressBar.bmp create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/AnimationFunctions.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator2D.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator3D.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Definitions.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float2D.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float3D.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/FloatExtensions.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/IAnimator.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Icon.png create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2D.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2DExtensions.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3D.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3DExtensions.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/PathExtensions.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker`1.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Timer.cs create mode 100644 Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs create mode 100644 Source/Krypton Components/TestForm/CircularProgressBarTest.cs create mode 100644 Source/Krypton Components/TestForm/CircularProgressBarTest.resx diff --git a/Documents/Changelog/Changelog.md b/Documents/Changelog/Changelog.md index 00fc9e41b7..5e7a1457b0 100644 --- a/Documents/Changelog/Changelog.md +++ b/Documents/Changelog/Changelog.md @@ -45,6 +45,8 @@ ## 2026-11-xx - Build 2611 (V110 Nightly) - November 2026 +* Implemented [#3763](https://github.com/Krypton-Suite/Standard-Toolkit/issues/3763), Bring the `KryptonCircularProgressBar` over + * To use, you will need to download the `Krypton.Standard.Toolkit` NuGet package, as this control is part of the `Krypton.Toolkit.Utilities` assembly. * Resolved [#1870](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1870), Restored `BasePaletteMode` in `KryptonCustomPaletteBase` * Resolved [#3751](https://github.com/Krypton-Suite/Standard-Toolkit/issues/3751), `Krypton.Standard.Toolkit.Nightly` NuGet package does not upload * Implemented [#3657](https://github.com/Krypton-Suite/Standard-Toolkit/issues/3657), OS X Aqua Themes diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonKryptonCircularProgressBar.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonKryptonCircularProgressBar.cs new file mode 100644 index 0000000000..de733efbe2 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonKryptonCircularProgressBar.cs @@ -0,0 +1,925 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac & Ahmed Abdelhameed, tobitege et al. 2026 - 2026. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit.Utilities; + +/// The circular progress bar windows form control. +[Description("A circular progress bar for your applications.")] +[ToolboxItem(true)] +[ToolboxBitmap(typeof(KryptonCircularProgressBar), "ToolboxBitmaps.KryptonCircularProgressBar.bmp")] +[DefaultBindingProperty("Value")] +public class KryptonCircularProgressBar : KryptonProgressBar +{ + #region Instance Fields + + private readonly WinFormAnimation.Animator? _animator; + private int? _animatedStartAngle; + private float? _animatedValue; + private WinFormAnimation.AnimationFunctions.Function _animationFunction; + private Brush? _backBrush; + private WinFormAnimation.KnownAnimationFunctions _knownAnimationFunction; + private ProgressBarStyle? _lastStyle; + private int _lastValue; + + private readonly PaletteDoubleRedirect _outerRingStateCommon; + private readonly PaletteDouble _outerRingStateNormal; + private readonly PaletteDouble _outerRingStateDisabled; + + private readonly PaletteDoubleRedirect _innerRingStateCommon; + private readonly PaletteDouble _innerRingStateNormal; + private readonly PaletteDouble _innerRingStateDisabled; + + private readonly PaletteTripleRedirect _superscriptStateCommon; + private readonly PaletteTriple _superscriptStateNormal; + private readonly PaletteTriple _superscriptStateDisabled; + + private readonly PaletteTripleRedirect _subscriptStateCommon; + private readonly PaletteTriple _subscriptStateNormal; + private readonly PaletteTriple _subscriptStateDisabled; + + private IDisposable? _mementoProgressBack; + private IDisposable? _mementoOuterRingBack; + private IDisposable? _mementoInnerRingBack; + + #endregion + + #region Properties + + /// + /// Sets a known animation function. + /// + [Category("Behavior"), DefaultValue(WinFormAnimation.KnownAnimationFunctions.Linear)] + public WinFormAnimation.KnownAnimationFunctions AnimationFunction + { + get => _knownAnimationFunction; + set + { + _animationFunction = WinFormAnimation.AnimationFunctions.FromKnown(value); + _knownAnimationFunction = value; + } + } + + /// + /// Gets or sets the animation speed in milliseconds. + /// + [Category("Behavior"), DefaultValue(500)] + public int AnimationSpeed { get; set; } + + /// + /// Sets a custom animation function. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public WinFormAnimation.AnimationFunctions.Function CustomAnimationFunction + { + private get { return _animationFunction; } + set + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + _knownAnimationFunction = WinFormAnimation.KnownAnimationFunctions.None; + _animationFunction = value; + } + } + + /// + /// Gets or sets the font of text in the . + /// + /// + /// The of the text. The default is the font set by the container. + /// + [EditorBrowsable(EditorBrowsableState.Always)] + [Browsable(true)] + [AllowNull] + public override Font Font + { + get => base.Font; + set + { + if (value != null) + { + base.Font = value; + } + } + } + + /// + /// + [Category("Layout"), DefaultValue(2)] + public int InnerMargin { get; set; } + + /// + /// + [Category("Layout"), DefaultValue(-1)] + public int InnerWidth { get; set; } + + /// + /// + [Category("Layout"), DefaultValue(-25)] + public int OuterMargin { get; set; } + + /// + /// + [Category("Layout"), DefaultValue(26)] + public int OuterWidth { get; set; } + + /// + /// + [Category("Layout"), DefaultValue(25)] + public int ProgressWidth { get; set; } + + /// + /// + [Category("Appearance"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public Font SecondaryFont { get; set; } + + /// + /// + [Category("Layout"), DefaultValue(270)] + public int StartAngle { get; set; } + + /// + /// + [Category("Layout"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public Padding SubscriptMargin { get; set; } + + /// + /// + [Category("Appearance"), DefaultValue("")] + public string SubscriptText { get; set; } + + /// + /// + [Category("Layout"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public Padding SuperscriptMargin { get; set; } + + /// + /// + [Category("Appearance"), DefaultValue("")] + public string SuperscriptText { get; set; } + + /// + /// Gets or sets the text in the . + /// + [EditorBrowsable(EditorBrowsableState.Always)] + [Browsable(true)] + [AllowNull] + public override string Text + { + get => base.Text; + set => base.Text = value; + } + + /// + /// + [Category("Layout"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public Padding TextMargin { get; set; } + + /// + /// Gets access to the common outer ring appearance that other states can override. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining common outer ring appearance that other states can override.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteDoubleRedirect OuterRingStateCommon => _outerRingStateCommon; + + private bool ShouldSerializeOuterRingStateCommon() => !OuterRingStateCommon.IsDefault; + + /// + /// Gets access to the normal outer ring appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining normal outer ring appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteDouble OuterRingStateNormal => _outerRingStateNormal; + + private bool ShouldSerializeOuterRingStateNormal() => !OuterRingStateNormal.IsDefault; + + /// + /// Gets access to the disabled outer ring appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining disabled outer ring appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteDouble OuterRingStateDisabled => _outerRingStateDisabled; + + private bool ShouldSerializeOuterRingStateDisabled() => !OuterRingStateDisabled.IsDefault; + + /// + /// Gets access to the common inner ring appearance that other states can override. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining common inner ring appearance that other states can override.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteDoubleRedirect InnerRingStateCommon => _innerRingStateCommon; + + private bool ShouldSerializeInnerRingStateCommon() => !InnerRingStateCommon.IsDefault; + + /// + /// Gets access to the normal inner ring appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining normal inner ring appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteDouble InnerRingStateNormal => _innerRingStateNormal; + + private bool ShouldSerializeInnerRingStateNormal() => !InnerRingStateNormal.IsDefault; + + /// + /// Gets access to the disabled inner ring appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining disabled inner ring appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteDouble InnerRingStateDisabled => _innerRingStateDisabled; + + private bool ShouldSerializeInnerRingStateDisabled() => !InnerRingStateDisabled.IsDefault; + + /// + /// Gets access to the common superscript appearance that other states can override. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining common superscript text appearance that other states can override.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteTripleRedirect SuperscriptStateCommon => _superscriptStateCommon; + + private bool ShouldSerializeSuperscriptStateCommon() => !SuperscriptStateCommon.IsDefault; + + /// + /// Gets access to the normal superscript appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining normal superscript text appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteTriple SuperscriptStateNormal => _superscriptStateNormal; + + private bool ShouldSerializeSuperscriptStateNormal() => !SuperscriptStateNormal.IsDefault; + + /// + /// Gets access to the disabled superscript appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining disabled superscript text appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteTriple SuperscriptStateDisabled => _superscriptStateDisabled; + + private bool ShouldSerializeSuperscriptStateDisabled() => !SuperscriptStateDisabled.IsDefault; + + /// + /// Gets access to the common subscript appearance that other states can override. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining common subscript text appearance that other states can override.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteTripleRedirect SubscriptStateCommon => _subscriptStateCommon; + + private bool ShouldSerializeSubscriptStateCommon() => !SubscriptStateCommon.IsDefault; + + /// + /// Gets access to the normal subscript appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining normal subscript text appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteTriple SubscriptStateNormal => _subscriptStateNormal; + + private bool ShouldSerializeSubscriptStateNormal() => !SubscriptStateNormal.IsDefault; + + /// + /// Gets access to the disabled subscript appearance entries. + /// + [Category(@"Visuals")] + [Description(@"Overrides for defining disabled subscript text appearance.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public PaletteTriple SubscriptStateDisabled => _subscriptStateDisabled; + + private bool ShouldSerializeSubscriptStateDisabled() => !SubscriptStateDisabled.IsDefault; + + #endregion + + #region Constructor + + /// Initializes a new instance of the class. + public KryptonCircularProgressBar() + { + SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.OptimizedDoubleBuffer, true); + + _animator = DesignMode ? null : new WinFormAnimation.Animator(); + + AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Linear; + + AnimationSpeed = 500; + + MarqueeAnimationSpeed = 2000; + + StartAngle = 270; + + _lastValue = Value; + + DoubleBuffered = true; + + Font = new Font(Font.FontFamily, 72, FontStyle.Bold); + + SecondaryFont = new Font(Font.FontFamily, (float)(Font.Size * .5), FontStyle.Regular); + + OuterMargin = -25; + + OuterWidth = 26; + + ProgressWidth = 25; + + InnerMargin = 2; + + InnerWidth = -1; + + TextMargin = new Padding(8, 8, 0, 0); + + Value = 0; + + SuperscriptMargin = new Padding(10, 35, 0, 0); + + SuperscriptText = string.Empty; + + SubscriptMargin = new Padding(10, -35, 0, 0); + + SubscriptText = string.Empty; + + Size = new Size(320, 320); + + BackColor = Color.Transparent; + + _outerRingStateCommon = new PaletteDoubleRedirect(ProgressPaletteRedirect, + PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, OnCircularNeedPaint); + _outerRingStateNormal = new PaletteDouble(_outerRingStateCommon, OnCircularNeedPaint); + _outerRingStateDisabled = new PaletteDouble(_outerRingStateCommon, OnCircularNeedPaint); + + _innerRingStateCommon = new PaletteDoubleRedirect(ProgressPaletteRedirect, + PaletteBackStyle.PanelAlternate, PaletteBorderStyle.ControlClient, OnCircularNeedPaint); + _innerRingStateNormal = new PaletteDouble(_innerRingStateCommon, OnCircularNeedPaint); + _innerRingStateDisabled = new PaletteDouble(_innerRingStateCommon, OnCircularNeedPaint); + + _superscriptStateCommon = new PaletteTripleRedirect(ProgressPaletteRedirect, + PaletteBackStyle.PanelClient, PaletteBorderStyle.ControlClient, PaletteContentStyle.LabelNormalPanel, OnCircularNeedPaint); + _superscriptStateNormal = new PaletteTriple(_superscriptStateCommon, OnCircularNeedPaint); + _superscriptStateDisabled = new PaletteTriple(_superscriptStateCommon, OnCircularNeedPaint); + + _subscriptStateCommon = new PaletteTripleRedirect(ProgressPaletteRedirect, + PaletteBackStyle.PanelClient, PaletteBorderStyle.ControlClient, PaletteContentStyle.LabelNormalPanel, OnCircularNeedPaint); + _subscriptStateNormal = new PaletteTriple(_subscriptStateCommon, OnCircularNeedPaint); + _subscriptStateDisabled = new PaletteTriple(_subscriptStateCommon, OnCircularNeedPaint); + + Text = @"0"; + } + + #endregion + + #region Methods + + private static PointF AddPoint(PointF point, int value) + { + point.X += value; + + point.Y += value; + + return point; + } + + private static SizeF AddSize(SizeF size, int value) + { + size.Height += value; + + size.Width += value; + + return size; + } + + private static Rectangle ToRectangle(RectangleF rectangle) => new Rectangle((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height); + + private void OnCircularNeedPaint(object? sender, NeedLayoutEventArgs e) + { + if (e.NeedLayout) + { + Invalidate(true); + } + else + { + Invalidate(e.InvalidRect); + } + } + + private (IPaletteDouble PaletteState, PaletteState State) GetOuterRingPaletteState() => + !Enabled + ? (_outerRingStateDisabled, PaletteState.Disabled) + : (_outerRingStateNormal, PaletteState.Normal); + + private (IPaletteDouble PaletteState, PaletteState State) GetInnerRingPaletteState() => + !Enabled + ? (_innerRingStateDisabled, PaletteState.Disabled) + : (_innerRingStateNormal, PaletteState.Normal); + + private (IPaletteTriple PaletteState, PaletteState State) GetSuperscriptPaletteState() => + !Enabled + ? (_superscriptStateDisabled, PaletteState.Disabled) + : (_superscriptStateNormal, PaletteState.Normal); + + private (IPaletteTriple PaletteState, PaletteState State) GetSubscriptPaletteState() => + !Enabled + ? (_subscriptStateDisabled, PaletteState.Disabled) + : (_subscriptStateNormal, PaletteState.Normal); + + private static bool ShouldDrawPaletteBack(IPaletteBack paletteBack, PaletteState state, int ringWidth) + { + if (ringWidth == 0) + { + return false; + } + + if (paletteBack.GetBackDraw(state) == InheritBool.False) + { + return false; + } + + Color color = paletteBack.GetBackColor1(state); + return color != Color.Empty && color.A > 0; + } + + private static void DrawPaletteEllipseBack(RenderContext renderContext, + IRenderer renderer, + RectangleF rectangle, + IPaletteBack paletteBack, + PaletteState state, + ref IDisposable? memento) + { + Rectangle bounds = ToRectangle(rectangle); + if (bounds.Width <= 0 || bounds.Height <= 0) + { + return; + } + + using GraphicsPath path = new GraphicsPath(); + path.AddEllipse(bounds); + memento = renderer.RenderStandardBack.DrawBack(renderContext, bounds, path, paletteBack, + VisualOrientation.Top, state, memento); + } + + private static void DrawPalettePieBack(RenderContext renderContext, + IRenderer renderer, + RectangleF rectangle, + float startAngle, + float sweepAngle, + IPaletteBack paletteBack, + PaletteState state, + ref IDisposable? memento) + { + if (Math.Abs(sweepAngle) < 0.01f) + { + return; + } + + Rectangle bounds = ToRectangle(rectangle); + if (bounds.Width <= 0 || bounds.Height <= 0) + { + return; + } + + using GraphicsPath path = new GraphicsPath(); + path.AddPie(bounds, startAngle, sweepAngle); + memento = renderer.RenderStandardBack.DrawBack(renderContext, bounds, path, paletteBack, + VisualOrientation.Top, state, memento); + } + + /// + /// Initialize the animation for the continues styling + /// + /// True if it is the first execution of this function, otherwise false + protected virtual void InitializeContinues(bool firstTime) + { + if (_lastValue == Value && !firstTime) + { + return; + } + + _lastValue = Value; + + _animator?.Stop(); + _animatedStartAngle = null; + + if (AnimationSpeed <= 0) + { + _animatedValue = Value; + Invalidate(); + + return; + } + + _animator!.Paths = new[] + { + new WinFormAnimation.Path(_animatedValue ?? Value, Value, (ulong)AnimationSpeed, CustomAnimationFunction) + }; + _animator.Repeat = false; + _animator.Play( + new WinFormAnimation.SafeInvoker( + v => + { + try + { + _animatedValue = v; + Invalidate(); + } + catch + { + _animator.Stop(); + } + }, + this)); + } + + /// + /// Initialize the animation for the marquee styling + /// + /// True if it is the first execution of this function, otherwise false + protected virtual void InitializeMarquee(bool firstTime) + { + if (!firstTime && + (_animator?.ActivePath == null || + _animator.ActivePath.Duration == (ulong)MarqueeAnimationSpeed && + _animator.ActivePath.Function == CustomAnimationFunction)) + { + return; + } + + _animator?.Stop(); + _animatedValue = null; + + if (AnimationSpeed <= 0) + { + _animatedStartAngle = 0; + Invalidate(); + + return; + } + + _animator!.Paths = new[] { new WinFormAnimation.Path(0, 359, (ulong)MarqueeAnimationSpeed, CustomAnimationFunction) }; + _animator.Repeat = true; + _animator.Play( + new WinFormAnimation.SafeInvoker( + v => + { + try + { + _animatedStartAngle = (int)(v % 360); + Invalidate(); + } + catch + { + _animator.Stop(); + } + }, + this)); + } + + /// + /// Occurs when parent's display requires redrawing. + /// + /// + /// + protected virtual void ParentOnInvalidated(object? sender, InvalidateEventArgs invalidateEventArgs) => RecreateBackgroundBrush(); + + /// + /// Occurs when the parent resized. + /// + /// + /// + protected virtual void ParentOnResize(object? sender, EventArgs eventArgs) => RecreateBackgroundBrush(); + + /// + /// Update or create the brush used for drawing the background + /// + protected virtual void RecreateBackgroundBrush() + { + lock (this) + { + _backBrush?.Dispose(); + _backBrush = new SolidBrush(BackColor); + + if (BackColor.A == 255) + { + return; + } + + if (Parent is { Width: > 0, Height: > 0 }) + { + using (var parentImage = new Bitmap(Parent.Width, Parent.Height)) + { + using (var parentGraphic = Graphics.FromImage(parentImage)) + { + var pe = new PaintEventArgs(parentGraphic, + new Rectangle(new Point(0, 0), parentImage.Size)); + InvokePaintBackground(Parent, pe); + InvokePaint(Parent, pe); + + if (BackColor.A > 0) // Translucent + { + parentGraphic.FillRectangle(_backBrush, Bounds); + } + } + + _backBrush = new TextureBrush(parentImage); + ((TextureBrush)_backBrush).TranslateTransform(-Bounds.X, -Bounds.Y); + } + } + else + { + _backBrush = new SolidBrush(Color.FromArgb(255, BackColor)); + } + } + } + + /// + /// The function responsible for painting the control + /// + /// The paint event arguments. + protected virtual void StartPaint(PaintEventArgs e) + { + PaletteBase? palette = ResolvedPalette; + if (palette == null || _backBrush == null) + { + return; + } + + Graphics g = e.Graphics; + IRenderer renderer = palette.GetRenderer(); + using RenderContext renderContext = new RenderContext(this, g, e.ClipRectangle, renderer); + + var (barPaletteState, barState) = GetProgressBarPaletteState(); + var (outerPaletteState, outerState) = GetOuterRingPaletteState(); + var (innerPaletteState, innerState) = GetInnerRingPaletteState(); + var (superscriptPaletteState, superscriptState) = GetSuperscriptPaletteState(); + var (subscriptPaletteState, subscriptState) = GetSubscriptPaletteState(); + + lock (this) + { + g.TextRenderingHint = TextRenderingHint.AntiAlias; + g.SmoothingMode = SmoothingMode.AntiAlias; + var point = AddPoint(Point.Empty, 2); + var size = AddSize(Size, -2 * 2); + + if (OuterWidth + OuterMargin < 0) + { + var offset = Math.Abs(OuterWidth + OuterMargin); + point = AddPoint(Point.Empty, offset); + size = AddSize(Size, -2 * offset); + } + + if (ShouldDrawPaletteBack(outerPaletteState.PaletteBack, outerState, OuterWidth)) + { + DrawPaletteEllipseBack(renderContext, renderer, new RectangleF(point, size), + outerPaletteState.PaletteBack, outerState, ref _mementoOuterRingBack); + + if (OuterWidth >= 0) + { + point = AddPoint(point, OuterWidth); + size = AddSize(size, -2 * OuterWidth); + g.FillEllipse(_backBrush, new RectangleF(point, size)); + } + } + + point = AddPoint(point, OuterMargin); + size = AddSize(size, -2 * OuterMargin); + + float sweepAngle = Maximum == Minimum + ? 0f + : ((_animatedValue ?? Value) - Minimum) / (Maximum - Minimum) * 360f; + + DrawPalettePieBack(renderContext, renderer, new RectangleF(point, size), + _animatedStartAngle ?? StartAngle, sweepAngle, ValueBackPalette, barState, ref _mementoProgressBack); + + if (ProgressWidth >= 0) + { + point = AddPoint(point, ProgressWidth); + size = AddSize(size, -2 * ProgressWidth); + g.FillEllipse(_backBrush, new RectangleF(point, size)); + } + + point = AddPoint(point, InnerMargin); + size = AddSize(size, -2 * InnerMargin); + + if (ShouldDrawPaletteBack(innerPaletteState.PaletteBack, innerState, InnerWidth)) + { + DrawPaletteEllipseBack(renderContext, renderer, new RectangleF(point, size), + innerPaletteState.PaletteBack, innerState, ref _mementoInnerRingBack); + + if (InnerWidth >= 0) + { + point = AddPoint(point, InnerWidth); + size = AddSize(size, -2 * InnerWidth); + g.FillEllipse(_backBrush, new RectangleF(point, size)); + } + } + + if (Text == string.Empty) + { + return; + } + + point.X += TextMargin.Left; + point.Y += TextMargin.Top; + size.Width -= TextMargin.Right; + size.Height -= TextMargin.Bottom; + var stringFormat = + new StringFormat(RightToLeft == RightToLeft.Yes ? StringFormatFlags.DirectionRightToLeft : 0) + { + Alignment = StringAlignment.Center, + LineAlignment = StringAlignment.Near + }; + var textSize = g.MeasureString(Text, Font!); + var textPoint = new PointF( + point.X + (size.Width - textSize.Width) / 2, + point.Y + (size.Height - textSize.Height) / 2); + + if (SubscriptText != string.Empty || SuperscriptText != string.Empty) + { + float maxSWidth = 0; + var supSize = SizeF.Empty; + var subSize = SizeF.Empty; + + if (SuperscriptText != string.Empty) + { + supSize = g.MeasureString(SuperscriptText, SecondaryFont); + maxSWidth = Math.Max(supSize.Width, maxSWidth); + supSize.Width -= SuperscriptMargin.Right; + supSize.Height -= SuperscriptMargin.Bottom; + } + + if (SubscriptText != string.Empty) + { + subSize = g.MeasureString(SubscriptText, SecondaryFont); + maxSWidth = Math.Max(subSize.Width, maxSWidth); + subSize.Width -= SubscriptMargin.Right; + subSize.Height -= SubscriptMargin.Bottom; + } + + textPoint.X -= maxSWidth / 4; + + if (SuperscriptText != string.Empty) + { + var supPoint = new PointF( + textPoint.X + textSize.Width - supSize.Width / 2, + textPoint.Y - supSize.Height * 0.85f); + supPoint.X += SuperscriptMargin.Left; + supPoint.Y += SuperscriptMargin.Top; + Color superscriptColor = superscriptPaletteState.PaletteContent!.GetContentShortTextColor1(superscriptState); + using var superscriptBrush = new SolidBrush(superscriptColor); + g.DrawString( + SuperscriptText, + SecondaryFont, + superscriptBrush, + new RectangleF(supPoint, supSize), + stringFormat); + } + + if (SubscriptText != string.Empty) + { + var subPoint = new PointF( + textPoint.X + textSize.Width - subSize.Width / 2, + textPoint.Y + textSize.Height * 0.85f); + subPoint.X += SubscriptMargin.Left; + subPoint.Y += SubscriptMargin.Top; + Color subscriptColor = subscriptPaletteState.PaletteContent!.GetContentShortTextColor1(subscriptState); + using var subscriptBrush = new SolidBrush(subscriptColor); + g.DrawString( + SubscriptText, + SecondaryFont, + subscriptBrush, + new RectangleF(subPoint, subSize), + stringFormat); + } + } + + Color textColor = barPaletteState.PaletteContent!.GetContentShortTextColor1(barState); + using var textBrush = new SolidBrush(textColor); + g.DrawString( + Text, + Font, + textBrush, + new RectangleF(textPoint, textSize), + stringFormat); + } + } + + /// Increments the specified value. + /// The step. + public new void Increment(int step) => Value = Value + step; + + #endregion + + #region Overrides + + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + _mementoProgressBack?.Dispose(); + _mementoOuterRingBack?.Dispose(); + _mementoInnerRingBack?.Dispose(); + _backBrush?.Dispose(); + } + + base.Dispose(disposing); + } + + /// + protected override void OnLocationChanged(EventArgs e) + { + base.OnLocationChanged(e); + + Invalidate(); + } + + /// + protected override void OnPaint(PaintEventArgs e) + { + try + { + if (!DesignMode) + { + if (Style == ProgressBarStyle.Marquee) + { + InitializeMarquee(_lastStyle != Style); + } + else + { + InitializeContinues(_lastStyle != Style); + } + + _lastStyle = Style; + } + + if (ResolvedPalette == null) + { + base.OnPaint(e); + return; + } + + SyncThresholdColors(); + + if (_backBrush == null) + { + RecreateBackgroundBrush(); + } + + StartPaint(e); + } + catch (Exception exc) + { + DebugTools.NotImplemented(exc.ToString()); + } + } + + /// + protected override void OnParentBackColorChanged(EventArgs e) => RecreateBackgroundBrush(); + + /// + protected override void OnParentBackgroundImageChanged(EventArgs e) => RecreateBackgroundBrush(); + + /// + protected override void OnParentChanged(EventArgs e) + { + if (Parent != null) + { + Parent.Invalidated -= ParentOnInvalidated; + + Parent.Resize -= ParentOnResize; + } + + base.OnParentChanged(e); + + if (Parent != null) + { + Parent.Invalidated += ParentOnInvalidated; + + Parent.Resize += ParentOnResize; + } + } + + /// + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged(e); + + Invalidate(); + } + + #endregion +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/General/ValueChangedEventArgs.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/General/ValueChangedEventArgs.cs new file mode 100644 index 0000000000..78ac7163d0 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/General/ValueChangedEventArgs.cs @@ -0,0 +1,67 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit.Utilities; + +public class ValueChangedEventArgs : EventArgs +{ + #region Instance Fields + + private int _progressValue; + + private Color _progressColor; + + #endregion + + #region Public + + /// + /// Gets or sets the color of the progress. + /// + /// + /// The color of the progress. + /// + [Description("Gets or sets the color of the progress.")] + [DefaultValue(typeof(Color), "Green")] + public Color ProgressColor { get => _progressColor; set => _progressColor = value; } + + /// + /// Gets or sets the progress value. + /// + /// + /// The progress value. + /// + [Description("Gets or sets the progress value.")] + [DefaultValue(0)] + public int ProgressValue { get => _progressValue; set => _progressValue = value; } + + #endregion + + #region Identity + + /// + /// Initializes a new instance of the class. + /// + /// The progress value. + public ValueChangedEventArgs(int progressValue) => ProgressValue = progressValue; + + /// + /// Initializes a new instance of the class. + /// + /// Color of the progress. + /// The progress value. + public ValueChangedEventArgs(Color progressColor, int progressValue) + { + ProgressColor = progressColor; + + ProgressValue = progressValue; + } + + #endregion +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ToolboxBitmaps/KryptonCircularProgressBar.bmp b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ToolboxBitmaps/KryptonCircularProgressBar.bmp new file mode 100644 index 0000000000000000000000000000000000000000..5f6ff2bf581e2e9c7ac6f3766e965f5beebb6a19 GIT binary patch literal 380 zcmZ?rtzl#UgDN1Y0mK4O%*en27H0y=3volRAW#H^@7=oxB>w~96b3$qUkus|Zy3TD z?lSZ+9A!Adu#Vxs^c;o + false diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/AnimationFunctions.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/AnimationFunctions.cs new file mode 100644 index 0000000000..3e9cf78faa --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/AnimationFunctions.cs @@ -0,0 +1,681 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * +*/ + +#endregion + +namespace WinFormAnimation; + +/// +/// The functions gallery for animation +/// +public static class AnimationFunctions +{ + /// + /// The base delegate for defining new animation functions. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public delegate float Function(float time, float beginningValue, float changeInValue, float duration); + + /// + /// Returns a function delegate based on the passed known animation function + /// + /// The animation function + /// Animation function delegate + public static Function FromKnown(KnownAnimationFunctions knownFunction) + { + switch (knownFunction) + { + case KnownAnimationFunctions.CubicEaseIn: + return CubicEaseIn; + case KnownAnimationFunctions.CubicEaseInOut: + return CubicEaseInOut; + case KnownAnimationFunctions.CubicEaseOut: + return CubicEaseOut; + case KnownAnimationFunctions.Linear: + return Linear; + case KnownAnimationFunctions.CircularEaseInOut: + return CircularEaseInOut; + case KnownAnimationFunctions.CircularEaseIn: + return CircularEaseIn; + case KnownAnimationFunctions.CircularEaseOut: + return CircularEaseOut; + case KnownAnimationFunctions.QuadraticEaseIn: + return QuadraticEaseIn; + case KnownAnimationFunctions.QuadraticEaseOut: + return QuadraticEaseOut; + case KnownAnimationFunctions.QuadraticEaseInOut: + return QuadraticEaseInOut; + case KnownAnimationFunctions.QuarticEaseIn: + return QuarticEaseIn; + case KnownAnimationFunctions.QuarticEaseOut: + return QuarticEaseOut; + case KnownAnimationFunctions.QuarticEaseInOut: + return QuarticEaseInOut; + case KnownAnimationFunctions.QuinticEaseInOut: + return QuinticEaseInOut; + case KnownAnimationFunctions.QuinticEaseIn: + return QuinticEaseIn; + case KnownAnimationFunctions.QuinticEaseOut: + return QuinticEaseOut; + case KnownAnimationFunctions.SinusoidalEaseIn: + return SinusoidalEaseIn; + case KnownAnimationFunctions.SinusoidalEaseOut: + return SinusoidalEaseOut; + case KnownAnimationFunctions.SinusoidalEaseInOut: + return SinusoidalEaseInOut; + case KnownAnimationFunctions.ExponentialEaseIn: + return ExponentialEaseIn; + case KnownAnimationFunctions.ExponentialEaseOut: + return ExponentialEaseOut; + case KnownAnimationFunctions.ExponentialEaseInOut: + return ExponentialEaseInOut; + default: + throw new ArgumentOutOfRangeException(nameof(knownFunction), knownFunction, + @"The passed animation function is unknown."); + } + } + + + /// + /// The cubic ease-in animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float CubicEaseIn(float t, float b, float c, float d) + { + t /= d; + return c * t * t * t + b; + } + + /// + /// The cubic ease-in and ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float CubicEaseInOut(float t, float b, float c, float d) + { + t /= d / 2; + if (t < 1) + { + return c / 2 * t * t * t + b; + } + + t -= 2; + return c / 2 * (t * t * t + 2) + b; + } + + /// + /// The cubic ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float CubicEaseOut(float t, float b, float c, float d) + { + t /= d; + t--; + return c * (t * t * t + 1) + b; + } + + /// + /// The linear animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float Linear(float t, float b, float c, float d) + { + return c * t / d + b; + } + + /// + /// The circular ease-in and ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float CircularEaseInOut(float t, float b, float c, float d) + { + t /= d / 2; + if (t < 1) + { + return (float) (-c / 2 * (Math.Sqrt(1 - t * t) - 1) + b); + } + + t -= 2; + return (float) (c / 2 * (Math.Sqrt(1 - t * t) + 1) + b); + } + + + /// + /// The circular ease-in animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float CircularEaseIn(float t, float b, float c, float d) + { + t /= d; + return (float) (-c * (Math.Sqrt(1 - t * t) - 1) + b); + } + + + /// + /// The circular ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float CircularEaseOut(float t, float b, float c, float d) + { + t /= d; + t--; + return (float) (c * Math.Sqrt(1 - t * t) + b); + } + + + /// + /// The quadratic ease-in animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuadraticEaseIn(float t, float b, float c, float d) + { + t /= d; + return c * t * t + b; + } + + + /// + /// The quadratic ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuadraticEaseOut(float t, float b, float c, float d) + { + t /= d; + return -c * t * (t - 2) + b; + } + + + /// + /// The quadratic ease-in and ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuadraticEaseInOut(float t, float b, float c, float d) + { + t /= d / 2; + if (t < 1) + { + return c / 2 * t * t + b; + } + + t--; + return -c / 2 * (t * (t - 2) - 1) + b; + } + + /// + /// The quartic ease-in animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuarticEaseIn(float t, float b, float c, float d) + { + t /= d; + return c * t * t * t * t + b; + } + + /// + /// The quartic ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuarticEaseOut(float t, float b, float c, float d) + { + t /= d; + t--; + return -c * (t * t * t * t - 1) + b; + } + + /// + /// The quartic ease-in and ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuarticEaseInOut(float t, float b, float c, float d) + { + t /= d / 2; + if (t < 1) + { + return c / 2 * t * t * t * t + b; + } + + t -= 2; + return -c / 2 * (t * t * t * t - 2) + b; + } + + /// + /// The quintic ease-in and ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuinticEaseInOut(float t, float b, float c, float d) + { + t /= d / 2; + if (t < 1) + { + return c / 2 * t * t * t * t * t + b; + } + + t -= 2; + return c / 2 * (t * t * t * t * t + 2) + b; + } + + /// + /// The quintic ease-in animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuinticEaseIn(float t, float b, float c, float d) + { + t /= d; + return c * t * t * t * t * t + b; + } + + /// + /// The quintic ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float QuinticEaseOut(float t, float b, float c, float d) + { + t /= d; + t--; + return c * (t * t * t * t * t + 1) + b; + } + + /// + /// The sinusoidal ease-in animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float SinusoidalEaseIn(float t, float b, float c, float d) + { + return (float) (-c * Math.Cos(t / d * (Math.PI / 2)) + c + b); + } + + /// + /// The sinusoidal ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float SinusoidalEaseOut(float t, float b, float c, float d) + { + return (float) (c * Math.Sin(t / d * (Math.PI / 2)) + b); + } + + /// + /// The sinusoidal ease-in and ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float SinusoidalEaseInOut(float t, float b, float c, float d) + { + return (float) (-c / 2 * (Math.Cos(Math.PI * t / d) - 1) + b); + } + + /// + /// The exponential ease-in animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float ExponentialEaseIn(float t, float b, float c, float d) + { + return (float) (c * Math.Pow(2, 10 * (t / d - 1)) + b); + } + + /// + /// The exponential ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float ExponentialEaseOut(float t, float b, float c, float d) + { + return (float) (c * (-Math.Pow(2, -10 * t / d) + 1) + b); + } + + + /// + /// The exponential ease-in and ease-out animation function. + /// + /// + /// The time of the animation. + /// + /// + /// The starting value. + /// + /// + /// The different between starting and ending value. + /// + /// + /// The duration of the animations. + /// + /// + /// The calculated current value of the animation + /// + public static float ExponentialEaseInOut(float t, float b, float c, float d) + { + t /= d / 2; + if (t < 1) + { + return (float) (c / 2 * Math.Pow(2, 10 * (t - 1)) + b); + } + + t--; + return (float) (c / 2 * (-Math.Pow(2, -10 * t) + 2) + b); + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator.cs new file mode 100644 index 0000000000..afaf8db27d --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator.cs @@ -0,0 +1,481 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The one dimensional animator class, useful for animating raw values +/// +internal class Animator : IAnimator +{ + private readonly List _paths = []; + + private readonly List _tempPaths = []; + + private readonly Timer _timer; + + private bool _tempReverseRepeat; + + /// + /// The callback to get invoked at the end of the animation + /// + protected SafeInvoker? EndCallback; + + /// + /// The callback to get invoked at each frame + /// + protected SafeInvoker? FrameCallback; + + /// + /// The target object to change the property of + /// + protected object? TargetObject; + + /// + /// Initializes a new instance of the class. + /// + public Animator() + : this([]) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator(FPSLimiterKnownValues fpsLimiter) + : this([], fpsLimiter) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The path of the animation + /// + public Animator(Path path) + : this([path]) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The path of the animation + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator(Path path, FPSLimiterKnownValues fpsLimiter) + : this([path], fpsLimiter) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// An array containing the list of paths of the animation + /// + public Animator(Path[] paths) : this(paths, FPSLimiterKnownValues.LimitThirty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// An array containing the list of paths of the animation + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator(Path[] paths, FPSLimiterKnownValues fpsLimiter) + { + CurrentStatus = AnimatorStatus.Stopped; + _timer = new Timer(Elapsed, fpsLimiter); + Paths = paths; + } + + /// + /// Gets or sets an array containing the list of paths of the animation + /// + /// Animation is running + public Path[] Paths + { + get => _paths.ToArray(); + set + { + if (CurrentStatus == AnimatorStatus.Stopped) + { + _paths.Clear(); + _paths.AddRange(value); + } + else + { + throw new InvalidOperationException("Animation is running."); + } + } + } + + /// + /// Gets the currently active path. + /// + public Path? ActivePath { get; private set; } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation after its ending + /// + public virtual bool Repeat { get; set; } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation in reverse after its ending. + /// + public virtual bool ReverseRepeat { get; set; } + + /// + /// Gets the current status of the animation + /// + public virtual AnimatorStatus CurrentStatus { get; private set; } + + /// + /// Pause the animation + /// + public virtual void Pause() + { + if (CurrentStatus != AnimatorStatus.OnHold && CurrentStatus != AnimatorStatus.Playing) + { + return; + } + + _timer.Stop(); + CurrentStatus = AnimatorStatus.Paused; + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + public virtual void Play(object targetObject, string propertyName) + { + Play(targetObject, propertyName, null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + /// + /// The callback to get invoked at the end of the animation + /// + public virtual void Play(object targetObject, string propertyName, SafeInvoker? endCallback) + { + TargetObject = targetObject; + var prop = TargetObject.GetType() + .GetProperty( + propertyName, + BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance | + BindingFlags.SetProperty); + if (prop == null) + { + return; + } + + Play( + new SafeInvoker( + value => prop.SetValue(TargetObject, Convert.ChangeType(value, prop.PropertyType), null), + TargetObject), + endCallback); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// Any object containing a property + /// + public virtual void Play(T targetObject, Expression> propertySetter) + { + Play(targetObject, propertySetter, null); + } + + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// The callback to get invoked at the end of the animation + /// + /// + /// Any object containing a property + /// + public virtual void Play(T targetObject, Expression>? propertySetter, SafeInvoker? endCallback) + { + if (propertySetter == null) + { + return; + } + + TargetObject = targetObject; + + var property = + (propertySetter.Body as MemberExpression ?? + ((UnaryExpression) propertySetter.Body).Operand as MemberExpression)?.Member as PropertyInfo; + if (property == null) + { + throw new ArgumentException(nameof(propertySetter)); + } + + Play( + new SafeInvoker( + value => property.SetValue(TargetObject, Convert.ChangeType(value, property.PropertyType), null), + TargetObject), + endCallback); + } + + /// + /// Resume the animation from where it paused + /// + public virtual void Resume() + { + if (CurrentStatus == AnimatorStatus.Paused) + { + _timer.Resume(); + } + } + + /// + /// Stops the animation and resets its status, resume is no longer possible + /// + public virtual void Stop() + { + _timer.Stop(); + lock (_tempPaths) + { + _tempPaths.Clear(); + } + + ActivePath = null; + CurrentStatus = AnimatorStatus.Stopped; + _tempReverseRepeat = false; + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The property to change + /// + public virtual void Play(object targetObject, KnownProperties property) + { + Play(targetObject, property, null); + } + + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The property to change + /// + /// + /// The callback to get invoked at the end of the animation + /// + public virtual void Play(object targetObject, KnownProperties property, SafeInvoker? endCallback) + { + Play(targetObject, property.ToString(), endCallback); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The callback to get invoked at each frame + /// + public virtual void Play(SafeInvoker frameCallback) + { + Play(frameCallback, (SafeInvoker?)null); + } + + + /// + /// Starts the playing of the animation + /// + /// + /// The callback to get invoked at each frame + /// + /// + /// The callback to get invoked at the end of the animation + /// + public virtual void Play(SafeInvoker frameCallback, SafeInvoker? endCallback) + { + Stop(); + FrameCallback = frameCallback; + EndCallback = endCallback; + _timer.ResetClock(); + lock (_tempPaths) + { + _tempPaths.AddRange(_paths); + } + + _timer.Start(); + } + + private void Elapsed(ulong millSinceBeginning = 0) + { + while (true) + { + lock (_tempPaths) + { + if (ActivePath == null && _tempPaths.Count > 0) + { + while (ActivePath == null) + { + if (_tempReverseRepeat) + { + ActivePath = _tempPaths[_tempPaths.Count - 1]; + _tempPaths.RemoveAt(_tempPaths.Count - 1); + } + else + { + ActivePath = _tempPaths[0]; + _tempPaths.RemoveAt(0); + } + + _timer.ResetClock(); + millSinceBeginning = 0; + } + } + + var ended = ActivePath == null; + if (ActivePath != null) + { + if (!_tempReverseRepeat && millSinceBeginning < ActivePath.Delay) + { + CurrentStatus = AnimatorStatus.OnHold; + return; + } + + if (millSinceBeginning - (!_tempReverseRepeat ? ActivePath.Delay : 0) <= ActivePath.Duration) + { + if (CurrentStatus != AnimatorStatus.Playing) + { + CurrentStatus = AnimatorStatus.Playing; + } + + var value = ActivePath.Function( + _tempReverseRepeat + ? ActivePath.Duration - millSinceBeginning + : millSinceBeginning - ActivePath.Delay, ActivePath.Start, ActivePath.Change, + ActivePath.Duration); + FrameCallback!.Invoke(value); + return; + } + + if (CurrentStatus == AnimatorStatus.Playing) + { + if (_tempPaths.Count == 0) + { + // For the last path, we make sure that control is in end point + FrameCallback!.Invoke(_tempReverseRepeat ? ActivePath!.Start : ActivePath!.End); + ended = true; + } + else + { + if ((_tempReverseRepeat && ActivePath.Delay > 0) || + (!_tempReverseRepeat && _tempPaths.FirstOrDefault()?.Delay > 0)) + // Or if the next path or this one in reverse order has a delay + { + FrameCallback!.Invoke(_tempReverseRepeat ? ActivePath!.Start : ActivePath!.End); + } + } + } + + if (_tempReverseRepeat && millSinceBeginning - ActivePath!.Duration < ActivePath!.Delay) + { + CurrentStatus = AnimatorStatus.OnHold; + return; + } + + ActivePath = null; + } + + if (!ended) + { + return; + } + } + + if (Repeat) + { + lock (_tempPaths) + { + _tempPaths.AddRange(_paths); + _tempReverseRepeat = ReverseRepeat && !_tempReverseRepeat; + } + + millSinceBeginning = 0; + continue; + } + + Stop(); + EndCallback?.Invoke(); + break; + } + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator2D.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator2D.cs new file mode 100644 index 0000000000..c8913072ac --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator2D.cs @@ -0,0 +1,470 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The two-dimensional animator class, useful for animating values +/// created from two underlying values +/// +internal class Animator2D : IAnimator +{ + private readonly List _paths = []; + + + /// + /// The callback to get invoked at the end of the animation + /// + protected SafeInvoker? EndCallback; + + /// + /// The callback to get invoked at each frame + /// + protected SafeInvoker? FrameCallback; + + /// + /// A boolean value indicating if the EndInvoker already invoked + /// + protected bool IsEnded; + + /// + /// The target object to change the property of + /// + protected object? TargetObject; + + /// + /// The latest horizontal value + /// + protected float? XValue; + + /// + /// The latest vertical value + /// + protected float? YValue; + + + /// + /// Initializes a new instance of the class. + /// + public Animator2D() + : this([]) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator2D(FPSLimiterKnownValues fpsLimiter) + : this([], fpsLimiter) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The path of the animation + /// + public Animator2D(Path2D path) + : this([path]) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The path of the animation + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator2D(Path2D path, FPSLimiterKnownValues fpsLimiter) + : this([path], fpsLimiter) + { + } + + + /// + /// Initializes a new instance of the class. + /// + /// + /// An array containing the list of paths of the animation + /// + public Animator2D(Path2D[] paths) : this(paths, FPSLimiterKnownValues.LimitThirty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// An array containing the list of paths of the animation + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator2D(Path2D[] paths, FPSLimiterKnownValues fpsLimiter) + { + HorizontalAnimator = new Animator(fpsLimiter); + VerticalAnimator = new Animator(fpsLimiter); + Paths = paths; + } + + /// + /// Gets the currently active path. + /// + public Path2D ActivePath => new(HorizontalAnimator.ActivePath!, VerticalAnimator.ActivePath!); + + /// + /// Gets the horizontal animator. + /// + public Animator HorizontalAnimator { get; protected set; } + + /// + /// Gets the vertical animator. + /// + public Animator VerticalAnimator { get; protected set; } + + /// + /// Gets or sets an array containing the list of paths of the animation + /// + /// Animation is running + public Path2D[] Paths + { + get => _paths.ToArray(); + set + { + if (CurrentStatus == AnimatorStatus.Stopped) + { + _paths.Clear(); + _paths.AddRange(value); + var pathsH = new List(); + var pathsV = new List(); + foreach (var p in value) + { + pathsH.Add(p.HorizontalPath); + pathsV.Add(p.VerticalPath); + } + + HorizontalAnimator.Paths = pathsH.ToArray(); + VerticalAnimator.Paths = pathsV.ToArray(); + } + else + { + throw new InvalidOperationException("Animation is running."); + } + } + } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation after its ending + /// + public virtual bool Repeat + { + get => HorizontalAnimator.Repeat && VerticalAnimator.Repeat; + + set => HorizontalAnimator.Repeat = VerticalAnimator.Repeat = value; + } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation in reverse after its ending. + /// + public virtual bool ReverseRepeat + { + get => HorizontalAnimator.ReverseRepeat && VerticalAnimator.ReverseRepeat; + + set => HorizontalAnimator.ReverseRepeat = VerticalAnimator.ReverseRepeat = value; + } + + /// + /// Gets the current status of the animation + /// + public virtual AnimatorStatus CurrentStatus + { + get + { + if (HorizontalAnimator.CurrentStatus == AnimatorStatus.Stopped + && VerticalAnimator.CurrentStatus == AnimatorStatus.Stopped) + { + return AnimatorStatus.Stopped; + } + + if (HorizontalAnimator.CurrentStatus == AnimatorStatus.Paused + && VerticalAnimator.CurrentStatus == AnimatorStatus.Paused) + { + return AnimatorStatus.Paused; + } + + if (HorizontalAnimator.CurrentStatus == AnimatorStatus.OnHold + && VerticalAnimator.CurrentStatus == AnimatorStatus.OnHold) + { + return AnimatorStatus.OnHold; + } + + return AnimatorStatus.Playing; + } + } + + /// + /// Pause the animation + /// + public virtual void Pause() + { + if (CurrentStatus == AnimatorStatus.OnHold || CurrentStatus == AnimatorStatus.Playing) + { + HorizontalAnimator.Pause(); + VerticalAnimator.Pause(); + } + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + public virtual void Play(object targetObject, string propertyName) + { + Play(targetObject, propertyName, null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + /// + /// The callback to get invoked at the end of the animation + /// + public virtual void Play(object targetObject, string propertyName, SafeInvoker? endCallback) + { + TargetObject = targetObject; + var prop = TargetObject.GetType() + .GetProperty( + propertyName, + BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance | + BindingFlags.SetProperty); + if (prop == null) + { + return; + } + + Play( + new SafeInvoker( + value => + prop.SetValue(TargetObject, Convert.ChangeType(value, prop.PropertyType), null), + TargetObject), + endCallback); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// Any object containing a property + /// + public virtual void Play(T targetObject, Expression> propertySetter) + { + Play(targetObject, propertySetter, null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// The callback to get invoked at the end of the animation + /// + /// + /// Any object containing a property + /// + public virtual void Play(T targetObject, Expression>? propertySetter, SafeInvoker? endCallback) + { + if (propertySetter == null) + { + return; + } + + TargetObject = targetObject; + + var property = + (propertySetter.Body as MemberExpression ?? + ((UnaryExpression) propertySetter.Body).Operand as MemberExpression)?.Member as PropertyInfo; + if (property == null) + { + throw new ArgumentException(nameof(propertySetter)); + } + + Play( + new SafeInvoker( + value => + property.SetValue(TargetObject, Convert.ChangeType(value, property.PropertyType), null), + TargetObject), + endCallback); + } + + /// + /// Resume the animation from where it paused + /// + public virtual void Resume() + { + if (CurrentStatus == AnimatorStatus.Paused) + { + HorizontalAnimator.Resume(); + VerticalAnimator.Resume(); + } + } + + /// + /// Stops the animation and resets its status, resume is no longer possible + /// + public virtual void Stop() + { + HorizontalAnimator.Stop(); + VerticalAnimator.Stop(); + XValue = YValue = null; + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The property to change + /// + public void Play(object targetObject, KnownProperties property) + { + Play(targetObject, property, null); + } + + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The property to change + /// + /// + /// The callback to get invoked at the end of the animation + /// + public void Play(object targetObject, KnownProperties property, SafeInvoker? endCallback) + { + Play(targetObject, property.ToString(), endCallback); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The callback to get invoked at each frame + /// + public void Play(SafeInvoker frameCallback) + { + Play(frameCallback, (SafeInvoker?)null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The callback to get invoked at each frame + /// + /// + /// The callback to get invoked at the end of the animation + /// + public void Play(SafeInvoker frameCallback, SafeInvoker? endCallback) + { + Stop(); + FrameCallback = frameCallback; + EndCallback = endCallback; + HorizontalAnimator.Play( + new SafeInvoker( + value => + { + XValue = value; + InvokeSetter(); + }), + new SafeInvoker(InvokeFinisher)); + VerticalAnimator.Play( + new SafeInvoker( + value => + { + YValue = value; + InvokeSetter(); + }), + new SafeInvoker(InvokeFinisher)); + } + + private void InvokeFinisher() + { + if (EndCallback != null && !IsEnded) + { + lock (EndCallback) + { + if (CurrentStatus == AnimatorStatus.Stopped) + { + IsEnded = true; + EndCallback.Invoke(); + } + } + } + } + + private void InvokeSetter() + { + if (XValue != null && YValue != null) + { + FrameCallback!.Invoke(new Float2D(XValue.Value, YValue.Value)); + } + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator3D.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator3D.cs new file mode 100644 index 0000000000..166ce4a7d7 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Animator3D.cs @@ -0,0 +1,504 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The three-dimensional animator class, useful for animating values +/// created from three underlying values +/// +internal class Animator3D : IAnimator +{ + private readonly List _paths = []; + + /// + /// The callback to get invoked at the end of the animation + /// + protected SafeInvoker? EndCallback; + + /// + /// The callback to get invoked at each frame + /// + protected SafeInvoker? FrameCallback; + + /// + /// A boolean value indicating if the EndInvoker already invoked + /// + protected bool IsEnded; + + /// + /// The target object to change the property of + /// + protected object? TargetObject; + + /// + /// The latest horizontal value + /// + protected float? XValue; + + /// + /// The latest vertical value + /// + protected float? YValue; + + /// + /// The latest depth value + /// + protected float? ZValue; + + + /// + /// Initializes a new instance of the class. + /// + public Animator3D() + : this([]) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator3D(FPSLimiterKnownValues fpsLimiter) + : this([], fpsLimiter) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The path of the animation + /// + public Animator3D(Path3D path) + : this([path]) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The path of the animation + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator3D(Path3D path, FPSLimiterKnownValues fpsLimiter) + : this([path], fpsLimiter) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// An array containing the list of paths of the animation + /// + public Animator3D(Path3D[] paths) : this(paths, FPSLimiterKnownValues.LimitThirty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// An array containing the list of paths of the animation + /// + /// + /// Limits the maximum frames per seconds + /// + public Animator3D(Path3D[] paths, FPSLimiterKnownValues fpsLimiter) + { + HorizontalAnimator = new Animator(fpsLimiter); + VerticalAnimator = new Animator(fpsLimiter); + DepthAnimator = new Animator(fpsLimiter); + Paths = paths; + } + + /// + /// Gets the currently active path. + /// + public Path3D ActivePath => new( + HorizontalAnimator.ActivePath!, + VerticalAnimator.ActivePath!, + DepthAnimator.ActivePath!); + + /// + /// Gets the horizontal animator. + /// + public Animator HorizontalAnimator { get; protected set; } + + /// + /// Gets the vertical animator. + /// + public Animator VerticalAnimator { get; protected set; } + + /// + /// Gets the depth animator. + /// + public Animator DepthAnimator { get; protected set; } + + + /// + /// Gets or sets an array containing the list of paths of the animation + /// + /// Animation is running + public Path3D[] Paths + { + get => _paths.ToArray(); + set + { + if (CurrentStatus == AnimatorStatus.Stopped) + { + _paths.Clear(); + _paths.AddRange(value); + var pathsX = new List(); + var pathsY = new List(); + var pathsZ = new List(); + foreach (var p in value) + { + pathsX.Add(p.HorizontalPath); + pathsY.Add(p.VerticalPath); + pathsZ.Add(p.DepthPath); + } + + HorizontalAnimator.Paths = pathsX.ToArray(); + VerticalAnimator.Paths = pathsY.ToArray(); + DepthAnimator.Paths = pathsZ.ToArray(); + } + else + { + throw new NotSupportedException("Animation is running."); + } + } + } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation after its ending + /// + public virtual bool Repeat + { + get => HorizontalAnimator.Repeat && VerticalAnimator.Repeat && DepthAnimator.Repeat; + + set => HorizontalAnimator.Repeat = VerticalAnimator.Repeat = DepthAnimator.Repeat = value; + } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation in reverse after its ending. + /// + public virtual bool ReverseRepeat + { + get => + HorizontalAnimator.ReverseRepeat && VerticalAnimator.ReverseRepeat + && DepthAnimator.ReverseRepeat; + + set => + HorizontalAnimator.ReverseRepeat = + VerticalAnimator.ReverseRepeat = DepthAnimator.ReverseRepeat = value; + } + + /// + /// Gets the current status of the animation + /// + public virtual AnimatorStatus CurrentStatus + { + get + { + if (HorizontalAnimator.CurrentStatus == AnimatorStatus.Stopped + && VerticalAnimator.CurrentStatus == AnimatorStatus.Stopped + && DepthAnimator.CurrentStatus == AnimatorStatus.Stopped) + { + return AnimatorStatus.Stopped; + } + + if (HorizontalAnimator.CurrentStatus == AnimatorStatus.Paused + && VerticalAnimator.CurrentStatus == AnimatorStatus.Paused + && DepthAnimator.CurrentStatus == AnimatorStatus.Paused) + { + return AnimatorStatus.Paused; + } + + if (HorizontalAnimator.CurrentStatus == AnimatorStatus.OnHold + && VerticalAnimator.CurrentStatus == AnimatorStatus.OnHold + && DepthAnimator.CurrentStatus == AnimatorStatus.OnHold) + { + return AnimatorStatus.OnHold; + } + + return AnimatorStatus.Playing; + } + } + + /// + /// Pause the animation + /// + public virtual void Pause() + { + if (CurrentStatus == AnimatorStatus.OnHold || CurrentStatus == AnimatorStatus.Playing) + { + HorizontalAnimator.Pause(); + VerticalAnimator.Pause(); + DepthAnimator.Pause(); + } + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + public virtual void Play(object targetObject, string propertyName) + { + Play(targetObject, propertyName, null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + /// + /// The callback to get invoked at the end of the animation + /// + public virtual void Play(object targetObject, string propertyName, SafeInvoker? endCallback) + { + TargetObject = targetObject; + var prop = TargetObject.GetType() + .GetProperty( + propertyName, + BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance | + BindingFlags.SetProperty); + if (prop == null) + { + return; + } + + Play( + new SafeInvoker( + value => + prop.SetValue(TargetObject, Convert.ChangeType(value, prop.PropertyType), null), + TargetObject), + endCallback); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// Any object containing a property + /// + public virtual void Play(T targetObject, Expression> propertySetter) + { + Play(targetObject, propertySetter, null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// The callback to get invoked at the end of the animation + /// + /// + /// Any object containing a property + /// + public virtual void Play(T targetObject, Expression>? propertySetter, SafeInvoker? endCallback) + { + if (propertySetter == null) + { + return; + } + + TargetObject = targetObject; + + var property = + (propertySetter.Body as MemberExpression ?? + ((UnaryExpression) propertySetter.Body).Operand as MemberExpression)?.Member as PropertyInfo; + if (property == null) + { + throw new ArgumentException(nameof(propertySetter)); + } + + Play( + new SafeInvoker( + value => + property.SetValue(TargetObject, Convert.ChangeType(value, property.PropertyType), null), + TargetObject), + endCallback); + } + + /// + /// Resume the animation from where it paused + /// + public virtual void Resume() + { + if (CurrentStatus == AnimatorStatus.Paused) + { + HorizontalAnimator.Resume(); + VerticalAnimator.Resume(); + DepthAnimator.Resume(); + } + } + + /// + /// Stops the animation and resets its status, resume is no longer possible + /// + public virtual void Stop() + { + HorizontalAnimator.Stop(); + VerticalAnimator.Stop(); + DepthAnimator.Stop(); + XValue = YValue = ZValue = null; + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The property to change + /// + public void Play(object targetObject, KnownProperties property) + { + Play(targetObject, property, null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The property to change + /// + /// + /// The callback to get invoked at the end of the animation + /// + public void Play(object targetObject, KnownProperties property, SafeInvoker? endCallback) + { + Play(targetObject, property.ToString(), endCallback); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The callback to get invoked at each frame + /// + public void Play(SafeInvoker frameCallback) + { + Play(frameCallback, (SafeInvoker?)null); + } + + /// + /// Starts the playing of the animation + /// + /// + /// The callback to get invoked at each frame + /// + /// + /// The callback to get invoked at the end of the animation + /// + public void Play(SafeInvoker frameCallback, SafeInvoker? endCallback) + { + Stop(); + FrameCallback = frameCallback; + EndCallback = endCallback; + IsEnded = false; + HorizontalAnimator.Play( + new SafeInvoker( + value => + { + XValue = value; + InvokeSetter(); + }), + new SafeInvoker(InvokeFinisher)); + VerticalAnimator.Play( + new SafeInvoker( + value => + { + YValue = value; + InvokeSetter(); + }), + new SafeInvoker(InvokeFinisher)); + DepthAnimator.Play( + new SafeInvoker( + value => + { + ZValue = value; + InvokeSetter(); + }), + new SafeInvoker(InvokeFinisher)); + } + + private void InvokeFinisher() + { + if (EndCallback != null && !IsEnded) + { + lock (EndCallback) + { + if (CurrentStatus == AnimatorStatus.Stopped) + { + IsEnded = true; + EndCallback.Invoke(); + } + } + } + } + + private void InvokeSetter() + { + if (XValue != null && YValue != null && ZValue != null) + { + FrameCallback!.Invoke(new Float3D(XValue.Value, YValue.Value, ZValue.Value)); + } + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Definitions.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Definitions.cs new file mode 100644 index 0000000000..c4e1cdfda0 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Definitions.cs @@ -0,0 +1,283 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The possible statuses for an animator instance +/// +public enum AnimatorStatus +{ + /// + /// Animation is stopped + /// + Stopped, + + /// + /// Animation is now playing + /// + Playing, + + /// + /// Animation is now on hold for path delay, consider this value as playing + /// + OnHold, + + /// + /// Animation is paused + /// + Paused +} + +/// +/// FPS limiter known values +/// +public enum FPSLimiterKnownValues +{ + /// + /// Limits maximum frames per second to 10fps + /// + LimitTen = 10, + + /// + /// Limits maximum frames per second to 20fps + /// + LimitTwenty = 20, + + /// + /// Limits maximum frames per second to 30fps + /// + LimitThirty = 30, + + /// + /// Limits maximum frames per second to 60fps + /// + LimitSixty = 60, + + /// + /// Limits maximum frames per second to 100fps + /// + LimitOneHundred = 100, + + /// + /// Limits maximum frames per second to 200fps + /// + LimitTwoHundred = 200, + + /// + /// Adds no limit to the number of frames per second + /// + NoFPSLimit = -1 +} + +/// +/// Contains a list of all known animation functions +/// +public enum KnownAnimationFunctions +{ + /// + /// No known animation function + /// + None, + + /// + /// The cubic ease-in animation function. + /// + CubicEaseIn, + + /// + /// The cubic ease-in and ease-out animation function. + /// + CubicEaseInOut, + + /// + /// The cubic ease-out animation function. + /// + CubicEaseOut, + + /// + /// The linear animation function. + /// + Linear, + + /// + /// The circular ease-in and ease-out animation function. + /// + CircularEaseInOut, + + /// + /// The circular ease-in animation function. + /// + CircularEaseIn, + + /// + /// The circular ease-out animation function. + /// + CircularEaseOut, + + /// + /// The quadratic ease-in animation function. + /// + QuadraticEaseIn, + + /// + /// The quadratic ease-out animation function. + /// + QuadraticEaseOut, + + /// + /// The quadratic ease-in and ease-out animation function. + /// + QuadraticEaseInOut, + + /// + /// The quartic ease-in animation function. + /// + QuarticEaseIn, + + /// + /// The quartic ease-out animation function. + /// + QuarticEaseOut, + + /// + /// The quartic ease-in and ease-out animation function. + /// + QuarticEaseInOut, + + /// + /// The quintic ease-in and ease-out animation function. + /// + QuinticEaseInOut, + + /// + /// The quintic ease-in animation function. + /// + QuinticEaseIn, + + /// + /// The quintic ease-out animation function. + /// + QuinticEaseOut, + + /// + /// The sinusoidal ease-in animation function. + /// + SinusoidalEaseIn, + + /// + /// The sinusoidal ease-out animation function. + /// + SinusoidalEaseOut, + + /// + /// The sinusoidal ease-in and ease-out animation function. + /// + SinusoidalEaseInOut, + + /// + /// The exponential ease-in animation function. + /// + ExponentialEaseIn, + + /// + /// The exponential ease-out animation function. + /// + ExponentialEaseOut, + + /// + /// The exponential ease-in and ease-out animation function. + /// + ExponentialEaseInOut +} + +/// +/// The known one dimensional properties of WinForm controls +/// +public enum KnownProperties +{ + /// + /// The property named 'Value' of the object + /// + Value = 0, + + /// + /// The property named 'Text' of the object + /// + Text = 1, + + /// + /// The property named 'Caption' of the object + /// + Caption = 2, + + /// + /// The property named 'BackColor' of the object + /// + BackColor = 3, + + /// + /// The property named 'ForeColor' of the object + /// + ForeColor = 4, + + /// + /// The property named 'Opacity' of the object + /// + Opacity = 5 +} + +/// +/// The known two-dimensional properties of WinForm controls +/// +public enum KnownTwoDimensionalProperties +{ + /// + /// The property named 'Size' of the object + /// + Size, + + /// + /// The property named 'Location' of the object + /// + Location +} + +/// +/// The known three-dimensional properties of WinForm controls +/// +public enum KnownColorProperties +{ + /// + /// The property named 'BackColor' of the object + /// + BackColor, + + /// + /// The property named 'ForeColor' of the object + /// + ForeColor +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float2D.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float2D.cs new file mode 100644 index 0000000000..996af3125b --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float2D.cs @@ -0,0 +1,640 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The Float2D class contains two values and +/// represents a point in a 2D plane +/// +internal class Float2D : IConvertible, IEquatable, IEquatable, IEquatable, IEquatable, + IEquatable +{ + /// + /// Initializes a new instance of the class. + /// + /// + /// The horizontal value + /// + /// + /// The vertical value + /// + public Float2D(float x, float y) + { + X = x; + Y = y; + } + + /// + /// Initializes a new instance of the class. + /// + public Float2D() : this(0, 0) + { + } + + /// + /// Gets the horizontal value of the point + /// + public float X { get; set; } + + /// + /// Gets the vertical value of the point + /// + public float Y { get; set; } + + /// + /// Returns the for this instance. + /// + /// + /// The enumerated constant that is the of the class or value type that implements + /// this interface. + /// + public TypeCode GetTypeCode() + { + return TypeCode.Object; + } + + /// + /// Converts the value of this instance to an equivalent Boolean value using the specified culture-specific formatting + /// information. + /// + /// + /// A Boolean value equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public bool ToBoolean(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 8-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public byte ToByte(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent Unicode character using the specified culture-specific + /// formatting information. + /// + /// + /// A Unicode character equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public char ToChar(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent using the specified + /// culture-specific formatting information. + /// + /// + /// A instance equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public DateTime ToDateTime(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent number using the specified + /// culture-specific formatting information. + /// + /// + /// A number equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public decimal ToDecimal(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent double-precision floating-point number using the specified + /// culture-specific formatting information. + /// + /// + /// A double-precision floating-point number equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public double ToDouble(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 16-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 16-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public short ToInt16(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent 32-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 32-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public int ToInt32(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 64-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 64-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public long ToInt64(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 8-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public sbyte ToSByte(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent single-precision floating-point number using the specified + /// culture-specific formatting information. + /// + /// + /// A single-precision floating-point number equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public float ToSingle(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 16-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public ushort ToUInt16(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 32-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public uint ToUInt32(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 64-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public ulong ToUInt64(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent using the specified + /// culture-specific formatting information. + /// + /// + /// A instance equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + public string ToString(IFormatProvider? provider) + { + return ToString(); + } + + /// + /// Converts the value of this instance to an of the specified + /// that has an equivalent value, using the specified culture-specific formatting + /// information. + /// + /// + /// An instance of type whose value is equivalent to + /// the value of this instance. + /// + /// The to which the value of this instance is converted. + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + public object ToType(Type conversionType, IFormatProvider? provider) + { + if (conversionType == typeof(Point)) + { + return (Point) this; + } + + if (conversionType == typeof(Size)) + { + return (Size) this; + } + + if (conversionType == typeof(PointF)) + { + return (PointF) this; + } + + if (conversionType == typeof(SizeF)) + { + return (SizeF) this; + } + + throw new InvalidCastException(); + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(Float2D? other) + { + return other is not null && this == other; + } + + /// + /// Indicates whether the current object is equal to a object. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(Point other) + { + return this == other; + } + + /// + /// Indicates whether the current object is equal to a object. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(PointF other) + { + return this == other; + } + + /// + /// Indicates whether the current object is equal to a object. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(Size other) + { + return this == other; + } + + /// + /// Indicates whether the current object is equal to a object. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(SizeF other) + { + return this == other; + } + + /// + /// Determines whether the specified is equal to the current + /// . + /// + /// + /// true if the specified is equal to the current ; + /// otherwise, false. + /// + /// The to compare with the current . + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + var conversionType = obj.GetType(); + if (conversionType == typeof(Point)) + { + return this == (Point) obj; + } + + if (conversionType == typeof(PointF)) + { + return this == (PointF) obj; + } + + if (conversionType == typeof(Size)) + { + return this == (Size) obj; + } + + if (conversionType == typeof(SizeF)) + { + return this == (SizeF) obj; + } + + return obj.GetType() == GetType() && Equals((Float2D) obj); + } + + /// + /// Serves as a hash function for a particular type. This code will change of the values of the X and Y changes. Make + /// sure to not change the values while stored in a hash dependent data structure. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + unchecked + { + // ReSharper disable NonReadonlyMemberInGetHashCode + return (X.GetHashCode() * 397) ^ Y.GetHashCode(); + // ReSharper restore NonReadonlyMemberInGetHashCode + } + } + + /// + /// Compares two objects for equality + /// + /// Left object + /// Right object + /// true if both objects are equal, otherwise false + public static bool operator ==(Float2D left, Float2D right) + { + if (ReferenceEquals(left, null) || ReferenceEquals(right, null)) + { + return ReferenceEquals(left, null) && ReferenceEquals(right, null); + } + + // ReSharper disable CompareOfFloatsByEqualityOperator + return ReferenceEquals(left, right) || ((double) left.X == right.X && (double) left.Y == right.Y); + // ReSharper restore CompareOfFloatsByEqualityOperator + } + + /// + /// Compares two objects for in-equality + /// + /// Left object + /// Right object + /// false if both objects are equal, otherwise true + public static bool operator !=(Float2D left, Float2D right) + { + return !(left == right); + } + + /// + /// Represents the values as an instance of the class + /// + /// + /// The class to convert + /// + /// + /// A new instance of the class representing the values in the instance + /// + public static implicit operator Size(Float2D float2D) + { + return new Size((int) float2D.X, (int) float2D.Y); + } + + /// + /// Represents the values as an instance of the class + /// + /// + /// The class to convert + /// + /// + /// A new instance of the class representing the values in the instance + /// + public static implicit operator Point(Float2D float2D) + { + return new Point((int) float2D.X, (int) float2D.Y); + } + + + /// + /// Represents the values as an instance of the class + /// + /// + /// The class to convert + /// + /// + /// A new instance of the class representing the values in the instance + /// + public static implicit operator SizeF(Float2D float2D) + { + return new SizeF(float2D.X, float2D.Y); + } + + /// + /// Represents the values as an instance of the class + /// + /// + /// The class to convert + /// + /// + /// A new instance of the class representing the values in the instance + /// + public static implicit operator PointF(Float2D float2D) + { + return new PointF(float2D.X, float2D.Y); + } + + /// + /// Returns a string that represents the current . + /// + /// + /// A string that represents the current . + /// + public override string ToString() + { + return "(" + X.ToString("0.00") + "," + Y.ToString("0.00") + ")"; + } + + /// + /// Creates and returns a new instance of the class from a instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D FromPoint(Point point) + { + return new Float2D(point.X, point.Y); + } + + /// + /// Creates and returns a new instance of the class from a instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D FromPoint(PointF point) + { + return new Float2D(point.X, point.Y); + } + + /// + /// Creates and returns a new instance of the class from a instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D FromSize(Size size) + { + return new Float2D(size.Width, size.Height); + } + + /// + /// Creates and returns a new instance of the class from a instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D FromSize(SizeF size) + { + return new Float2D(size.Width, size.Height); + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float3D.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float3D.cs new file mode 100644 index 0000000000..64507e75c4 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Float3D.cs @@ -0,0 +1,509 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The Float3D class contains two values and +/// represents a point in a 3D plane +/// +internal class Float3D : IConvertible, IEquatable, IEquatable +{ + /// + /// Initializes a new instance of the class. + /// + /// + /// The horizontal value + /// + /// + /// The vertical value + /// + /// + /// The depth value + /// + public Float3D(float x, float y, float z) + { + X = x; + Y = y; + Z = z; + } + + /// + /// Initializes a new instance of the class. + /// + public Float3D() : this(0, 0, 0) + { + } + + /// + /// Gets the horizontal value of the point + /// + public float X { get; set; } + + /// + /// Gets the vertical value of the point + /// + public float Y { get; set; } + + /// + /// Gets the depth value of the point + /// + public float Z { get; set; } + + /// + /// Returns the for this instance. + /// + /// + /// The enumerated constant that is the of the class or value type that implements + /// this interface. + /// + public TypeCode GetTypeCode() + { + return TypeCode.Object; + } + + + /// + /// Converts the value of this instance to an equivalent Boolean value using the specified culture-specific formatting + /// information. + /// + /// + /// A Boolean value equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public bool ToBoolean(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 8-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public byte ToByte(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent Unicode character using the specified culture-specific + /// formatting information. + /// + /// + /// A Unicode character equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public char ToChar(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent using the specified + /// culture-specific formatting information. + /// + /// + /// A instance equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public DateTime ToDateTime(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent number using the specified + /// culture-specific formatting information. + /// + /// + /// A number equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public decimal ToDecimal(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent double-precision floating-point number using the specified + /// culture-specific formatting information. + /// + /// + /// A double-precision floating-point number equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public double ToDouble(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 16-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 16-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public short ToInt16(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent 32-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 32-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public int ToInt32(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 64-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 64-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public long ToInt64(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 8-bit signed integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public sbyte ToSByte(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent single-precision floating-point number using the specified + /// culture-specific formatting information. + /// + /// + /// A single-precision floating-point number equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public float ToSingle(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 16-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public ushort ToUInt16(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 32-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public uint ToUInt32(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + + /// + /// Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified culture-specific + /// formatting information. + /// + /// + /// An 64-bit unsigned integer equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + /// This method is not supported + public ulong ToUInt64(IFormatProvider? provider) + { + throw new InvalidCastException(); + } + + /// + /// Converts the value of this instance to an equivalent using the specified + /// culture-specific formatting information. + /// + /// + /// A instance equivalent to the value of this instance. + /// + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + public string ToString(IFormatProvider? provider) + { + return ToString(); + } + + /// + /// Converts the value of this instance to an of the specified + /// that has an equivalent value, using the specified culture-specific formatting + /// information. + /// + /// + /// An instance of type whose value is equivalent to + /// the value of this instance. + /// + /// The to which the value of this instance is converted. + /// + /// An interface implementation that supplies + /// culture-specific formatting information. + /// + public object ToType(Type conversionType, IFormatProvider? provider) + { + if (conversionType == typeof(Color)) + { + return (Color) this; + } + + throw new InvalidCastException(); + } + + /// + /// Indicates whether the current object is equal to a object. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(Color other) + { + return this == other; + } + + /// + /// Indicates whether the current object is equal to another object of the same type. + /// + /// + /// true if the current object is equal to the parameter; otherwise, false. + /// + /// An object to compare with this object. + public bool Equals(Float3D? other) + { + return other is not null && this == other; + } + + /// + /// Determines whether the specified is equal to the current + /// . + /// + /// + /// true if the specified is equal to the current ; + /// otherwise, false. + /// + /// The to compare with the current . + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + var conversionType = obj.GetType(); + if (conversionType == typeof(Color)) + { + return this == (Color) obj; + } + + return obj.GetType() == GetType() && Equals((Float3D) obj); + } + + /// + /// Serves as a hash function for a particular type. This code will change of the values of the X and Y changes. Make + /// sure to not change the values while stored in a hash dependent data structure. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + unchecked + { + // ReSharper disable NonReadonlyMemberInGetHashCode + var hashCode = X.GetHashCode(); + hashCode = (hashCode * 397) ^ Y.GetHashCode(); + hashCode = (hashCode * 397) ^ Z.GetHashCode(); + return hashCode; + // ReSharper restore NonReadonlyMemberInGetHashCode + } + } + + + /// + /// Compares two objects for equality + /// + /// Left object + /// Right object + /// true if both objects are equal, otherwise false + public static bool operator ==(Float3D left, Float3D right) + { + if (ReferenceEquals(left, null) || ReferenceEquals(right, null)) + { + return ReferenceEquals(left, null) && ReferenceEquals(right, null); + } + + // ReSharper disable CompareOfFloatsByEqualityOperator + return ReferenceEquals(left, right) || + ((double) left.X == right.X && (double) left.Y == right.Y && (double) left.Z == right.Z); + // ReSharper restore CompareOfFloatsByEqualityOperator + } + + /// + /// Compares two objects for in-equality + /// + /// Left object + /// Right object + /// false if both objects are equal, otherwise true + public static bool operator !=(Float3D left, Float3D right) + { + return !(left == right); + } + + /// + /// Represents the values as an instance of the class + /// + /// + /// The class to convert + /// + /// + /// A new instance of the class representing the values in the instance + /// + public static implicit operator Color(Float3D float3D) + { + return Color.FromArgb((int) float3D.X, (int) float3D.Y, (int) float3D.Z); + } + + /// + /// Returns a string that represents the current . + /// + /// + /// A string that represents the current . + /// + public override string ToString() => $"( {X:0.00}, {Y:0.00}, {Z:0.00} )"; + + /// + /// Creates and returns a new instance of the class from a instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float3D FromColor(Color color) => new(color.R, color.G, color.B); +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/FloatExtensions.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/FloatExtensions.cs new file mode 100644 index 0000000000..6cf3ddbc72 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/FloatExtensions.cs @@ -0,0 +1,68 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// Contains public extension methods about Float2D and Float3D classes +/// +internal static class FloatExtensions +{ + /// + /// Creates and returns a new instance of the class from this instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D ToFloat2D(this Point point) => Float2D.FromPoint(point); + + /// + /// Creates and returns a new instance of the class from this instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D ToFloat2D(this PointF point) => Float2D.FromPoint(point); + + /// + /// Creates and returns a new instance of the class from this instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D ToFloat2D(this Size size) => Float2D.FromSize(size); + + /// + /// Creates and returns a new instance of the class from this instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float2D ToFloat2D(this SizeF size) => Float2D.FromSize(size); + + /// + /// Creates and returns a new instance of the class from this instance + /// + /// The object to create the instance from + /// The newly created instance + public static Float3D ToFloat3D(this Color color) => Float3D.FromColor(color); +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/IAnimator.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/IAnimator.cs new file mode 100644 index 0000000000..2b93690f3b --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/IAnimator.cs @@ -0,0 +1,119 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The base interface for any Animator class, custom or build-in +/// +internal interface IAnimator +{ + /// + /// Gets the current status of the animation + /// + AnimatorStatus CurrentStatus { get; } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation after its ending + /// + bool Repeat { get; set; } + + /// + /// Gets or sets a value indicating whether animator should repeat the animation in reverse after its ending. + /// + bool ReverseRepeat { get; set; } + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + void Play(object targetObject, string propertyName); + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The name of the property to change + /// + /// + /// The callback to get invoked at the end of the animation + /// + void Play(object targetObject, string propertyName, SafeInvoker? endCallback); + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// Any object containing a property + /// + void Play(T targetObject, Expression> propertySetter); + + /// + /// Starts the playing of the animation + /// + /// + /// The target object to change the property + /// + /// + /// The expression that represents the property of the target object + /// + /// + /// The callback to get invoked at the end of the animation + /// + /// + /// Any object containing a property + /// + void Play(T targetObject, Expression> propertySetter, SafeInvoker? endCallback); + + /// + /// Resume the animation from where it paused + /// + void Resume(); + + /// + /// Stops the animation and resets its status, resume is no longer possible + /// + void Stop(); + + /// + /// Pause the animation + /// + void Pause(); +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Icon.png b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Icon.png new file mode 100644 index 0000000000000000000000000000000000000000..32e81302703a6e0507112aa5121de5a04348d331 GIT binary patch literal 12792 zcmbWecUV(jvo^dFLT{mCXd(38tCY}tFCx8H=}0f3BS=R?=?DUXfOMscpaKHYkrs*+ zL8;OqFTdwJ&w0N;&ULQu`|{6TYiI76d(E2JNoGx+=#pdnXq+FImKXM-Kw-<|vDJAf_XzZTs*=VTPBYwQr};UMLRke7qY1WVs3@N^2Wg9m#)^75AsmPPzauk_vcpW6Zm_`gH~ zJY*67MaoP^AFkx>=L8qy7vpmf6c&O@Nbw7aiAo6x@xp}#g+v5|1O%y%cj z=O5w~U>D5i<`snEVw_-2>{V zWdgx=J_17gf&!kN|E%j@(*6O4PXCw2|0wNm9OC07VCdxU{n*dpZaj`lVFx=wdwU0aKCwIJ@i~Z#+Vj~v zJ4x_4I!o9~3JFR%I0_2?N6-I+7g17BP!tqZ5>gZu6B1GpR}fbbR2EfImJpUyQ591a z{|{Ef%Rj)*%fabCw%zV*{~N3Lzhb48{G99py#0*5y&wH23iMsQ1HAoRy?x+HN^s5x zZeEVwLH=C-?9hKLSlP+XEzrqP)z8}#{x26xyZsO5#T*0$odm@N`9z#VocP3?MFsh! z?1aVn1RaGWgq@tkgv7*!5dX$I{{MBIz#S=pf8yl-5jX$2br+2P4F5X|?k4}8M^0XM z$>VpIC4oL7i~zvTprNc_9Q`!0x>__TMwpp8W1?@+TMG~wXO5#Ieu9daDqLFY29EukQK)}&Z6cP>vL-8Pr z05}?ncQ?TU;X%O6!2e4jG)eLX^@apV57$AuPX|oi@8q<^()1Z@*D@k<_YWC95^7CZ zB{Xn27WB3X04oIgG{ThVF;9)|jK}QRy5q^M3yKZm-T zS^?{yrhPle>>lvoRU1rpigR76LMHj*Z!ll@tfzbPoA0%%*)U>v(KqkZQVZSpOdL{R zgj>tV{pw=6sj98nz=Pcd-JZ7BELtlejj(v;Fx_I~SM@N9SIy@H!k)zJ5H$W$Fy)bR zJV`jcTM%ue>EVilOl6!zuze)2Td<1SM6Z&!ON{GkRFL4qS_6kn*zv_yUHOGhGUdzg zcGC7gRZzK}`fA^LEhf%MB%B$wS9ZU6Mrejbz-XObPJ^7Tvq0~!U!q(PmKGtg1|&Lr z-%aecdQhDGsj3QIn5;FO@|mf6@fO%`ge{K?q|VvUv;B=j{Le0#yX6QWBkQ-D-9NOYY$hj8WI@D0}J^wKu-; zu*7O#QB2W(uv#jcd+mdDJN8&=6&yj$j~S=IUwT$TTc-n*qXA{?1NFS})CbRNgiv}n zzJ3;RF_{|5!2}e&iJB(oiHK-7vhzsz)ssi0__A@po=*nG7?ZN<_RGyrj8lAf}|@yQb5Q7;!nJ4ThV8Jtp-F6zT&%P#t($# z5cy0fi7lRT*}D)T`{Y(zuj@#TM`&%lF2PkKhF6;L73fo$t{pnr?1_bw*lV~{!9E{( z2oFwbg(|y6WuY=5oR&p5{XU-H~V$^<-jLURY!2*W5wF1S$LP zA?;u>^hcRO%nC*8AFkJ1Gr6jsZ?&nwNhA%cpEFvwNnahrS6||^&eX39rE7q8A<^1` z!HBxjm?w5b3(AIT&!}X}f@|0Xxn}S|aTZhZDFM#rY$~EZCvgo?8x0y{eY}7Db+cfg zzj!#`yK8j|BG9sN*&#D)e+)YL1YIp(4W`Ef9~1kh+jE+kD__zy^=d=r#`vy1ULoRK z;P3-!>AV0qC2LG{`74}Z4~b{rvkEh`<@yoUAHfqugCgPFKaT)6HA1)8{;|{c} zjUp}>)5Css6>$hkDU&6g$l#l&K~W36s)>gLw+r5ldFF77xgbSXJAAuTL@bk>V2^it zVyiKLD0)iIT4_`w}v~1yi5&u@bgbpWAJ2GNNzHgw@s5DI^F{s0X%u+3yPEMce z&0k*uHuQT;)6FYg&pjEWn5KqOl)*lPW{Wlt*2U+KnLsCp^6&m!w!+f64H(vTxqsO3 zLZoj<9>+*HpIaZiDJbMPqjK+MQ3SlyMaTa}F*=)$9^Ghsl7v_9&|bQ#z^~~df8R@{ zEn>BTLdvdnRq!lix@X051gbY@1OQBYH}Q*Y+qG2|>OpTGCz%SPK@23HAC z3oD|$ZM&!qV!b&PgN<)2N9$L-6!46Wx4Z3`N=H|F@IercBc(;P@Kd|SF_FP&s=LQ0 zr&DWeMVtf`^L1u`*R_`l&H`!hjcYFd5&qo+F9u}z*xLms*GN9BY6C>C_X9(m8T0}X zyHlR>@(V%B-(@E7RXnx;Z-GuNR>?0TdsOi5Pr! zC%r?>ZgtSZ`+Qb&B2`x?)3vqE(?pAR%WRUSk4Evhzp97sIM zzfTh@L`Fag3t704rvRZCOe8#wHT%1iXfx%+2vuLRgrtKl#k1$FlNphzQbkhl_vgIeiU}aaV+M*{fMJXwKF>{@3q!W4W%TdukojdaU_) z$a|RXH`o>Hz>#;kcCgjN{9>A)~3_vXh8y^;h%88te%PgU_-boBt4eXQ^1 z-T*~jBD-&~-LHAvY?_j8NU*+D#PD8C|4>M;W)jf|OVDrRjXXkMmUs_SGNVr9DL&m4 zXVfjTS;)2R}KGti7yCJ?)I` zW&5WQS#w*aq*tcP?3*=F9@%BVNH^2L$B5p7eZ3TK-sRj~#uwuY?>QPz0)@ zgCpb4ew<%?Z*k6lbYG&OsWfS`mY?v5WklGGlfgICa0&>*2Z*^1x_1?aFMQ6zwNft{ zZ(=^z@Pz5B6;M8m#TWx%!)iXJZ|w;Xf$2(K zx7b|Pze@Y|nbnGbkFx}4-H{oU4o)DWb(Qm$iYkSz=sP?lzt?NhuGnfPXx7w{L+!~& zvUgK2=`0YCKE^{XSi$7wkF+n~hBPn<-n03bzrr5s_zq@cx_*Ooi}B5ch<^zjk=^7Y zZC&4Qe;Jy@ghze#8Uf0#kaZOU1`N|Ez~e}r%UzALbP>A>n2phTs_re$Z;F;VGKmJG zR>wc%GX}_XK78ZrN|vjAt&4c#odw4~7{TG_1#uNTKV&*N;0B^td-1%jyXO8(?eRO%5P##%so2 zD{Q@DR1V!n1=aX6{`L-G`+}gJ3ardcLuW1OzJ2tX(aDN>DPGzq1rfdf#uuGfP&4=k z<;}!x{&!RYjM|Rvy!EB_w=rHP(TX5eRZa?j@MUw1VG}}ksZ~iNo_qBXH_qU|Sq1#{ z4SSjT79{*i^C7_~9e8_i?Y&NF^D}Kq@jeFJW2FRj6U2hB#9VVtob|FkY}dRC)m~gG7GECUvml{pra}b9c#-Y%w!U}-6cAP|6&O} zut1z{G4hD#8vQP^)!}aCMln|%R ziyD#ZM`3fz@B`H54DB~FM%Q_Pmu5@q11fG?jO)#XuLnJoAwF}plw$BOh!3~7DTOuM z^O@K^CwS1uvR$<{s*@%)=|jc&nbTm8$JoE!h)wMoIE?|-yY*nI12OeE3p-bCK zyA17b+pC|eJ^?g?o2+ex&g_8;i=VtlGwr%jj3-f-GH%V+aNbe*D*W>@ zBJ>TvS>o`M8;hz3A^F~$aax0qdL&Ju!NzbwF--_ijCov6A!4YRQyzBnB3Z2LDYQIQvcLGi z|Gw>typQEGjAu7LV@t$kWL0uZ~gTK;lpbQE7Ew`j1L}JTP3RSBu)$d9^vJa zDlwE~+;q7|d#sObZ!JC-2wA@OhUoEq3J;rwlxfc$)qO7kk`qD`ljg}@xm$@#dbx(u z+6L6x@5A1k!vmaa-aYbOvkABN)d!#*v#9JduBuh`l+$PgjEv1MwVy^Q$Oc97kg|c_E4nkhi1gVn9ytKFsn#C*dlu9 zcM(hzT=jN|#wLP%$7k4hPF;Ftzt|6$u`QsZu zx?zauG{f(N)K?v{iQOuHI5AsBzpv<{!?2UMmt~dh`R+5zTDUnfae$RdPm7qi!TOc* z)`SjAhY8h8jgp>a77&$QK^ors;bivj zG6htc;^q`F$t)z|vB>+7)s#!U^(uTq0CWvZ?E%vfQO>1GQPH0G3Sc$HP$D7?p)Jpe zKBcovaq7WW?c~Ll6R{8}T!b6P&r6+21i*I7q$0h;L4^*AEF59$9y(W+or+ErR7{OB zV3~f0CBgoSro?2P_qHgrZ;*lQ%H-eOWilQe~7h`bCOP0KJA@)zW|K=(Phn0v~Y~Dk8h+V9EtiDh$t%I=mA!1NI z5%n$Vg$FsXXfNiN#u!&DV*-{)+Tc#FbkFELQvrS6FF!OdxSiC%m0r@@^w~x>cq)ZoGn_;{hnEf3qD4dE~8~_Cb?UDH8M=F5kbs`&mpAh@mN(b+4r7*Cj^_O%NE1KZog2+frPoxr$oE0m+#wQkCZ9ra)!19hoC}GE2<~+ zR9L%`9-CB_qqN5kn3=^^AO|+{C{<`N)b~y>0T;9PunbTg6{o z?%advq~x@HuQmgny-`}4;tjd02U!f2{XzCWF6r+;D}ETOUCg!Nux?cJ0V&#&nJI`a$Qjwo?G+R4yX8T zF@4(0PfL--c}JNW#oC***@yK}_R29=13+3FFXZ9PgodmV4u3kQv4_Kg%8F@tg|CUf zNox~0B(Ac?q<6BXGa8aDV8QR*h^6eu#;`=OGKh+%1~fanAC|JIiacmHI^7j`;8~&+ z)*^W$xL+iTDzey}n#UGH?^u!nny42~gV;%tAQg_wG3thp>!iP@Di6b%;>gF)XJ(&L zUJV~?#J4O}zgtR`sbvXm{a&K9xZf7~D_~Su=yLgrBIzf|h~hr7SP zU2{p9^$p4cs-ss|u^5cBO$?h1)s9+$R-l}b8K8E*f32UI_ANa-Rt?4RdA&=*TyN{SK1xv z;L5mmPpN>V20tf+{Y@r-V^(0fOUw^ch$ybg_QX&|H_Szf z@-j@-gyI=>P~0Yn(dKsn3{V;sn`Z|oL1JH@F3gjRQ++smeAI=OiHWUqRvcj)FZNwK zP6^YoX&q)DVYFGIeUtbgLY=}S_r98$QIihv>Z|4HkmDeqy#`_hM1@z;S6{jKS*dyP zFr2Bz^1|w zFlxI6eh&2sG-$;usl*25(U&7`gGh|2y18-JJKc@=rdQgn;{ z^R_g~Hf>XozJ3a|8cBirifVhV0iSNEIL)~?zLGH@@m-+NxKcjJDND=dXsRzYGuZ4I zuEgZHwI_dMGuIt}D=?r9Ry|Ud#GG*?5(tE`7>?IBy3u4fu+61088f{|e7s4fs|lLr z<|-N20}B?aj$=HZqQD|P^`lPY2d@G@8b9y0tY4FyKJiE%>4&Yq7NQ^yA3f|mSUVi` z3}|U-;lmL_>xg;juRr6zC6PcZ>i1CHM~R7N{1FuuN!)+ZY!}CQmbI{tpX9@!SUtH4 z3JCrnF|cCc;qDH;&uLUB&aP5fsqop`<$iQ;Y;yHrj}i5+o=WL)^+#emH!c?d;qW0paGe|Zf>QZXAp+u>=u z&o{^D#ja8J-2^Nc(SV4BKxy#dEWMnG;;ZxARbYu#opO;O$g+Vq7s%1vm_rck+A!Do zT3{Bj%gWMAdoDZi82biCMl|s&pDvxCPn*Sv2tyWe9eJ-8VFCsCOSi18Ikm1kgn*e$ z1Kcu^`0Z9u<10h>9Ut50KWVh%P2YhWiQ2cl;F#nj%P*(#u=g!)SR7~6g!mEce$(>e=E>QAs}-gXbWyX8lTaIaH3r$^=eAe+{fdgr^t$nps}T+GocgBZPf%y?OyFVAxu(skk(MylO;n(X%=lmgIOX*@hB2p@;e~&^ z|dtyK@Koy#mVx1&$?>M?wk>?YSSzqTZQHm%o(q)*QZB$2+3Vb zc3_*s`=L7M^~B1Pa(FbH0Eu@{<5>4Nnn2bhVG_gV*UkvY(Gmr}M#d{*fzYaa!b7n&w>PNe$+68I&rU*m8{+=-Pj3d&Us;m?&0#ue)3fr4xVBfP6`%T*e~OW%okR60{bHxN5U2Es;v;Oe};L)!uQm1#7pAIS>e3d4TqkJ6hoZ~@@UbG?hm7t5(4rbo_!|XdO0X(TJu@;g!viYiL+{GhBQ+&c^Lh=z z-3pu5?%?PYGu6$@h;fX;TP~B9pH!X2zmyaJF)=aU+oN5+DO9N=3E?ughXz!*^VML0 z7Fe*w$!6?|i;)1VF5RVr7?u>P6Q2W#AE#a;XL8`mbG_og+ffQA5 zqyv#V@Tp2?BZMLd`SX?IN5fr_#x}^!U-FU%?3uct zKLm3UEgQ&lZ*xe=6tEcg*^E^ayBw$3DG$r{7q;IgDg-nD)czLZSX!5R)JG#yMJ~dL zMwGlz2Y{Efop(~Q+r!kemrMlhTro)7yRf?Zz1VX6b<0nfi^Q>Pk&Ug*!7Tlz`AAWi`* z)J2!KJU4TZumhNa*-gM#uVtqoy{v%HpkwduSgkAg5(lBvZZK2O%iL>-DbDrxb|zPk zAK*{MxRC)4E!g>`n&XfZkDEkw5I7NKD>nB!*L)xfNYC;DB!9TgI(Tfqvy{#K8uEb20K3qc@11#plLm zpRVG{)B*KhFFbuCDAj1~eY>uvg40;lkWiwGV&TG(XfLF1mtcx=8?uS^YC{Jw!t z$OSM)k7d5sl`g{~bK{Ix!hVl4BV2ZJ>ly+S_J4?aQ!Y_OmfjIrG9Vm&Gu-KB^b;4w zCcx%T=ZjWo#Z^DlSKxoAlj`zilpz&WyukH%m2?mH{AR1;c0dFH)KSObB))#cr4I6W zo?|X}cwD|9KnQs+eS!9tZsOErXn+O7k9C-QMBbK>vF!=4t&f0MKFxY zgrQ{yUFTp{EwO6#Ar=;>`7knAn8-$MbMi5I*U}{~)){{V(ezVv)O{efQ5^dr&Yo_M z!MaY$`z4LUwg+^ZZ(01GYH#2He`AA#eSJ7+t@3|rdk69>cjii9iG%z z5QDc3PS5V?VsOu2hNuAeCbkuJB<4vGMyZ+9v-!j1v5tfUji7=FjLxQJ&!@`UZ`75T zp@yW}yHB&(>GQ6Egm?xtw{QnG*|YeUAo=Gl+z0m-G%Svu-_;|ULyKS>beq%1mr=4d z_$BcJ#h>{$BNGgR^fUnK9~~DTz|l;-FE44tHqA!W-e1*c&By+gte?ycX9IxJ&Pl$2 zH~kOG-!!+gcY=bltm1N!wjaC7U+H>U1|*$dk?+{IRgaJE$_13}z2mi{_)2P1@&mD_Hl7Hkrw;1V29Qo=Sq6D~>pfZMtsr~IXnuPEaA6;=| zqmUUSn6o`x}S=-%W1#>QfrNtvsB&2LYF4 zN?>|2t!m|Uug9`=&xP#7>yL5n4o4hna5HaUV*JehC}=}r{S{ow%+Ub7xOrC%N^8wO zA(}9aqPxyfT>dSc4*`U39#hZjpi+MBx)*mizHN5od^6* z@XYpuqqc4_$&N-bUP5d)JQKm;L?XL~ZhW6g)L1m*KTe6)b z_;PrsQXkiV{tsQ*dyTm9z=z(z?kD0c6F5To#ha^_=^0)#f;Okh%fMHOsGr|@M*4Sc zPp;m=)GS5{$94n5ro60qQD>HY5|K4Ol@!+oeHrW0*U|*HWpv4TDIdcnHX_BmSiPsq z-_>QjccDn=em3jDN;i8~ClH*H86q8ZjwRu+;tH-xJPS^t!DeinqJGMbUPx3RnYs03 zv`#E~RwX4hWA8;*KdHu5cF6t?wJbrFAJOyk`rUOy`q2U77x*<}Q`-r{Q)+VN)u1rS zVS@=egJ=rgt(CETvUw#|YIN8>oZK7BY%%&Y4FbYyL(}a`H$FmVGVu|0- zTwH{F|Lki9=Rgw-|CLLeUB3)(uNG31Q)7@{tmNHdal^B+)H^tr^Vted4Ny@3%1VTb zTwX!DY_@zmeb=eWZax~7JZopwy||dCRP4m(Hhd#9eDO+S)-E4?7$N>n$2J*O;}|7H z9PnEqkDus$hio@BU#GrFXzkDIkj~qg%}L@ksnd{*Ra~sGn%rZxj6gE`Ov>P3rtNe* zrf&08`OIe4AY#Ee#DW+1PB4i8&LY^Fv;n;^nBF!s1Xw4E1Qj34nMW6*5@PFbfw zi$ex7TU(82*vXv7mKQ!E$sOwU2hTlq?fWZoL_LpNQum3klkw5I>hk*EQ$M-oJp`^i zg}C!ac+%W$Hm`0_95D+Pk?aE5!ta5{O=&6v($sW^MN6`plrba47pBYYRdrXYFvEKv zbeU&22yWZ(pN!7P|NJ|{3_+8ao1MfKpOH*Bz0{^V(w|wq%nZEf)H$88m${}1>Ag$| z^(j8(G{Eb`8mo-Pr`3>&(p!g_(KwiaJAd?Fb@zJgR)m{^2-glr5cD1%9!)p*$Oyto z=c(MZ(QY%$#jj3|K>F~tl<=3mllq)tVmzU8ox+@Fkv1>Ks`F+Cg4DwjI&0JOWvX60 zRMOE&g`%+ag@UDbkZ_Ayds#pBiv3C1%w}eSH+^{XP2G0PS{6xP^=3~Ebv{_s>+nYj z!~f{9cz;z=1V9wPyU27D$%2<6elLuuZKaWDnXYbdOc=iaekI}Q8wILy?r|Ykr%_*x zKMZXAeD>K6rT#IsZjq81@J1D-)B3cBbOsBe^={o0QquB(?h)xN$@$3{I?`oov$OAy zSSFi)ybFg0Gp~`f3iPTr&sXHLK+p`h*{#${Pmk?C#ld`VQ&2B(!b)7Z$|eVoIddbH ztJ5&B-3z?+rHs|T2@M425xF>?-v@uO>_JAUPM~0Q(k^veFYVJR3@ANwlv{b@!RxmL z@1XS$94L3vK9?~8}DGDzSuaXM?pl=Z&)=tVk{Y)^n!DAQqJQEU8MV+3EEKbw*uAAFk3P zru6#wOfrKq*QKA2Wbv3$Bhl(e)@1D?R~nS-If)w$OF2m1Fh1;{*XV{m!x_EF?L0ZFY5}vFe%juBWnpKg|P?D(^{OC_;w;pLzQrEEB(ubJlXsS!;rx6jd z-I21z=klc)qJN;^15#I3FbkP|pIW8wT4XQBJSIz=eCFzW9*Kj;&%GHHl@*Zui&>k1 zO2+cbw{7&k^%xzKicki7if;S;Ij_dT>$f>r)%Xe1V;O0i#~*msYKLxO{0y(-K6D*?Wqgd@j<4RPd6ar|xGCENQaGgIfhCg?%Y6%2hu- zym50f=q|+6XL_>iX9v!A^>N5`V@#>{o9sSEe}jm@px<$o+~0rpKzH=^q!Y;1a5~y` zDFX9G_~X`lt)ez7pAZ`!wOZZ9KgTRalu-jVAC*med-@}NWOmTcl^(uTANf6)U$p`F zB^_%ljjU8eONe}WeBNhQuJm)`*>#(wcR_CX`}w+3$pTLa!IQt0C&&EoKbV(_KWg;w z;9;B&vPa@a)QaIHl0;;*gNmYDFKBwtlGr>?5V?5v8myTzS@`gffCJYp3K0b&g@WAm zko9zDDo(2w7ZUGVY~HR6C<=;n*&h1^7^>hpA|VGZ^>+9Bin)$yW5U5-@Ns_BXLt<> z!DCZNseUK&o<`B0(y>4?=mH!Tfa|Xkfe7KSK4y@^5Dd&tV zKDbhpSPvtlc)xkD8^5#>x~MBln)*cp{=$dmLOL_WB#u^$SoxkG)m&^9Kdkq9b-k-< z{DqFO^=Z?2bG_rl+tGs`?av$b`Z)=Mevfi4Niw5s0gvMf-YnB>dAX2{+-u!vl0_{iyGLQ2}aSL3<<`ynA+Pv1_I9u?EOw{7bFpq*0wCaao?cd#-j^cN*3V~?h#*9XrqXbb1 z9|E@z)}dl|J;4Q7)cc5u+goyWlwOk~;4rWLUgheDJ@-HZgNIpGoY&(g#{+E`V+Mnt z>9q^9V{J5@t*?;b2RVM)7kZjiMbsSqo9xS%Fw{PNWc~9B1O)n+HQA-4g-S7+;$fKj zdRJaR;t%1O=~bh8yo;dt6h8@XA9W=W_0M9gjYL61Sy1qo2dn~-Nxg(2$Nj$(!0_jp zfqaOU{A9W*owtk|T~JkV(AY=DTl_-?1!+!#m|Sz$pYhv+BtP~eDepR$rTdo4iNS}o za+6_q_>#F4wz%vIj$gQe4jT>WJShVCLcn9r1I$fB5pO@=Q#0}00yu=gYU|IkhiwZAR~uz;rueLbFE T2x0&H7ehluSGi8nHs=2T@%$S4 literal 0 HcmV?d00001 diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path.cs new file mode 100644 index 0000000000..1b40a8e166 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path.cs @@ -0,0 +1,176 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The Path class is a representation of a line in a 1D plane and the +/// speed in which the animator plays it +/// +internal class Path +{ + /// + /// Initializes a new instance of the class. + /// + public Path() : this(0, 0, 0, 0, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting value + /// + /// + /// The ending value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// Duration is less than zero + /// + public Path(float start, float end, ulong duration) : this(start, end, duration, 0, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting value + /// + /// + /// The ending value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path(float start, float end, ulong duration, AnimationFunctions.Function function) + : this(start, end, duration, 0, function) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting value + /// + /// + /// The ending value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// Duration is less than zero + /// + public Path(float start, float end, ulong duration, ulong delay) : this(start, end, duration, delay, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting value + /// + /// + /// The ending value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path(float start, float end, ulong duration, ulong delay, AnimationFunctions.Function? function) + { + Start = start; + End = end; + Function = function ?? AnimationFunctions.Linear; + Duration = duration; + Delay = delay; + } + + /// + /// Gets the difference of starting and ending values + /// + public float Change => End - Start; + + /// + /// Gets or sets the starting delay + /// + public ulong Delay { get; set; } + + /// + /// Gets or sets the duration in milliseconds + /// + public ulong Duration { get; set; } + + /// + /// Gets or sets the ending value + /// + public float End { get; set; } + + /// + /// Gets or sets the animation function + /// + public AnimationFunctions.Function Function { get; set; } + + /// + /// Gets or sets the starting value + /// + public float Start { get; set; } + + /// + /// Creates and returns a new based on the current path but in reverse order + /// + /// + /// A new which is the reverse of the current + /// + public Path Reverse() + { + return new Path(End, Start, Duration, Delay, Function); + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2D.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2D.cs new file mode 100644 index 0000000000..8222712b61 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2D.cs @@ -0,0 +1,321 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The Path2D class is a representation of a line in a 2D plane and the +/// speed in which the animator plays it +/// +internal class Path2D +{ + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path2D( + float startX, + float endX, + float startY, + float endY, + ulong duration, + ulong delay, + AnimationFunctions.Function function) + : this(new Path(startX, endX, duration, delay, function), new Path(startY, endY, duration, delay, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// Duration is less than zero + /// + public Path2D( + float startX, + float endX, + float startY, + float endY, + ulong duration, + ulong delay) + : this(new Path(startX, endX, duration, delay), new Path(startY, endY, duration, delay)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path2D( + float startX, + float endX, + float startY, + float endY, + ulong duration, + AnimationFunctions.Function function) + : this(new Path(startX, endX, duration, function), new Path(startY, endY, duration, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// Duration is less than zero + /// + public Path2D( + float startX, + float endX, + float startY, + float endY, + ulong duration) + : this(new Path(startX, endX, duration), new Path(startY, endY, duration)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point or location + /// + /// + /// The ending point or location + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path2D(Float2D start, Float2D end, ulong duration, ulong delay, AnimationFunctions.Function function) + : this( + new Path(start.X, end.X, duration, delay, function), + new Path(start.Y, end.Y, duration, delay, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point or location + /// + /// + /// The ending point or location + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// Duration is less than zero + /// + public Path2D(Float2D start, Float2D end, ulong duration, ulong delay) + : this( + new Path(start.X, end.X, duration, delay), + new Path(start.Y, end.Y, duration, delay)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point or location + /// + /// + /// The ending point or location + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path2D(Float2D start, Float2D end, ulong duration, AnimationFunctions.Function function) + : this( + new Path(start.X, end.X, duration, function), + new Path(start.Y, end.Y, duration, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point or location + /// + /// + /// The ending point or location + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// Duration is less than zero + /// + public Path2D(Float2D start, Float2D end, ulong duration) + : this( + new Path(start.X, end.X, duration), + new Path(start.Y, end.Y, duration)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The horizontal path. + /// + /// + /// The vertical path. + /// + public Path2D(Path x, Path y) + { + HorizontalPath = x; + VerticalPath = y; + } + + /// + /// Gets the horizontal path + /// + public Path HorizontalPath { get; } + + /// + /// Gets the vertical path + /// + public Path VerticalPath { get; } + + /// + /// Gets the starting point of the path + /// + public Float2D Start => new(HorizontalPath.Start, VerticalPath.Start); + + + /// + /// Gets the ending point of the path + /// + public Float2D End => new(HorizontalPath.End, VerticalPath.End); + + /// + /// Creates and returns a new based on the current path but in reverse order + /// + /// + /// A new which is the reverse of the current + /// + public Path2D Reverse() + { + return new Path2D(HorizontalPath.Reverse(), VerticalPath.Reverse()); + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2DExtensions.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2DExtensions.cs new file mode 100644 index 0000000000..1d62085ad3 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path2DExtensions.cs @@ -0,0 +1,294 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// Contains public extensions methods about Path2D class +/// +internal static class Path2DExtensions +{ + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, Float2D end, ulong duration) + { + return paths.Concat([new Path2D(paths.Last().End, end, duration)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, Float2D end, ulong duration, + AnimationFunctions.Function function) + { + return paths.Concat([new Path2D(paths.Last().End, end, duration, function)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, Float2D end, ulong duration, ulong delay) + { + return paths.Concat([new Path2D(paths.Last().End, end, duration, delay)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, Float2D end, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return paths.Concat([new Path2D(paths.Last().End, end, duration, delay, function)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, float endX, float endY, ulong duration) + { + return paths.Concat([new Path2D(paths.Last().End, new Float2D(endX, endY), duration)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, float endX, float endY, ulong duration, + AnimationFunctions.Function function) + { + return + paths.Concat([new Path2D(paths.Last().End, new Float2D(endX, endY), duration, function)]) + .ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, float endX, float endY, ulong duration, ulong delay) + { + return + paths.Concat([new Path2D(paths.Last().End, new Float2D(endX, endY), duration, delay)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D[] paths, float endX, float endY, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return + paths.Concat([new Path2D(paths.Last().End, new Float2D(endX, endY), duration, delay, function)]) + .ToArray(); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, Float2D end, ulong duration) + { + return path.ToArray().ContinueTo(end, duration); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, Float2D end, ulong duration, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(end, duration, function); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, Float2D end, ulong duration, ulong delay) + { + return path.ToArray().ContinueTo(end, duration, delay); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, Float2D end, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(end, duration, delay, function); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, float endX, float endY, ulong duration) + { + return path.ToArray().ContinueTo(endX, endY, duration); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, float endX, float endY, ulong duration, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(endX, endY, duration, function); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, float endX, float endY, ulong duration, ulong delay) + { + return path.ToArray().ContinueTo(endX, endY, duration, delay); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path2D[] ContinueTo(this Path2D path, float endX, float endY, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(endX, endY, duration, delay, function); + } + + /// + /// Continue the path array with a new ones + /// + /// Array of paths + /// An array of new paths to adds + /// An array of paths including the new ones + public static Path2D[] ContinueTo(this Path2D[] paths, params Path2D[] newPaths) + { + return paths.Concat(newPaths).ToArray(); + } + + /// + /// Continue the path with a new ones + /// + /// The path to continue + /// An array of new paths to adds + /// An array of paths including the new ones + public static Path2D[] ContinueTo(this Path2D path, params Path2D[] newPaths) + { + return path.ToArray().ContinueTo(newPaths); + } + + /// + /// Contains a single path in an array + /// + /// The path to add to the array + /// An array of paths including the new ones + public static Path2D[] ToArray(this Path2D path) + { + return [path]; + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3D.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3D.cs new file mode 100644 index 0000000000..8799e19ce4 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3D.cs @@ -0,0 +1,376 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The Path3D class is a representation of a line in a 3D plane and the +/// speed in which the animator plays it +/// +internal class Path3D +{ + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The starting depth value + /// + /// + /// The ending depth value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path3D( + float startX, + float endX, + float startY, + float endY, + float startZ, + float endZ, + ulong duration, + ulong delay, + AnimationFunctions.Function function) + : this( + new Path(startX, endX, duration, delay, function), + new Path(startY, endY, duration, delay, function), + new Path(startZ, endZ, duration, delay, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The starting depth value + /// + /// + /// The ending depth value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// Duration is less than zero + /// + public Path3D( + float startX, + float endX, + float startY, + float endY, + float startZ, + float endZ, + ulong duration, + ulong delay) + : this( + new Path(startX, endX, duration, delay), + new Path(startY, endY, duration, delay), + new Path(startZ, endZ, duration, delay)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The starting depth value + /// + /// + /// The ending depth value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path3D( + float startX, + float endX, + float startY, + float endY, + float startZ, + float endZ, + ulong duration, + AnimationFunctions.Function function) + : this( + new Path(startX, endX, duration, function), + new Path(startY, endY, duration, function), + new Path(startZ, endZ, duration, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting horizontal value + /// + /// + /// The ending horizontal value + /// + /// + /// The starting vertical value + /// + /// + /// The ending vertical value + /// + /// + /// The starting depth value + /// + /// + /// The ending depth value + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// Duration is less than zero + /// + public Path3D( + float startX, + float endX, + float startY, + float endY, + float startZ, + float endZ, + ulong duration) + : this(new Path(startX, endX, duration), new Path(startY, endY, duration), new Path(startZ, endZ, duration)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point in a 3D plane + /// + /// + /// The ending point in a 3D plane + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path3D(Float3D start, Float3D end, ulong duration, ulong delay, AnimationFunctions.Function function) + : this( + new Path(start.X, end.X, duration, delay, function), + new Path(start.Y, end.Y, duration, delay, function), + new Path(start.Z, end.Z, duration, delay, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point in a 3D plane + /// + /// + /// The ending point in a 3D plane + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The time in milliseconds that the animator must wait before playing this path + /// + /// + /// Duration is less than zero + /// + public Path3D(Float3D start, Float3D end, ulong duration, ulong delay) + : this( + new Path(start.X, end.X, duration, delay), + new Path(start.Y, end.Y, duration, delay), + new Path(start.Z, end.Z, duration, delay)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point in a 3D plane + /// + /// + /// The ending point in a 3D plane + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// The animation function + /// + /// + /// Duration is less than zero + /// + public Path3D(Float3D start, Float3D end, ulong duration, AnimationFunctions.Function function) + : this( + new Path(start.X, end.X, duration, function), + new Path(start.Y, end.Y, duration, function), + new Path(start.Z, end.Z, duration, function)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The starting point in a 3D plane + /// + /// + /// The ending point in a 3D plane + /// + /// + /// The time in milliseconds that the animator must play this path + /// + /// + /// Duration is less than zero + /// + public Path3D(Float3D start, Float3D end, ulong duration) + : this( + new Path(start.X, end.X, duration), + new Path(start.Y, end.Y, duration), + new Path(start.Z, end.Z, duration)) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The horizontal path. + /// + /// + /// The vertical path. + /// + /// + /// The depth path. + /// + public Path3D(Path x, Path y, Path z) + { + HorizontalPath = x; + VerticalPath = y; + DepthPath = z; + } + + /// + /// Gets the horizontal path + /// + public Path HorizontalPath { get; } + + /// + /// Gets the vertical path + /// + public Path VerticalPath { get; } + + /// + /// Gets the depth path + /// + public Path DepthPath { get; } + + + /// + /// Gets the starting point of the path + /// + public Float3D Start => new(HorizontalPath.Start, VerticalPath.Start, DepthPath.Start); + + + /// + /// Gets the ending point of the path + /// + public Float3D End => new(HorizontalPath.End, VerticalPath.End, DepthPath.End); + + /// + /// Creates and returns a new based on the current path but in reverse order + /// + /// + /// A new which is the reverse of the current + /// + public Path3D Reverse() + { + return new Path3D(HorizontalPath.Reverse(), VerticalPath.Reverse(), DepthPath.Reverse()); + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3DExtensions.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3DExtensions.cs new file mode 100644 index 0000000000..c98ea7c7ed --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Path3DExtensions.cs @@ -0,0 +1,305 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// Contains public extensions methods about Path3D class +/// +internal static class Path3DExtensions +{ + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, Float3D end, ulong duration) => paths.Concat([new Path3D(paths.Last().End, end, duration)]).ToArray(); + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, Float3D end, ulong duration, + AnimationFunctions.Function function) => + paths.Concat([new Path3D(paths.Last().End, end, duration, function)]).ToArray(); + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, Float3D end, ulong duration, ulong delay) + { + return paths.Concat([new Path3D(paths.Last().End, end, duration, delay)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, Float3D end, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return paths.Concat([new Path3D(paths.Last().End, end, duration, delay, function)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, float endX, float endY, float endZ, ulong duration) + { + return paths.Concat([new Path3D(paths.Last().End, new Float3D(endX, endY, endZ), duration)]) + .ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, float endX, float endY, float endZ, ulong duration, + AnimationFunctions.Function function) + { + return + paths.Concat([new Path3D(paths.Last().End, new Float3D(endX, endY, endZ), duration, function)]) + .ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, float endX, float endY, float endZ, ulong duration, + ulong delay) + { + return + paths.Concat([new Path3D(paths.Last().End, new Float3D(endX, endY, endZ), duration, delay)]) + .ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D[] paths, float endX, float endY, float endZ, ulong duration, + ulong delay, + AnimationFunctions.Function function) + { + return + paths.Concat([new Path3D(paths.Last().End, new Float3D(endX, endY, endZ), duration, delay, function)]) + .ToArray(); + } + + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, Float3D end, ulong duration) + { + return path.ToArray().ContinueTo(end, duration); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, Float3D end, ulong duration, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(end, duration, function); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, Float3D end, ulong duration, ulong delay) + { + return path.ToArray().ContinueTo(end, duration, delay); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, Float3D end, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(end, duration, delay, function); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, float endX, float endY, float endZ, ulong duration) + { + return path.ToArray().ContinueTo(endX, endY, endZ, duration); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, float endX, float endY, float endZ, ulong duration, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(endX, endY, endZ, duration, function); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, float endX, float endY, float endZ, ulong duration, + ulong delay) + { + return path.ToArray().ContinueTo(endX, endY, endZ, duration, delay); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Horizontal value of the next point to follow + /// Vertical value of the next point to follow + /// Depth value of the next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path3D[] ContinueTo(this Path3D path, float endX, float endY, float endZ, ulong duration, + ulong delay, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(endX, endY, endZ, duration, delay, function); + } + + + /// + /// Continue the path array with a new ones + /// + /// Array of paths + /// An array of new paths to adds + /// An array of paths including the new ones + public static Path3D[] ContinueTo(this Path3D[] paths, params Path3D[] newPaths) + { + return paths.Concat(newPaths).ToArray(); + } + + /// + /// Continue the path with a new ones + /// + /// The path to continue + /// An array of new paths to adds + /// An array of paths including the new ones + public static Path3D[] ContinueTo(this Path3D path, params Path3D[] newPaths) + { + return path.ToArray().ContinueTo(newPaths); + } + + /// + /// Contains a single path in an array + /// + /// The path to add to the array + /// An array of paths including the new ones + public static Path3D[] ToArray(this Path3D path) + { + return [path]; + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/PathExtensions.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/PathExtensions.cs new file mode 100644 index 0000000000..cf0a604fe0 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/PathExtensions.cs @@ -0,0 +1,174 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// Contains public extensions methods about Path class +/// +internal static class PathExtensions +{ + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path[] paths, float end, ulong duration) + { + return paths.Concat([new Path(paths.Last().End, end, duration)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path[] paths, float end, ulong duration, + AnimationFunctions.Function function) + { + return paths.Concat([new Path(paths.Last().End, end, duration, function)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path[] paths, float end, ulong duration, ulong delay) + { + return paths.Concat([new Path(paths.Last().End, end, duration, delay)]).ToArray(); + } + + /// + /// Continue the last paths with a new one + /// + /// Array of paths + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path[] paths, float end, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return paths.Concat([new Path(paths.Last().End, end, duration, delay, function)]).ToArray(); + } + + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path path, float end, ulong duration) + { + return path.ToArray().ContinueTo(end, duration); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Animation controller function + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path path, float end, ulong duration, AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(end, duration, function); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path path, float end, ulong duration, ulong delay) + { + return path.ToArray().ContinueTo(end, duration, delay); + } + + /// + /// Continue the path with a new one + /// + /// The path to continue + /// Next point to follow + /// Duration of the animation + /// Starting delay + /// Animation controller function + /// An array of paths including the newly created one + public static Path[] ContinueTo(this Path path, float end, ulong duration, ulong delay, + AnimationFunctions.Function function) + { + return path.ToArray().ContinueTo(end, duration, delay, function); + } + + + /// + /// Continue the path array with a new ones + /// + /// Array of paths + /// An array of new paths to adds + /// An array of paths including the new ones + public static Path[] ContinueTo(this Path[] paths, params Path[] newPaths) + { + return paths.Concat(newPaths).ToArray(); + } + + /// + /// Continue the path with a new ones + /// + /// The path to continue + /// An array of new paths to adds + /// An array of paths including the new ones + public static Path[] ContinueTo(this Path path, params Path[] newPaths) + { + return path.ToArray().ContinueTo(newPaths); + } + + /// + /// Contains a single path in an array + /// + /// The path to add to the array + /// An array of paths including the new ones + public static Path[] ToArray(this Path path) + { + return [path]; + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker.cs new file mode 100644 index 0000000000..2b8338bee7 --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker.cs @@ -0,0 +1,166 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The safe invoker class is a delegate reference holder that always +/// execute them in the correct thread based on the passed control. +/// +internal class SafeInvoker +{ + private MethodInfo? _invokeMethod; + + private PropertyInfo? _invokeRequiredProperty; + private object? _targetControl; + + /// + /// Initializes a new instance of the SafeInvoker class. + /// + /// + /// The callback to be invoked + /// + /// + /// The control to be used to invoke the callback in UI thread + /// + public SafeInvoker(Action action, object? targetControl) : this((Delegate) action, targetControl) + { + } + + /// + /// Initializes a new instance of the SafeInvoker class. + /// + /// + /// The callback to be invoked + /// + /// + /// The control to be used to invoke the callback in UI thread + /// + protected SafeInvoker(Delegate action, object? targetControl) + { + UnderlyingDelegate = action; + if (targetControl != null) + { + TargetControl = targetControl; + } + } + + /// + /// Initializes a new instance of the SafeInvoker class. + /// + /// + /// The callback to be invoked + /// + public SafeInvoker(Action action) : this(action, null) + { + } + + /// + /// Gets or sets the reference to the control that's going to be used to invoke the callback in UI thread + /// + protected object? TargetControl + { + get => _targetControl; + set + { + if (value == null) + { + return; + } + + _invokeRequiredProperty = value.GetType() + .GetProperty("InvokeRequired", BindingFlags.Instance | BindingFlags.Public); + _invokeMethod = value.GetType() + .GetMethod( + "Invoke", + BindingFlags.Instance | BindingFlags.Public, + Type.DefaultBinder, + [typeof(Delegate)], + null); + if (_invokeRequiredProperty != null && _invokeMethod != null) + { + _targetControl = value; + } + } + } + + + /// + /// Gets the reference to the callback to be invoked + /// + protected Delegate UnderlyingDelegate { get; } + + /// + /// Invoke the contained callback + /// + public virtual void Invoke() + { + Invoke(null); + } + + /// + /// Invoke the referenced callback + /// + /// The argument to send to the callback + protected void Invoke(object? value) + { + try + { + ThreadPool.QueueUserWorkItem( + state => + { + try + { + if (TargetControl != null + && _invokeRequiredProperty != null + && _invokeMethod != null + && (bool)_invokeRequiredProperty.GetValue(TargetControl)!) + { + _invokeMethod.Invoke( + TargetControl, + [ + new Action( + () => UnderlyingDelegate.DynamicInvoke(value != null + ? [value] + : null)) + ]); + return; + } + } + catch + { + // ignored + } + + UnderlyingDelegate.DynamicInvoke(value != null ? [value] : null); + }); + } + catch + { + // ignored + } + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker`1.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker`1.cs new file mode 100644 index 0000000000..a4497dc54d --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/SafeInvoker`1.cs @@ -0,0 +1,66 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The safe invoker class is a delegate reference holder that always +/// execute them in the correct thread based on the passed control. +/// +internal class SafeInvoker : SafeInvoker +{ + /// + /// Initializes a new instance of the SafeInvoker class. + /// + /// + /// The callback to be invoked + /// + /// + /// The control to be used to invoke the callback in UI thread + /// + public SafeInvoker(Action action, object? targetControl) : base(action, targetControl) + { + } + + /// + /// Initializes a new instance of the SafeInvoker class. + /// + /// + /// The callback to be invoked + /// + public SafeInvoker(Action action) : this(action, null) + { + } + + /// + /// Invoke the contained callback with the specified value as the parameter + /// + /// + public void Invoke(T value) + { + Invoke((object?)value); + } +} \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Timer.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Timer.cs new file mode 100644 index 0000000000..98cda122ca --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Utilities/WinFormAnimatiion/General/Timer.cs @@ -0,0 +1,187 @@ +#region Original MIT License + +/* The MIT License (MIT) + * + * Copyright (c) 2016 - 2020 Soroush Falahati + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#endregion + +#region Modified License + +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ + +#endregion + +namespace WinFormAnimation; + +/// +/// The timer class, will execute your code in specific time frames +/// +internal class Timer +{ + private static Thread? _timerThread; + + private static readonly object LockHandle = new(); + + private static readonly long StartTimeAsMs = DateTime.Now.Ticks; + + private static readonly List Subscribers = []; + + private readonly Action _callback; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The callback to be executed at each tick + /// + /// + /// The max ticks per second + /// + public Timer(Action callback, FPSLimiterKnownValues fpsKnownLimit = FPSLimiterKnownValues.LimitThirty) + : this(callback, (int) fpsKnownLimit) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The callback to be executed at each tick + /// + /// + /// The max ticks per second + /// + public Timer(Action callback, int fpsLimit) + { + _callback = callback ?? throw new ArgumentNullException(nameof(callback)); + FrameLimiter = fpsLimit; + lock (LockHandle) + { + if (_timerThread == null) + { + (_timerThread = new Thread(ThreadCycle) {IsBackground = true}).Start(); + } + } + } + + /// + /// Gets the time of the last frame/tick related to the global-timer start reference + /// + public long LastTick { get; private set; } + + /// + /// Gets or sets the maximum frames/ticks per second + /// + public int FrameLimiter { get; set; } + + /// + /// Gets the time of the first frame/tick related to the global-timer start reference + /// + public long FirstTick { get; private set; } + + + private void Tick() + { + if (1000 / FrameLimiter < GetTimeDifferenceAsMs() - LastTick) + { + LastTick = GetTimeDifferenceAsMs(); + _callback((ulong) (LastTick - FirstTick)); + } + } + + private static long GetTimeDifferenceAsMs() + { + return (DateTime.Now.Ticks - StartTimeAsMs) / 10000; + } + + private static void ThreadCycle() + { + while (true) + try + { + bool hibernate; + lock (Subscribers) + { + hibernate = Subscribers.Count == 0; + if (!hibernate) + { + foreach (var t in Subscribers.ToList()) + t.Tick(); + } + } + + Thread.Sleep(hibernate ? 50 : 1); + } + catch + { + // ignored + } + + // ReSharper disable once FunctionNeverReturns + } + + /// + /// The method to reset the time of the starting frame/tick + /// + public void ResetClock() + { + FirstTick = GetTimeDifferenceAsMs(); + } + + /// + /// The method to resume the timer after stopping it + /// + public void Resume() + { + lock (Subscribers) + { + if (!Subscribers.Contains(this)) + { + FirstTick += GetTimeDifferenceAsMs() - LastTick; + Subscribers.Add(this); + } + } + } + + /// + /// The method to start the timer from the beginning + /// + public void Start() + { + lock (Subscribers) + { + if (!Subscribers.Contains(this)) + { + FirstTick = GetTimeDifferenceAsMs(); + Subscribers.Add(this); + } + } + } + + /// + /// The method to stop the timer from generating any new ticks/frames + /// + public void Stop() + { + lock (Subscribers) + { + if (Subscribers.Contains(this)) + { + Subscribers.Remove(this); + } + } + } +} diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonProgressBar.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonProgressBar.cs index f36aa47c62..987757f168 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonProgressBar.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonProgressBar.cs @@ -1892,6 +1892,35 @@ internal void UpdateThresholdColor() #endregion + #region Protected + + /// + /// Gets the palette redirector used by the progress bar. + /// + protected PaletteRedirect ProgressPaletteRedirect => _paletteRedirect; + + /// + /// Gets the resolved palette instance. + /// + protected PaletteBase? ResolvedPalette => _palette; + + /// + /// Gets the palette used for the progress value fill. + /// + protected IPaletteBack ValueBackPalette => _stateBackValue; + + /// + /// Gets the progress bar palette triple and state for the current enabled state. + /// + protected (IPaletteTriple BarPaletteState, PaletteState BarState) GetProgressBarPaletteState() => GetBarPaletteState(); + + /// + /// Updates threshold-based colours when tri-state values are enabled. + /// + protected void SyncThresholdColors() => UpdateThresholdColor(); + + #endregion + #region Designer removal /// diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/AboutToolkit/AboutToolkitImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/AboutToolkit/AboutToolkitImageResources.Designer.cs index 325d306d6a..315857a87e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/AboutToolkit/AboutToolkitImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/AboutToolkit/AboutToolkitImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.AboutToolkit { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class AboutToolkitImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Buttons/ButtonImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Buttons/ButtonImageResources.Designer.cs index fe1befc6df..17eb8fa248 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Buttons/ButtonImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Buttons/ButtonImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.Buttons { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ButtonImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/CommandLink/CommandLinkImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/CommandLink/CommandLinkImageResources.Designer.cs index 6ab65a537b..6fb2f0b196 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/CommandLink/CommandLinkImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/CommandLink/CommandLinkImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.CommandLink { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class CommandLinkImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/OutlookGridImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/OutlookGridImageResources.Designer.cs index 1b0833e7df..74183f48ae 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/OutlookGridImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/OutlookGridImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.OutlookGrid { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class OutlookGridImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/Strings/OutlookGridStringResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/Strings/OutlookGridStringResources.Designer.cs index 4ee11e29b3..c82c538954 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/Strings/OutlookGridStringResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/OutlookGrid/Strings/OutlookGridStringResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.OutlookGrid.Strings { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class OutlookGridStringResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/PaletteSchemas/PaletteSchemaResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/PaletteSchemas/PaletteSchemaResources.Designer.cs index 965bb6d890..97d74d9a33 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/PaletteSchemas/PaletteSchemaResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/PaletteSchemas/PaletteSchemaResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.PaletteSchemas { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class PaletteSchemaResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Sort/SortingImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Sort/SortingImageResources.Designer.cs index 22ff6ba899..ce7a110039 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Sort/SortingImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/Sort/SortingImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.Sort { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class SortingImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/ToolkitLogos/ToolkitLogoResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/ToolkitLogos/ToolkitLogoResources.Designer.cs index de7b2b1aad..1b640f042b 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/ToolkitLogos/ToolkitLogoResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/ToolkitLogos/ToolkitLogoResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.ToolkitLogos { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ToolkitLogoResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows10UACShieldImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows10UACShieldImageResources.Designer.cs index f19c575463..1f9a5d994e 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows10UACShieldImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows10UACShieldImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.UAC { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Windows10UACShieldImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows11UACShieldImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows11UACShieldImageResources.Designer.cs index 6e0a4310fa..10bb1e238a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows11UACShieldImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows11UACShieldImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.UAC { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Windows11UACShieldImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows7And8xUACShieldImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows7And8xUACShieldImageResources.Designer.cs index e0eea71332..1eac8d9dc2 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows7And8xUACShieldImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/Windows7And8xUACShieldImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.UAC { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Windows7And8xUACShieldImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/WindowsVistaUACShieldImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/WindowsVistaUACShieldImageResources.Designer.cs index 768335b9b6..9be05bda00 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/WindowsVistaUACShieldImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/UAC/WindowsVistaUACShieldImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.UAC { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class WindowsVistaUACShieldImageResources { diff --git a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/WindowsLogos/WindowsLogoImageResources.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/WindowsLogos/WindowsLogoImageResources.Designer.cs index 074bf59be6..7776ad0bb9 100644 --- a/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/WindowsLogos/WindowsLogoImageResources.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/ResourceFiles/WindowsLogos/WindowsLogoImageResources.Designer.cs @@ -19,7 +19,7 @@ namespace Krypton.Toolkit.ResourceFiles.WindowsLogos { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class WindowsLogoImageResources { diff --git a/Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs b/Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs new file mode 100644 index 0000000000..84007ace19 --- /dev/null +++ b/Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs @@ -0,0 +1,806 @@ +namespace TestForm +{ + partial class CircularProgressBarTest + { + private System.ComponentModel.IContainer components = null; + + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + private void InitializeComponent() + { + this.kryptonPanel1 = new Krypton.Toolkit.KryptonPanel(); + this.kcpbMain = new Krypton.Toolkit.Utilities.KryptonCircularProgressBar(); + this.klblPreviewCaption = new Krypton.Toolkit.KryptonLabel(); + this.kcpbMarquee = new Krypton.Toolkit.Utilities.KryptonCircularProgressBar(); + this.klblMarqueeCaption = new Krypton.Toolkit.KryptonLabel(); + this.kcpbDisabled = new Krypton.Toolkit.Utilities.KryptonCircularProgressBar(); + this.klblDisabledCaption = new Krypton.Toolkit.KryptonLabel(); + this.kryptonPanelControls = new Krypton.Toolkit.KryptonPanel(); + this.kryptonGroupBoxSimulation = new Krypton.Toolkit.KryptonGroupBox(); + this.kbtnStopSimulation = new Krypton.Toolkit.KryptonButton(); + this.kbtnStartSimulation = new Krypton.Toolkit.KryptonButton(); + this.kbtnReset = new Krypton.Toolkit.KryptonButton(); + this.kryptonGroupBoxPalette = new Krypton.Toolkit.KryptonGroupBox(); + this.kbtnSelectDisabledInGrid = new Krypton.Toolkit.KryptonButton(); + this.kbtnSelectMarqueeInGrid = new Krypton.Toolkit.KryptonButton(); + this.kbtnSelectMainInGrid = new Krypton.Toolkit.KryptonButton(); + this.kchkEnabled = new Krypton.Toolkit.KryptonCheckBox(); + this.kcbtnMainTextColor = new Krypton.Toolkit.KryptonColorButton(); + this.kcbtnInnerRingColor = new Krypton.Toolkit.KryptonColorButton(); + this.kcbtnOuterRingColor = new Krypton.Toolkit.KryptonColorButton(); + this.kcbtnProgressColor = new Krypton.Toolkit.KryptonColorButton(); + this.kcmbValueBackColorStyle = new Krypton.Toolkit.KryptonComboBox(); + this.klblValueBackColorStyle = new Krypton.Toolkit.KryptonLabel(); + this.kryptonThemeComboBox1 = new Krypton.Toolkit.KryptonThemeComboBox(); + this.klblTheme = new Krypton.Toolkit.KryptonLabel(); + this.kryptonGroupBoxTriState = new Krypton.Toolkit.KryptonGroupBox(); + this.kbtnTriStatePreset = new Krypton.Toolkit.KryptonButton(); + this.kchkAutoThreshold = new Krypton.Toolkit.KryptonCheckBox(); + this.kchkTriState = new Krypton.Toolkit.KryptonCheckBox(); + this.kryptonGroupBoxText = new Krypton.Toolkit.KryptonGroupBox(); + this.kchkUseValueAsText = new Krypton.Toolkit.KryptonCheckBox(); + this.txtSubscript = new Krypton.Toolkit.KryptonTextBox(); + this.klblSubscript = new Krypton.Toolkit.KryptonLabel(); + this.txtSuperscript = new Krypton.Toolkit.KryptonTextBox(); + this.klblSuperscript = new Krypton.Toolkit.KryptonLabel(); + this.kryptonGroupBoxAnimation = new Krypton.Toolkit.KryptonGroupBox(); + this.knudMarqueeSpeed = new Krypton.Toolkit.KryptonNumericUpDown(); + this.klblMarqueeSpeed = new Krypton.Toolkit.KryptonLabel(); + this.kcmbAnimationFunction = new Krypton.Toolkit.KryptonComboBox(); + this.klblAnimationFunction = new Krypton.Toolkit.KryptonLabel(); + this.knudAnimationSpeed = new Krypton.Toolkit.KryptonNumericUpDown(); + this.klblAnimationSpeed = new Krypton.Toolkit.KryptonLabel(); + this.kcmbStyle = new Krypton.Toolkit.KryptonComboBox(); + this.klblStyle = new Krypton.Toolkit.KryptonLabel(); + this.kryptonGroupBoxValue = new Krypton.Toolkit.KryptonGroupBox(); + this.kbtnDecrement = new Krypton.Toolkit.KryptonButton(); + this.kbtnIncrement = new Krypton.Toolkit.KryptonButton(); + this.knudMaximum = new Krypton.Toolkit.KryptonNumericUpDown(); + this.klblMaximum = new Krypton.Toolkit.KryptonLabel(); + this.knudMinimum = new Krypton.Toolkit.KryptonNumericUpDown(); + this.klblMinimum = new Krypton.Toolkit.KryptonLabel(); + this.ktrkValue = new Krypton.Toolkit.KryptonTrackBar(); + this.klblValue = new Krypton.Toolkit.KryptonLabel(); + this.kryptonPropertyGrid1 = new Krypton.Toolkit.KryptonPropertyGrid(); + this.klblStatus = new Krypton.Toolkit.KryptonLabel(); + this.klblHeading = new Krypton.Toolkit.KryptonLabel(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).BeginInit(); + this.kryptonPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanelControls)).BeginInit(); + this.kryptonPanelControls.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxSimulation)).BeginInit(); + this.kryptonGroupBoxSimulation.Panel.SuspendLayout(); + this.kryptonGroupBoxSimulation.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxPalette)).BeginInit(); + this.kryptonGroupBoxPalette.Panel.SuspendLayout(); + this.kryptonGroupBoxPalette.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbValueBackColorStyle)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonThemeComboBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxTriState)).BeginInit(); + this.kryptonGroupBoxTriState.Panel.SuspendLayout(); + this.kryptonGroupBoxTriState.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxText)).BeginInit(); + this.kryptonGroupBoxText.Panel.SuspendLayout(); + this.kryptonGroupBoxText.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxAnimation)).BeginInit(); + this.kryptonGroupBoxAnimation.Panel.SuspendLayout(); + this.kryptonGroupBoxAnimation.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbAnimationFunction)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbStyle)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxValue)).BeginInit(); + this.kryptonGroupBoxValue.Panel.SuspendLayout(); + this.kryptonGroupBoxValue.SuspendLayout(); + this.SuspendLayout(); + // + // kryptonPanel1 + // + this.kryptonPanel1.Controls.Add(this.klblHeading); + this.kryptonPanel1.Controls.Add(this.klblStatus); + this.kryptonPanel1.Controls.Add(this.kryptonPropertyGrid1); + this.kryptonPanel1.Controls.Add(this.kryptonPanelControls); + this.kryptonPanel1.Controls.Add(this.klblDisabledCaption); + this.kryptonPanel1.Controls.Add(this.kcpbDisabled); + this.kryptonPanel1.Controls.Add(this.klblMarqueeCaption); + this.kryptonPanel1.Controls.Add(this.kcpbMarquee); + this.kryptonPanel1.Controls.Add(this.klblPreviewCaption); + this.kryptonPanel1.Controls.Add(this.kcpbMain); + this.kryptonPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.kryptonPanel1.Location = new System.Drawing.Point(0, 0); + this.kryptonPanel1.Name = "kryptonPanel1"; + this.kryptonPanel1.Size = new System.Drawing.Size(1184, 711); + this.kryptonPanel1.TabIndex = 0; + // + // kcpbMain + // + this.kcpbMain.AnimationSpeed = 500; + this.kcpbMain.Location = new System.Drawing.Point(24, 88); + this.kcpbMain.Name = "kcpbMain"; + this.kcpbMain.Size = new System.Drawing.Size(320, 320); + this.kcpbMain.StateCommon.Back.Color1 = System.Drawing.Color.MediumSeaGreen; + this.kcpbMain.StateDisabled.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.OneNote; + this.kcpbMain.StateNormal.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.GlassNormalFull; + this.kcpbMain.SubscriptText = "CPU"; + this.kcpbMain.SuperscriptText = "%"; + this.kcpbMain.TabIndex = 0; + this.kcpbMain.Text = "65"; + this.kcpbMain.Value = 65; + this.kcpbMain.ValueBackColorStyle = Krypton.Toolkit.PaletteColorStyle.GlassNormalFull; + // + // klblPreviewCaption + // + this.klblPreviewCaption.Location = new System.Drawing.Point(24, 64); + this.klblPreviewCaption.Name = "klblPreviewCaption"; + this.klblPreviewCaption.Size = new System.Drawing.Size(248, 20); + this.klblPreviewCaption.TabIndex = 1; + this.klblPreviewCaption.Values.Text = "Main control — palette-driven progress arc"; + // + // kcpbMarquee + // + this.kcpbMarquee.AnimationSpeed = 500; + this.kcpbMarquee.Location = new System.Drawing.Point(24, 456); + this.kcpbMarquee.MarqueeAnimationSpeed = 2000; + this.kcpbMarquee.Name = "kcpbMarquee"; + this.kcpbMarquee.Size = new System.Drawing.Size(150, 150); + this.kcpbMarquee.StateCommon.Back.Color1 = System.Drawing.Color.SteelBlue; + this.kcpbMarquee.StateDisabled.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.OneNote; + this.kcpbMarquee.StateNormal.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.GlassNormalFull; + this.kcpbMarquee.Style = System.Windows.Forms.ProgressBarStyle.Marquee; + this.kcpbMarquee.TabIndex = 2; + this.kcpbMarquee.Text = "…"; + this.kcpbMarquee.Value = 50; + // + // klblMarqueeCaption + // + this.klblMarqueeCaption.Location = new System.Drawing.Point(24, 432); + this.klblMarqueeCaption.Name = "klblMarqueeCaption"; + this.klblMarqueeCaption.Size = new System.Drawing.Size(103, 20); + this.klblMarqueeCaption.TabIndex = 3; + this.klblMarqueeCaption.Values.Text = "Marquee sample"; + // + // kcpbDisabled + // + this.kcpbDisabled.AnimationSpeed = 500; + this.kcpbDisabled.Enabled = false; + this.kcpbDisabled.Location = new System.Drawing.Point(194, 456); + this.kcpbDisabled.Name = "kcpbDisabled"; + this.kcpbDisabled.Size = new System.Drawing.Size(150, 150); + this.kcpbDisabled.StateCommon.Back.Color1 = System.Drawing.Color.DimGray; + this.kcpbDisabled.StateDisabled.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.OneNote; + this.kcpbDisabled.StateNormal.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.GlassNormalFull; + this.kcpbDisabled.TabIndex = 4; + this.kcpbDisabled.Text = "40"; + this.kcpbDisabled.Value = 40; + // + // klblDisabledCaption + // + this.klblDisabledCaption.Location = new System.Drawing.Point(194, 432); + this.klblDisabledCaption.Name = "klblDisabledCaption"; + this.klblDisabledCaption.Size = new System.Drawing.Size(103, 20); + this.klblDisabledCaption.TabIndex = 5; + this.klblDisabledCaption.Values.Text = "Disabled sample"; + // + // kryptonPanelControls + // + this.kryptonPanelControls.AutoScroll = true; + this.kryptonPanelControls.Controls.Add(this.kryptonGroupBoxValue); + this.kryptonPanelControls.Controls.Add(this.kryptonGroupBoxAnimation); + this.kryptonPanelControls.Controls.Add(this.kryptonGroupBoxText); + this.kryptonPanelControls.Controls.Add(this.kryptonGroupBoxTriState); + this.kryptonPanelControls.Controls.Add(this.kryptonGroupBoxPalette); + this.kryptonPanelControls.Controls.Add(this.kryptonGroupBoxSimulation); + this.kryptonPanelControls.Location = new System.Drawing.Point(368, 64); + this.kryptonPanelControls.Name = "kryptonPanelControls"; + this.kryptonPanelControls.Size = new System.Drawing.Size(396, 630); + this.kryptonPanelControls.TabIndex = 6; + // + // kryptonGroupBoxSimulation + // + this.kryptonGroupBoxSimulation.Dock = System.Windows.Forms.DockStyle.Top; + this.kryptonGroupBoxSimulation.Location = new System.Drawing.Point(0, 886); + this.kryptonGroupBoxSimulation.Name = "kryptonGroupBoxSimulation"; + // + // kryptonGroupBoxSimulation.Panel + // + this.kryptonGroupBoxSimulation.Panel.Controls.Add(this.kbtnStopSimulation); + this.kryptonGroupBoxSimulation.Panel.Controls.Add(this.kbtnStartSimulation); + this.kryptonGroupBoxSimulation.Panel.Controls.Add(this.kbtnReset); + this.kryptonGroupBoxSimulation.Size = new System.Drawing.Size(379, 88); + this.kryptonGroupBoxSimulation.TabIndex = 5; + this.kryptonGroupBoxSimulation.Values.Heading = "Simulation"; + // + // kbtnStopSimulation + // + this.kbtnStopSimulation.Enabled = false; + this.kbtnStopSimulation.Location = new System.Drawing.Point(178, 12); + this.kbtnStopSimulation.Name = "kbtnStopSimulation"; + this.kbtnStopSimulation.Size = new System.Drawing.Size(75, 25); + this.kbtnStopSimulation.TabIndex = 2; + this.kbtnStopSimulation.Values.Text = "Stop"; + this.kbtnStopSimulation.Click += new System.EventHandler(this.kbtnStopSimulation_Click); + // + // kbtnStartSimulation + // + this.kbtnStartSimulation.Location = new System.Drawing.Point(97, 12); + this.kbtnStartSimulation.Name = "kbtnStartSimulation"; + this.kbtnStartSimulation.Size = new System.Drawing.Size(75, 25); + this.kbtnStartSimulation.TabIndex = 1; + this.kbtnStartSimulation.Values.Text = "Start"; + this.kbtnStartSimulation.Click += new System.EventHandler(this.kbtnStartSimulation_Click); + // + // kbtnReset + // + this.kbtnReset.Location = new System.Drawing.Point(16, 12); + this.kbtnReset.Name = "kbtnReset"; + this.kbtnReset.Size = new System.Drawing.Size(75, 25); + this.kbtnReset.TabIndex = 0; + this.kbtnReset.Values.Text = "Reset"; + this.kbtnReset.Click += new System.EventHandler(this.kbtnReset_Click); + // + // kryptonGroupBoxPalette + // + this.kryptonGroupBoxPalette.Dock = System.Windows.Forms.DockStyle.Top; + this.kryptonGroupBoxPalette.Location = new System.Drawing.Point(0, 598); + this.kryptonGroupBoxPalette.Name = "kryptonGroupBoxPalette"; + // + // kryptonGroupBoxPalette.Panel + // + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kbtnSelectDisabledInGrid); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kbtnSelectMarqueeInGrid); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kbtnSelectMainInGrid); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kchkEnabled); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kcbtnMainTextColor); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kcbtnInnerRingColor); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kcbtnOuterRingColor); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kcbtnProgressColor); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kcmbValueBackColorStyle); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.klblValueBackColorStyle); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.kryptonThemeComboBox1); + this.kryptonGroupBoxPalette.Panel.Controls.Add(this.klblTheme); + this.kryptonGroupBoxPalette.Size = new System.Drawing.Size(379, 288); + this.kryptonGroupBoxPalette.TabIndex = 4; + this.kryptonGroupBoxPalette.Values.Heading = "Palette && appearance"; + // + // kbtnSelectDisabledInGrid + // + this.kbtnSelectDisabledInGrid.Location = new System.Drawing.Point(250, 248); + this.kbtnSelectDisabledInGrid.Name = "kbtnSelectDisabledInGrid"; + this.kbtnSelectDisabledInGrid.Size = new System.Drawing.Size(110, 25); + this.kbtnSelectDisabledInGrid.TabIndex = 11; + this.kbtnSelectDisabledInGrid.Values.Text = "Grid: Disabled"; + this.kbtnSelectDisabledInGrid.Click += new System.EventHandler(this.kbtnSelectDisabledInGrid_Click); + // + // kbtnSelectMarqueeInGrid + // + this.kbtnSelectMarqueeInGrid.Location = new System.Drawing.Point(134, 248); + this.kbtnSelectMarqueeInGrid.Name = "kbtnSelectMarqueeInGrid"; + this.kbtnSelectMarqueeInGrid.Size = new System.Drawing.Size(110, 25); + this.kbtnSelectMarqueeInGrid.TabIndex = 10; + this.kbtnSelectMarqueeInGrid.Values.Text = "Grid: Marquee"; + this.kbtnSelectMarqueeInGrid.Click += new System.EventHandler(this.kbtnSelectMarqueeInGrid_Click); + // + // kbtnSelectMainInGrid + // + this.kbtnSelectMainInGrid.Location = new System.Drawing.Point(18, 248); + this.kbtnSelectMainInGrid.Name = "kbtnSelectMainInGrid"; + this.kbtnSelectMainInGrid.Size = new System.Drawing.Size(110, 25); + this.kbtnSelectMainInGrid.TabIndex = 9; + this.kbtnSelectMainInGrid.Values.Text = "Grid: Main"; + this.kbtnSelectMainInGrid.Click += new System.EventHandler(this.kbtnSelectMainInGrid_Click); + // + // kchkEnabled + // + this.kchkEnabled.Checked = true; + this.kchkEnabled.CheckState = System.Windows.Forms.CheckState.Checked; + this.kchkEnabled.Location = new System.Drawing.Point(18, 220); + this.kchkEnabled.Name = "kchkEnabled"; + this.kchkEnabled.Size = new System.Drawing.Size(120, 20); + this.kchkEnabled.TabIndex = 8; + this.kchkEnabled.Values.Text = "Main enabled"; + this.kchkEnabled.CheckedChanged += new System.EventHandler(this.kchkEnabled_CheckedChanged); + // + // kcbtnMainTextColor + // + this.kcbtnMainTextColor.Location = new System.Drawing.Point(194, 184); + this.kcbtnMainTextColor.Name = "kcbtnMainTextColor"; + this.kcbtnMainTextColor.Size = new System.Drawing.Size(166, 25); + this.kcbtnMainTextColor.TabIndex = 7; + this.kcbtnMainTextColor.Values.Text = "Centre text colour"; + this.kcbtnMainTextColor.SelectedColorChanged += new System.EventHandler(this.kcbtnMainTextColor_SelectedColorChanged); + // + // kcbtnInnerRingColor + // + this.kcbtnInnerRingColor.Location = new System.Drawing.Point(18, 184); + this.kcbtnInnerRingColor.Name = "kcbtnInnerRingColor"; + this.kcbtnInnerRingColor.Size = new System.Drawing.Size(166, 25); + this.kcbtnInnerRingColor.TabIndex = 6; + this.kcbtnInnerRingColor.Values.Text = "Inner ring colour"; + this.kcbtnInnerRingColor.SelectedColorChanged += new System.EventHandler(this.kcbtnInnerRingColor_SelectedColorChanged); + // + // kcbtnOuterRingColor + // + this.kcbtnOuterRingColor.Location = new System.Drawing.Point(194, 152); + this.kcbtnOuterRingColor.Name = "kcbtnOuterRingColor"; + this.kcbtnOuterRingColor.Size = new System.Drawing.Size(166, 25); + this.kcbtnOuterRingColor.TabIndex = 5; + this.kcbtnOuterRingColor.Values.Text = "Outer ring colour"; + this.kcbtnOuterRingColor.SelectedColorChanged += new System.EventHandler(this.kcbtnOuterRingColor_SelectedColorChanged); + // + // kcbtnProgressColor + // + this.kcbtnProgressColor.Location = new System.Drawing.Point(18, 152); + this.kcbtnProgressColor.Name = "kcbtnProgressColor"; + this.kcbtnProgressColor.SelectedColor = System.Drawing.Color.MediumSeaGreen; + this.kcbtnProgressColor.Size = new System.Drawing.Size(166, 25); + this.kcbtnProgressColor.TabIndex = 4; + this.kcbtnProgressColor.Values.Text = "Progress arc colour"; + this.kcbtnProgressColor.SelectedColorChanged += new System.EventHandler(this.kcbtnProgressColor_SelectedColorChanged); + // + // kcmbValueBackColorStyle + // + this.kcmbValueBackColorStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.kcmbValueBackColorStyle.DropDownWidth = 260; + this.kcmbValueBackColorStyle.Location = new System.Drawing.Point(18, 120); + this.kcmbValueBackColorStyle.Name = "kcmbValueBackColorStyle"; + this.kcmbValueBackColorStyle.Size = new System.Drawing.Size(342, 22); + this.kcmbValueBackColorStyle.TabIndex = 3; + this.kcmbValueBackColorStyle.SelectedIndexChanged += new System.EventHandler(this.kcmbValueBackColorStyle_SelectedIndexChanged); + // + // klblValueBackColorStyle + // + this.klblValueBackColorStyle.Location = new System.Drawing.Point(18, 96); + this.klblValueBackColorStyle.Name = "klblValueBackColorStyle"; + this.klblValueBackColorStyle.Size = new System.Drawing.Size(129, 20); + this.klblValueBackColorStyle.TabIndex = 2; + this.klblValueBackColorStyle.Values.Text = "Value back color style"; + // + // kryptonThemeComboBox1 + // + this.kryptonThemeComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.kryptonThemeComboBox1.DropDownWidth = 342; + this.kryptonThemeComboBox1.IntegralHeight = false; + this.kryptonThemeComboBox1.Location = new System.Drawing.Point(18, 40); + this.kryptonThemeComboBox1.Name = "kryptonThemeComboBox1"; + this.kryptonThemeComboBox1.Size = new System.Drawing.Size(342, 22); + this.kryptonThemeComboBox1.TabIndex = 1; + // + // klblTheme + // + this.klblTheme.Location = new System.Drawing.Point(18, 16); + this.klblTheme.Name = "klblTheme"; + this.klblTheme.Size = new System.Drawing.Size(84, 20); + this.klblTheme.TabIndex = 0; + this.klblTheme.Values.Text = "Global theme"; + // + // kryptonGroupBoxTriState + // + this.kryptonGroupBoxTriState.Dock = System.Windows.Forms.DockStyle.Top; + this.kryptonGroupBoxTriState.Location = new System.Drawing.Point(0, 486); + this.kryptonGroupBoxTriState.Name = "kryptonGroupBoxTriState"; + // + // kryptonGroupBoxTriState.Panel + // + this.kryptonGroupBoxTriState.Panel.Controls.Add(this.kbtnTriStatePreset); + this.kryptonGroupBoxTriState.Panel.Controls.Add(this.kchkAutoThreshold); + this.kryptonGroupBoxTriState.Panel.Controls.Add(this.kchkTriState); + this.kryptonGroupBoxTriState.Size = new System.Drawing.Size(379, 112); + this.kryptonGroupBoxTriState.TabIndex = 3; + this.kryptonGroupBoxTriState.Values.Heading = "Tri-state thresholds"; + // + // kbtnTriStatePreset + // + this.kbtnTriStatePreset.Location = new System.Drawing.Point(18, 72); + this.kbtnTriStatePreset.Name = "kbtnTriStatePreset"; + this.kbtnTriStatePreset.Size = new System.Drawing.Size(166, 25); + this.kbtnTriStatePreset.TabIndex = 2; + this.kbtnTriStatePreset.Values.Text = "Apply red/amber/green"; + this.kbtnTriStatePreset.Click += new System.EventHandler(this.kbtnTriStatePreset_Click); + // + // kchkAutoThreshold + // + this.kchkAutoThreshold.Location = new System.Drawing.Point(18, 44); + this.kchkAutoThreshold.Name = "kchkAutoThreshold"; + this.kchkAutoThreshold.Size = new System.Drawing.Size(186, 20); + this.kchkAutoThreshold.TabIndex = 1; + this.kchkAutoThreshold.Values.Text = "Auto-calculate thresholds"; + this.kchkAutoThreshold.CheckedChanged += new System.EventHandler(this.kchkAutoThreshold_CheckedChanged); + // + // kchkTriState + // + this.kchkTriState.Location = new System.Drawing.Point(18, 16); + this.kchkTriState.Name = "kchkTriState"; + this.kchkTriState.Size = new System.Drawing.Size(140, 20); + this.kchkTriState.TabIndex = 0; + this.kchkTriState.Values.Text = "Use tri-state colours"; + this.kchkTriState.CheckedChanged += new System.EventHandler(this.kchkTriState_CheckedChanged); + // + // kryptonGroupBoxText + // + this.kryptonGroupBoxText.Dock = System.Windows.Forms.DockStyle.Top; + this.kryptonGroupBoxText.Location = new System.Drawing.Point(0, 346); + this.kryptonGroupBoxText.Name = "kryptonGroupBoxText"; + // + // kryptonGroupBoxText.Panel + // + this.kryptonGroupBoxText.Panel.Controls.Add(this.kchkUseValueAsText); + this.kryptonGroupBoxText.Panel.Controls.Add(this.txtSubscript); + this.kryptonGroupBoxText.Panel.Controls.Add(this.klblSubscript); + this.kryptonGroupBoxText.Panel.Controls.Add(this.txtSuperscript); + this.kryptonGroupBoxText.Panel.Controls.Add(this.klblSuperscript); + this.kryptonGroupBoxText.Size = new System.Drawing.Size(379, 140); + this.kryptonGroupBoxText.TabIndex = 2; + this.kryptonGroupBoxText.Values.Heading = "Centre text"; + // + // kchkUseValueAsText + // + this.kchkUseValueAsText.Location = new System.Drawing.Point(18, 104); + this.kchkUseValueAsText.Name = "kchkUseValueAsText"; + this.kchkUseValueAsText.Size = new System.Drawing.Size(165, 20); + this.kchkUseValueAsText.TabIndex = 4; + this.kchkUseValueAsText.Values.Text = "Use progress value as text"; + this.kchkUseValueAsText.CheckedChanged += new System.EventHandler(this.kchkUseValueAsText_CheckedChanged); + // + // txtSubscript + // + this.txtSubscript.Location = new System.Drawing.Point(94, 68); + this.txtSubscript.Name = "txtSubscript"; + this.txtSubscript.Size = new System.Drawing.Size(266, 23); + this.txtSubscript.TabIndex = 3; + this.txtSubscript.TextChanged += new System.EventHandler(this.txtSubscript_TextChanged); + // + // klblSubscript + // + this.klblSubscript.Location = new System.Drawing.Point(18, 70); + this.klblSubscript.Name = "klblSubscript"; + this.klblSubscript.Size = new System.Drawing.Size(63, 20); + this.klblSubscript.TabIndex = 2; + this.klblSubscript.Values.Text = "Subscript"; + // + // txtSuperscript + // + this.txtSuperscript.Location = new System.Drawing.Point(94, 36); + this.txtSuperscript.Name = "txtSuperscript"; + this.txtSuperscript.Size = new System.Drawing.Size(266, 23); + this.txtSuperscript.TabIndex = 1; + this.txtSuperscript.TextChanged += new System.EventHandler(this.txtSuperscript_TextChanged); + // + // klblSuperscript + // + this.klblSuperscript.Location = new System.Drawing.Point(18, 38); + this.klblSuperscript.Name = "klblSuperscript"; + this.klblSuperscript.Size = new System.Drawing.Size(74, 20); + this.klblSuperscript.TabIndex = 0; + this.klblSuperscript.Values.Text = "Superscript"; + // + // kryptonGroupBoxAnimation + // + this.kryptonGroupBoxAnimation.Dock = System.Windows.Forms.DockStyle.Top; + this.kryptonGroupBoxAnimation.Location = new System.Drawing.Point(0, 176); + this.kryptonGroupBoxAnimation.Name = "kryptonGroupBoxAnimation"; + // + // kryptonGroupBoxAnimation.Panel + // + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.knudMarqueeSpeed); + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.klblMarqueeSpeed); + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.kcmbAnimationFunction); + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.klblAnimationFunction); + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.knudAnimationSpeed); + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.klblAnimationSpeed); + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.kcmbStyle); + this.kryptonGroupBoxAnimation.Panel.Controls.Add(this.klblStyle); + this.kryptonGroupBoxAnimation.Size = new System.Drawing.Size(379, 170); + this.kryptonGroupBoxAnimation.TabIndex = 1; + this.kryptonGroupBoxAnimation.Values.Heading = "Style && animation"; + // + // knudMarqueeSpeed + // + this.knudMarqueeSpeed.Location = new System.Drawing.Point(194, 128); + this.knudMarqueeSpeed.Maximum = new decimal(new int[] { 10000, 0, 0, 0 }); + this.knudMarqueeSpeed.Minimum = new decimal(new int[] { 50, 0, 0, 0 }); + this.knudMarqueeSpeed.Name = "knudMarqueeSpeed"; + this.knudMarqueeSpeed.Size = new System.Drawing.Size(166, 22); + this.knudMarqueeSpeed.TabIndex = 7; + this.knudMarqueeSpeed.Value = new decimal(new int[] { 2000, 0, 0, 0 }); + this.knudMarqueeSpeed.ValueChanged += new System.EventHandler(this.knudMarqueeSpeed_ValueChanged); + // + // klblMarqueeSpeed + // + this.klblMarqueeSpeed.Location = new System.Drawing.Point(18, 130); + this.klblMarqueeSpeed.Name = "klblMarqueeSpeed"; + this.klblMarqueeSpeed.Size = new System.Drawing.Size(149, 20); + this.klblMarqueeSpeed.TabIndex = 6; + this.klblMarqueeSpeed.Values.Text = "Marquee speed (sample)"; + // + // kcmbAnimationFunction + // + this.kcmbAnimationFunction.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.kcmbAnimationFunction.DropDownWidth = 260; + this.kcmbAnimationFunction.Location = new System.Drawing.Point(194, 96); + this.kcmbAnimationFunction.Name = "kcmbAnimationFunction"; + this.kcmbAnimationFunction.Size = new System.Drawing.Size(166, 22); + this.kcmbAnimationFunction.TabIndex = 5; + this.kcmbAnimationFunction.SelectedIndexChanged += new System.EventHandler(this.kcmbAnimationFunction_SelectedIndexChanged); + // + // klblAnimationFunction + // + this.klblAnimationFunction.Location = new System.Drawing.Point(18, 98); + this.klblAnimationFunction.Name = "klblAnimationFunction"; + this.klblAnimationFunction.Size = new System.Drawing.Size(116, 20); + this.klblAnimationFunction.TabIndex = 4; + this.klblAnimationFunction.Values.Text = "Animation function"; + // + // knudAnimationSpeed + // + this.knudAnimationSpeed.Location = new System.Drawing.Point(194, 64); + this.knudAnimationSpeed.Maximum = new decimal(new int[] { 5000, 0, 0, 0 }); + this.knudAnimationSpeed.Name = "knudAnimationSpeed"; + this.knudAnimationSpeed.Size = new System.Drawing.Size(166, 22); + this.knudAnimationSpeed.TabIndex = 3; + this.knudAnimationSpeed.Value = new decimal(new int[] { 500, 0, 0, 0 }); + this.knudAnimationSpeed.ValueChanged += new System.EventHandler(this.knudAnimationSpeed_ValueChanged); + // + // klblAnimationSpeed + // + this.klblAnimationSpeed.Location = new System.Drawing.Point(18, 66); + this.klblAnimationSpeed.Name = "klblAnimationSpeed"; + this.klblAnimationSpeed.Size = new System.Drawing.Size(104, 20); + this.klblAnimationSpeed.TabIndex = 2; + this.klblAnimationSpeed.Values.Text = "Animation speed"; + // + // kcmbStyle + // + this.kcmbStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.kcmbStyle.DropDownWidth = 260; + this.kcmbStyle.Location = new System.Drawing.Point(194, 32); + this.kcmbStyle.Name = "kcmbStyle"; + this.kcmbStyle.Size = new System.Drawing.Size(166, 22); + this.kcmbStyle.TabIndex = 1; + this.kcmbStyle.SelectedIndexChanged += new System.EventHandler(this.kcmbStyle_SelectedIndexChanged); + // + // klblStyle + // + this.klblStyle.Location = new System.Drawing.Point(18, 34); + this.klblStyle.Name = "klblStyle"; + this.klblStyle.Size = new System.Drawing.Size(87, 20); + this.klblStyle.TabIndex = 0; + this.klblStyle.Values.Text = "Progress style"; + // + // kryptonGroupBoxValue + // + this.kryptonGroupBoxValue.Dock = System.Windows.Forms.DockStyle.Top; + this.kryptonGroupBoxValue.Location = new System.Drawing.Point(0, 0); + this.kryptonGroupBoxValue.Name = "kryptonGroupBoxValue"; + // + // kryptonGroupBoxValue.Panel + // + this.kryptonGroupBoxValue.Panel.Controls.Add(this.kbtnDecrement); + this.kryptonGroupBoxValue.Panel.Controls.Add(this.kbtnIncrement); + this.kryptonGroupBoxValue.Panel.Controls.Add(this.knudMaximum); + this.kryptonGroupBoxValue.Panel.Controls.Add(this.klblMaximum); + this.kryptonGroupBoxValue.Panel.Controls.Add(this.knudMinimum); + this.kryptonGroupBoxValue.Panel.Controls.Add(this.klblMinimum); + this.kryptonGroupBoxValue.Panel.Controls.Add(this.ktrkValue); + this.kryptonGroupBoxValue.Panel.Controls.Add(this.klblValue); + this.kryptonGroupBoxValue.Size = new System.Drawing.Size(379, 176); + this.kryptonGroupBoxValue.TabIndex = 0; + this.kryptonGroupBoxValue.Values.Heading = "Value && range"; + // + // kbtnDecrement + // + this.kbtnDecrement.Location = new System.Drawing.Point(285, 136); + this.kbtnDecrement.Name = "kbtnDecrement"; + this.kbtnDecrement.Size = new System.Drawing.Size(75, 25); + this.kbtnDecrement.TabIndex = 7; + this.kbtnDecrement.Values.Text = "− Step"; + this.kbtnDecrement.Click += new System.EventHandler(this.kbtnDecrement_Click); + // + // kbtnIncrement + // + this.kbtnIncrement.Location = new System.Drawing.Point(194, 136); + this.kbtnIncrement.Name = "kbtnIncrement"; + this.kbtnIncrement.Size = new System.Drawing.Size(75, 25); + this.kbtnIncrement.TabIndex = 6; + this.kbtnIncrement.Values.Text = "+ Step"; + this.kbtnIncrement.Click += new System.EventHandler(this.kbtnIncrement_Click); + // + // knudMaximum + // + this.knudMaximum.Location = new System.Drawing.Point(285, 104); + this.knudMaximum.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + this.knudMaximum.Name = "knudMaximum"; + this.knudMaximum.Size = new System.Drawing.Size(75, 22); + this.knudMaximum.TabIndex = 5; + this.knudMaximum.Value = new decimal(new int[] { 100, 0, 0, 0 }); + this.knudMaximum.ValueChanged += new System.EventHandler(this.knudMaximum_ValueChanged); + // + // klblMaximum + // + this.klblMaximum.Location = new System.Drawing.Point(194, 106); + this.klblMaximum.Name = "klblMaximum"; + this.klblMaximum.Size = new System.Drawing.Size(63, 20); + this.klblMaximum.TabIndex = 4; + this.klblMaximum.Values.Text = "Maximum"; + // + // knudMinimum + // + this.knudMinimum.Location = new System.Drawing.Point(94, 104); + this.knudMinimum.Name = "knudMinimum"; + this.knudMinimum.Size = new System.Drawing.Size(75, 22); + this.knudMinimum.TabIndex = 3; + this.knudMinimum.ValueChanged += new System.EventHandler(this.knudMinimum_ValueChanged); + // + // klblMinimum + // + this.klblMinimum.Location = new System.Drawing.Point(18, 106); + this.klblMinimum.Name = "klblMinimum"; + this.klblMinimum.Size = new System.Drawing.Size(60, 20); + this.klblMinimum.TabIndex = 2; + this.klblMinimum.Values.Text = "Minimum"; + // + // ktrkValue + // + this.ktrkValue.Location = new System.Drawing.Point(18, 56); + this.ktrkValue.Maximum = 100; + this.ktrkValue.Name = "ktrkValue"; + this.ktrkValue.Size = new System.Drawing.Size(342, 33); + this.ktrkValue.TabIndex = 1; + this.ktrkValue.TickFrequency = 10; + this.ktrkValue.TickStyle = System.Windows.Forms.TickStyle.Both; + this.ktrkValue.Value = 65; + this.ktrkValue.ValueChanged += new System.EventHandler(this.ktrkValue_ValueChanged); + // + // klblValue + // + this.klblValue.Location = new System.Drawing.Point(18, 28); + this.klblValue.Name = "klblValue"; + this.klblValue.Size = new System.Drawing.Size(74, 20); + this.klblValue.TabIndex = 0; + this.klblValue.Values.Text = "Value: 65"; + // + // kryptonPropertyGrid1 + // + this.kryptonPropertyGrid1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.kryptonPropertyGrid1.Location = new System.Drawing.Point(784, 64); + this.kryptonPropertyGrid1.Name = "kryptonPropertyGrid1"; + this.kryptonPropertyGrid1.Padding = new System.Windows.Forms.Padding(1); + this.kryptonPropertyGrid1.Size = new System.Drawing.Size(384, 630); + this.kryptonPropertyGrid1.TabIndex = 7; + this.kryptonPropertyGrid1.Text = "kryptonPropertyGrid1"; + // + // klblStatus + // + this.klblStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.klblStatus.Location = new System.Drawing.Point(24, 676); + this.klblStatus.Name = "klblStatus"; + this.klblStatus.Size = new System.Drawing.Size(1144, 20); + this.klblStatus.TabIndex = 8; + this.klblStatus.Values.Text = "Adjust controls or use the property grid to explore palette states."; + // + // klblHeading + // + this.klblHeading.Location = new System.Drawing.Point(24, 16); + this.klblHeading.Name = "klblHeading"; + this.klblHeading.Size = new System.Drawing.Size(520, 30); + this.klblHeading.StateCommon.ShortText.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Bold); + this.klblHeading.TabIndex = 9; + this.klblHeading.Values.Text = "KryptonCircularProgressBar — palette, animation, and tri-state demo"; + // + // CircularProgressBarTest + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1184, 711); + this.Controls.Add(this.kryptonPanel1); + this.MinimumSize = new System.Drawing.Size(1000, 650); + this.Name = "CircularProgressBarTest"; + this.Text = "KryptonCircularProgressBar Demo"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.CircularProgressBarTest_FormClosed); + this.Load += new System.EventHandler(this.CircularProgressBarTest_Load); + this.Controls.SetChildIndex(this.kryptonPanel1, 0); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).EndInit(); + this.kryptonPanel1.ResumeLayout(false); + this.kryptonPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanelControls)).EndInit(); + this.kryptonPanelControls.ResumeLayout(false); + this.kryptonGroupBoxSimulation.Panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxSimulation)).EndInit(); + this.kryptonGroupBoxSimulation.ResumeLayout(false); + this.kryptonGroupBoxPalette.Panel.ResumeLayout(false); + this.kryptonGroupBoxPalette.Panel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxPalette)).EndInit(); + this.kryptonGroupBoxPalette.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.kcmbValueBackColorStyle)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonThemeComboBox1)).EndInit(); + this.kryptonGroupBoxTriState.Panel.ResumeLayout(false); + this.kryptonGroupBoxTriState.Panel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxTriState)).EndInit(); + this.kryptonGroupBoxTriState.ResumeLayout(false); + this.kryptonGroupBoxText.Panel.ResumeLayout(false); + this.kryptonGroupBoxText.Panel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxText)).EndInit(); + this.kryptonGroupBoxText.ResumeLayout(false); + this.kryptonGroupBoxAnimation.Panel.ResumeLayout(false); + this.kryptonGroupBoxAnimation.Panel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxAnimation)).EndInit(); + this.kryptonGroupBoxAnimation.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.kcmbAnimationFunction)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kcmbStyle)).EndInit(); + this.kryptonGroupBoxValue.Panel.ResumeLayout(false); + this.kryptonGroupBoxValue.Panel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBoxValue)).EndInit(); + this.kryptonGroupBoxValue.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Krypton.Toolkit.KryptonPanel kryptonPanel1; + private Krypton.Toolkit.Utilities.KryptonCircularProgressBar kcpbMain; + private Krypton.Toolkit.KryptonLabel klblPreviewCaption; + private Krypton.Toolkit.Utilities.KryptonCircularProgressBar kcpbMarquee; + private Krypton.Toolkit.KryptonLabel klblMarqueeCaption; + private Krypton.Toolkit.Utilities.KryptonCircularProgressBar kcpbDisabled; + private Krypton.Toolkit.KryptonLabel klblDisabledCaption; + private Krypton.Toolkit.KryptonPanel kryptonPanelControls; + private Krypton.Toolkit.KryptonGroupBox kryptonGroupBoxValue; + private Krypton.Toolkit.KryptonTrackBar ktrkValue; + private Krypton.Toolkit.KryptonLabel klblValue; + private Krypton.Toolkit.KryptonNumericUpDown knudMinimum; + private Krypton.Toolkit.KryptonLabel klblMinimum; + private Krypton.Toolkit.KryptonNumericUpDown knudMaximum; + private Krypton.Toolkit.KryptonLabel klblMaximum; + private Krypton.Toolkit.KryptonButton kbtnIncrement; + private Krypton.Toolkit.KryptonButton kbtnDecrement; + private Krypton.Toolkit.KryptonGroupBox kryptonGroupBoxAnimation; + private Krypton.Toolkit.KryptonComboBox kcmbStyle; + private Krypton.Toolkit.KryptonLabel klblStyle; + private Krypton.Toolkit.KryptonNumericUpDown knudAnimationSpeed; + private Krypton.Toolkit.KryptonLabel klblAnimationSpeed; + private Krypton.Toolkit.KryptonComboBox kcmbAnimationFunction; + private Krypton.Toolkit.KryptonLabel klblAnimationFunction; + private Krypton.Toolkit.KryptonNumericUpDown knudMarqueeSpeed; + private Krypton.Toolkit.KryptonLabel klblMarqueeSpeed; + private Krypton.Toolkit.KryptonGroupBox kryptonGroupBoxText; + private Krypton.Toolkit.KryptonTextBox txtSuperscript; + private Krypton.Toolkit.KryptonLabel klblSuperscript; + private Krypton.Toolkit.KryptonTextBox txtSubscript; + private Krypton.Toolkit.KryptonLabel klblSubscript; + private Krypton.Toolkit.KryptonCheckBox kchkUseValueAsText; + private Krypton.Toolkit.KryptonGroupBox kryptonGroupBoxTriState; + private Krypton.Toolkit.KryptonCheckBox kchkTriState; + private Krypton.Toolkit.KryptonCheckBox kchkAutoThreshold; + private Krypton.Toolkit.KryptonButton kbtnTriStatePreset; + private Krypton.Toolkit.KryptonGroupBox kryptonGroupBoxPalette; + private Krypton.Toolkit.KryptonLabel klblTheme; + private Krypton.Toolkit.KryptonThemeComboBox kryptonThemeComboBox1; + private Krypton.Toolkit.KryptonComboBox kcmbValueBackColorStyle; + private Krypton.Toolkit.KryptonLabel klblValueBackColorStyle; + private Krypton.Toolkit.KryptonColorButton kcbtnProgressColor; + private Krypton.Toolkit.KryptonColorButton kcbtnOuterRingColor; + private Krypton.Toolkit.KryptonColorButton kcbtnInnerRingColor; + private Krypton.Toolkit.KryptonColorButton kcbtnMainTextColor; + private Krypton.Toolkit.KryptonCheckBox kchkEnabled; + private Krypton.Toolkit.KryptonButton kbtnSelectMainInGrid; + private Krypton.Toolkit.KryptonButton kbtnSelectMarqueeInGrid; + private Krypton.Toolkit.KryptonButton kbtnSelectDisabledInGrid; + private Krypton.Toolkit.KryptonGroupBox kryptonGroupBoxSimulation; + private Krypton.Toolkit.KryptonButton kbtnReset; + private Krypton.Toolkit.KryptonButton kbtnStartSimulation; + private Krypton.Toolkit.KryptonButton kbtnStopSimulation; + private Krypton.Toolkit.KryptonPropertyGrid kryptonPropertyGrid1; + private Krypton.Toolkit.KryptonLabel klblStatus; + private Krypton.Toolkit.KryptonLabel klblHeading; + } +} diff --git a/Source/Krypton Components/TestForm/CircularProgressBarTest.cs b/Source/Krypton Components/TestForm/CircularProgressBarTest.cs new file mode 100644 index 0000000000..9339bbc17d --- /dev/null +++ b/Source/Krypton Components/TestForm/CircularProgressBarTest.cs @@ -0,0 +1,259 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), et al. 2026 - 2026. All rights reserved. + * + */ +#endregion + +using Krypton.Toolkit.Utilities; + +namespace TestForm; + +/// +/// Comprehensive demonstration of palette integration, +/// animation, tri-state thresholds, and layout options. +/// +public partial class CircularProgressBarTest : KryptonForm +{ + private readonly System.Windows.Forms.Timer _simulationTimer; + private bool _simulationRunning; + + public CircularProgressBarTest() + { + InitializeComponent(); + + _simulationTimer = new System.Windows.Forms.Timer { Interval = 80 }; + _simulationTimer.Tick += OnSimulationTick; + } + + private void CircularProgressBarTest_Load(object? sender, EventArgs e) + { + Icon = SystemIcons.Application; + + PopulateComboFromEnum(kcmbStyle, typeof(ProgressBarStyle)); + kcmbStyle.SelectedItem = ProgressBarStyle.Continuous; + + PopulateComboFromEnum(kcmbValueBackColorStyle, typeof(PaletteColorStyle)); + kcmbValueBackColorStyle.SelectedItem = kcpbMain.ValueBackColorStyle; + + PopulateComboFromEnum(kcmbAnimationFunction, typeof(WinFormAnimation.KnownAnimationFunctions)); + kcmbAnimationFunction.SelectedItem = kcpbMain.AnimationFunction; + + kcpbMain.Value = ktrkValue.Value; + kcpbDisabled.Value = 40; + kcpbMarquee.Style = ProgressBarStyle.Marquee; + + knudMinimum.Value = kcpbMain.Minimum; + knudMaximum.Value = kcpbMain.Maximum; + knudAnimationSpeed.Value = kcpbMain.AnimationSpeed; + knudMarqueeSpeed.Value = kcpbMarquee.MarqueeAnimationSpeed; + + txtSuperscript.Text = kcpbMain.SuperscriptText; + txtSubscript.Text = kcpbMain.SubscriptText; + kchkUseValueAsText.Checked = kcpbMain.UseValueAsText; + kchkTriState.Checked = kcpbMain.TriStateValues.UseTriStateColors; + kchkAutoThreshold.Checked = kcpbMain.TriStateValues.AutoCalculateThresholdValues; + kchkEnabled.Checked = kcpbMain.Enabled; + + kryptonPropertyGrid1.SelectedObject = kcpbMain; + + UpdateValueLabel(kcpbMain.Value); + UpdateStatusLabel(); + UpdateSimulationButtons(); + } + + private void CircularProgressBarTest_FormClosed(object? sender, FormClosedEventArgs e) + { + _simulationTimer.Stop(); + } + + private static void PopulateComboFromEnum(KryptonComboBox combo, Type enumType) + { + combo.Items.Clear(); + foreach (object value in Enum.GetValues(enumType)) + { + combo.Items.Add(value); + } + } + + private void OnSimulationTick(object? sender, EventArgs e) + { + int next = kcpbMain.Value + kcpbMain.Step; + if (next > kcpbMain.Maximum) + { + next = kcpbMain.Minimum; + } + + kcpbMain.Value = next; + ktrkValue.Value = Math.Max(ktrkValue.Minimum, Math.Min(ktrkValue.Maximum, next)); + } + + private void UpdateValueLabel(int value) => klblValue.Values.Text = $@"Value: {value} / {kcpbMain.Maximum}"; + + private void UpdateStatusLabel() + { + klblStatus.Values.Text = _simulationRunning + ? @"Simulation running — value advances automatically." + : @"Adjust controls or use the property grid to explore palette states."; + } + + private void ktrkValue_ValueChanged(object? sender, EventArgs e) + { + kcpbMain.Value = ktrkValue.Value; + UpdateValueLabel(kcpbMain.Value); + } + + private void kbtnIncrement_Click(object? sender, EventArgs e) => kcpbMain.Increment(kcpbMain.Step); + + private void kbtnDecrement_Click(object? sender, EventArgs e) => kcpbMain.Increment(-kcpbMain.Step); + + private void kbtnReset_Click(object? sender, EventArgs e) + { + StopSimulation(); + kcpbMain.Value = kcpbMain.Minimum; + ktrkValue.Value = kcpbMain.Minimum; + UpdateValueLabel(kcpbMain.Value); + } + + private void kbtnStartSimulation_Click(object? sender, EventArgs e) + { + _simulationRunning = true; + _simulationTimer.Start(); + UpdateStatusLabel(); + UpdateSimulationButtons(); + } + + private void kbtnStopSimulation_Click(object? sender, EventArgs e) => StopSimulation(); + + private void StopSimulation() + { + _simulationRunning = false; + _simulationTimer.Stop(); + UpdateStatusLabel(); + UpdateSimulationButtons(); + } + + private void UpdateSimulationButtons() + { + kbtnStartSimulation.Enabled = !_simulationRunning; + kbtnStopSimulation.Enabled = _simulationRunning; + } + + private void knudMinimum_ValueChanged(object? sender, EventArgs e) + { + kcpbMain.Minimum = (int)knudMinimum.Value; + ktrkValue.Minimum = kcpbMain.Minimum; + ktrkValue.Value = Math.Max(ktrkValue.Minimum, ktrkValue.Value); + } + + private void knudMaximum_ValueChanged(object? sender, EventArgs e) + { + kcpbMain.Maximum = (int)knudMaximum.Value; + ktrkValue.Maximum = kcpbMain.Maximum; + ktrkValue.Value = Math.Min(ktrkValue.Maximum, ktrkValue.Value); + UpdateValueLabel(kcpbMain.Value); + } + + private void kcmbStyle_SelectedIndexChanged(object? sender, EventArgs e) + { + if (kcmbStyle.SelectedItem is ProgressBarStyle style) + { + kcpbMain.Style = style; + } + } + + private void knudAnimationSpeed_ValueChanged(object? sender, EventArgs e) + { + kcpbMain.AnimationSpeed = (int)knudAnimationSpeed.Value; + } + + private void kcmbAnimationFunction_SelectedIndexChanged(object? sender, EventArgs e) + { + if (kcmbAnimationFunction.SelectedItem is WinFormAnimation.KnownAnimationFunctions function) + { + kcpbMain.AnimationFunction = function; + } + } + + private void knudMarqueeSpeed_ValueChanged(object? sender, EventArgs e) + { + kcpbMarquee.MarqueeAnimationSpeed = (int)knudMarqueeSpeed.Value; + } + + private void txtSuperscript_TextChanged(object? sender, EventArgs e) => kcpbMain.SuperscriptText = txtSuperscript.Text; + + private void txtSubscript_TextChanged(object? sender, EventArgs e) => kcpbMain.SubscriptText = txtSubscript.Text; + + private void kchkUseValueAsText_CheckedChanged(object? sender, EventArgs e) + { + kcpbMain.UseValueAsText = kchkUseValueAsText.Checked; + if (kchkUseValueAsText.Checked) + { + kcpbMain.Text = $@"{kcpbMain.Value}%"; + } + } + + private void kchkTriState_CheckedChanged(object? sender, EventArgs e) + { + kcpbMain.TriStateValues.UseTriStateColors = kchkTriState.Checked; + } + + private void kchkAutoThreshold_CheckedChanged(object? sender, EventArgs e) + { + kcpbMain.TriStateValues.AutoCalculateThresholdValues = kchkAutoThreshold.Checked; + } + + private void kbtnTriStatePreset_Click(object? sender, EventArgs e) + { + kcpbMain.TriStateValues.UseTriStateColors = true; + kcpbMain.TriStateValues.AutoCalculateThresholdValues = true; + kcpbMain.TriStateValues.LowThresholdValues.StateCommon.Back.Color1 = Color.IndianRed; + kcpbMain.TriStateValues.MediumThresholdValues.StateCommon.Back.Color1 = Color.Goldenrod; + kcpbMain.TriStateValues.HighThresholdValues.StateCommon.Back.Color1 = Color.MediumSeaGreen; + kchkTriState.Checked = true; + kchkAutoThreshold.Checked = true; + kcpbMain.Value = 80; + ktrkValue.Value = 80; + } + + private void kcmbValueBackColorStyle_SelectedIndexChanged(object? sender, EventArgs e) + { + if (kcmbValueBackColorStyle.SelectedItem is PaletteColorStyle style) + { + kcpbMain.ValueBackColorStyle = style; + } + } + + private void kcbtnProgressColor_SelectedColorChanged(object? sender, ColorEventArgs e) + { + kcpbMain.StateCommon.Back.Color1 = e.Color; + } + + private void kcbtnOuterRingColor_SelectedColorChanged(object? sender, ColorEventArgs e) + { + kcpbMain.OuterRingStateCommon.Back.Color1 = e.Color; + } + + private void kcbtnInnerRingColor_SelectedColorChanged(object? sender, ColorEventArgs e) + { + kcpbMain.InnerRingStateCommon.Back.Color1 = e.Color; + } + + private void kcbtnMainTextColor_SelectedColorChanged(object? sender, ColorEventArgs e) + { + kcpbMain.StateNormal.Content.ShortText.Color1 = e.Color; + } + + private void kchkEnabled_CheckedChanged(object? sender, EventArgs e) + { + kcpbMain.Enabled = kchkEnabled.Checked; + } + + private void kbtnSelectMainInGrid_Click(object? sender, EventArgs e) => kryptonPropertyGrid1.SelectedObject = kcpbMain; + + private void kbtnSelectMarqueeInGrid_Click(object? sender, EventArgs e) => kryptonPropertyGrid1.SelectedObject = kcpbMarquee; + + private void kbtnSelectDisabledInGrid_Click(object? sender, EventArgs e) => kryptonPropertyGrid1.SelectedObject = kcpbDisabled; +} diff --git a/Source/Krypton Components/TestForm/CircularProgressBarTest.resx b/Source/Krypton Components/TestForm/CircularProgressBarTest.resx new file mode 100644 index 0000000000..459ff7366d --- /dev/null +++ b/Source/Krypton Components/TestForm/CircularProgressBarTest.resx @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/Krypton Components/TestForm/StartScreen.cs b/Source/Krypton Components/TestForm/StartScreen.cs index a6795bff12..67ef3cfe7c 100644 --- a/Source/Krypton Components/TestForm/StartScreen.cs +++ b/Source/Krypton Components/TestForm/StartScreen.cs @@ -105,6 +105,7 @@ private void AddButtons() CreateButton("NotifyIcon", "Comprehensive demonstration of KryptonNotifyIcon with all events, balloon tips, and context menu support."); CreateButton("OAuth2 PKCE Demo", "Comprehensive OAuth2 with PKCE demo. Sign in with Azure AD, Google, or GitHub using embedded WebView2 or system browser. Configure client ID, redirect URI, and scopes."); CreateButton("QR Code (KryptonQRCode)", "Native QR code generation without external packages: live preview, ECC levels, module size, colors, quiet zone, Save PNG, clipboard, and static GenerateBitmap API."); + CreateButton("Circular Progress Bar", "Comprehensive demo of KryptonCircularProgressBar: palette-driven outer/inner rings and progress arc, theme switching, tri-state thresholds, animation, marquee and disabled samples, and property-grid exploration."); CreateButton("ProgressBar", "Checkout if progress has been made."); CreateButton("ScrollBar", "Comprehensive demonstration of KryptonHScrollBar and KryptonVScrollBar controls with basic usage, scrolling content, synchronization, theming, programmatic control, and event logging."); CreateButton("Scrollbar Manager", "Comprehensive demonstration of KryptonScrollbarManager with container mode, native wrapper mode, dynamic content, and integration examples."); From 816afd9316e22e4ff4e132ba39e7c95ea4c84224 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 22 Jun 2026 18:49:41 +0100 Subject: [PATCH 2/5] * Rename --- ...ryptonCircularProgressBar.cs => KryptonCircularProgressBar.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/{KryptonKryptonCircularProgressBar.cs => KryptonCircularProgressBar.cs} (100%) diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonKryptonCircularProgressBar.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs similarity index 100% rename from Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonKryptonCircularProgressBar.cs rename to Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs From 62441693d8125f0beafbbc0579c2e88c5dcfc01a Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Mon, 22 Jun 2026 18:54:57 +0100 Subject: [PATCH 3/5] * Designer support --- .../KryptonCircularProgressBar.cs | 3 +- .../KryptonCircularProgressBarActionList.cs | 379 ++++++++++++++++++ .../KryptonCircularProgressBarDesigner.cs | 42 ++ 3 files changed, 423 insertions(+), 1 deletion(-) create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Action Lists/KryptonCircularProgressBarActionList.cs create mode 100644 Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Designers/KryptonCircularProgressBarDesigner.cs diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs index de733efbe2..ca0332dd83 100644 --- a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs @@ -2,7 +2,7 @@ /* * * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) - * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac & Ahmed Abdelhameed, tobitege et al. 2026 - 2026. All rights reserved. + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. * */ #endregion @@ -14,6 +14,7 @@ namespace Krypton.Toolkit.Utilities; [ToolboxItem(true)] [ToolboxBitmap(typeof(KryptonCircularProgressBar), "ToolboxBitmaps.KryptonCircularProgressBar.bmp")] [DefaultBindingProperty("Value")] +[Designer(typeof(KryptonCircularProgressBarDesigner))] public class KryptonCircularProgressBar : KryptonProgressBar { #region Instance Fields diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Action Lists/KryptonCircularProgressBarActionList.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Action Lists/KryptonCircularProgressBarActionList.cs new file mode 100644 index 0000000000..cf26505c5f --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Action Lists/KryptonCircularProgressBarActionList.cs @@ -0,0 +1,379 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit.Utilities; + +/// +/// Smart-tag action list for . +/// +internal class KryptonCircularProgressBarActionList : DesignerActionList +{ + #region Instance Fields + + private readonly KryptonCircularProgressBar _control; + private readonly IComponentChangeService? _service; + + #endregion + + #region Identity + + /// + /// Initialize a new instance of the class. + /// + /// Designer that owns this action list instance. + public KryptonCircularProgressBarActionList(KryptonCircularProgressBarDesigner owner) + : base(owner.Component) + { + _control = (owner.Component as KryptonCircularProgressBar)!; + _service = GetService(typeof(IComponentChangeService)) as IComponentChangeService; + } + + #endregion + + #region Smart-Tag Properties + + /// Gets or sets the current progress value. + public int Value + { + get => _control.Value; + set + { + if (_control.Value != value) + { + _service?.OnComponentChanged(_control, null, _control.Value, value); + _control.Value = value; + } + } + } + + /// Gets or sets the minimum progress value. + public int Minimum + { + get => _control.Minimum; + set + { + if (_control.Minimum != value) + { + _service?.OnComponentChanged(_control, null, _control.Minimum, value); + _control.Minimum = value; + } + } + } + + /// Gets or sets the maximum progress value. + public int Maximum + { + get => _control.Maximum; + set + { + if (_control.Maximum != value) + { + _service?.OnComponentChanged(_control, null, _control.Maximum, value); + _control.Maximum = value; + } + } + } + + /// Gets or sets the progress bar display style. + public ProgressBarStyle Style + { + get => _control.Style; + set + { + if (_control.Style != value) + { + _service?.OnComponentChanged(_control, null, _control.Style, value); + _control.Style = value; + } + } + } + + /// Gets or sets whether the numeric value is shown as centre text. + public bool UseValueAsText + { + get => _control.UseValueAsText; + set + { + if (_control.UseValueAsText != value) + { + _service?.OnComponentChanged(_control, null, _control.UseValueAsText, value); + _control.UseValueAsText = value; + } + } + } + + /// Gets or sets the centre display text. + public string Text + { + get => _control.Text; + set + { + if (_control.Text != value) + { + _service?.OnComponentChanged(_control, null, _control.Text, value); + _control.Text = value; + } + } + } + + /// Gets or sets the superscript annotation text. + public string SuperscriptText + { + get => _control.SuperscriptText; + set + { + if (_control.SuperscriptText != value) + { + _service?.OnComponentChanged(_control, null, _control.SuperscriptText, value); + _control.SuperscriptText = value; + } + } + } + + /// Gets or sets the subscript annotation text. + public string SubscriptText + { + get => _control.SubscriptText; + set + { + if (_control.SubscriptText != value) + { + _service?.OnComponentChanged(_control, null, _control.SubscriptText, value); + _control.SubscriptText = value; + } + } + } + + /// Gets or sets the value transition duration in milliseconds. + public int AnimationSpeed + { + get => _control.AnimationSpeed; + set + { + if (_control.AnimationSpeed != value) + { + _service?.OnComponentChanged(_control, null, _control.AnimationSpeed, value); + _control.AnimationSpeed = value; + } + } + } + + /// Gets or sets the easing function used when animating value changes. + public WinFormAnimation.KnownAnimationFunctions AnimationFunction + { + get => _control.AnimationFunction; + set + { + if (_control.AnimationFunction != value) + { + _service?.OnComponentChanged(_control, null, _control.AnimationFunction, value); + _control.AnimationFunction = value; + } + } + } + + /// Gets or sets the marquee rotation period in milliseconds. + public int MarqueeAnimationSpeed + { + get => _control.MarqueeAnimationSpeed; + set + { + if (_control.MarqueeAnimationSpeed != value) + { + _service?.OnComponentChanged(_control, null, _control.MarqueeAnimationSpeed, value); + _control.MarqueeAnimationSpeed = value; + } + } + } + + /// Gets or sets the outer ring thickness. + public int OuterWidth + { + get => _control.OuterWidth; + set + { + if (_control.OuterWidth != value) + { + _service?.OnComponentChanged(_control, null, _control.OuterWidth, value); + _control.OuterWidth = value; + } + } + } + + /// Gets or sets the progress arc band thickness. + public int ProgressWidth + { + get => _control.ProgressWidth; + set + { + if (_control.ProgressWidth != value) + { + _service?.OnComponentChanged(_control, null, _control.ProgressWidth, value); + _control.ProgressWidth = value; + } + } + } + + /// Gets or sets the inner ring thickness. + public int InnerWidth + { + get => _control.InnerWidth; + set + { + if (_control.InnerWidth != value) + { + _service?.OnComponentChanged(_control, null, _control.InnerWidth, value); + _control.InnerWidth = value; + } + } + } + + /// Gets or sets the progress arc start angle in degrees. + public int StartAngle + { + get => _control.StartAngle; + set + { + if (_control.StartAngle != value) + { + _service?.OnComponentChanged(_control, null, _control.StartAngle, value); + _control.StartAngle = value; + } + } + } + + /// Gets or sets whether tri-state threshold colours are used for the progress arc. + public bool UseTriStateColors + { + get => _control.TriStateValues.UseTriStateColors; + set + { + if (_control.TriStateValues.UseTriStateColors != value) + { + _service?.OnComponentChanged(_control, null, _control.TriStateValues.UseTriStateColors, value); + _control.TriStateValues.UseTriStateColors = value; + } + } + } + + /// Gets or sets the palette colour style for the progress arc fill. + public PaletteColorStyle ValueBackColorStyle + { + get => _control.ValueBackColorStyle; + set + { + if (_control.ValueBackColorStyle != value) + { + _service?.OnComponentChanged(_control, null, _control.ValueBackColorStyle, value); + _control.ValueBackColorStyle = value; + } + } + } + + /// Gets or sets the primary progress arc colour. + public Color ProgressColor + { + get => _control.StateCommon.Back.Color1; + set + { + if (_control.StateCommon.Back.Color1 != value) + { + _service?.OnComponentChanged(_control, null, _control.StateCommon.Back.Color1, value); + _control.StateCommon.Back.Color1 = value; + } + } + } + + #endregion + + #region Smart-Tag Methods + + /// + /// Sets the control width and height to the larger of the two dimensions so the indicator stays circular. + /// + public void MakeSquare() + { + int size = Math.Max(_control.Width, _control.Height); + if (_control.Width == size && _control.Height == size) + { + return; + } + + Size newSize = new Size(size, size); + _service?.OnComponentChanged(_control, null, _control.Size, newSize); + _control.Size = newSize; + } + + #endregion + + #region Public Override + + /// + public override DesignerActionItemCollection GetSortedActionItems() + { + DesignerActionItemCollection actions = new DesignerActionItemCollection(); + + if (_control == null) + { + return actions; + } + + actions.Add(new DesignerActionHeaderItem("Progress")); + actions.Add(new DesignerActionPropertyItem(nameof(Value), "Value", "Progress", + "Current progress between Minimum and Maximum.")); + actions.Add(new DesignerActionPropertyItem(nameof(Minimum), "Minimum", "Progress", + "Lower bound of the progress range.")); + actions.Add(new DesignerActionPropertyItem(nameof(Maximum), "Maximum", "Progress", + "Upper bound of the progress range.")); + actions.Add(new DesignerActionPropertyItem(nameof(Style), "Style", "Progress", + "Continuous shows value; Marquee rotates the arc segment.")); + + actions.Add(new DesignerActionHeaderItem("Text")); + actions.Add(new DesignerActionPropertyItem(nameof(UseValueAsText), "Use value as text", "Text", + "When enabled, centre text is formatted from the current Value.")); + actions.Add(new DesignerActionPropertyItem(nameof(Text), "Centre text", "Text", + "Primary value displayed in the centre of the control.")); + actions.Add(new DesignerActionPropertyItem(nameof(SuperscriptText), "Superscript", "Text", + "Small annotation drawn beside the top of the centre text.")); + actions.Add(new DesignerActionPropertyItem(nameof(SubscriptText), "Subscript", "Text", + "Small annotation drawn beside the bottom of the centre text.")); + + actions.Add(new DesignerActionHeaderItem("Animation")); + actions.Add(new DesignerActionPropertyItem(nameof(AnimationSpeed), "Value speed (ms)", "Animation", + "Duration of animated transitions when Value changes. Zero disables animation.")); + actions.Add(new DesignerActionPropertyItem(nameof(AnimationFunction), "Easing", "Animation", + "Easing curve applied to value transitions.")); + actions.Add(new DesignerActionPropertyItem(nameof(MarqueeAnimationSpeed), "Marquee speed (ms)", "Animation", + "Rotation period when Style is Marquee.")); + + actions.Add(new DesignerActionHeaderItem("Layout")); + actions.Add(new DesignerActionPropertyItem(nameof(OuterWidth), "Outer ring width", "Layout", + "Thickness of the outer decorative ring. Zero hides the ring.")); + actions.Add(new DesignerActionPropertyItem(nameof(ProgressWidth), "Progress width", "Layout", + "Thickness of the progress arc band.")); + actions.Add(new DesignerActionPropertyItem(nameof(InnerWidth), "Inner ring width", "Layout", + "Thickness of the inner decorative ring. Zero hides the ring.")); + actions.Add(new DesignerActionPropertyItem(nameof(StartAngle), "Start angle", "Layout", + "Progress arc origin in degrees (GDI+ convention).")); + actions.Add(new DesignerActionMethodItem(this, nameof(MakeSquare), "Make square", "Layout", + "Sets Width and Height to the larger dimension so the control renders as a true circle.")); + + actions.Add(new DesignerActionHeaderItem("Visuals")); + actions.Add(new DesignerActionPropertyItem(nameof(ProgressColor), "Progress colour", "Visuals", + "Primary colour of the progress arc (StateCommon.Back.Color1).")); + actions.Add(new DesignerActionPropertyItem(nameof(ValueBackColorStyle), "Progress colour style", "Visuals", + "Palette drawing style for the progress arc fill.")); + actions.Add(new DesignerActionPropertyItem(nameof(UseTriStateColors), "Use tri-state colours", "Visuals", + "When enabled, progress colour changes by low/medium/high thresholds (TriStateValues).")); + + return actions; + } + + #endregion +} diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Designers/KryptonCircularProgressBarDesigner.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Designers/KryptonCircularProgressBarDesigner.cs new file mode 100644 index 0000000000..8d600f97cf --- /dev/null +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/Designers/Designers/KryptonCircularProgressBarDesigner.cs @@ -0,0 +1,42 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac, Ahmed Abdelhameed, tobitege, KamaniAR, Lesandro Gotardo (aka lesandrog), Jorge A. Avilés (aka mcpbcs) et al. 2026 - 2026. All rights reserved. + * + */ +#endregion + +namespace Krypton.Toolkit.Utilities; + +/// +/// Designer for . +/// +internal class KryptonCircularProgressBarDesigner : ControlDesigner +{ + #region Identity + + /// + /// Initialize a new instance of the class. + /// + public KryptonCircularProgressBarDesigner() => AutoResizeHandles = true; + + #endregion + + #region Public Overrides + + /// + /// Gets the design-time action lists supported by the component associated with the designer. + /// + public override DesignerActionListCollection ActionLists + { + get + { + DesignerActionListCollection actions = new DesignerActionListCollection(); + actions.Add(new KryptonCircularProgressBarActionList(this)); + return actions; + } + } + + #endregion +} From c7934941cff8b51d7f5415530e084fe3afb0b8de Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Tue, 23 Jun 2026 06:59:05 +0100 Subject: [PATCH 4/5] Update KryptonCircularProgressBar.cs --- .../KryptonCircularProgressBar.cs | 434 +++++++++++++++++- 1 file changed, 419 insertions(+), 15 deletions(-) diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs index ca0332dd83..6d7a1c0ac9 100644 --- a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs @@ -48,10 +48,67 @@ public class KryptonCircularProgressBar : KryptonProgressBar private IDisposable? _mementoOuterRingBack; private IDisposable? _mementoInnerRingBack; + private int _innerMargin = 2; + private int _innerWidth = -1; + private int _outerMargin = -25; + private int _outerWidth = 26; + private int _progressWidth = 25; + private Font _secondaryFont; + private Padding _subscriptMargin; + private string _subscriptText = string.Empty; + private Padding _superscriptMargin; + private string _superscriptText = string.Empty; + private Padding _textMargin; + + private const int MinimumDiameter = 48; + #endregion #region Properties + /// + /// Gets and sets the automatic resize of the control to fit centre text and ring layout. + /// + [Category("Layout")] + [Localizable(true)] + [Browsable(true)] + [EditorBrowsable(EditorBrowsableState.Always)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + [RefreshProperties(RefreshProperties.All)] + [DefaultValue(true)] + public override bool AutoSize + { + get => base.AutoSize; + set + { + if (base.AutoSize == value) + { + return; + } + + base.AutoSize = value; + + if (value) + { + PerformLayout(); + } + } + } + + /// + /// Gets and sets the mode for when auto sizing. + /// + [Browsable(false)] + [Localizable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [DefaultValue(AutoSizeMode.GrowAndShrink)] + public AutoSizeMode AutoSizeMode + { + get => GetAutoSizeMode(); + set => SetAutoSizeMode(value); + } + /// /// Sets a known animation function. /// @@ -107,42 +164,123 @@ public override Font Font get => base.Font; set { - if (value != null) + if (value == null || ReferenceEquals(base.Font, value)) { - base.Font = value; + return; } + + base.Font = value; + OnContentLayoutChanged(); } } /// /// [Category("Layout"), DefaultValue(2)] - public int InnerMargin { get; set; } + public int InnerMargin + { + get => _innerMargin; + set + { + if (_innerMargin == value) + { + return; + } + + _innerMargin = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Layout"), DefaultValue(-1)] - public int InnerWidth { get; set; } + public int InnerWidth + { + get => _innerWidth; + set + { + if (_innerWidth == value) + { + return; + } + + _innerWidth = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Layout"), DefaultValue(-25)] - public int OuterMargin { get; set; } + public int OuterMargin + { + get => _outerMargin; + set + { + if (_outerMargin == value) + { + return; + } + + _outerMargin = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Layout"), DefaultValue(26)] - public int OuterWidth { get; set; } + public int OuterWidth + { + get => _outerWidth; + set + { + if (_outerWidth == value) + { + return; + } + + _outerWidth = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Layout"), DefaultValue(25)] - public int ProgressWidth { get; set; } + public int ProgressWidth + { + get => _progressWidth; + set + { + if (_progressWidth == value) + { + return; + } + + _progressWidth = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Appearance"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Font SecondaryFont { get; set; } + public Font SecondaryFont + { + get => _secondaryFont; + set + { + if (ReferenceEquals(_secondaryFont, value)) + { + return; + } + + _secondaryFont = value; + OnContentLayoutChanged(); + } + } /// /// @@ -152,22 +290,78 @@ public override Font Font /// /// [Category("Layout"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Padding SubscriptMargin { get; set; } + public Padding SubscriptMargin + { + get => _subscriptMargin; + set + { + if (_subscriptMargin == value) + { + return; + } + + _subscriptMargin = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Appearance"), DefaultValue("")] - public string SubscriptText { get; set; } + public string SubscriptText + { + get => _subscriptText; + set + { + value ??= string.Empty; + + if (_subscriptText == value) + { + return; + } + + _subscriptText = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Layout"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Padding SuperscriptMargin { get; set; } + public Padding SuperscriptMargin + { + get => _superscriptMargin; + set + { + if (_superscriptMargin == value) + { + return; + } + + _superscriptMargin = value; + OnContentLayoutChanged(); + } + } /// /// [Category("Appearance"), DefaultValue("")] - public string SuperscriptText { get; set; } + public string SuperscriptText + { + get => _superscriptText; + set + { + value ??= string.Empty; + + if (_superscriptText == value) + { + return; + } + + _superscriptText = value; + OnContentLayoutChanged(); + } + } /// /// Gets or sets the text in the . @@ -184,7 +378,41 @@ public override string Text /// /// [Category("Layout"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Padding TextMargin { get; set; } + public Padding TextMargin + { + get => _textMargin; + set + { + if (_textMargin == value) + { + return; + } + + _textMargin = value; + OnContentLayoutChanged(); + } + } + + /// Gets or sets the current position of the progress bar. + [Category("Behavior")] + [Bindable(true)] + [Description("Gets or sets the current position of the progress bar.")] + [RefreshProperties(RefreshProperties.Repaint)] + [DefaultValue(0)] + public new int Value + { + get => base.Value; + set + { + if (base.Value == value) + { + return; + } + + base.Value = value; + OnContentLayoutChanged(); + } + } /// /// Gets access to the common outer ring appearance that other states can override. @@ -355,8 +583,6 @@ public KryptonCircularProgressBar() SubscriptText = string.Empty; - Size = new Size(320, 320); - BackColor = Color.Transparent; _outerRingStateCommon = new PaletteDoubleRedirect(ProgressPaletteRedirect, @@ -380,12 +606,150 @@ public KryptonCircularProgressBar() _subscriptStateDisabled = new PaletteTriple(_subscriptStateCommon, OnCircularNeedPaint); Text = @"0"; + + AutoSize = true; + AutoSizeMode = AutoSizeMode.GrowAndShrink; + Size = GetPreferredSize(Size.Empty); } #endregion #region Methods + private void OnContentLayoutChanged() + { + if (AutoSize && (IsHandleCreated || DesignMode)) + { + PerformLayout(); + } + + Invalidate(); + } + + private SizeF MeasureTextContent(Graphics graphics) + { + string text = Text ?? string.Empty; + if (text.Length == 0) + { + return SizeF.Empty; + } + + graphics.TextRenderingHint = TextRenderingHint.AntiAlias; + + Font secondaryFont = SecondaryFont ?? Font!; + SizeF textSize = graphics.MeasureString(text, Font!); + float left = 0; + float top = 0; + float right = textSize.Width; + float bottom = textSize.Height; + + if (!string.IsNullOrEmpty(SubscriptText) || !string.IsNullOrEmpty(SuperscriptText)) + { + float maxSWidth = 0; + SizeF supSize = SizeF.Empty; + SizeF subSize = SizeF.Empty; + + if (!string.IsNullOrEmpty(SuperscriptText)) + { + supSize = graphics.MeasureString(SuperscriptText, secondaryFont); + maxSWidth = Math.Max(supSize.Width, maxSWidth); + supSize.Width -= SuperscriptMargin.Right; + supSize.Height -= SuperscriptMargin.Bottom; + } + + if (!string.IsNullOrEmpty(SubscriptText)) + { + subSize = graphics.MeasureString(SubscriptText, secondaryFont); + maxSWidth = Math.Max(subSize.Width, maxSWidth); + subSize.Width -= SubscriptMargin.Right; + subSize.Height -= SubscriptMargin.Bottom; + } + + left -= maxSWidth / 4f; + + if (!string.IsNullOrEmpty(SuperscriptText)) + { + float supLeft = left + textSize.Width - supSize.Width / 2f + SuperscriptMargin.Left; + float supTop = top - supSize.Height * 0.85f + SuperscriptMargin.Top; + left = Math.Min(left, supLeft); + top = Math.Min(top, supTop); + right = Math.Max(right, supLeft + supSize.Width); + bottom = Math.Max(bottom, supTop + supSize.Height); + } + + if (!string.IsNullOrEmpty(SubscriptText)) + { + float subLeft = left + textSize.Width - subSize.Width / 2f + SubscriptMargin.Left; + float subTop = top + textSize.Height * 0.85f + SubscriptMargin.Top; + right = Math.Max(right, subLeft + subSize.Width); + bottom = Math.Max(bottom, subTop + subSize.Height); + } + } + + return new SizeF(right - left, bottom - top); + } + + private Size CalculateContentPreferredSize() + { + SizeF contentSize; + using (var image = new Bitmap(1, 1)) + using (Graphics graphics = Graphics.FromImage(image)) + { + contentSize = MeasureTextContent(graphics); + } + + float width = contentSize.Width; + float height = contentSize.Height; + + if (width <= 0 || height <= 0) + { + width = 16; + height = 16; + } + + width += TextMargin.Horizontal; + height += TextMargin.Vertical; + + if (InnerWidth != 0 && InnerWidth >= 0) + { + width += 2 * InnerWidth; + height += 2 * InnerWidth; + } + + width += 2 * InnerMargin; + height += 2 * InnerMargin; + + if (ProgressWidth >= 0) + { + width += 2 * ProgressWidth; + height += 2 * ProgressWidth; + } + + width -= 2 * OuterMargin; + height -= 2 * OuterMargin; + + if (OuterWidth != 0 && OuterWidth >= 0) + { + width += 2 * OuterWidth; + height += 2 * OuterWidth; + } + + if (OuterWidth + OuterMargin < 0) + { + float offset = Math.Abs(OuterWidth + OuterMargin); + width += 2 * offset; + height += 2 * offset; + } + + width += 4; + height += 4; + + int diameter = (int)Math.Ceiling(Math.Max(width, height)); + diameter = Math.Max(diameter, MinimumDiameter); + + return new Size(diameter, diameter); + } + private static PointF AddPoint(PointF point, int value) { point.X += value; @@ -826,6 +1190,46 @@ protected virtual void StartPaint(PaintEventArgs e) #region Overrides + /// + public override Size GetPreferredSize(Size proposedSize) + { + if (!AutoSize) + { + return base.GetPreferredSize(proposedSize); + } + + Size preferredSize = CalculateContentPreferredSize(); + + if (MaximumSize.Width > 0) + { + preferredSize.Width = Math.Min(MaximumSize.Width, preferredSize.Width); + } + + if (MaximumSize.Height > 0) + { + preferredSize.Height = Math.Min(MaximumSize.Height, preferredSize.Height); + } + + if (MinimumSize.Width > 0) + { + preferredSize.Width = Math.Max(MinimumSize.Width, preferredSize.Width); + } + + if (MinimumSize.Height > 0) + { + preferredSize.Height = Math.Max(MinimumSize.Height, preferredSize.Height); + } + + return preferredSize; + } + + /// + protected override void OnTextChanged(EventArgs e) + { + base.OnTextChanged(e); + OnContentLayoutChanged(); + } + /// protected override void Dispose(bool disposing) { From cca2e55f7eb8fc34b2ff9ff647fde3eea65e861e Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Wed, 24 Jun 2026 09:41:56 +0100 Subject: [PATCH 5/5] * Improve rendering --- .../KryptonCircularProgressBar.cs | 443 +++++++++++------- .../CircularProgressBarTest.Designer.cs | 4 +- 2 files changed, 263 insertions(+), 184 deletions(-) diff --git a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs index 6d7a1c0ac9..cbd881a5f2 100644 --- a/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs +++ b/Source/Krypton Components/Krypton.Toolkit.Utilities/Components/Krypton Circular Progress Bar/ControlsToolkit/KryptonCircularProgressBar.cs @@ -61,6 +61,8 @@ public class KryptonCircularProgressBar : KryptonProgressBar private Padding _textMargin; private const int MinimumDiameter = 48; + private const float MinimumSupersampleScale = 2f; + private const float MaximumSupersampleScale = 3f; #endregion @@ -571,15 +573,15 @@ public KryptonCircularProgressBar() InnerWidth = -1; - TextMargin = new Padding(8, 8, 0, 0); + TextMargin = Padding.Empty; Value = 0; - SuperscriptMargin = new Padding(10, 35, 0, 0); + SuperscriptMargin = Padding.Empty; SuperscriptText = string.Empty; - SubscriptMargin = new Padding(10, -35, 0, 0); + SubscriptMargin = Padding.Empty; SubscriptText = string.Empty; @@ -626,67 +628,142 @@ private void OnContentLayoutChanged() Invalidate(); } - private SizeF MeasureTextContent(Graphics graphics) + private static void ConfigureGraphicsQuality(Graphics graphics) { - string text = Text ?? string.Empty; - if (text.Length == 0) - { - return SizeF.Empty; - } - + graphics.SmoothingMode = SmoothingMode.HighQuality; + graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; + graphics.CompositingQuality = CompositingQuality.HighQuality; + graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; + } - Font secondaryFont = SecondaryFont ?? Font!; - SizeF textSize = graphics.MeasureString(text, Font!); - float left = 0; - float top = 0; - float right = textSize.Width; - float bottom = textSize.Height; + private float GetPaintScaleFactor() + { + float dpiScale = IsHandleCreated && DeviceDpi > 0 ? DeviceDpi / 96f : 1f; + return Math.Min(MaximumSupersampleScale, Math.Max(MinimumSupersampleScale, dpiScale)); + } + + private void ReleasePaletteMementos() + { + _mementoProgressBack?.Dispose(); + _mementoProgressBack = null; + _mementoOuterRingBack?.Dispose(); + _mementoOuterRingBack = null; + _mementoInnerRingBack?.Dispose(); + _mementoInnerRingBack = null; + } - if (!string.IsNullOrEmpty(SubscriptText) || !string.IsNullOrEmpty(SuperscriptText)) + private static void FillEllipseHole(Graphics graphics, Brush brush, PointF point, SizeF size) + { + using GraphicsPath holePath = new GraphicsPath(); + holePath.AddEllipse(point.X, point.Y, size.Width, size.Height); + graphics.FillPath(brush, holePath); + } + + private static readonly StringFormat s_centreTextMeasureFormat = CreateCentreTextMeasureFormat(); + + private static StringFormat CreateCentreTextMeasureFormat() + { + StringFormat format = (StringFormat)StringFormat.GenericTypographic.Clone(); + format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; + return format; + } + + private struct CentreTextLayout + { + public RectangleF Main; + public RectangleF Superscript; + public RectangleF Subscript; + public bool HasSuperscript; + public bool HasSubscript; + public RectangleF Bounds; + + public void Offset(float dx, float dy) { - float maxSWidth = 0; - SizeF supSize = SizeF.Empty; - SizeF subSize = SizeF.Empty; + Main.Offset(dx, dy); - if (!string.IsNullOrEmpty(SuperscriptText)) + if (HasSuperscript) { - supSize = graphics.MeasureString(SuperscriptText, secondaryFont); - maxSWidth = Math.Max(supSize.Width, maxSWidth); - supSize.Width -= SuperscriptMargin.Right; - supSize.Height -= SuperscriptMargin.Bottom; + Superscript.Offset(dx, dy); } - if (!string.IsNullOrEmpty(SubscriptText)) + if (HasSubscript) { - subSize = graphics.MeasureString(SubscriptText, secondaryFont); - maxSWidth = Math.Max(subSize.Width, maxSWidth); - subSize.Width -= SubscriptMargin.Right; - subSize.Height -= SubscriptMargin.Bottom; + Subscript.Offset(dx, dy); } - left -= maxSWidth / 4f; + Bounds.Offset(dx, dy); + } + } + + private CentreTextLayout CalculateCentreTextLayout(Graphics graphics, RectangleF textArea) + { + string text = Text ?? string.Empty; + Font mainFont = Font!; + Font secondaryFont = SecondaryFont ?? mainFont; + + SizeF mainSize = graphics.MeasureString(text, mainFont, int.MaxValue, s_centreTextMeasureFormat); + bool hasSuperscript = !string.IsNullOrEmpty(SuperscriptText); + bool hasSubscript = !string.IsNullOrEmpty(SubscriptText); + + var layout = new CentreTextLayout + { + Main = new RectangleF(0, 0, mainSize.Width, mainSize.Height), + HasSuperscript = hasSuperscript, + HasSubscript = hasSubscript, + Bounds = new RectangleF(0, 0, mainSize.Width, mainSize.Height) + }; + + if (hasSuperscript || hasSubscript) + { + SizeF supSize = hasSuperscript + ? graphics.MeasureString(SuperscriptText, secondaryFont, int.MaxValue, s_centreTextMeasureFormat) + : SizeF.Empty; + SizeF subSize = hasSubscript + ? graphics.MeasureString(SubscriptText, secondaryFont, int.MaxValue, s_centreTextMeasureFormat) + : SizeF.Empty; + + float suffixWidth = Math.Max(hasSuperscript ? supSize.Width : 0f, hasSubscript ? subSize.Width : 0f); + float anchorX = layout.Main.Width - suffixWidth * 0.22f; - if (!string.IsNullOrEmpty(SuperscriptText)) + if (hasSuperscript) { - float supLeft = left + textSize.Width - supSize.Width / 2f + SuperscriptMargin.Left; - float supTop = top - supSize.Height * 0.85f + SuperscriptMargin.Top; - left = Math.Min(left, supLeft); - top = Math.Min(top, supTop); - right = Math.Max(right, supLeft + supSize.Width); - bottom = Math.Max(bottom, supTop + supSize.Height); + layout.Superscript = new RectangleF( + anchorX + SuperscriptMargin.Left, + -supSize.Height * 0.40f + SuperscriptMargin.Top, + supSize.Width, + supSize.Height); + layout.Bounds = RectangleF.Union(layout.Bounds, layout.Superscript); } - if (!string.IsNullOrEmpty(SubscriptText)) + if (hasSubscript) { - float subLeft = left + textSize.Width - subSize.Width / 2f + SubscriptMargin.Left; - float subTop = top + textSize.Height * 0.85f + SubscriptMargin.Top; - right = Math.Max(right, subLeft + subSize.Width); - bottom = Math.Max(bottom, subTop + subSize.Height); + layout.Subscript = new RectangleF( + anchorX + SubscriptMargin.Left, + layout.Main.Height - subSize.Height * 0.60f + SubscriptMargin.Top, + subSize.Width, + subSize.Height); + layout.Bounds = RectangleF.Union(layout.Bounds, layout.Subscript); } } - return new SizeF(right - left, bottom - top); + float offsetX = textArea.X + (textArea.Width - layout.Bounds.Width) / 2f - layout.Bounds.X; + float offsetY = textArea.Y + (textArea.Height - layout.Bounds.Height) / 2f - layout.Bounds.Y; + layout.Offset(offsetX, offsetY); + + return layout; + } + + private SizeF MeasureTextContent(Graphics graphics) + { + if (string.IsNullOrEmpty(Text)) + { + return SizeF.Empty; + } + + ConfigureGraphicsQuality(graphics); + CentreTextLayout layout = CalculateCentreTextLayout(graphics, new RectangleF(0, 0, 10000, 10000)); + return layout.Bounds.Size; } private Size CalculateContentPreferredSize() @@ -750,25 +827,21 @@ private Size CalculateContentPreferredSize() return new Size(diameter, diameter); } - private static PointF AddPoint(PointF point, int value) + private static PointF InsetPoint(PointF point, float value) { point.X += value; - point.Y += value; - return point; } - private static SizeF AddSize(SizeF size, int value) + private static SizeF InsetSize(SizeF size, float value) { - size.Height += value; - - size.Width += value; - + size.Width -= 2f * value; + size.Height -= 2f * value; return size; } - private static Rectangle ToRectangle(RectangleF rectangle) => new Rectangle((int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height); + private static Rectangle ToRectangle(RectangleF rectangle) => Rectangle.Round(rectangle); private void OnCircularNeedPaint(object? sender, NeedLayoutEventArgs e) { @@ -832,7 +905,7 @@ private static void DrawPaletteEllipseBack(RenderContext renderContext, } using GraphicsPath path = new GraphicsPath(); - path.AddEllipse(bounds); + path.AddEllipse(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); memento = renderer.RenderStandardBack.DrawBack(renderContext, bounds, path, paletteBack, VisualOrientation.Top, state, memento); } @@ -858,7 +931,7 @@ private static void DrawPalettePieBack(RenderContext renderContext, } using GraphicsPath path = new GraphicsPath(); - path.AddPie(bounds, startAngle, sweepAngle); + path.AddPie(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, startAngle, sweepAngle); memento = renderer.RenderStandardBack.DrawBack(renderContext, bounds, path, paletteBack, VisualOrientation.Top, state, memento); } @@ -1017,14 +1090,25 @@ protected virtual void RecreateBackgroundBrush() protected virtual void StartPaint(PaintEventArgs e) { PaletteBase? palette = ResolvedPalette; - if (palette == null || _backBrush == null) + if (palette == null || _backBrush == null || Width <= 0 || Height <= 0) { return; } - Graphics g = e.Graphics; IRenderer renderer = palette.GetRenderer(); - using RenderContext renderContext = new RenderContext(this, g, e.ClipRectangle, renderer); + float paintScale = GetPaintScaleFactor(); + int bufferWidth = (int)Math.Ceiling(Width * paintScale); + int bufferHeight = (int)Math.Ceiling(Height * paintScale); + + using var paintSurface = new Bitmap(bufferWidth, bufferHeight, PixelFormat.Format32bppPArgb); + using Graphics paintGraphics = Graphics.FromImage(paintSurface); + ConfigureGraphicsQuality(paintGraphics); + paintGraphics.Clear(Color.Transparent); + paintGraphics.ScaleTransform(paintScale, paintScale); + + ReleasePaletteMementos(); + + using RenderContext renderContext = new RenderContext(this, paintGraphics, new Rectangle(0, 0, Width, Height), renderer); var (barPaletteState, barState) = GetProgressBarPaletteState(); var (outerPaletteState, outerState) = GetOuterRingPaletteState(); @@ -1034,152 +1118,145 @@ protected virtual void StartPaint(PaintEventArgs e) lock (this) { - g.TextRenderingHint = TextRenderingHint.AntiAlias; - g.SmoothingMode = SmoothingMode.AntiAlias; - var point = AddPoint(Point.Empty, 2); - var size = AddSize(Size, -2 * 2); - - if (OuterWidth + OuterMargin < 0) - { - var offset = Math.Abs(OuterWidth + OuterMargin); - point = AddPoint(Point.Empty, offset); - size = AddSize(Size, -2 * offset); - } + PaintCircularContent( + paintGraphics, + renderContext, + renderer, + barPaletteState, + barState, + outerPaletteState, + outerState, + innerPaletteState, + innerState, + superscriptPaletteState, + superscriptState, + subscriptPaletteState, + subscriptState); + } - if (ShouldDrawPaletteBack(outerPaletteState.PaletteBack, outerState, OuterWidth)) - { - DrawPaletteEllipseBack(renderContext, renderer, new RectangleF(point, size), - outerPaletteState.PaletteBack, outerState, ref _mementoOuterRingBack); + ConfigureGraphicsQuality(e.Graphics); + e.Graphics.CompositingMode = CompositingMode.SourceOver; + e.Graphics.DrawImage(paintSurface, 0, 0, Width, Height); + } - if (OuterWidth >= 0) - { - point = AddPoint(point, OuterWidth); - size = AddSize(size, -2 * OuterWidth); - g.FillEllipse(_backBrush, new RectangleF(point, size)); - } - } + private void PaintCircularContent( + Graphics g, + RenderContext renderContext, + IRenderer renderer, + IPaletteTriple barPaletteState, + PaletteState barState, + IPaletteDouble outerPaletteState, + PaletteState outerState, + IPaletteDouble innerPaletteState, + PaletteState innerState, + IPaletteTriple superscriptPaletteState, + PaletteState superscriptState, + IPaletteTriple subscriptPaletteState, + PaletteState subscriptState) + { + Brush backBrush = _backBrush!; + ConfigureGraphicsQuality(g); - point = AddPoint(point, OuterMargin); - size = AddSize(size, -2 * OuterMargin); + PointF point = new PointF(2f, 2f); + SizeF size = new SizeF(Width - 4f, Height - 4f); - float sweepAngle = Maximum == Minimum - ? 0f - : ((_animatedValue ?? Value) - Minimum) / (Maximum - Minimum) * 360f; + if (OuterWidth + OuterMargin < 0) + { + float offset = Math.Abs(OuterWidth + OuterMargin); + point = new PointF(offset, offset); + size = new SizeF(Width - 2f * offset, Height - 2f * offset); + } - DrawPalettePieBack(renderContext, renderer, new RectangleF(point, size), - _animatedStartAngle ?? StartAngle, sweepAngle, ValueBackPalette, barState, ref _mementoProgressBack); + if (ShouldDrawPaletteBack(outerPaletteState.PaletteBack, outerState, OuterWidth)) + { + DrawPaletteEllipseBack(renderContext, renderer, new RectangleF(point, size), + outerPaletteState.PaletteBack, outerState, ref _mementoOuterRingBack); - if (ProgressWidth >= 0) + if (OuterWidth >= 0) { - point = AddPoint(point, ProgressWidth); - size = AddSize(size, -2 * ProgressWidth); - g.FillEllipse(_backBrush, new RectangleF(point, size)); + point = InsetPoint(point, OuterWidth); + size = InsetSize(size, OuterWidth); + FillEllipseHole(g, backBrush, point, size); } + } - point = AddPoint(point, InnerMargin); - size = AddSize(size, -2 * InnerMargin); + point = InsetPoint(point, OuterMargin); + size = InsetSize(size, OuterMargin); - if (ShouldDrawPaletteBack(innerPaletteState.PaletteBack, innerState, InnerWidth)) - { - DrawPaletteEllipseBack(renderContext, renderer, new RectangleF(point, size), - innerPaletteState.PaletteBack, innerState, ref _mementoInnerRingBack); + float sweepAngle = Maximum == Minimum + ? 0f + : ((_animatedValue ?? Value) - Minimum) / (Maximum - Minimum) * 360f; - if (InnerWidth >= 0) - { - point = AddPoint(point, InnerWidth); - size = AddSize(size, -2 * InnerWidth); - g.FillEllipse(_backBrush, new RectangleF(point, size)); - } - } + DrawPalettePieBack(renderContext, renderer, new RectangleF(point, size), + _animatedStartAngle ?? StartAngle, sweepAngle, ValueBackPalette, barState, ref _mementoProgressBack); - if (Text == string.Empty) + if (ProgressWidth >= 0) + { + point = InsetPoint(point, ProgressWidth); + size = InsetSize(size, ProgressWidth); + FillEllipseHole(g, backBrush, point, size); + } + + point = InsetPoint(point, InnerMargin); + size = InsetSize(size, InnerMargin); + + if (ShouldDrawPaletteBack(innerPaletteState.PaletteBack, innerState, InnerWidth)) + { + DrawPaletteEllipseBack(renderContext, renderer, new RectangleF(point, size), + innerPaletteState.PaletteBack, innerState, ref _mementoInnerRingBack); + + if (InnerWidth >= 0) { - return; + point = InsetPoint(point, InnerWidth); + size = InsetSize(size, InnerWidth); + FillEllipseHole(g, backBrush, point, size); } + } - point.X += TextMargin.Left; - point.Y += TextMargin.Top; - size.Width -= TextMargin.Right; - size.Height -= TextMargin.Bottom; - var stringFormat = - new StringFormat(RightToLeft == RightToLeft.Yes ? StringFormatFlags.DirectionRightToLeft : 0) - { - Alignment = StringAlignment.Center, - LineAlignment = StringAlignment.Near - }; - var textSize = g.MeasureString(Text, Font!); - var textPoint = new PointF( - point.X + (size.Width - textSize.Width) / 2, - point.Y + (size.Height - textSize.Height) / 2); - - if (SubscriptText != string.Empty || SuperscriptText != string.Empty) - { - float maxSWidth = 0; - var supSize = SizeF.Empty; - var subSize = SizeF.Empty; + if (Text == string.Empty) + { + return; + } - if (SuperscriptText != string.Empty) - { - supSize = g.MeasureString(SuperscriptText, SecondaryFont); - maxSWidth = Math.Max(supSize.Width, maxSWidth); - supSize.Width -= SuperscriptMargin.Right; - supSize.Height -= SuperscriptMargin.Bottom; - } + var textArea = new RectangleF( + point.X + TextMargin.Left, + point.Y + TextMargin.Top, + size.Width - TextMargin.Horizontal, + size.Height - TextMargin.Vertical); - if (SubscriptText != string.Empty) - { - subSize = g.MeasureString(SubscriptText, SecondaryFont); - maxSWidth = Math.Max(subSize.Width, maxSWidth); - subSize.Width -= SubscriptMargin.Right; - subSize.Height -= SubscriptMargin.Bottom; - } + CentreTextLayout layout = CalculateCentreTextLayout(g, textArea); - textPoint.X -= maxSWidth / 4; + using var drawFormat = new StringFormat(StringFormat.GenericTypographic) + { + Alignment = StringAlignment.Center, + LineAlignment = StringAlignment.Center, + FormatFlags = StringFormatFlags.NoClip | StringFormatFlags.NoWrap + }; - if (SuperscriptText != string.Empty) - { - var supPoint = new PointF( - textPoint.X + textSize.Width - supSize.Width / 2, - textPoint.Y - supSize.Height * 0.85f); - supPoint.X += SuperscriptMargin.Left; - supPoint.Y += SuperscriptMargin.Top; - Color superscriptColor = superscriptPaletteState.PaletteContent!.GetContentShortTextColor1(superscriptState); - using var superscriptBrush = new SolidBrush(superscriptColor); - g.DrawString( - SuperscriptText, - SecondaryFont, - superscriptBrush, - new RectangleF(supPoint, supSize), - stringFormat); - } + if (RightToLeft == RightToLeft.Yes) + { + drawFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft; + } - if (SubscriptText != string.Empty) - { - var subPoint = new PointF( - textPoint.X + textSize.Width - subSize.Width / 2, - textPoint.Y + textSize.Height * 0.85f); - subPoint.X += SubscriptMargin.Left; - subPoint.Y += SubscriptMargin.Top; - Color subscriptColor = subscriptPaletteState.PaletteContent!.GetContentShortTextColor1(subscriptState); - using var subscriptBrush = new SolidBrush(subscriptColor); - g.DrawString( - SubscriptText, - SecondaryFont, - subscriptBrush, - new RectangleF(subPoint, subSize), - stringFormat); - } - } + Font secondaryFont = SecondaryFont ?? Font!; + + if (layout.HasSuperscript) + { + Color superscriptColor = superscriptPaletteState.PaletteContent!.GetContentShortTextColor1(superscriptState); + using var superscriptBrush = new SolidBrush(superscriptColor); + g.DrawString(SuperscriptText, secondaryFont, superscriptBrush, layout.Superscript, drawFormat); + } - Color textColor = barPaletteState.PaletteContent!.GetContentShortTextColor1(barState); - using var textBrush = new SolidBrush(textColor); - g.DrawString( - Text, - Font, - textBrush, - new RectangleF(textPoint, textSize), - stringFormat); + if (layout.HasSubscript) + { + Color subscriptColor = subscriptPaletteState.PaletteContent!.GetContentShortTextColor1(subscriptState); + using var subscriptBrush = new SolidBrush(subscriptColor); + g.DrawString(SubscriptText, secondaryFont, subscriptBrush, layout.Subscript, drawFormat); } + + Color textColor = barPaletteState.PaletteContent!.GetContentShortTextColor1(barState); + using var textBrush = new SolidBrush(textColor); + g.DrawString(Text, Font, textBrush, layout.Main, drawFormat); } /// Increments the specified value. @@ -1323,6 +1400,8 @@ protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); + ReleasePaletteMementos(); + RecreateBackgroundBrush(); Invalidate(); } diff --git a/Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs b/Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs index 84007ace19..aa3b0c4df5 100644 --- a/Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs +++ b/Source/Krypton Components/TestForm/CircularProgressBarTest.Designer.cs @@ -125,14 +125,13 @@ private void InitializeComponent() this.kcpbMain.AnimationSpeed = 500; this.kcpbMain.Location = new System.Drawing.Point(24, 88); this.kcpbMain.Name = "kcpbMain"; - this.kcpbMain.Size = new System.Drawing.Size(320, 320); this.kcpbMain.StateCommon.Back.Color1 = System.Drawing.Color.MediumSeaGreen; this.kcpbMain.StateDisabled.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.OneNote; this.kcpbMain.StateNormal.Back.ColorStyle = Krypton.Toolkit.PaletteColorStyle.GlassNormalFull; this.kcpbMain.SubscriptText = "CPU"; this.kcpbMain.SuperscriptText = "%"; this.kcpbMain.TabIndex = 0; - this.kcpbMain.Text = "65"; + this.kcpbMain.UseValueAsText = true; this.kcpbMain.Value = 65; this.kcpbMain.ValueBackColorStyle = Krypton.Toolkit.PaletteColorStyle.GlassNormalFull; // @@ -447,6 +446,7 @@ private void InitializeComponent() this.kchkUseValueAsText.Size = new System.Drawing.Size(165, 20); this.kchkUseValueAsText.TabIndex = 4; this.kchkUseValueAsText.Values.Text = "Use progress value as text"; + this.kchkUseValueAsText.Checked = true; this.kchkUseValueAsText.CheckedChanged += new System.EventHandler(this.kchkUseValueAsText_CheckedChanged); // // txtSubscript