Refactor Helper to FormatHelper with improved documentation

- Rename Helper class to FormatHelper for clarity
- Add comprehensive XML documentation
- Update all references in BinFileSaver, ArchUnits, and Bin
- Remove unused System.Drawing import
- Better method documentation explaining parameters and return values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
AJ
2025-11-22 23:02:24 -05:00
parent 70f1380847
commit f55092d877
4 changed files with 24 additions and 12 deletions

View File

@@ -25,7 +25,7 @@ namespace CutList.Forms
using (var writer = new StreamWriter(file))
{
writer.AutoFlush = true;
PaddingWidthOfItemLength = _bins.Max(b => b.Items.Max(i => SawCut.Helper.ConvertToMixedFraction(i.Length).Length));
PaddingWidthOfItemLength = _bins.Max(b => b.Items.Max(i => SawCut.FormatHelper.ConvertToMixedFraction(i.Length).Length));
var id = 1;
foreach (var bin in _bins)
@@ -55,8 +55,8 @@ namespace CutList.Forms
private void WriteBinSummary(StreamWriter writer, Bin bin, int id)
{
var totalLength = SawCut.Helper.ConvertToMixedFraction(bin.Length);
var remainingLength = SawCut.Helper.ConvertToMixedFraction(bin.RemainingLength);
var totalLength = SawCut.FormatHelper.ConvertToMixedFraction(bin.Length);
var remainingLength = SawCut.FormatHelper.ConvertToMixedFraction(bin.RemainingLength);
var utilization = Math.Round(bin.Utilization * 100, 2);
writer.WriteLine($"{id}. Length: {totalLength}, {remainingLength} remaining, {bin.Items.Count} items, {utilization}% utilization");
@@ -72,7 +72,7 @@ namespace CutList.Forms
{
var first = group.First();
var count = group.Count();
var length = SawCut.Helper.ConvertToMixedFraction(first.Length).PadLeft(PaddingWidthOfItemLength);
var length = SawCut.FormatHelper.ConvertToMixedFraction(first.Length).PadLeft(PaddingWidthOfItemLength);
var name = first.Name;
var pcsSingularOrPlural = count == 1 ? "pc " : "pcs";

View File

@@ -60,7 +60,7 @@ namespace SawCut
public static string FormatFromInches(double totalInches)
{
var feet = Math.Floor(totalInches / 12.0);
var inches = Helper.ConvertToMixedFraction(totalInches - (feet * 12.0));
var inches = FormatHelper.ConvertToMixedFraction(totalInches - (feet * 12.0));
if (feet > 0)
{

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
namespace SawCut
{
@@ -70,8 +69,8 @@ namespace SawCut
public override string ToString()
{
var totalLength = Helper.ConvertToMixedFraction(Math.Round(Length, 4));
var remainingLength = Helper.ConvertToMixedFraction(Math.Round(RemainingLength, 4));
var totalLength = FormatHelper.ConvertToMixedFraction(Math.Round(Length, 4));
var remainingLength = FormatHelper.ConvertToMixedFraction(Math.Round(RemainingLength, 4));
var utilitation = Math.Round(Utilization * 100, 2);
return $"Length: {totalLength}, {remainingLength} remaining, {Items.Count} items, {utilitation}% utilization";

View File

@@ -1,10 +1,18 @@
using System;
using System.Drawing;
using System;
namespace SawCut
{
public static class Helper
/// <summary>
/// Provides formatting utilities for displaying measurements and values.
/// </summary>
public static class FormatHelper
{
/// <summary>
/// Converts a decimal measurement to a mixed fraction string representation.
/// </summary>
/// <param name="input">The decimal value to convert</param>
/// <param name="precision">The denominator precision (default 32 for 1/32")</param>
/// <returns>A string in the format "whole-numerator/denominator"</returns>
public static string ConvertToMixedFraction(decimal input, int precision = 32)
{
// Get the whole number part
@@ -30,6 +38,11 @@ namespace SawCut
return $"{wholeNumber}-{numerator}/{denominator}";
}
/// <summary>
/// Converts a double measurement to a mixed fraction string representation.
/// </summary>
/// <param name="input">The double value to convert</param>
/// <returns>A string in the format "whole-numerator/denominator"</returns>
public static string ConvertToMixedFraction(double input)
{
return ConvertToMixedFraction((decimal)input);