Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Implement #1023 #1024

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=======

## 2023-11-xx - Build 2311 - November 2023
* Implemented [#1023](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1023), Please remove "sealed" from `KryptonWrapLabel` and `KryptonLinkWrapLabel`
* Added ability to embed links into the `KryptonMessageBox` content. The new options are:-
- `ContentAreaType` - Defines content area type of a `KryptonMessageBox`, default is normal
- `LinkLabelCommand` - Specifies a `KryptonCommand` if using the `MessageBoxContentAreaType.LinkLabel` type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializePaletteContentStyleStrings() => !ContentStyleStrings.IsDefault;

/// <summary>Resets the palette content style strings.</summary>
public void ResetPaletteContentStyleStrings() => ContentStyleStrings.Reset();

/// <summary>Gets the image effect strings.</summary>
Expand All @@ -271,6 +272,7 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializePaletteImageEffectStrings() => !ImageEffectStrings.IsDefault;

/// <summary>Resets the palette image effect strings.</summary>
public void ResetPaletteImageEffectStrings() => ImageEffectStrings.Reset();

/// <summary>Gets the image style strings.</summary>
Expand All @@ -284,6 +286,7 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializePaletteImageStyleStrings() => !ImageStyleStrings.IsDefault;

/// <summary>Resets the palette image style strings.</summary>
public void ResetPaletteImageStyleStrings() => ImageStyleStrings.Reset();

/// <summary>Gets the palette mode strings.</summary>
Expand Down Expand Up @@ -311,6 +314,7 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializePaletteTextTrimStrings() => !TextTrimStrings.IsDefault;

/// <summary>Resets the palette text trim strings.</summary>
public void ResetPaletteTextTrimStrings() => TextTrimStrings.Reset();

/// <summary>Gets the placement mode strings.</summary>
Expand All @@ -324,6 +328,7 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializePlacementModeStrings() => !PlacementModeStrings.IsDefault;

/// <summary>Resets the placement mode strings.</summary>
public void ResetPlacementModeStrings() => PlacementModeStrings.Reset();

/// <summary>Gets the separator style strings.</summary>
Expand All @@ -337,6 +342,7 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializeSeparatorStyleStrings() => !SeparatorStyles.IsDefault;

/// <summary>Resets the separator style strings.</summary>
public void ResetSeparatorStyleStrings() => SeparatorStyles.Reset();

/// <summary>Gets the tab border style strings.</summary>
Expand All @@ -350,6 +356,7 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializeTabBorderStyleStrings() => !TabBorderStyles.IsDefault;

/// <summary>Resets the tab border style strings.</summary>
public void ResetTabBorderStyleStrings() => TabBorderStyles.Reset();

/// <summary>Gets the tab style strings.</summary>
Expand All @@ -363,8 +370,23 @@ public class KryptonLanguageManager : Component

private bool ShouldSerializeTabStyleStrings() => !TabStyles.IsDefault;

/// <summary>Resets the tab style strings.</summary>
public void ResetTabStyleStrings() => TabStyles.Reset();

/// <summary>Gets the scrollbar strings.</summary>
/// <value>The scrollbar strings.</value>
[Category(@"Visuals")]
[Description(@"Collection of scrollbar strings.")]
[MergableProperty(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Localizable(true)]
public KryptonScrollBarStrings KryptonScrollBarStrings => ScrollBarStrings;

private bool ShouldSerializeKryptonScrollBarStrings() => !ScrollBarStrings.IsDefault;

/// <summary>Resets the krypton scroll bar strings.</summary>
public void ResetKryptonScrollBarStrings() => ScrollBarStrings.Reset();

#endregion

#region Static Strings
Expand Down Expand Up @@ -437,24 +459,42 @@ public class KryptonLanguageManager : Component
/// <value>The content style strings.</value>
public static PaletteContentStyleStrings ContentStyleStrings { get; } = new();

/// <summary>Gets the image effect strings.</summary>
/// <value>The image effect strings.</value>
public static PaletteImageEffectStrings ImageEffectStrings { get; } = new();

/// <summary>Gets the image style strings.</summary>
/// <value>The image style strings.</value>
public static PaletteImageStyleStrings ImageStyleStrings { get; } = new();

/// <summary>Gets the mode strings.</summary>
/// <value>The mode strings.</value>
public static PaletteModeStrings ModeStrings { get; } = new();

/// <summary>Gets the text trim strings.</summary>
/// <value>The text trim strings.</value>
public static PaletteTextTrimStrings TextTrimStrings { get; } = new();

/// <summary>Gets the placement mode strings.</summary>
/// <value>The placement mode strings.</value>
public static PlacementModeStrings PlacementModeStrings { get; } = new();

/// <summary>Gets the separator styles.</summary>
/// <value>The separator styles.</value>
public static SeparatorStyleStrings SeparatorStyles { get; } = new();

/// <summary>Gets the tab border styles.</summary>
/// <value>The tab border styles.</value>
public static TabBorderStyleStrings TabBorderStyles { get; } = new();

/// <summary>Gets the tab styles.</summary>
/// <value>The tab styles.</value>
public static TabStyleStrings TabStyles { get; } = new();

/// <summary>Gets the scroll bar strings.</summary>
/// <value>The scroll bar strings.</value>
public static KryptonScrollBarStrings ScrollBarStrings { get; } = new();

#endregion

#region Identity
Expand Down Expand Up @@ -497,7 +537,8 @@ public KryptonLanguageManager()
ShouldSerializePlacementModeStrings() ||
ShouldSerializeSeparatorStyleStrings() ||
ShouldSerializeTabBorderStyleStrings() ||
ShouldSerializeTabStyleStrings());
ShouldSerializeTabStyleStrings() ||
ShouldSerializeKryptonScrollBarStrings());

