Skip to content

Commit 6a82214

Browse files
committed
fix: Scientific Calculator bugs and dependency updates
- Bump version to 0.1.1 - Fix Enter key re-activating last clicked button instead of calculating - Fix unary minus being ignored in calculations - Update Avalonia 11.3.9 → 11.3.10, System.Text.Json 10.0.0 → 10.0.1 - Fix deprecation/platform warnings in AsciiArtGenerator and ImageConverter - Add ".NET" suffix to app title in all localizations
1 parent 83ba0ee commit 6a82214

20 files changed

Lines changed: 71 additions & 299 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.1] - 2025-12-23
9+
10+
### Changed
11+
12+
- Updated Avalonia packages from 11.3.9 to 11.3.10 (required by Flowery.NET).
13+
- Updated System.Text.Json from 10.0.0 to 10.0.1.
14+
- Updated App_Title in all localization files to include ".NET" suffix.
15+
16+
### Fixed
17+
18+
- Fixed deprecation warning in `AsciiArtGenerator.cs` by replacing `SKFilterQuality` with `SKSamplingOptions`.
19+
- Fixed CA1416 platform compatibility warnings in `ImageConverter.cs` by adding `[SupportedOSPlatform("windows")]` attribute.
20+
- Fixed Scientific Calculator: Enter key now always triggers calculation instead of re-activating the last clicked button.
21+
- Fixed Scientific Calculator: Unary minus was being ignored, causing negative results to become positive in subsequent calculations (e.g., `-1522 + 2000` incorrectly returned `3517` instead of `478`).
22+
- App title in all localizations now state ".NET" at the end
23+
824
## [0.1.0] - 2025-12-20
925

1026
### Added

