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

1908-V100-KDGV-Column-indicator-image-class-update #1982

Merged
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
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