diff --git a/CommonControls/ComCtlResources.cs b/CommonControls/ComCtlResources.cs
index e3c880c..de413d0 100644
--- a/CommonControls/ComCtlResources.cs
+++ b/CommonControls/ComCtlResources.cs
@@ -19,20 +19,25 @@ internal static class ComCtlResources
internal const string ErrorWrongParameters = "Wrong Arguments provided: ";
///
- /// Error, Color Selection parameters (const). Value: "Error selecting color".
+ /// Error, Color Selection parameters (const). Value: "Error selecting color.".
///
- internal const string ErrorColorSelection = "Error selecting color";
+ internal const string ErrorColorSelection = "Error selecting color.";
///
- /// Error, Color switching parameters (const). Value:"Error switching color".
+ /// Error, Color switching parameters (const). Value:"Error switching color.".
///
- internal const string ErrorSwitchingColor = "Error switching color";
+ internal const string ErrorSwitchingColor = "Error switching color.";
///
/// The error could not load image (const). Value: "Error could not load Image:".
///
internal const string ErrorCouldNotLoadImage = "Error could not load Image:";
+ ///
+ /// The information ardoner null (const). Value: "Adorner was outside of the image control.".
+ ///
+ internal const string InformationArdonerNull = "Adorner was outside of the image control.";
+
///
/// Error, Color Selection initializing parameters (const). Value: "Error initializing color selection control"
///
diff --git a/CommonControls/ImageZoom.xaml.cs b/CommonControls/ImageZoom.xaml.cs
index c8fe871..2e358f5 100644
--- a/CommonControls/ImageZoom.xaml.cs
+++ b/CommonControls/ImageZoom.xaml.cs
@@ -11,6 +11,7 @@
// ReSharper disable UnusedType.Global
using System;
+using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Documents;
@@ -420,6 +421,12 @@ private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
_mouseDown = false;
MainCanvas.ReleaseMouseCapture();
+ if (_selectionAdorner == null)
+ {
+ Trace.Write(ComCtlResources.InformationArdonerNull);
+ return;
+ }
+
//clicked Endpoint
switch (ZoomTool)
diff --git a/CommonControls/Thumbnails.xaml b/CommonControls/Thumbnails.xaml
index 11564aa..31d0cf2 100644
--- a/CommonControls/Thumbnails.xaml
+++ b/CommonControls/Thumbnails.xaml
@@ -7,19 +7,17 @@
d:DesignHeight="450"
d:DesignWidth="800" Loaded="UserControl_Loaded">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CommonControls/Thumbnails.xaml.cs b/CommonControls/Thumbnails.xaml.cs
index 340bb9b..1a6734f 100644
--- a/CommonControls/Thumbnails.xaml.cs
+++ b/CommonControls/Thumbnails.xaml.cs
@@ -151,11 +151,6 @@ public sealed partial class Thumbnails : IDisposable
///
private int _originalWidth;
- ///
- /// The previous selected border
- ///
- private Border _previousSelectedBorder;
-
///
/// The selection
///
@@ -305,6 +300,11 @@ public ICommand ImageLoadedCommand
///
private ConcurrentDictionary ChkBox { get; set; }
+ ///
+ /// The border
+ ///
+ private ConcurrentDictionary Border { get; set; }
+
///
/// Gets or sets the selection.
///
@@ -417,6 +417,7 @@ private async void LoadImages()
Keys = new ConcurrentDictionary();
ImageDct = new ConcurrentDictionary();
+ Border = new ConcurrentDictionary();
Selection = new List();
if (SelectBox) ChkBox = new ConcurrentDictionary();
@@ -494,9 +495,13 @@ private async Task LoadImageAsync(int key, string name, Panel exGrid)
Child = images, // Set the image as the child of the border
BorderThickness = new Thickness(0), // Initially no border
BorderBrush = Brushes.Transparent, // Initially transparent
- Margin = new Thickness(1) // Optionally add some margin for spacing
+ Margin = new Thickness(1), // Optionally add some margin for spacing
+ Name = string.Concat(ComCtlResources.ImageAdd, key)
};
+ //add a reference to Border for later use
+ Border.TryAdd(key, border);
+
// Add image click handler (this should run on the UI thread)
images.MouseDown += ImageClick_MouseDown;
@@ -624,22 +629,28 @@ private void ImageClick_MouseDown(object sender, MouseButtonEventArgs e)
var clickedBorder = clickedImage.Parent as Border;
if (clickedBorder == null) return;
- // Clear previous selection highlight if any
- if (_previousSelectedBorder != null)
- {
- _previousSelectedBorder.BorderBrush = Brushes.Transparent; // Reset previous border highlight
- _previousSelectedBorder.BorderThickness = new Thickness(0); // Reset thickness
- }
-
- // Highlight the currently clicked thumbnail
- clickedBorder.BorderBrush = Brushes.Blue; // Highlight with blue border
- clickedBorder.BorderThickness = new Thickness(2); // Set border thickness
+ // Update the selected border (reuse the UpdateSelectedBorder method)
+ UpdateSelectedBorder(clickedBorder);
+ }
- // Update the currently selected border
- _currentSelectedBorder = clickedBorder;
+ ///
+ /// Next Border of this instance.
+ ///
+ public void Next()
+ {
+ int currentIndex = _currentSelectedBorder == null ? -1 : GetCurrentIndex(_currentSelectedBorder.Name);
+ int newIndex = (currentIndex + 1) % Border.Count; // Loop to the start if at the end
+ SelectImageAtIndex(newIndex);
+ }
- // Update the previous selected border to the current one
- _previousSelectedBorder = _currentSelectedBorder;
+ ///
+ /// Previous Border of this instance.
+ ///
+ public void Previous()
+ {
+ int currentIndex = _currentSelectedBorder == null ? -1 : GetCurrentIndex(_currentSelectedBorder.Name);
+ int newIndex = (currentIndex - 1 + Border.Count) % Border.Count; // Loop to the end if at the start
+ SelectImageAtIndex(newIndex);
}
///
@@ -738,6 +749,55 @@ private void OnImageThumbClicked(ImageEventArgs args)
ImageClicked?.Invoke(this, args);
}
+ ///
+ /// Gets the index of the current.
+ ///
+ /// The key.
+ /// Index of Border
+ private int GetCurrentIndex(string name)
+ {
+ // Find the index of the selected border
+ return Border
+ .Where(pair => pair.Value.Name == name)
+ .Select(pair => pair.Key)
+ .FirstOrDefault();
+ }
+
+ ///
+ /// Selects the index of the image at.
+ ///
+ /// The index.
+ private void SelectImageAtIndex(int index)
+ {
+ if (index < 0 || index >= Border.Count || !Border.ContainsKey(index)) return;
+
+ var border = Border[index];
+
+ // Now, update the current selected border with the found Border
+ UpdateSelectedBorder(border);
+ }
+
+ ///
+ /// Updates the selected border.
+ ///
+ /// The new selected border.
+ private void UpdateSelectedBorder(Border newSelectedBorder)
+ {
+ // Remove the "selected" style from the previously selected border
+ if (_currentSelectedBorder != null)
+ {
+ _currentSelectedBorder.BorderBrush = Brushes.Transparent; // Reset previous border
+ _currentSelectedBorder.BorderThickness = new Thickness(0); // Reset thickness
+ }
+
+ // Set the new border as selected
+ newSelectedBorder.BorderBrush = Brushes.Blue; // Set a color for the border
+ newSelectedBorder.BorderThickness = new Thickness(2); // Set thickness to highlight
+
+ // Update the current selected border reference
+ _currentSelectedBorder = newSelectedBorder;
+ }
+
///
/// Disposes the specified disposing.
///
diff --git a/Imaging/ColorHsv.cs b/Imaging/ColorHsv.cs
index cfdd047..65189a5 100644
--- a/Imaging/ColorHsv.cs
+++ b/Imaging/ColorHsv.cs
@@ -376,7 +376,9 @@ public override int GetHashCode()
///
public static bool operator ==(ColorHsv left, ColorHsv right)
{
- return left?.Equals(right) == true;
+ if (ReferenceEquals(left, right)) return true; // Same reference
+ if (left is null || right is null) return false; // One is null
+ return left.Equals(right);
}
///
diff --git a/Imaging/TextureGenerator.cs b/Imaging/TextureGenerator.cs
index cba87e3..248306c 100644
--- a/Imaging/TextureGenerator.cs
+++ b/Imaging/TextureGenerator.cs
@@ -18,7 +18,7 @@ namespace Imaging
/// Main Entry Class that will handle all things related to textures
///
///
- public class TextureGenerator : ITextureGenerator
+ public sealed class TextureGenerator : ITextureGenerator
{
///
/// Initializes a new instance of the class.