Make document footer more dynamic
This commit is contained in:
@ -195,5 +195,44 @@ namespace Elwig.Helpers {
|
||||
var d = new ManualWeighingDialog();
|
||||
return d.ShowDialog() == true ? (d.Weight, d.Reason) : null;
|
||||
}
|
||||
|
||||
public static Footer GenerateFooter(string lineBreak, string seperator) {
|
||||
return new Footer(lineBreak, seperator);
|
||||
}
|
||||
|
||||
public class Footer {
|
||||
private string Text = "";
|
||||
private readonly string LineBreak;
|
||||
private readonly string Seperator;
|
||||
private bool FirstLine = true;
|
||||
private bool FirstItemInLine = true;
|
||||
|
||||
public Footer(string lineBreak, string seperator) {
|
||||
LineBreak = lineBreak;
|
||||
Seperator = seperator;
|
||||
}
|
||||
|
||||
public Footer Item(string? text) {
|
||||
if (text == null) return this;
|
||||
Text += FirstItemInLine ? (FirstLine ? "" : LineBreak) : Seperator;
|
||||
Text += text;
|
||||
FirstLine = false;
|
||||
FirstItemInLine = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Footer Item(string name, string? text) {
|
||||
return text == null ? this : Item($"{name}: {text}");
|
||||
}
|
||||
|
||||
public Footer NextLine() {
|
||||
FirstItemInLine = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user