Skip to content

Commit 644a861

Browse files
format and cleanup
1 parent a8d7aa7 commit 644a861

69 files changed

Lines changed: 177 additions & 203 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
189 Bytes
Loading
48 Bytes
Loading

CoreBuilder/Extensions/WhoAmIExtension.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public sealed class WhoAmIExtension : ICommandExtension
3131
public string Namespace => "System";
3232

3333
/// <inheritdoc />
34-
public CommandResult Invoke(ICommand command, string[] extensionArgs, Func<string[], CommandResult> executor, string[] commandArgs)
34+
public CommandResult Invoke(ICommand command, string[] extensionArgs, Func<string[], CommandResult> executor,
35+
string[] commandArgs)
3536
{
3637
if (extensionArgs.Length == 0)
3738
{

CoreBuilder/UI/LogWindow.xaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
<!-- Log Area -->
3333
<ScrollViewer x:Name="ScrollViewer"
3434
VerticalScrollBarVisibility="Auto">
35-
<TextBox x:Name="LogText"
36-
Cursor="Arrow"
37-
IsReadOnly="True"
38-
Focusable="True"
39-
FontFamily="Consolas"
40-
TextWrapping="Wrap"
41-
Margin="10" />
35+
<TextBox x:Name="LogText"
36+
Cursor="Arrow"
37+
IsReadOnly="True"
38+
Focusable="True"
39+
FontFamily="Consolas"
40+
TextWrapping="Wrap"
41+
Margin="10" />
4242
</ScrollViewer>
4343
</DockPanel>
4444
</Window>

DataFormatter/FormatterApiFacade.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22
* COPYRIGHT: See COPYING in the top level directory
33
* PROJECT: DataFormatter
44
* FILE: FormatterApiFacade.cs
5-
* PURPOSE: Api Facade for the DataFormatter library
5+
* PURPOSE: Api Façade for the DataFormatter library
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/
88

9+
// ReSharper disable UnusedMember.Global
10+
// ReSharper disable UnusedType.Global
11+
912
using System.Collections.Generic;
13+
using System.Threading.Tasks;
14+
1015

1116
namespace DataFormatter
1217
{
18+
/// <summary>
19+
/// Central API Façade for the DataFormatter library
20+
/// </summary>
1321
public static class FormatterApiFacade
1422
{
1523
/// <summary>
@@ -26,7 +34,8 @@ public static class FormatterApiFacade
2634
/// <param name="file">The file.</param>
2735
/// <param name="data">The data.</param>
2836
/// <param name="sep">The sep.</param>
29-
public static void WriteCsv(string file, IEnumerable<List<string>> data, string sep) => CsvHandler.WriteCsv(file, data, sep);
37+
public static void WriteCsv(string file, IEnumerable<List<string>> data, string sep) =>
38+
CsvHandler.WriteCsv(file, data, sep);
3039

3140
/// <summary>
3241
/// Reads the CSV with layers.
@@ -52,20 +61,20 @@ public static void WriteCsvWithLayers(string file, char sep, List<List<string>>
5261
/// </summary>
5362
/// <param name="path">The path.</param>
5463
/// <returns>the values as String[]. Can return null.</returns>
55-
public static IEnumerable<string> ReadFile(string path) => ReadText.ReadFile(path);
64+
public static IEnumerable<string>? ReadFile(string path) => ReadText.ReadFile(path);
5665

5766
/// <summary>
5867
/// Writes the file.
5968
/// </summary>
6069
/// <param name="path">The path.</param>
6170
/// <param name="content">The content.</param>
62-
public static void WriteFile(string path, IEnumerable<string> content) => ReadText.WriteFile(path, content);
71+
public static async Task WriteFile(string path, IEnumerable<string> content) => await ReadText.WriteFile(path, content);
6372

6473
/// <summary>
6574
/// Reads the object.
6675
/// </summary>
6776
/// <param name="path">The path.</param>
6877
/// <returns>Readable Obj File</returns>
69-
public static ObjFile ReadObj(string path) => ReaderObj.ReadObj(path);
78+
public static ObjFile? ReadObj(string path) => ReaderObj.ReadObj(path);
7079
}
7180
}

Imaging/Helpers/FileHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal static class FileHelper
2323
/// <summary>
2424
/// The number regex
2525
/// </summary>
26-
private static readonly Regex _numberRegex = new Regex(@"\d+", RegexOptions.Compiled);
26+
private static readonly Regex NumberRegex = new(@"\d+", RegexOptions.Compiled);
2727

2828
/// <summary>
2929
/// Gets the files by extension full path.
@@ -103,7 +103,7 @@ internal static List<string> SortNaturally(this IEnumerable<string> paths)
103103
/// <returns>Extracted numbers.</returns>
104104
private static int ExtractNumber(string name)
105105
{
106-
var match = _numberRegex.Match(name);
106+
var match = NumberRegex.Match(name);
107107
return match.Success ? int.Parse(match.Value) : int.MaxValue;
108108
}
109109
}

Imaging/Helpers/FiltersStream.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ private static Bitmap ApplySobel(Bitmap originalImage)
330330
{
331331
for (var i = -1; i <= 1; i++)
332332
{
333-
var pixel = sourceBuffer.GetPixel(x + i, y + j);
334333
var (r, g, b, a) = sourceBuffer.GetPixel(x + i, y + j);
335334

336335
int grayValue = r; // grayscale

Imaging/Helpers/ImageStreamHsv.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
*/
88

99
using System;
10-
using System.Collections.Generic;
11-
using System.Diagnostics;
1210
using System.Drawing;
1311

1412
namespace Imaging.Helpers
@@ -111,26 +109,5 @@ private static Bitmap ProcessImage(Bitmap image, Action<ColorHsv> pixelOp)
111109

112110
return result.Bitmap;
113111
}
114-
115-
116-
/// <summary>
117-
/// Applies the pixel changes.
118-
/// </summary>
119-
/// <param name="result">The result.</param>
120-
/// <param name="pixelsToSet">The pixels to set.</param>
121-
/// <returns>Processed Image</returns>
122-
private static Bitmap ApplyPixelChanges(DirectBitmap result, List<(int x, int y, Color color)> pixelsToSet)
123-
{
124-
try
125-
{
126-
result.SetPixelsSimd(pixelsToSet);
127-
return result.Bitmap;
128-
}
129-
catch (Exception ex)
130-
{
131-
Trace.WriteLine($"{ImagingResources.ErrorPixel} {ex.Message}");
132-
return null;
133-
}
134-
}
135112
}
136113
}

Imaging/ImageGifInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public sealed class FrameInfo
145145
/// <value>
146146
/// The delay time.
147147
/// </value>
148-
public double DelayTime { get; set; } // Delay time in seconds
148+
public double DelayTime { get; init; } // Delay time in seconds
149149

150150

151151
/// <summary>

Imaging/ImagingFacade.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66
* PROGRAMER: Peter Geinitz (Wayfarer)
77
*/
88

9+
// ReSharper disable UnusedMember.Global
10+
// ReSharper disable UnusedType.Global
11+
912
using System;
1013
using System.Collections.Generic;
1114
using System.Drawing;
1215
using System.Drawing.Imaging;
16+
using System.Linq;
1317
using System.Threading.Tasks;
1418
using System.Windows.Media.Imaging;
1519
using Imaging.Enums;
1620

1721
namespace Imaging
1822
{
1923
/// <summary>
20-
/// Unified facade for the Imaging engine.
24+
/// Unified façade for the Imaging engine.
2125
/// This class provides a stable public API for common image processing tasks,
2226
/// including loading, saving, conversion, resizing, filtering, pixel manipulation,
2327
/// GIF handling, blending, and texture generation.
@@ -26,8 +30,8 @@ namespace Imaging
2630
/// </summary>
2731
public static class ImagingFacade
2832
{
29-
3033
#region Register
34+
3135
/// <summary>
3236
/// Gets the singleton instance of the <see cref="ImageRegister"/>.
3337
/// Allows querying and modifying filter and texture settings globally.
@@ -46,7 +50,8 @@ public static class ImagingFacade
4650
/// </summary>
4751
/// <param name="filter">The filter type.</param>
4852
/// <param name="config">The new filter configuration.</param>
49-
public static void SetFilterSettings(FiltersType filter, FiltersConfig config) => Register.SetSettings(filter, config);
53+
public static void SetFilterSettings(FiltersType filter, FiltersConfig config) =>
54+
Register.SetSettings(filter, config);
5055

5156
/// <summary>
5257
/// Retrieves all available filters.
@@ -73,7 +78,8 @@ public static class ImagingFacade
7378
/// </summary>
7479
/// <param name="texture">The texture type.</param>
7580
/// <param name="config">The new texture configuration.</param>
76-
public static void SetTextureSettings(TextureType texture, TextureConfiguration config) => Register.SetSettings(texture, config);
81+
public static void SetTextureSettings(TextureType texture, TextureConfiguration config) =>
82+
Register.SetSettings(texture, config);
7783

7884
/// <summary>
7985
/// Gets the property names used by a specific texture type.
@@ -104,6 +110,7 @@ public static class ImagingFacade
104110
/// Gets the last error message recorded by the Imaging engine.
105111
/// </summary>
106112
public static string? LastError => Register.LastError;
113+
107114
#endregion
108115

109116
#region Load / Save
@@ -191,7 +198,7 @@ public static Bitmap Crop(Bitmap image, int x, int y, int width, int height)
191198
/// <param name="image">The source bitmap.</param>
192199
/// <param name="filter">The filter type to apply.</param>
193200
/// <returns>The filtered <see cref="Bitmap"/>.</returns>
194-
public static Bitmap ApplyFilter(Bitmap image, FiltersType filter)
201+
public static Bitmap? ApplyFilter(Bitmap image, FiltersType filter)
195202
=> new ImageRender().FilterImage(image, filter);
196203

197204
/// <summary>
@@ -203,7 +210,8 @@ public static Bitmap ApplyFilter(Bitmap image, FiltersType filter)
203210
/// <param name="shapeParams">Optional parameters for the mask shape.</param>
204211
/// <param name="startPoint">Optional start point for the filter.</param>
205212
/// <returns>The filtered <see cref="Bitmap"/>.</returns>
206-
public static Bitmap ApplyFilterArea(Bitmap image, FiltersType filter, MaskShape shape, object shapeParams, System.Drawing.Point? startPoint = null)
213+
public static Bitmap ApplyFilterArea(Bitmap image, FiltersType filter, MaskShape shape, object shapeParams,
214+
Point? startPoint = null)
207215
=> new ImageRender().FilterImageArea(image, null, null, filter, shape, shapeParams, startPoint);
208216

209217
#endregion
@@ -216,7 +224,7 @@ public static Bitmap ApplyFilterArea(Bitmap image, FiltersType filter, MaskShape
216224
/// <param name="image">The bitmap.</param>
217225
/// <param name="p">The pixel location.</param>
218226
/// <returns>The <see cref="Color"/> of the pixel.</returns>
219-
public static Color GetPixel(Bitmap image, System.Drawing.Point p)
227+
public static Color GetPixel(Bitmap image, Point p)
220228
=> new ImageRender().GetPixel(image, p);
221229

222230
/// <summary>
@@ -225,7 +233,7 @@ public static Color GetPixel(Bitmap image, System.Drawing.Point p)
225233
/// <param name="image">The bitmap.</param>
226234
/// <param name="p">The pixel location.</param>
227235
/// <param name="color">The color to set.</param>
228-
public static void SetPixel(Bitmap image, System.Drawing.Point p, Color color)
236+
public static void SetPixel(Bitmap image, Point p, Color color)
229237
=> new ImageRender().SetPixel(image, p, color);
230238

231239
/// <summary>
@@ -250,7 +258,7 @@ public static void FloodFill(Bitmap image, int x, int y, Color newColor)
250258
/// <param name="x">X-coordinate for overlay placement.</param>
251259
/// <param name="y">Y-coordinate for overlay placement.</param>
252260
/// <returns>The combined <see cref="Bitmap"/>.</returns>
253-
public static Bitmap Combine(Bitmap baseImage, Bitmap overlay, int x, int y)
261+
public static Bitmap? Combine(Bitmap baseImage, Bitmap overlay, int x, int y)
254262
=> new ImageRender().CombineBitmap(baseImage, overlay, x, y);
255263

256264
/// <summary>
@@ -316,8 +324,7 @@ public static async Task<IReadOnlyList<Bitmap>> LoadGifAsync(string path)
316324
var sources = await new ImageRender().LoadGifAsync(path);
317325

318326
var frames = new List<Bitmap>(sources.Count);
319-
foreach (var src in sources)
320-
frames.Add(ImageExtension.ToBitmap((BitmapImage)src));
327+
frames.AddRange(sources.Select(src => ((BitmapImage)src).ToBitmap()));
321328

322329
return frames;
323330
}
@@ -344,7 +351,8 @@ public static void CreateGif(IEnumerable<FrameInfo> frames, string target)
344351
/// <param name="shapeParams">Optional parameters for the shape.</param>
345352
/// <param name="startPoint">Optional starting point.</param>
346353
/// <returns>The generated texture as a <see cref="Bitmap"/>.</returns>
347-
public static Bitmap GenerateTexture(int width, int height, TextureType type, MaskShape shape, object shapeParams, System.Drawing.Point? startPoint = null)
354+
public static Bitmap? GenerateTexture(int width, int height, TextureType type, MaskShape shape,
355+
object shapeParams, Point? startPoint = null)
348356
=> new TextureGenerator().GenerateTexture(width, height, type, shape, startPoint, shapeParams);
349357

350358
#endregion

0 commit comments

Comments
 (0)