/// <summary>Resets this instance.</summary>
public void Reset()
Expand Down Expand Up @@ -549,6 +590,8 @@ public void Reset()
ResetTabBorderStyleStrings();

ResetTabStyleStrings();

ResetKryptonScrollBarStrings();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
#endregion

// ReSharper disable VirtualMemberCallInConstructor
namespace Krypton.Toolkit
{
/// <summary>
Expand All @@ -20,10 +21,10 @@ namespace Krypton.Toolkit
[Designer(typeof(KryptonLinkWrapLabelDesigner))]
[DesignerCategory(@"code")]
[Description(@"Displays descriptive information.")]
public sealed class KryptonLinkWrapLabel : LinkLabel
public class KryptonLinkWrapLabel : LinkLabel
{
#region Static Field
private static MethodInfo _miPTB;
private static MethodInfo? _miPtb;
#endregion

#region Instance Fields
Expand Down Expand Up @@ -331,7 +332,7 @@ public PaletteBase? Palette
if (_localPalette != value)
{
// Remember the starting palette
PaletteBase old = _localPalette;
PaletteBase? old = _localPalette;

// Use the provided palette value
SetPalette(value);
Expand Down Expand Up @@ -425,7 +426,7 @@ public IRenderer? Renderer
/// </summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public ToolStripRenderer CreateToolStripRenderer() => Renderer.RenderToolStrip(GetResolvedPalette());
public ToolStripRenderer? CreateToolStripRenderer() => Renderer?.RenderToolStrip(GetResolvedPalette());

/// <summary>
/// Update the font property.
Expand All @@ -434,7 +435,7 @@ public IRenderer? Renderer
[EditorBrowsable(EditorBrowsableState.Never)]
public void UpdateFont()
{
Font font;
Font? font;
Color textColor;
PaletteTextHint hint;
PaletteState ps = PaletteState.Normal;
Expand Down Expand Up @@ -526,7 +527,7 @@ private void OnPaletteChanged(EventArgs e)
// Layout and repaint with new settings
NeedPaint(true);

PaletteChanged?.Invoke(this, e);
PaletteChanged.Invoke(this, e);
}

/// <summary>
Expand All @@ -535,7 +536,7 @@ private void OnPaletteChanged(EventArgs e)
/// <param name="e">An EventArgs containing the event data.</param>
protected override void OnPaint(PaintEventArgs e)
{
Font font;
Font? font;
Color textColor;
PaletteTextHint hint;
PaletteState ps = PaletteState.Normal;
Expand Down Expand Up @@ -594,27 +595,33 @@ protected override void OnPaint(PaintEventArgs e)
/// Raises the PaintBackground event.
/// </summary>
/// <param name="pEvent">An PaintEventArgs containing the event data.</param>
protected override void OnPaintBackground(PaintEventArgs pEvent)
protected override void OnPaintBackground(PaintEventArgs? pEvent)
{
// Do we have a parent control and we need to paint background?
if (Parent != null)
{
// Only grab the required reference once
if (_miPTB == null)
if (_miPtb == null)
{
// Use reflection so we can call the Windows Forms internal method for painting parent background
_miPTB = typeof(Control).GetMethod("PaintTransparentBackground",
_miPtb = typeof(Control).GetMethod("PaintTransparentBackground",
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod,
null, CallingConventions.HasThis,
new[] { typeof(PaintEventArgs), typeof(Rectangle), typeof(Region) },
null);
}

_miPTB.Invoke(this, new object[] { pEvent, ClientRectangle, null });
if (pEvent != null)
{
_miPtb?.Invoke(this, new object[] { pEvent, ClientRectangle, null });
}
}
else
{
base.OnPaintBackground(pEvent);
if (pEvent != null)
{
base.OnPaintBackground(pEvent);
}
}
}

Expand Down Expand Up @@ -791,7 +798,7 @@ private void SetPalette(PaletteBase? palette)
_palette = palette;

// Get the renderer associated with the palette
Renderer = _palette.GetRenderer();
Renderer = _palette?.GetRenderer();

// Hook to new palette events
if (_palette != null)
Expand All @@ -806,7 +813,7 @@ private void SetPalette(PaletteBase? palette)
private void OnPaletteNeedPaint(object sender, NeedLayoutEventArgs e) => NeedPaint(e);

// Change in base renderer or base palette require we fetch the latest renderer
private void OnBaseChanged(object sender, EventArgs e) => Renderer = _palette.GetRenderer();
private void OnBaseChanged(object sender, EventArgs e) => Renderer = _palette?.GetRenderer();

/// <summary>Called when [global palette changed].</summary>
/// <param name="sender">The sender.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,4 @@ private static DialogResult ShowCore(IWin32Window? owner,

#endregion
}
}
}
Loading