Skip to content

Commit

Permalink
Merge pull request #1982 from giduac/1908-V100-KDGV-Column-indicator-…
Browse files Browse the repository at this point in the history
…image-class-update

1908-V100-KDGV-Column-indicator-image-class-update
  • Loading branch information
PWagner1 authored Dec 20, 2024
2 parents 8e0d5ad + f969fc6 commit 6cddc93
Showing 1 changed file with 1 addition and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ internal class KryptonDataGridViewCellIndicatorImage : IDisposable
private int _size;
// Datagridview the column belongs to.
private KryptonDataGridView? _dataGridView;
// Concurrency lock
private ReaderWriterLockSlim _rwls;
// State of disposal
private bool _disposed = false;

Expand All @@ -39,7 +37,6 @@ internal class KryptonDataGridViewCellIndicatorImage : IDisposable
public KryptonDataGridViewCellIndicatorImage(int imageSize = 14)
{
_size = imageSize;
_rwls = new();

UpdateCellIndicatorImage(true);
KryptonManager.GlobalPaletteChanged += OnKryptonManagerGlobalPaletteChanged;
Expand Down Expand Up @@ -78,17 +75,7 @@ public KryptonDataGridView? DataGridView
/// <summary>
/// Cell indicator image.
/// </summary>
public virtual Image? Image
{
get
{
_rwls.EnterReadLock();
var image = _image?.Clone() as Image;
_rwls.ExitReadLock();

return image;
}
}
public virtual Image? Image => _image;

/// <inheritdoc/>>
public void Dispose()
Expand Down Expand Up @@ -144,18 +131,12 @@ private void UpdateCellIndicatorImage(bool updateFromKryptonManager)
{
if (updateFromKryptonManager)
{
_rwls.EnterWriteLock();

// Probably the case used most, so first to check.
_image = KryptonManager.CurrentGlobalPalette.GetGalleryButtonImage(_paletteRibbonGalleryButton, _paletteState)!;
ResizeCellIndicatorImage();

_rwls.ExitWriteLock();
}
else if (DataGridView is KryptonDataGridView dataGridView)
{
_rwls.EnterWriteLock();

if (dataGridView.Palette is not null && dataGridView.PaletteMode == PaletteMode.Custom)
{
// The grid has a custom palette instance assigned to it and PaletteMode is Custom
Expand All @@ -170,8 +151,6 @@ private void UpdateCellIndicatorImage(bool updateFromKryptonManager)
}

ResizeCellIndicatorImage();

_rwls.ExitWriteLock();
}
}

Expand Down

0 comments on commit 6cddc93

Please sign in to comment.