|
|
|
@ -55,18 +55,38 @@ namespace zaaReloaded2.Medication |
|
|
|
|
/// <param name="document"></param> |
|
|
|
|
public void FormatOneColumn(Document document) |
|
|
|
|
{ |
|
|
|
|
if (document == null) |
|
|
|
|
{ |
|
|
|
|
throw new ArgumentNullException( |
|
|
|
|
"Cannot format prescriptions because no document was given."); |
|
|
|
|
} |
|
|
|
|
DoFormat("Medikation einspaltig formatieren", |
|
|
|
|
document, |
|
|
|
|
writer => |
|
|
|
|
{ |
|
|
|
|
foreach (Prescription p in Prescriptions) |
|
|
|
|
{ |
|
|
|
|
writer.WriteLine(p.ToString()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Helpers.StartUndo("Medikation formatieren"); |
|
|
|
|
foreach (Prescription p in Prescriptions) |
|
|
|
|
{ |
|
|
|
|
document.ActiveWindow.Selection.TypeText(p.ToString() + "\r"); |
|
|
|
|
} |
|
|
|
|
Helpers.EndUndo(); |
|
|
|
|
/// <summary> |
|
|
|
|
/// Writes a block of prescriptions with two columns to a |
|
|
|
|
/// Word document. |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="document"></param> |
|
|
|
|
public void FormatTwoColumns(Document document) |
|
|
|
|
{ |
|
|
|
|
DoFormat("Medikation zweispaltig formatieren", |
|
|
|
|
document, |
|
|
|
|
writer => |
|
|
|
|
{ |
|
|
|
|
for (int i = 0; i < Prescriptions.Count; i += 2) |
|
|
|
|
{ |
|
|
|
|
writer.Write(Prescriptions[i].ToString()); |
|
|
|
|
if (i + 1 < Prescriptions.Count) |
|
|
|
|
{ |
|
|
|
|
writer.Write("\t" + Prescriptions[i+1].ToString()); |
|
|
|
|
} |
|
|
|
|
writer.WriteLine(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -77,6 +97,95 @@ namespace zaaReloaded2.Medication |
|
|
|
|
{ |
|
|
|
|
throw new NotImplementedException(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Private methods |
|
|
|
|
|
|
|
|
|
void AddDisclaimer(zaaReloaded2.Formatter.DocumentWriter writer) |
|
|
|
|
{ |
|
|
|
|
writer.WriteLine("<highlight><b>Bitte Medikation überprüfen!</b></highlight>"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Creates a paragraph and character styles in the document. |
|
|
|
|
/// </summary> |
|
|
|
|
void CreateStyles(Document document) |
|
|
|
|
{ |
|
|
|
|
if (document != null) |
|
|
|
|
{ |
|
|
|
|
Style style; |
|
|
|
|
// Don't see a better way to check for the existence of a particular |
|
|
|
|
// paragraph style than by using a try...catch construction. |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
style = document.Styles[Properties.Settings.Default.DrugsParagraph]; |
|
|
|
|
} |
|
|
|
|
catch |
|
|
|
|
{ |
|
|
|
|
// Add default paragraph style for laboratory |
|
|
|
|
style = document.Styles.Add(Properties.Settings.Default.DrugsParagraph); |
|
|
|
|
style.Font.Size = 10; // pt |
|
|
|
|
style.Font.Bold = 0; |
|
|
|
|
style.Font.Italic = 0; |
|
|
|
|
style.Font.Underline = 0; |
|
|
|
|
style.ParagraphFormat.SpaceAfter = 0; |
|
|
|
|
style.ParagraphFormat.SpaceBefore = 0; |
|
|
|
|
style.ParagraphFormat.LeftIndent = 0; // pt |
|
|
|
|
style.ParagraphFormat.FirstLineIndent = 0; // pt |
|
|
|
|
style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft; |
|
|
|
|
style.ParagraphFormat.TabStops.ClearAll(); |
|
|
|
|
int tabStop = 108; // 108 pt = 2.5 in = 3.8 cm |
|
|
|
|
int halfWay = 227; // 227 pt = 3.15 in = 8 cm |
|
|
|
|
style.ParagraphFormat.TabStops.Add(tabStop); |
|
|
|
|
style.ParagraphFormat.TabStops.Add(halfWay); |
|
|
|
|
style.ParagraphFormat.TabStops.Add(halfWay + tabStop); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// try |
|
|
|
|
// { |
|
|
|
|
// style = document.Styles[Properties.Settings.Default.DrugsHeader]; |
|
|
|
|
// } |
|
|
|
|
// catch |
|
|
|
|
// { |
|
|
|
|
// // Add header paragraph style for laboratory |
|
|
|
|
// style = document.Styles.Add(Properties.Settings.Default.DrugsHeader); |
|
|
|
|
// style.Font.Size = 10; // pt |
|
|
|
|
// style.Font.Bold = 1; |
|
|
|
|
// style.Font.Italic = 0; |
|
|
|
|
// style.Font.Underline = WdUnderline.wdUnderlineSingle; |
|
|
|
|
// style.ParagraphFormat.SpaceAfter = 0; |
|
|
|
|
// style.ParagraphFormat.SpaceBefore = 12; |
|
|
|
|
// style.ParagraphFormat.LeftIndent = 36; // pt |
|
|
|
|
// style.ParagraphFormat.FirstLineIndent = -36; // pt |
|
|
|
|
// style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; |
|
|
|
|
// style.set_NextParagraphStyle(document.Styles[Properties.Settings.Default.DrugsParagraph]); |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Does the heavy lifting in a DRY way. |
|
|
|
|
/// </summary> |
|
|
|
|
void DoFormat(string description, Document document, |
|
|
|
|
Action<zaaReloaded2.Formatter.DocumentWriter> outputAction) |
|
|
|
|
{ |
|
|
|
|
if (document == null) |
|
|
|
|
{ |
|
|
|
|
throw new ArgumentNullException( |
|
|
|
|
"Cannot format prescriptions because no document was given."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Helpers.StartUndo(description); |
|
|
|
|
zaaReloaded2.Formatter.DocumentWriter writer = new zaaReloaded2.Formatter.DocumentWriter(document); |
|
|
|
|
CreateStyles(document); |
|
|
|
|
writer.Write(String.Format("<style:{0}>", Properties.Settings.Default.DrugsParagraph)); |
|
|
|
|
outputAction(writer); |
|
|
|
|
AddDisclaimer(writer); |
|
|
|
|
// writer.Write("</style>"); // causes COM exceptions, needs fix |
|
|
|
|
writer.Flush(); |
|
|
|
|
Helpers.EndUndo(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|