diff --git a/CutList/Forms/BinFileSaver.cs b/CutList/Forms/BinFileSaver.cs index eab8f55..f43174e 100644 --- a/CutList/Forms/BinFileSaver.cs +++ b/CutList/Forms/BinFileSaver.cs @@ -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"; diff --git a/SawCut/ArchUnits.cs b/SawCut/ArchUnits.cs index 5bbf4fc..e55965b 100644 --- a/SawCut/ArchUnits.cs +++ b/SawCut/ArchUnits.cs @@ -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) { diff --git a/SawCut/Bin.cs b/SawCut/Bin.cs index ea0fc30..1542faa 100644 --- a/SawCut/Bin.cs +++ b/SawCut/Bin.cs @@ -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"; diff --git a/SawCut/Helper.cs b/SawCut/FormatHelper.cs similarity index 60% rename from SawCut/Helper.cs rename to SawCut/FormatHelper.cs index a84ffa5..3d167cd 100644 --- a/SawCut/Helper.cs +++ b/SawCut/FormatHelper.cs @@ -1,10 +1,18 @@ -using System; -using System.Drawing; +using System; namespace SawCut { - public static class Helper + /// + /// Provides formatting utilities for displaying measurements and values. + /// + public static class FormatHelper { + /// + /// Converts a decimal measurement to a mixed fraction string representation. + /// + /// The decimal value to convert + /// The denominator precision (default 32 for 1/32") + /// A string in the format "whole-numerator/denominator" public static string ConvertToMixedFraction(decimal input, int precision = 32) { // Get the whole number part @@ -30,6 +38,11 @@ namespace SawCut return $"{wholeNumber}-{numerator}/{denominator}"; } + /// + /// Converts a double measurement to a mixed fraction string representation. + /// + /// The double value to convert + /// A string in the format "whole-numerator/denominator" public static string ConvertToMixedFraction(double input) { return ConvertToMixedFraction((decimal)input); @@ -46,4 +59,4 @@ namespace SawCut return Math.Abs(a); } } -} \ No newline at end of file +}