Skip to content

Commit 19ee063

Browse files
Fixed bug for minimising to system tray
1 parent a52769e commit 19ee063

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

Chromatics/Forms/Uc_Settings.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,19 +577,31 @@ private void OnResize(object sender, EventArgs e)
577577

578578
private static Image ScaleImage(Image image, int maxWidth, int maxHeight)
579579
{
580+
if (image == null)
581+
throw new ArgumentNullException(nameof(image), "The image parameter cannot be null.");
582+
583+
if (maxWidth <= 0 || maxHeight <= 0)
584+
throw new ArgumentException("maxWidth and maxHeight must be greater than zero.");
585+
580586
var ratioX = (double)maxWidth / image.Width;
581587
var ratioY = (double)maxHeight / image.Height;
582588
var ratio = Math.Min(ratioX, ratioY);
583589

584590
var newWidth = (int)(image.Width * ratio);
585591
var newHeight = (int)(image.Height * ratio);
586592

593+
if (newWidth <= 0 || newHeight <= 0)
594+
throw new ArgumentException("Calculated width and height must be greater than zero.");
595+
587596
var newImage = new Bitmap(newWidth, newHeight);
588597

589598
using (var graphics = Graphics.FromImage(newImage))
599+
{
590600
graphics.DrawImage(image, 0, 0, newWidth, newHeight);
601+
}
591602

592603
return newImage;
593604
}
605+
594606
}
595607
}

Chromatics/Helpers/FileOperationsHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,9 @@ public static string GetCsvData(string url, string csvPath)
607607
return path;
608608
}
609609

610-
#if DEBUG
610+
#if DEBUG
611611
Debug.WriteLine(@"An error occurred downloading the file " + csvPath + @" from URI: " + url);
612-
#endif
612+
#endif
613613

614614
return string.Empty;
615615
}
@@ -626,7 +626,7 @@ public static WeatherData GetUpdatedWeatherData()
626626
// GarlandTools
627627
var dataStoreResult = http.GetAsync(new Uri(@"https://www.garlandtools.org/db/doc/core/en/3/data.json")).GetAwaiter().GetResult();
628628

629-
if (File.Exists(WeatherRateIndicesOutputPath))
629+
if (File.Exists(WeatherKindsOutputPath) && File.Exists(WeatherRateIndicesOutputPath) && File.Exists(TerriTypesOutputPath))
630630
{
631631
var fileInfo = new FileInfo(WeatherRateIndicesOutputPath);
632632
var lastModified = dataStoreResult.Content.Headers.LastModified;

Chromatics/Models/PaletteColorModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,6 @@ public class PaletteColorModel
426426
public ColorMapping WeatherVacuityBase = new("Vacuity (Base)", PaletteTypes.ReactiveWeather, Color.Purple);
427427
public ColorMapping WeatherVacuityHighlight = new("Vacuity (Highlight)", PaletteTypes.ReactiveWeather, Color.Violet);
428428

429-
public ColorMapping WeatherProjectionBase = new("Projection (Base)", PaletteTypes.ReactiveWeather, Color.DeepSkyBlue);
430-
public ColorMapping WeatherProjectionHighlight = new("Projection (Highlight)", PaletteTypes.ReactiveWeather, Color.Aqua);
431-
432429
public ColorMapping WeatherReminiscenceBase = new("Reminiscence (Base)", PaletteTypes.ReactiveWeather, Color.Gold);
433430
public ColorMapping WeatherReminiscenceHighlight = new("Reminiscence (Highlight)", PaletteTypes.ReactiveWeather, Color.Yellow);
434431

0 commit comments

Comments
 (0)