From 068979aa28bd3bafe3031c1a9586c124e9ba9867 Mon Sep 17 00:00:00 2001 From: lukegor Date: Sun, 14 Jul 2024 17:56:47 +0200 Subject: [PATCH] feature: add rotation; fix: fix zoom; chore: further split .resx --- JSharp/JSharp.csproj | 40 ++- JSharp/Resources/Errors.Designer.cs | 135 ++++++++ JSharp/Resources/Errors.de.resx | 144 +++++++++ JSharp/Resources/Errors.pl-PL.resx | 144 +++++++++ JSharp/Resources/Errors.resx | 144 +++++++++ JSharp/Resources/Histogram.de.resx | 129 ++++++++ .../Icons/{ => ToolBar_Icons}/ClearCanvas.ico | Bin .../{ => ToolBar_Icons}/DrawRectangle.ico | Bin .../{icon1.ico => ToolBar_Icons/JSharp.ico} | Bin .../Icons/{ => ToolBar_Icons}/LineSegment.ico | Bin .../Icons/{ => ToolBar_Icons}/N-A-icon.ico | Bin .../Icons/{ => ToolBar_Icons}/NoneIcon.ico | Bin JSharp/Resources/Strings.Designer.cs | 81 +---- JSharp/Resources/Strings.de.resx | 294 ++++++++++++++++++ JSharp/Resources/Strings.pl-PL.resx | 27 +- JSharp/Resources/Strings.resx | 27 +- JSharp/Resources/UIStrings.de.resx | 144 +++++++++ .../AlreadyGrayscaleErrorValidator.cs | 2 +- .../Validators/HistogramOpenValidator.cs | 2 +- .../Validators/ImageFocusedValidator.cs | 2 +- .../Validators/ImageGrayScaleValidator.cs | 2 +- .../Validators/ImageNotGrayScaleValidator.cs | 2 +- .../Validators/ImageXyzValidator.cs | 2 +- JSharp/ViewModels/MainWindowViewModel.cs | 101 +++--- JSharp/ViewModels/NewImageWindowViewModel.cs | 14 +- JSharp/Views/MainWindow.xaml | 9 +- JSharp/config.json | 3 - 27 files changed, 1255 insertions(+), 193 deletions(-) create mode 100644 JSharp/Resources/Errors.Designer.cs create mode 100644 JSharp/Resources/Errors.de.resx create mode 100644 JSharp/Resources/Errors.pl-PL.resx create mode 100644 JSharp/Resources/Errors.resx create mode 100644 JSharp/Resources/Histogram.de.resx rename JSharp/Resources/Icons/{ => ToolBar_Icons}/ClearCanvas.ico (100%) rename JSharp/Resources/Icons/{ => ToolBar_Icons}/DrawRectangle.ico (100%) rename JSharp/Resources/Icons/{icon1.ico => ToolBar_Icons/JSharp.ico} (100%) rename JSharp/Resources/Icons/{ => ToolBar_Icons}/LineSegment.ico (100%) rename JSharp/Resources/Icons/{ => ToolBar_Icons}/N-A-icon.ico (100%) rename JSharp/Resources/Icons/{ => ToolBar_Icons}/NoneIcon.ico (100%) create mode 100644 JSharp/Resources/Strings.de.resx create mode 100644 JSharp/Resources/UIStrings.de.resx diff --git a/JSharp/JSharp.csproj b/JSharp/JSharp.csproj index 8e53df2..37437d8 100644 --- a/JSharp/JSharp.csproj +++ b/JSharp/JSharp.csproj @@ -8,7 +8,7 @@ true Łukasz Górski Copyright © 2024 Łukasz Górski - Resources\Icons\icon1.ico + Resources\Icons\ToolBar_Icons\JSharp.ico https://github.com/lukegor/JSharp Apache-2.0 true @@ -18,25 +18,24 @@ - - - - - - + + + + + - + - - - - - - + + + + + + @@ -58,6 +57,11 @@ True Settings.settings + + True + True + Errors.resx + True True @@ -91,6 +95,10 @@ + + ResXFileCodeGenerator + Errors.Designer.cs + PublicResXFileCodeGenerator Histogram.Designer.cs @@ -127,4 +135,8 @@ + + + + diff --git a/JSharp/Resources/Errors.Designer.cs b/JSharp/Resources/Errors.Designer.cs new file mode 100644 index 0000000..df769e3 --- /dev/null +++ b/JSharp/Resources/Errors.Designer.cs @@ -0,0 +1,135 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace JSharp.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // 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.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Errors { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Errors() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JSharp.Resources.Errors", typeof(Errors).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to The image is already grayscale. + /// + internal static string AlreadyGrayscale_Error { + get { + return ResourceManager.GetString("AlreadyGrayscale_Error", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Histogram for the image is already open.. + /// + internal static string HistogramAlreadyOpen { + get { + return ResourceManager.GetString("HistogramAlreadyOpen", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The operation requires for the histogram of the selected image to be open.. + /// + internal static string HistogramNotOpen { + get { + return ResourceManager.GetString("HistogramNotOpen", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The selected operation may only be performed on color images.. + /// + internal static string ImageNotColor { + get { + return ResourceManager.GetString("ImageNotColor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The selected operation may only be performed on grayscale images.. + /// + internal static string ImageNotGrayscale { + get { + return ResourceManager.GetString("ImageNotGrayscale", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Failed to load image.. + /// + internal static string LoadingFailed { + get { + return ResourceManager.GetString("LoadingFailed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No image is focused. + /// + internal static string NoImageFocused { + get { + return ResourceManager.GetString("NoImageFocused", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No image is open. + /// + internal static string NoImageOpen { + get { + return ResourceManager.GetString("NoImageOpen", resourceCulture); + } + } + } +} diff --git a/JSharp/Resources/Errors.de.resx b/JSharp/Resources/Errors.de.resx new file mode 100644 index 0000000..fcf14e3 --- /dev/null +++ b/JSharp/Resources/Errors.de.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Das Bild ist bereits in Graustufen dargestellt + + + Das Histogramm für das Bild ist bereits geöffnet. + + + Für den Vorgang muss das Histogramm des ausgewählten Bildes geöffnet sein. + + + Der ausgewählte Vorgang kann nur für Farbbilder ausgeführt werden. + + + Der ausgewählte Vorgang kann nur für Graustufenbilder ausgeführt werden. + + + Bild konnte nicht geladen werden. + + + Kein Bild ist fokussiert + + + Kein Bild ist geöffnet + + \ No newline at end of file diff --git a/JSharp/Resources/Errors.pl-PL.resx b/JSharp/Resources/Errors.pl-PL.resx new file mode 100644 index 0000000..ad3ae66 --- /dev/null +++ b/JSharp/Resources/Errors.pl-PL.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Obraz jest już szaroodcieniowy + + + Histogram wybranego obrazu jest już otwarty + + + Wybrana operacja wymaga żeby histogram wybranego obrazu był otwarty. + + + Wybrana operacja może być wykonana tylko na obrazach kolorowych. + + + Wybrana operacja może być wykonana tylko na obrazach szaroodcieniowych. + + + Nie udało się załadować obrazu. + + + Nie wybrano obrazka + + + Żaden obraz nie jest otwarty + + \ No newline at end of file diff --git a/JSharp/Resources/Errors.resx b/JSharp/Resources/Errors.resx new file mode 100644 index 0000000..6fab472 --- /dev/null +++ b/JSharp/Resources/Errors.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + The image is already grayscale + + + Histogram for the image is already open. + + + The operation requires for the histogram of the selected image to be open. + + + The selected operation may only be performed on color images. + + + The selected operation may only be performed on grayscale images. + + + Failed to load image. + + + No image is focused + + + No image is open + + \ No newline at end of file diff --git a/JSharp/Resources/Histogram.de.resx b/JSharp/Resources/Histogram.de.resx new file mode 100644 index 0000000..59c0b35 --- /dev/null +++ b/JSharp/Resources/Histogram.de.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Histogramm + + + Pixelanzahl + + + Häufigkeitstabellen zum Histogramm + + \ No newline at end of file diff --git a/JSharp/Resources/Icons/ClearCanvas.ico b/JSharp/Resources/Icons/ToolBar_Icons/ClearCanvas.ico similarity index 100% rename from JSharp/Resources/Icons/ClearCanvas.ico rename to JSharp/Resources/Icons/ToolBar_Icons/ClearCanvas.ico diff --git a/JSharp/Resources/Icons/DrawRectangle.ico b/JSharp/Resources/Icons/ToolBar_Icons/DrawRectangle.ico similarity index 100% rename from JSharp/Resources/Icons/DrawRectangle.ico rename to JSharp/Resources/Icons/ToolBar_Icons/DrawRectangle.ico diff --git a/JSharp/Resources/Icons/icon1.ico b/JSharp/Resources/Icons/ToolBar_Icons/JSharp.ico similarity index 100% rename from JSharp/Resources/Icons/icon1.ico rename to JSharp/Resources/Icons/ToolBar_Icons/JSharp.ico diff --git a/JSharp/Resources/Icons/LineSegment.ico b/JSharp/Resources/Icons/ToolBar_Icons/LineSegment.ico similarity index 100% rename from JSharp/Resources/Icons/LineSegment.ico rename to JSharp/Resources/Icons/ToolBar_Icons/LineSegment.ico diff --git a/JSharp/Resources/Icons/N-A-icon.ico b/JSharp/Resources/Icons/ToolBar_Icons/N-A-icon.ico similarity index 100% rename from JSharp/Resources/Icons/N-A-icon.ico rename to JSharp/Resources/Icons/ToolBar_Icons/N-A-icon.ico diff --git a/JSharp/Resources/Icons/NoneIcon.ico b/JSharp/Resources/Icons/ToolBar_Icons/NoneIcon.ico similarity index 100% rename from JSharp/Resources/Icons/NoneIcon.ico rename to JSharp/Resources/Icons/ToolBar_Icons/NoneIcon.ico diff --git a/JSharp/Resources/Strings.Designer.cs b/JSharp/Resources/Strings.Designer.cs index 936af62..4744419 100644 --- a/JSharp/Resources/Strings.Designer.cs +++ b/JSharp/Resources/Strings.Designer.cs @@ -60,15 +60,6 @@ internal Strings() { } } - /// - /// Looks up a localized string similar to The image is already grayscale. - /// - public static string AlreadyGrayscale_Error { - get { - return ResourceManager.GetString("AlreadyGrayscale_Error", resourceCulture); - } - } - /// /// Looks up a localized string similar to Author:. /// @@ -222,24 +213,6 @@ public static string Grayize { } } - /// - /// Looks up a localized string similar to Histogram for the image is already open.. - /// - public static string HistogramAlreadyOpen { - get { - return ResourceManager.GetString("HistogramAlreadyOpen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The operation requires for the histogram of the selected image to be open.. - /// - public static string HistogramNotOpen { - get { - return ResourceManager.GetString("HistogramNotOpen", resourceCulture); - } - } - /// /// Looks up a localized string similar to Image. /// @@ -267,24 +240,6 @@ public static string ImageCalculator { } } - /// - /// Looks up a localized string similar to The selected operation may only be performed on color images.. - /// - public static string ImageNotColor { - get { - return ResourceManager.GetString("ImageNotColor", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The selected operation may only be performed on grayscale images.. - /// - public static string ImageNotGrayscale { - get { - return ResourceManager.GetString("ImageNotGrayscale", resourceCulture); - } - } - /// /// Looks up a localized string similar to Inpaint. /// @@ -303,15 +258,6 @@ public static string KernelMaskSize { } } - /// - /// Looks up a localized string similar to Failed to load image.. - /// - public static string LoadingFailed { - get { - return ResourceManager.GetString("LoadingFailed", resourceCulture); - } - } - /// /// Looks up a localized string similar to Mask. /// @@ -366,24 +312,6 @@ public static string Negate { } } - /// - /// Looks up a localized string similar to No image is focused. - /// - public static string NoImageFocused { - get { - return ResourceManager.GetString("NoImageFocused", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No image is open. - /// - public static string NoImageOpen { - get { - return ResourceManager.GetString("NoImageOpen", resourceCulture); - } - } - /// /// Looks up a localized string similar to Open. /// @@ -492,6 +420,15 @@ public static string Rhombus { } } + /// + /// Looks up a localized string similar to Rotate. + /// + public static string Rotate { + get { + return ResourceManager.GetString("Rotate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Save. /// diff --git a/JSharp/Resources/Strings.de.resx b/JSharp/Resources/Strings.de.resx new file mode 100644 index 0000000..23fc08a --- /dev/null +++ b/JSharp/Resources/Strings.de.resx @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Autor: + + + Neues Fenster erstellen + + + Wählen Sie die Anzahl der Posterisierungsstufen + + + Konvertieren + + + Konvolvieren + + + Zählen + + + Dilatieren + + + Doppel- und Einzelfaltung + + + Duplikatieren + + + Kantenerkennung (Hough) + + + Umgang mit Kantenpixeln + + + Histogramm äqualisieren + + + Erodieren + + + Fehler + + + Filter + + + GrabCut + + + RGB zu Graustufen + + + Bild + + + Bildverarbeitungsprogramm + + + Bildrechner + + + Inpaint + + + Kernel-/Maskengröße + + + Maske + + + Median + + + Morphologisches Öffnen + + + Morphologische Schließen + + + Elementare morphologische Operationen + + + Negieren + + + Öffnen + + + Graustufen Öffnen + + + RGB Öffnen + + + Helligkeit + + + Handlungsprofil + + + Posterisieren + + + Herunterskalieren + + + Vergrößern + + + Rechteck + + + RGB zu HSV + + + RGB zu LAB + + + Rhombus + + + Drehen + + + Speichern + + + Alles Speichern + + + Speichern als... + + + Histogramm anzeigen + + + Größe + + + Skelettieren + + + Kanäle teilen + + + Stretch-Kontrast + + + Dehnungshistogramm + + + Strukturierendes Element + + + Bild 1: + + + Bild 2: + + + Betrieb: + + + Schwellenwertverfahren + + + Adaptiv + + + Otsu + + + Wasserscheide + + \ No newline at end of file diff --git a/JSharp/Resources/Strings.pl-PL.resx b/JSharp/Resources/Strings.pl-PL.resx index 2057404..7c0f3a0 100644 --- a/JSharp/Resources/Strings.pl-PL.resx +++ b/JSharp/Resources/Strings.pl-PL.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Obraz jest już szaroodcieniowy - Autor: @@ -168,12 +165,6 @@ Konwertuj RGB na Szaroodcieniowy - - Histogram wybranego obrazu jest już otwarty - - - Wybrana operacja wymaga żeby histogram wybranego obrazu był otwarty. - Obraz @@ -183,21 +174,12 @@ Kalkulator Obrazów - - Wybrana operacja może być wykonana tylko na obrazach kolorowych. - - - Wybrana operacja może być wykonana tylko na obrazach szaroodcieniowych. - Inpainting Rozmiar kernela/maski - - Nie udało się załadować obrazu. - Maska @@ -216,12 +198,6 @@ Negacja - - Nie wybrano obrazka - - - Żaden obraz nie jest otwarty - Otwórz @@ -258,6 +234,9 @@ Romb + + Obróć + Zapisz diff --git a/JSharp/Resources/Strings.resx b/JSharp/Resources/Strings.resx index 47952f1..40214f6 100644 --- a/JSharp/Resources/Strings.resx +++ b/JSharp/Resources/Strings.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - The image is already grayscale - Author: @@ -171,12 +168,6 @@ RGB to Grayscale - - Histogram for the image is already open. - - - The operation requires for the histogram of the selected image to be open. - Image @@ -186,21 +177,12 @@ Image Calculator - - The selected operation may only be performed on color images. - - - The selected operation may only be performed on grayscale images. - Inpaint Kernel/Mask Size - - Failed to load image. - Mask @@ -219,12 +201,6 @@ Negate - - No image is focused - - - No image is open - Open @@ -261,6 +237,9 @@ Rhombus + + Rotate + Save diff --git a/JSharp/Resources/UIStrings.de.resx b/JSharp/Resources/UIStrings.de.resx new file mode 100644 index 0000000..501da7f --- /dev/null +++ b/JSharp/Resources/UIStrings.de.resx @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Über + + + Übernehmen + + + Abbrechen + + + Bestätigen + + + Beenden + + + Datei + + + Hilfe + + + Einstellungen + + \ No newline at end of file diff --git a/JSharp/Validation/Validators/AlreadyGrayscaleErrorValidator.cs b/JSharp/Validation/Validators/AlreadyGrayscaleErrorValidator.cs index 73c3596..3b8509a 100644 --- a/JSharp/Validation/Validators/AlreadyGrayscaleErrorValidator.cs +++ b/JSharp/Validation/Validators/AlreadyGrayscaleErrorValidator.cs @@ -20,7 +20,7 @@ public string Validate() { if (numberOfChannels == Constants.Grayscale_ChannelCount) { - return Strings.AlreadyGrayscale_Error; + return Errors.AlreadyGrayscale_Error; } return null; // No error message if condition is met } diff --git a/JSharp/Validation/Validators/HistogramOpenValidator.cs b/JSharp/Validation/Validators/HistogramOpenValidator.cs index a53a2e0..bda1633 100644 --- a/JSharp/Validation/Validators/HistogramOpenValidator.cs +++ b/JSharp/Validation/Validators/HistogramOpenValidator.cs @@ -22,7 +22,7 @@ public string Validate() { if (histogramWindowViewModel == null) { - return Strings.HistogramNotOpen; + return Errors.HistogramNotOpen; } return null; // No error message if condition is met } diff --git a/JSharp/Validation/Validators/ImageFocusedValidator.cs b/JSharp/Validation/Validators/ImageFocusedValidator.cs index 2f622b4..da95e5a 100644 --- a/JSharp/Validation/Validators/ImageFocusedValidator.cs +++ b/JSharp/Validation/Validators/ImageFocusedValidator.cs @@ -21,7 +21,7 @@ public string Validate() { if (focusedImage == null) { - return Strings.NoImageFocused; + return Errors.NoImageFocused; } return null; // No error message if condition is met } diff --git a/JSharp/Validation/Validators/ImageGrayScaleValidator.cs b/JSharp/Validation/Validators/ImageGrayScaleValidator.cs index 9d024e3..be06e10 100644 --- a/JSharp/Validation/Validators/ImageGrayScaleValidator.cs +++ b/JSharp/Validation/Validators/ImageGrayScaleValidator.cs @@ -21,7 +21,7 @@ public string Validate() { if (numberOfChannels != Constants.Grayscale_ChannelCount) { - return Strings.ImageNotGrayscale; + return Errors.ImageNotGrayscale; } return null; // No error message if condition is met } diff --git a/JSharp/Validation/Validators/ImageNotGrayScaleValidator.cs b/JSharp/Validation/Validators/ImageNotGrayScaleValidator.cs index 803a324..a4ef41e 100644 --- a/JSharp/Validation/Validators/ImageNotGrayScaleValidator.cs +++ b/JSharp/Validation/Validators/ImageNotGrayScaleValidator.cs @@ -21,7 +21,7 @@ public string Validate() { if (numberOfChannels == Constants.Grayscale_ChannelCount) { - return Strings.AlreadyGrayscale_Error; + return Errors.AlreadyGrayscale_Error; } return null; // No error message if condition is met } diff --git a/JSharp/Validation/Validators/ImageXyzValidator.cs b/JSharp/Validation/Validators/ImageXyzValidator.cs index 4895c39..4668975 100644 --- a/JSharp/Validation/Validators/ImageXyzValidator.cs +++ b/JSharp/Validation/Validators/ImageXyzValidator.cs @@ -20,7 +20,7 @@ public string Validate() { if (numberOfChannels == Constants.XYZ_ChannelCount) { - return Strings.AlreadyGrayscale_Error; + return Errors.AlreadyGrayscale_Error; } return null; // No error message if condition is met } diff --git a/JSharp/ViewModels/MainWindowViewModel.cs b/JSharp/ViewModels/MainWindowViewModel.cs index a31863c..eaa28e3 100644 --- a/JSharp/ViewModels/MainWindowViewModel.cs +++ b/JSharp/ViewModels/MainWindowViewModel.cs @@ -102,6 +102,7 @@ public System.Windows.Controls.RadioButton SelectedButton public DelegateCommand GrabCut_ClickCommand { get; } public DelegateCommand DetailedAnalyze_ClickCommand { get; } public DelegateCommand OpenSettings_ClickCommand { get; } + public DelegateCommand Rotate_ClickCommand { get; } #endregion public MainWindowViewModel() @@ -146,6 +147,7 @@ public MainWindowViewModel() GrabCut_ClickCommand = new DelegateCommand(GrabCut_Click); DetailedAnalyze_ClickCommand = new DelegateCommand(DetailedAnalyze_Click); OpenSettings_ClickCommand = new DelegateCommand(OpenSettings_Click); + Rotate_ClickCommand = new DelegateCommand(Rotate_Click); #endregion } @@ -285,7 +287,7 @@ private void Duplicate_Click() } else { - MessageBox.Show(Strings.LoadingFailed); + MessageBox.Show(Errors.LoadingFailed); } } } @@ -363,7 +365,7 @@ internal void Save() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -374,7 +376,7 @@ private void SaveAs_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -385,7 +387,7 @@ private void SaveAll_Click() { if (OpenImageWindows == null || OpenImageWindows.Count == 0) { - MessageBox.Show(Strings.NoImageOpen, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageOpen, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -399,7 +401,7 @@ private void SaveAll_Click() private void Negate_Click() { Func condition = () => FocusedImage == null ? false : true; - string? errorMessage = ValidationManager.ValidateCondition(Strings.NoImageFocused, condition); + string? errorMessage = ValidationManager.ValidateCondition(Errors.NoImageFocused, condition); if (errorMessage != null) { MessageBox.Show(errorMessage, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); @@ -443,17 +445,17 @@ private void ShowHistogram_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.histogramWindowViewModel != null) { - MessageBox.Show(Strings.HistogramAlreadyOpen, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.HistogramAlreadyOpen, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } FocusedImage.MakeHistogram(); @@ -463,12 +465,12 @@ private void ConvertRgbToHsv_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.XYZ_ChannelCount) { - MessageBox.Show(Strings.ImageNotColor, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotColor, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } FocusedImage.ConvertToRgb(ColorSpaceType.HSV); @@ -480,12 +482,12 @@ private void SplitChannels_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.XYZ_ChannelCount) { - MessageBox.Show(Strings.ImageNotColor, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotColor, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } DisplaySplitChannels(FocusedImage.ColorSpaceType); @@ -543,12 +545,12 @@ private void ConvertRgbToLab_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.XYZ_ChannelCount) { - MessageBox.Show(Strings.ImageNotColor, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotColor, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -615,12 +617,12 @@ private void Posterize_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -640,12 +642,12 @@ private void Convolve_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -666,12 +668,12 @@ private void Median_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -692,7 +694,7 @@ private void ImageCalculator_Click() { if (OpenImageWindows == null || OpenImageWindows.Count == 0) { - MessageBox.Show(Strings.NoImageOpen, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageOpen, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -710,7 +712,7 @@ private void ImageCalculator_Click() if (img1.NumberOfChannels != Constants.Grayscale_ChannelCount || img2.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -747,12 +749,12 @@ private void DoubleConvolve_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -777,7 +779,7 @@ private void Erode_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -804,7 +806,7 @@ private void Dilate_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -831,7 +833,7 @@ private void MorphologicalOpen_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -858,7 +860,7 @@ private void MorphologicalClose_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -885,12 +887,12 @@ private void Threshold_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -906,7 +908,7 @@ private void SimpleAnalyze_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -921,7 +923,7 @@ private void Analyze_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -946,7 +948,7 @@ private void Skeletonize_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } (int[] data, _) = ImageProcessingCore.CalculateHistogramValues(FocusedImage.MatImage); @@ -963,7 +965,7 @@ private void Hough_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -974,7 +976,7 @@ private void PlotProfile_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } var points = FocusedImage.Points.Select(p => p.Value).ToArray(); @@ -985,7 +987,7 @@ private void PlotProfile_Click() } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -1000,7 +1002,7 @@ public void PyramidUp_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -1026,7 +1028,7 @@ private void PyramidDown_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -1048,16 +1050,27 @@ private void PyramidDown_Click() } } + private void Rotate_Click() + { + if (FocusedImage == null) + { + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + FocusedImage.Rotate(); + } + private void SimpleThreshold_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) { - MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -1073,7 +1086,7 @@ private void Watershed_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } @@ -1107,7 +1120,7 @@ private void GrabCut_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } var points = FocusedImage.Points.Select(p => p.Value).ToArray(); @@ -1118,7 +1131,7 @@ private void GrabCut_Click() } //else if (FocusedImage.MatImage.NumberOfChannels != Constants.Grayscale_ChannelCount) //{ - // MessageBox.Show(Strings.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + // MessageBox.Show(Errors.ImageNotGrayscale, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); // return; //} @@ -1154,7 +1167,7 @@ private void DetailedAnalyze_Click() { if (FocusedImage == null) { - MessageBox.Show(Strings.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show(Errors.NoImageFocused, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } diff --git a/JSharp/ViewModels/NewImageWindowViewModel.cs b/JSharp/ViewModels/NewImageWindowViewModel.cs index 4018ad2..a051ed0 100644 --- a/JSharp/ViewModels/NewImageWindowViewModel.cs +++ b/JSharp/ViewModels/NewImageWindowViewModel.cs @@ -188,6 +188,8 @@ internal void ScaleZoom(bool isZoomIn) ZoomScale *= MainWindowViewModel.CumulativeZoomChange; else ZoomScale /= MainWindowViewModel.CumulativeZoomChange; + + UpdateWindowSize(); } public void UpdateImageSource(Mat newImage) @@ -201,8 +203,8 @@ public void UpdateImageSource(Mat newImage) private void UpdateWindowSize() { - this.Width = Source.Width + widthAdjustmentConst; - this.Height = Source.Height + heightAdjustmentConst; + this.Width = (Source.Width * ZoomScale) + widthAdjustmentConst; + this.Height = (Source.Height * ZoomScale) + heightAdjustmentConst; } #endregion @@ -523,6 +525,14 @@ internal void PyramidDown() UpdateImageSource(image); UpdateWindowSize(); } + + internal void Rotate() + { + Mat image = this.MatImage; + CvInvoke.Rotate(image, image, RotateFlags.Rotate90Clockwise); + UpdateImageSource(image); + UpdateWindowSize(); + } #endregion } } diff --git a/JSharp/Views/MainWindow.xaml b/JSharp/Views/MainWindow.xaml index 6d46d1c..b79ac09 100644 --- a/JSharp/Views/MainWindow.xaml +++ b/JSharp/Views/MainWindow.xaml @@ -49,6 +49,7 @@ + @@ -98,7 +99,7 @@ - + @@ -106,7 +107,7 @@ - + @@ -114,7 +115,7 @@ - + @@ -123,7 +124,7 @@ - + diff --git a/JSharp/config.json b/JSharp/config.json index 5fcfe26..e69de29 100644 --- a/JSharp/config.json +++ b/JSharp/config.json @@ -1,3 +0,0 @@ -{ - "Language": "Default" -} \ No newline at end of file