OpenSourceToolkit.Calculators/ScientificCalculator.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private static Queue<string> ShuntingYard(string expression)
2828
{
2929
var outputQueue = new Queue<string>();
3030
var operatorStack = new Stack<string>();
31-
31+
3232
// Tokenize
3333
var tokens = Tokenize(expression);
3434

@@ -51,8 +51,8 @@ private static Queue<string> ShuntingYard(string expression)
5151
}
5252
else if (IsOperator(token))
5353
{
54-
while (operatorStack.Count > 0 &&
55-
IsOperator(operatorStack.Peek()) &&
54+
while (operatorStack.Count > 0 &&
55+
IsOperator(operatorStack.Peek()) &&
5656
GetPrecedence(operatorStack.Peek()) >= GetPrecedence(token))
5757
{
5858
outputQueue.Enqueue(operatorStack.Pop());
@@ -96,11 +96,11 @@ private static List<string> Tokenize(string expression)
9696
{
9797
var tokens = new List<string>();
9898
var buffer = "";
99-
99+
100100
for (int i = 0; i < expression.Length; i++)
101101
{
102102
char c = expression[i];
103-
103+
104104
if (char.IsDigit(c) || c == '.')
105105
{
106106
buffer += c;
@@ -112,7 +112,7 @@ private static List<string> Tokenize(string expression)
112112
tokens.Add(buffer);
113113
buffer = "";
114114
}
115-
115+
116116
if (char.IsLetter(c))
117117
{
118118
// Function or constant
@@ -130,7 +130,7 @@ private static List<string> Tokenize(string expression)
130130
}
131131
}
132132
}
133-
133+
134134
if (!string.IsNullOrEmpty(buffer))
135135
{
136136
tokens.Add(buffer);
@@ -194,20 +194,21 @@ private static double EvaluateRPN(Queue<string> rpn)
194194

195195
private static bool IsOperator(string token)
196196
{
197-
return token == "+" || token == "-" || token == "*" || token == "/" || token == "^" || token == "%";
197+
return token == "+" || token == "-" || token == "*" || token == "/" || token == "^" || token == "%" || token == "neg";
198198
}
199199

200200
private static bool IsFunction(string token)
201201
{
202-
return token == "sin" || token == "cos" || token == "tan" ||
203-
token == "asin" || token == "acos" || token == "atan" ||
204-
token == "sqrt" || token == "log" || token == "ln" ||
205-
token == "abs" || token == "floor" || token == "ceil" ||
202+
return token == "sin" || token == "cos" || token == "tan" ||
203+
token == "asin" || token == "acos" || token == "atan" ||
204+
token == "sqrt" || token == "log" || token == "ln" ||
205+
token == "abs" || token == "floor" || token == "ceil" ||
206206
token == "round" || token == "trunc";
207207
}
208208

209209
private static int GetPrecedence(string op)
210210
{
211+
if (op == "neg") return 5; // Unary negation has highest precedence
211212
if (op == "^") return 4;
212213
if (op == "*" || op == "/" || op == "%") return 3;
213214
if (op == "+" || op == "-") return 2;

OpenSourceToolkit.Converters/ImageConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
using System.Drawing;
33
using System.Drawing.Imaging;
44
using System.IO;
5+
using System.Runtime.Versioning;
56

67
namespace OpenSourceToolkit.Converters
78
{
9+
[SupportedOSPlatform("windows")]
810
public static class ImageConverter
911
{
1012
public static void Convert(string inputPath, string outputPath, ImageFormat format)

OpenSourceToolkit.Media/AsciiArtGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static string ConvertBitmapToAscii(SKBitmap bitmap, int width = 100)
2222
{
2323
var height = (int)(bitmap.Height * ((double)width / bitmap.Width) * 0.55); // 0.55 accounts for char aspect ratio
2424

25-
using var resized = bitmap.Resize(new SKImageInfo(width, height), SKFilterQuality.Medium);
25+
using var resized = bitmap.Resize(new SKImageInfo(width, height), new SKSamplingOptions(SKFilterMode.Linear));
2626
if (resized == null)
2727
throw new InvalidOperationException("Failed to resize image");
2828

OpenSourceToolkit.NET/Localization/ar.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"App_Title": "مجموعة الأدوات المفتوحة",
2+
"App_Title": "مجموعة الأدوات المفتوحة .NET",
33
"App_Subtitle": "مجموعة مفتوحة المصدر من الأدوات اليومية المفيدة",
44
"Sidebar_SearchTools": "بحث في الأدوات...",
55
"Sidebar_Home": "الرئيسية",

OpenSourceToolkit.NET/Localization/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"App_Title": "OpenSource Werkzeugkasten",
2+
"App_Title": "OpenSource Werkzeugkasten .NET",
33
"App_Subtitle": "Open-Source-Sammlung nützlicher Alltagswerkzeuge.",
44
"Sidebar_SearchTools": "Werkzeuge suchen...",
55
"Sidebar_Home": "Startseite",

OpenSourceToolkit.NET/Localization/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"App_Title": "OpenSource Toolkit",
2+
"App_Title": "OpenSource Toolkit .NET",
33
"App_Subtitle": "Open source collection of useful daily utilities.",
44
"Sidebar_SearchTools": "Search tools...",
55
"Sidebar_Home": "Home",

OpenSourceToolkit.NET/Localization/es.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"App_Title": "Kit de herramientas OpenSource",
2+
"App_Title": "Kit de herramientas OpenSource .NET",
33
"App_Subtitle": "Colección de código abierto de utilidades diarias útiles.",
44
"Sidebar_SearchTools": "Buscar herramientas...",
55
"Sidebar_Home": "Inicio",

OpenSourceToolkit.NET/Localization/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"App_Title": "Boîte à outils OpenSource",
2+
"App_Title": "Boîte à outils OpenSource .NET",
33
"App_Subtitle": "Collection open source d'utilitaires quotidiens utiles.",
44
"Sidebar_SearchTools": "Rechercher des outils...",
55
"Sidebar_Home": "Accueil",

OpenSourceToolkit.NET/Localization/he.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"App_Title": "ארגז כלים בקוד פתוח",
2+
"App_Title": "ארגז כלים בקוד פתוח .NET",
33
"App_Subtitle": "אוסף קוד פתוח של כלי עזר יומיומיים שימושיים.",
44
"Sidebar_SearchTools": "חיפוש כלים...",
55
"Sidebar_Home": "דף הבית",

0 commit comments

Comments
 (0)