feat(fax): Fax machines print, copy, and send paper labels (#25979)

* feat(fax): Client fax file-print parses and stores label

* feat(fax): Fax machines print, copy, and send paper labels

* style(Fax): Comments and formatting

* feat(fax): Make fax admin logging more consistent and clear

* refactor(fax): Replace ternary with a simpler null coalescing

* refactor(fax): Make FaxSystem Send method signature consistent with Copy, PrintFile

* refactor(fax): Read entire file and process later instead of peeking first

* refactor(fax): Remove local variables only used for style

* style(fax): Fix some nearby style errors

* fix(fax): Undo an inaccurate change to admin log formatting

* refactor(fax): Separate `firstLine` variable

* fix(fax): Use Environment.NewLine

* bienvenidos

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
exincore
2024-04-28 01:12:45 -05:00
committed by GitHub
parent 5c817ddfc1
commit faa7f3461c
7 changed files with 72 additions and 17 deletions

View File

@@ -40,7 +40,7 @@ public sealed class FaxBoundUi : BoundUserInterface
{
if (_dialogIsOpen)
return;
_dialogIsOpen = true;
var filters = new FileDialogFilters(new FileDialogFilters.Group("txt"));
await using var file = await _fileDialogManager.OpenFile(filters);
@@ -52,8 +52,27 @@ public sealed class FaxBoundUi : BoundUserInterface
}
using var reader = new StreamReader(file);
var firstLine = await reader.ReadLineAsync();
string? label = null;
var content = await reader.ReadToEndAsync();
SendMessage(new FaxFileMessage(content[..Math.Min(content.Length, FaxFileMessageValidation.MaxContentSize)], _window.OfficePaper));
if (firstLine is { })
{
if (firstLine.StartsWith('#'))
{
label = firstLine[1..].Trim();
}
else
{
content = firstLine + "\n" + content;
}
}
SendMessage(new FaxFileMessage(
label?[..Math.Min(label.Length, FaxFileMessageValidation.MaxLabelSize)],
content[..Math.Min(content.Length, FaxFileMessageValidation.MaxContentSize)],
_window.OfficePaper));
}
private void OnSendButtonPressed()