diff --git a/Tests/Controller/Elements/ItemsTest.cs b/Tests/Controller/Elements/ItemsTest.cs index 8b3b861..8bfc489 100755 --- a/Tests/Controller/Elements/ItemsTest.cs +++ b/Tests/Controller/Elements/ItemsTest.cs @@ -24,6 +24,7 @@ using Microsoft.Office.Interop.Word; using zaaReloaded2.LabModel; using zaaReloaded2.Formatter; using zaa = zaaReloaded2.Controller.Elements; +using System.Text.RegularExpressions; namespace Tests.Controller.Elements { @@ -62,8 +63,10 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Na, K, Cl")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + - "Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r"); + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + "Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r") + ); Assert.AreEqual(expected, _document.Range().Text); } @@ -82,8 +85,10 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + - "Klinische Chemie: Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r"); + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + "Klinische Chemie: Na 133, K 6 (5)\r\r").Replace(Environment.NewLine, "\r") + ); Assert.AreEqual(expected, _document.Range().Text); } @@ -120,7 +125,9 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, *")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + ) + "Klinische Chemie: Na 133, Cl 110, K 6\r\r").Replace(Environment.NewLine, "\r"); Assert.AreEqual(expected, _document.Range().Text); } @@ -142,7 +149,9 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + )+ "Klinische Chemie: Na 133, SU-Protein 2,8\r\r").Replace(Environment.NewLine, "\r"); Assert.AreEqual(expected, _document.Range().Text); } @@ -164,10 +173,19 @@ namespace Tests.Controller.Elements _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, SU-*, *")); _formatter.Run(); string expected = ( - TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + + StripMarkup( + TimePointFormatter.DateAndTimeHeader(new DateTime(2015, 07, 13, 13, 31, 00)) + ) + "Klinische Chemie: Na 133, SU-Protein 2,8, Cl 110, U-Na 99\r\r") .Replace(Environment.NewLine, "\r"); Assert.AreEqual(expected, _document.Range().Text); } + + static string StripMarkup(string s) + { + return _markupStripper.Replace(s, string.Empty); + } + + static readonly Regex _markupStripper = new Regex(@"<[^>]+>"); } } diff --git a/Tests/Formatter/DocumentWriterTest.cs b/Tests/Formatter/DocumentWriterTest.cs index f3e201e..bb74e46 100755 --- a/Tests/Formatter/DocumentWriterTest.cs +++ b/Tests/Formatter/DocumentWriterTest.cs @@ -21,6 +21,7 @@ using System.Linq; using System.Text; using NUnit.Framework; using zaaReloaded2.Formatter; +using Microsoft.Office.Interop.Word; namespace Tests.Formatter { @@ -95,5 +96,15 @@ namespace Tests.Formatter Assert.IsFalse(_docWriter.HasBufferedText); Assert.AreEqual(String.Empty, _docWriter.ToString()); } + + [Test] + public void TextMarkup() + { + DocumentWriter output = new DocumentWriter(); + _docWriter.Parent = output; + _docWriter.Write("This is not bold. This is bold!\rThis not."); + _docWriter.Flush(); + Assert.AreEqual("This is not bold. This is bold!\rThis not.", output.Text); + } } } diff --git a/Tests/ViewModels/SettingsRepositoryViewModelTest.cs b/Tests/ViewModels/SettingsRepositoryViewModelTest.cs index ff434a1..afa5ddc 100755 --- a/Tests/ViewModels/SettingsRepositoryViewModelTest.cs +++ b/Tests/ViewModels/SettingsRepositoryViewModelTest.cs @@ -65,7 +65,12 @@ namespace Tests.ViewModels Assert.AreNotSame(orig, copy); Assert.AreNotSame(orig.RevealModelObject(), copy.RevealModelObject()); - Assert.AreEqual(String.Format("Kopie von {0}", orig.Name), copy.Name); + Assert.AreEqual( + String.Format( + "Kopie von {0}", + orig.Name.Replace(" (eingebaut)", String.Empty) + ), + copy.Name); Assert.IsTrue(copy.IsSelected); } } diff --git a/gimp/icon.xcf b/gimp/icon.xcf new file mode 100644 index 0000000..3974acf Binary files /dev/null and b/gimp/icon.xcf differ diff --git a/gimp/installbanner-small.xcf b/gimp/installbanner-small.xcf new file mode 100644 index 0000000..40ea3b1 Binary files /dev/null and b/gimp/installbanner-small.xcf differ diff --git a/gimp/installbanner.xcf b/gimp/installbanner.xcf new file mode 100644 index 0000000..aa5ebdd Binary files /dev/null and b/gimp/installbanner.xcf differ diff --git a/publish/setup-files/icon.bmp b/publish/setup-files/icon.bmp new file mode 100644 index 0000000..980b4c4 Binary files /dev/null and b/publish/setup-files/icon.bmp differ diff --git a/publish/setup-files/icon.ico b/publish/setup-files/icon.ico new file mode 100644 index 0000000..1f2373d Binary files /dev/null and b/publish/setup-files/icon.ico differ diff --git a/publish/setup-files/installbanner-small.bmp b/publish/setup-files/installbanner-small.bmp new file mode 100644 index 0000000..2a8c4f8 Binary files /dev/null and b/publish/setup-files/installbanner-small.bmp differ diff --git a/publish/setup-files/installbanner.bmp b/publish/setup-files/installbanner.bmp new file mode 100644 index 0000000..57054f2 Binary files /dev/null and b/publish/setup-files/installbanner.bmp differ diff --git a/publish/zaaReloaded2.iss b/publish/zaaReloaded2.iss index 8f60c05..9988d0d 100755 --- a/publish/zaaReloaded2.iss +++ b/publish/zaaReloaded2.iss @@ -67,9 +67,9 @@ AppSupportURL=http://zaa.nephrowiki.de AppUpdatesURL=http://zaa.nephrowiki.de ; Setup wizard -;SetupIconFile=setup-files\xltoolbox.ico -;WizardImageFile=setup-files\installbanner.bmp -;WizardSmallImageFile=setup-files\icon-48.bmp +SetupIconFile=setup-files\icon.ico +WizardImageFile=setup-files\installbanner.bmp +WizardSmallImageFile=setup-files\installbanner-small.bmp ArchitecturesAllowed=x86 x64 ArchitecturesInstallIn64BitMode=x64 DisableProgramGroupPage=true diff --git a/zaaReloaded2/Controller/Elements/Items.cs b/zaaReloaded2/Controller/Elements/Items.cs index 151237e..61f403d 100755 --- a/zaaReloaded2/Controller/Elements/Items.cs +++ b/zaaReloaded2/Controller/Elements/Items.cs @@ -199,6 +199,7 @@ namespace zaaReloaded2.Controller.Elements // item with itemName. ItemFormatter i = tpf.ItemFormatters[name]; i.HasBeenUsed = true; + i.IncludeMaterial = false; items.Add(i); } return items; diff --git a/zaaReloaded2/Defaults/ward.zaaReloaded b/zaaReloaded2/Defaults/ward.zaaReloaded index fe9677f..540b40e 100755 --- a/zaaReloaded2/Defaults/ward.zaaReloaded +++ b/zaaReloaded2/Defaults/ward.zaaReloaded @@ -3,19 +3,19 @@ 1 -<_a>-1732917544 -<_b>21822 -<_c>16721 -<_d>134 -<_e>250 -<_f>231 -<_g>106 -<_h>44 -<_i>93 -<_j>252 -<_k>234 +<_a>1443045381 +<_b>29162 +<_c>17774 +<_d>182 +<_e>243 +<_f>111 +<_g>227 +<_h>16 +<_i>47 +<_j>142 +<_k>57 -Station neu +Kopie von Standard für Station IfSpecialOrAbnormal 4 @@ -43,7 +43,7 @@ 1 -17 +16 @@ -76,11 +76,9 @@ - - -zaaReloaded2.Controller.Elements.NextColumn +zaaReloaded2.Controller.Elements.NextColumn 4 @@ -89,13 +87,13 @@ 0 -zaaReloaded2.Controller.Elements.SelectLastDay +zaaReloaded2.Controller.Elements.SelectLastDay 4 1 -17 +16 @@ -128,81 +126,75 @@ - - -zaaReloaded2.Controller.Elements.Items +zaaReloaded2.Controller.Elements.Items 4 1 -Klinische Chemie: Na, K, Cl, Mg, Ca, P, CaxP, Alb, Prot, Haptoglobin, LDH, Glukose, Harnsäure +Klinische Chemie: Na, K, Cl, Mg, Ca, P, CaxP, Alb, Prot, Haptoglobin, LDH, Glukose, Harnsäure 1 -Entzündung/Immunsystem: CRP, Pct, C3c, C4, Anti-DNAse B, ASL +Entzündung/Immunsystem: CRP, Pct, C3c, C4, Anti-DNAse B, ASL 1 -Kardiale Marker: CK, CKMB, Trop, NTproBNP +Kardiale Marker: CK, CKMB, Trop, NTproBNP 1 -Niere: Krea, Hst, eGFR (CKD-EPI) +Niere: Krea, Hst, eGFR (CKD-EPI) 1 -Sammelurin: SU-Proteinurie, SU-Alb, SU-CrCl, SU-HstCl, SU-GFR, SU-Natrium, SU-Zeit, SU-Volumen +Sammelurin: SU-Proteinurie, SU-Alb, SU-CrCl, SU-HstCl, SU-GFR, SU-Natrium, SU-Zeit, SU-Volumen 1 -Spot-Urin: U-* +Spot-Urin: U-* 1 -Leber: GOT, GGT, GPT, AP, Bilirubin, CHE +Leber: GOT, GGT, GPT, AP, Bilirubin, CHE 1 -Blutfette: TG, Chol, LDL, HDL, Lp(a) +Blutfette: TG, Chol, LDL, HDL, Lp(a) 1 -Hämatologie: Hb, Hkt, Reti, Leu, Thr, MCV, HbA1c, Retikulozyten, Fragmentozyten +Hämatologie: Hb, Hkt, Reti, Leu, Thr, Ery, Neu, Lym, Mon, Baso, Eos, MCV, HbA1c, Retikulozyten, Fragmentozyten 1 -Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa +Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa 1 -Diff.-BB: Ery, Neu, Lym, Mon, Baso, Eos +Hormone: iPTH, TSH 1 -Hormone: iPTH, TSH +Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin 1 -Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin +Eisenhaushalt: Eisen, Ferritin, Transferrin, Tf.-Sätt. 1 -Eisenhaushalt: Eisen, Ferritin, Transferrin, Tf.-Sätt. +BGA: pH, Std.-Bic., BE 1 -BGA: pH, Std.-Bic., BE +Hepatitis-Serologie: Anti-HBs, Anti-HBc 1 -Hepatitis-Serologie: Anti-HBs, Anti-HBc - - -1 -Weitere Werte: * +Weitere Werte: * diff --git a/zaaReloaded2/Formatter/DanielsStyle.cs b/zaaReloaded2/Formatter/DanielsStyle.cs index 8da4d84..0907d6e 100755 --- a/zaaReloaded2/Formatter/DanielsStyle.cs +++ b/zaaReloaded2/Formatter/DanielsStyle.cs @@ -79,12 +79,12 @@ namespace zaaReloaded2.Formatter static void FixSalutation(Document document) { - Regex sal = new Regex(@"^Mit.*?Grüßen"); + Regex sal = new Regex(@"^Mit.*?Grüßen\r"); Regex med = new Regex(@"^((Häusl|Empf).*?Medikat)|Therapieempf"); foreach (Paragraph p in document.Paragraphs) { - if (sal.IsMatch(p.Range.Text)) p.Range.Text = "Mit freundlichen, kollegialen Grüßen,"; - if (med.IsMatch(p.Range.Text)) p.Range.Text = "Aktuelle Medikation:"; + if (sal.IsMatch(p.Range.Text)) p.Range.Text = "Mit freundlichen, kollegialen Grüßen,\r"; + if (med.IsMatch(p.Range.Text)) p.Range.Text = "Aktuelle Medikation:\r"; } } } diff --git a/zaaReloaded2/Formatter/DocumentWriter.cs b/zaaReloaded2/Formatter/DocumentWriter.cs index 2c11113..ad1acfd 100755 --- a/zaaReloaded2/Formatter/DocumentWriter.cs +++ b/zaaReloaded2/Formatter/DocumentWriter.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Interop.Word; +using System.Text.RegularExpressions; namespace zaaReloaded2.Formatter { @@ -30,8 +31,19 @@ namespace zaaReloaded2.Formatter /// depending on whether there is text in the buffer or not. /// /// + /// /// Linking several DocumentWriters permits a cascading work flow /// with several buffers. + /// + /// + /// Markup support: The DocumentWriter supports basic markup to control + /// the text styles in the Word document. + /// + /// + /// <b> and </b> - bold/unbold + /// <style:NAME> - set the paragraph or character style + /// </style> - remove *character* style + /// /// class DocumentWriter { @@ -54,10 +66,18 @@ namespace zaaReloaded2.Formatter public bool HasBufferedText { get { return _buffer.Length > 0; } } /// - /// Gets or sets the desired paragraph style when flushing into - /// a Document. + /// Returns text without markup from the buffer. /// - public string ParagraphStyle { get; set; } + public string Text + { + get + { + if (!HasBufferedText) + throw new InvalidOperationException("This DocumentWriter does not have any text."); + + return _markupRegex.Replace(_buffer.ToString(), String.Empty); + } + } #endregion @@ -122,11 +142,7 @@ namespace zaaReloaded2.Formatter Selection s = Document.ActiveWindow.Selection; s.ClearCharacterDirectFormatting(); s.ClearParagraphDirectFormatting(); - if (!string.IsNullOrEmpty(ParagraphStyle)) - { - s.set_Style(ParagraphStyle); - } - s.Range.Text = _buffer.ToString(); + MarkupToDocument(_buffer.ToString()); } if (Parent != null) { @@ -166,9 +182,54 @@ namespace zaaReloaded2.Formatter #endregion + #region Private methods + + /// + /// Parses a string containing markup (e.g., "<b>", "</b>") + /// and writes formatted text to the current Document. + /// + void MarkupToDocument(string text) + { + string[] substrings = _markupRegex.Split(text); + Selection sel = Document.ActiveWindow.Selection; + foreach (string substring in substrings) + { + switch (substring) + { + case "": + sel.Font.Bold = 1; + break; + case "": + sel.Font.Bold = 0; + break; + case "": + sel.ClearCharacterStyle(); + break; + default: + Match styleMatch = _styleRegex.Match(substring); + if (styleMatch.Success) + { + sel.set_Style(styleMatch.Groups["style"].Value); + } + else + { + sel.TypeText(substring); + } + break; + } + } + } + + #endregion + #region Fields StringBuilder _buffer; + // Put pattern in parentheses so they will not be discarded by Regex.Split + // The splitting pattern must not contain subgroups! + static readonly Regex _markupRegex = new Regex(@"(<[^ >]+>)"); + static readonly Regex _styleRegex = new Regex(@"[^>]+)>"); + #endregion } diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index 83c2d02..ebedc68 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -119,10 +119,9 @@ namespace zaaReloaded2.Formatter /// current position of the cursor). public void Run() { - if (!CanRun) throw new InvalidOperationException("No laboratory data to format."); + if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format."); - CreateParagraphStyle(); - _secondaryBuffer.ParagraphStyle = zaaReloaded2.Properties.Settings.Default.ParagraphStyleName; + CreateStyles(); int current = 0; while (current < Settings.Elements.Count) { @@ -242,9 +241,9 @@ namespace zaaReloaded2.Formatter } /// - /// Creates a zaaReloaded2 paragraph style in the document. + /// Creates a paragraph and character styles in the document. /// - public void CreateParagraphStyle() + public void CreateStyles() { if (Document != null) { @@ -253,19 +252,57 @@ namespace zaaReloaded2.Formatter // paragraph style than by using a try...catch construction. try { - style = Document.Styles[Properties.Settings.Default.ParagraphStyleName]; + style = Document.Styles[Properties.Settings.Default.StyleParagraph]; } catch { - style = Document.Styles.Add(Properties.Settings.Default.ParagraphStyleName); + // Add default paragraph style for laboratory + style = Document.Styles.Add(Properties.Settings.Default.StyleParagraph); 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 = 36; // pt style.ParagraphFormat.FirstLineIndent = -36; // pt style.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphJustify; } + + try + { + style = Document.Styles[Properties.Settings.Default.StyleHeader]; + } + catch + { + // Add header paragraph style for laboratory + style = Document.Styles.Add(Properties.Settings.Default.StyleHeader); + 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.StyleParagraph]); + } + + /* + try + { + style = Document.Styles[Properties.Settings.Default.StyleAbnormal]; + } + catch + { + // Add character style for abnormal parameters + style = Document.Styles.Add( + Properties.Settings.Default.StyleAbnormal, + WdStyleType.wdStyleTypeCharacter); + style.Font.Bold = 1; + } + */ } } diff --git a/zaaReloaded2/Formatter/ItemFormatter.cs b/zaaReloaded2/Formatter/ItemFormatter.cs index 17d0bf3..4f6f1d7 100755 --- a/zaaReloaded2/Formatter/ItemFormatter.cs +++ b/zaaReloaded2/Formatter/ItemFormatter.cs @@ -132,7 +132,8 @@ namespace zaaReloaded2.Formatter string unit; if (LabItem.HasUnit) { - unit = String.Format(" {0}", LabItem.Unit); + string space = LabItem.Unit.StartsWith("/") ? String.Empty : " "; + unit = String.Format("{0}{1}", space, LabItem.Unit); } else { @@ -153,15 +154,22 @@ namespace zaaReloaded2.Formatter string name = IncludeMaterial ? LabItem.QualifiedName : LabItem.Name; - // Insert the formatted text into the document. - formatter.Write( + string output = String.Format( "{0} {1}{2}{3}", name, value, unit, reference - )); + ); + if (!LabItem.IsNormal) + { + output = String.Format( + "{0}", + output); + } + + formatter.Write(output); HasBeenUsed = true; } diff --git a/zaaReloaded2/Formatter/NoLaboratoryDataException.cs b/zaaReloaded2/Formatter/NoLaboratoryDataException.cs new file mode 100755 index 0000000..df47011 --- /dev/null +++ b/zaaReloaded2/Formatter/NoLaboratoryDataException.cs @@ -0,0 +1,35 @@ +/* NoLaboratoryDataException.cs + * part of zaaReloaded2 + * + * Copyright 2015 Daniel Kraus + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using System.Runtime.Serialization; + +namespace zaaReloaded2.Formatter +{ + [Serializable] + class NoLaboratoryDataException : Exception + { + public NoLaboratoryDataException() { } + public NoLaboratoryDataException(string message) : base(message) { } + public NoLaboratoryDataException(string message, + Exception innerException) + : base(message, innerException) { } + public NoLaboratoryDataException(SerializationInfo info, + StreamingContext context) + : base(info, context) { } + } +} diff --git a/zaaReloaded2/Formatter/TimePointFormatter.cs b/zaaReloaded2/Formatter/TimePointFormatter.cs index da8b41e..0dccbaf 100755 --- a/zaaReloaded2/Formatter/TimePointFormatter.cs +++ b/zaaReloaded2/Formatter/TimePointFormatter.cs @@ -68,10 +68,12 @@ namespace zaaReloaded2.Formatter static string FormatHeader(string text) { - return String.Format("{0}Laborwerte vom {1}:{2}", - Environment.NewLine, + return String.Format("Laborwerte vom {1}:{2}", + // Environment.NewLine, + Properties.Settings.Default.StyleHeader, text, - Environment.NewLine + Environment.NewLine, + Properties.Settings.Default.StyleParagraph ); } diff --git a/zaaReloaded2/Icons/icon.png b/zaaReloaded2/Icons/icon.png new file mode 100644 index 0000000..9b9024e Binary files /dev/null and b/zaaReloaded2/Icons/icon.png differ diff --git a/zaaReloaded2/LabModel/LabItem.cs b/zaaReloaded2/LabModel/LabItem.cs index 3fc6c7e..4ada2c5 100755 --- a/zaaReloaded2/LabModel/LabItem.cs +++ b/zaaReloaded2/LabModel/LabItem.cs @@ -123,7 +123,8 @@ namespace zaaReloaded2.LabModel public bool HasUpperLimit { get; protected set; } /// - /// Is true if is normal. + /// Is true if is normal. Returns true + /// if no limits and no normal value are known. /// public bool IsNormal { @@ -147,7 +148,7 @@ namespace zaaReloaded2.LabModel } else { - return (Value == Normal); + return String.IsNullOrEmpty(Normal) || (Value == Normal); } } } diff --git a/zaaReloaded2/Properties/Settings.Designer.cs b/zaaReloaded2/Properties/Settings.Designer.cs index bf379f7..d2e1e93 100755 --- a/zaaReloaded2/Properties/Settings.Designer.cs +++ b/zaaReloaded2/Properties/Settings.Designer.cs @@ -127,114 +127,6 @@ namespace zaaReloaded2.Properties { } } - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Klinische Chemie: Na, K, Cl, Mg, Pi, Alb, Prot, LDH, Hsre")] - public string DefaultItemsClinicalChem { - get { - return ((string)(this["DefaultItemsClinicalChem"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Hämatologie: Hb, Hkt, Reti, Leu, Thr, Neu, HbA1c")] - public string DefaultItemsHematology { - get { - return ((string)(this["DefaultItemsHematology"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa")] - public string DefaultItemsCoagulation { - get { - return ((string)(this["DefaultItemsCoagulation"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Spot-Urin: U-*")] - public string DefaultItemsSpotUrine { - get { - return ((string)(this["DefaultItemsSpotUrine"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Sammelurin: SU-*")] - public string DefaultItemsCollectedUrine { - get { - return ((string)(this["DefaultItemsCollectedUrine"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Weitere Werte: *")] - public string DefaultItemsOther { - get { - return ((string)(this["DefaultItemsOther"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Kardiale Marker: CK, CKMB, Trop, NTproBNP")] - public string DefaultItemsCardio { - get { - return ((string)(this["DefaultItemsCardio"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Blutfette: TG, Chol, LDL, HDL, Lp(a)")] - public string DefaultItemsLipids { - get { - return ((string)(this["DefaultItemsLipids"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Leber: GOT, GGT, GPT, AP, Bili, CHE")] - public string DefaultItemsLiver { - get { - return ((string)(this["DefaultItemsLiver"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Niere: Krea, Hst, eGFR")] - public string DefaultItemsKidney { - get { - return ((string)(this["DefaultItemsKidney"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Entzündung/Immunsystem: CRP, Pct, C3, C4")] - public string DefaultItemsInflammation { - get { - return ((string)(this["DefaultItemsInflammation"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin")] - public string DefaultItemsDrugs { - get { - return ((string)(this["DefaultItemsDrugs"])); - } - } - [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("00000000-0000-0000-0000-000000000000")] @@ -250,9 +142,9 @@ namespace zaaReloaded2.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Laborwerte")] - public string ParagraphStyleName { + public string StyleParagraph { get { - return ((string)(this["ParagraphStyleName"])); + return ((string)(this["StyleParagraph"])); } } @@ -303,5 +195,23 @@ namespace zaaReloaded2.Properties { this["ImportExportPath"] = value; } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Überschrift")] + public string StyleHeader { + get { + return ((string)(this["StyleHeader"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2-Pathologisch")] + public string StyleAbnormal { + get { + return ((string)(this["StyleAbnormal"])); + } + } } } diff --git a/zaaReloaded2/Properties/Settings.settings b/zaaReloaded2/Properties/Settings.settings index 45f429b..2ca76ce 100755 --- a/zaaReloaded2/Properties/Settings.settings +++ b/zaaReloaded2/Properties/Settings.settings @@ -35,46 +35,10 @@ Standard für NepA - - Klinische Chemie: Na, K, Cl, Mg, Pi, Alb, Prot, LDH, Hsre - - - Hämatologie: Hb, Hkt, Reti, Leu, Thr, Neu, HbA1c - - - Gerinnung: Quick, INR, PTT, Fibrinogen, ATIII, Anti-Xa - - - Spot-Urin: U-* - - - Sammelurin: SU-* - - - Weitere Werte: * - - - Kardiale Marker: CK, CKMB, Trop, NTproBNP - - - Blutfette: TG, Chol, LDL, HDL, Lp(a) - - - Leber: GOT, GGT, GPT, AP, Bili, CHE - - - Niere: Krea, Hst, eGFR - - - Entzündung/Immunsystem: CRP, Pct, C3, C4 - - - Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin - 00000000-0000-0000-0000-000000000000 - + zaaReloaded2-Laborwerte @@ -92,5 +56,11 @@ + + zaaReloaded2-Überschrift + + + zaaReloaded2-Pathologisch + \ No newline at end of file diff --git a/zaaReloaded2/Ribbon.cs b/zaaReloaded2/Ribbon.cs index 958e328..a556054 100755 --- a/zaaReloaded2/Ribbon.cs +++ b/zaaReloaded2/Ribbon.cs @@ -31,6 +31,9 @@ using zaaReloaded2.ViewModels; using zaaReloaded2.Importer.ZaaImporter; using zaaReloaded2.Formatter; using zaaReloaded2.Controller; +using Word = Microsoft.Office.Interop.Word; +using Bovender.Mvvm.Actions; +using Bovender.Mvvm.Messaging; // TODO: Follow these steps to enable the Ribbon (XML) item: @@ -79,7 +82,8 @@ namespace zaaReloaded2 public void Ribbon_Load(Office.IRibbonUI ribbonUI) { _ribbon = ribbonUI; - Globals.ThisAddIn.Application.WindowSelectionChange += Application_WindowSelectionChange; + Microsoft.Office.Interop.Word.Application word = Globals.ThisAddIn.Application; + word.WindowSelectionChange += Application_WindowSelectionChange; } /// @@ -152,9 +156,19 @@ namespace zaaReloaded2 } } + /// + /// Returns true if there is at least one paragraph selected. + /// + /// + /// The Selection object in Word is a bit tricky: Its Length property + /// is never 0, because even if no text passage is selected, the character + /// after the cursor is the content of the Selection. + /// public bool CanFormat(Office.IRibbonControl control) { - return Globals.ThisAddIn.Application.Selection.Paragraphs.Count > 0; + Word.Selection s = Globals.ThisAddIn.Application.ActiveWindow.Selection; + return s.Paragraphs.Count > 1 || + (s.Text.Length > 1 && s.Text.EndsWith("\r")); } #endregion @@ -182,12 +196,23 @@ namespace zaaReloaded2 void DoFormat(Settings settings) { ZaaImporter importer = new ZaaImporter(); - importer.Import(Globals.ThisAddIn.Application.Selection.Text); - Formatter.Formatter formatter =new Formatter.Formatter( + importer.Import(Globals.ThisAddIn.Application.ActiveWindow.Selection.Text); + Formatter.Formatter formatter = new Formatter.Formatter( Globals.ThisAddIn.Application.ActiveDocument); formatter.Settings = settings; formatter.Laboratory = importer.Laboratory; - formatter.Run(); + try + { + formatter.Run(); + } + catch (NoLaboratoryDataException) + { + NotificationAction a = new NotificationAction(); + a.Caption = "Formatieren nicht möglich"; + a.Message = "Die aktuelle Markierung scheint keine Labordaten zu enthalten."; + a.OkButtonLabel = "Schließen"; + a.Invoke(); + } } void DoChooseSettings() diff --git a/zaaReloaded2/ViewModels/AboutViewModel.cs b/zaaReloaded2/ViewModels/AboutViewModel.cs index 229e7dd..f9e25f5 100755 --- a/zaaReloaded2/ViewModels/AboutViewModel.cs +++ b/zaaReloaded2/ViewModels/AboutViewModel.cs @@ -57,7 +57,7 @@ namespace zaaReloaded2.ViewModels { get { - return String.Format("(c) Copyright {0} {1}", + return String.Format("© Copyright {0} {1}", PubYear, Properties.Settings.Default.Authors); } diff --git a/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs b/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs index 2c1b155..f96350c 100755 --- a/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs +++ b/zaaReloaded2/ViewModels/SettingsRepositoryViewModel.cs @@ -26,6 +26,7 @@ using zaaReloaded2.Controller; using System.Collections.ObjectModel; using System.Runtime.Serialization.Formatters.Soap; using System.IO; +using Microsoft.Office.Interop.Word; namespace zaaReloaded2.ViewModels { @@ -314,7 +315,12 @@ namespace zaaReloaded2.ViewModels bool CanUseSettings() { - return LastSelected != null && LastSelected.IsSelected; + Selection selection = Globals.ThisAddIn.Application.ActiveWindow.Selection; + return LastSelected != null && LastSelected.IsSelected && + ( + selection.Paragraphs.Count > 1 + || (selection.Text.Length > 1 && selection.Text.EndsWith("\r")) + ); } void DoAddSettings() diff --git a/zaaReloaded2/ViewModels/SettingsViewModel.cs b/zaaReloaded2/ViewModels/SettingsViewModel.cs index db33e3f..05af8a2 100755 --- a/zaaReloaded2/ViewModels/SettingsViewModel.cs +++ b/zaaReloaded2/ViewModels/SettingsViewModel.cs @@ -347,7 +347,7 @@ namespace zaaReloaded2.ViewModels picker.ElementChosenMessage.Sent += (sender, args) => { ElementViewModel newVM = args.Content.ViewModel as ElementViewModel; - if (IsTopLevelElement()) + if (LastSelectedElement == null || IsTopLevelElement()) { AddElementViewModel(newVM); } diff --git a/zaaReloaded2/Views/AboutView.xaml b/zaaReloaded2/Views/AboutView.xaml index 7a3683a..8d4b0b6 100755 --- a/zaaReloaded2/Views/AboutView.xaml +++ b/zaaReloaded2/Views/AboutView.xaml @@ -20,7 +20,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="clr-namespace:Bovender.Mvvm.Views.Settings;assembly=Bovender" - SizeToContent="WidthAndHeight" ResizeMode="NoResize" ShowInTaskbar="False" + Width="360" Height="320" ResizeMode="NoResize" ShowInTaskbar="False" b:WindowState.CenterScreen="True" Title="Über..." > @@ -28,13 +28,14 @@ + Homepage: - + Lizenz: diff --git a/zaaReloaded2/Views/ElementView.xaml b/zaaReloaded2/Views/ElementView.xaml index 3212ec7..4117257 100755 --- a/zaaReloaded2/Views/ElementView.xaml +++ b/zaaReloaded2/Views/ElementView.xaml @@ -21,22 +21,23 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:b="clr-namespace:Bovender.Mvvm.Views.Settings;assembly=Bovender" - SizeToContent="WidthAndHeight" ResizeMode="CanResizeWithGrip" ShowInTaskbar="False" + ResizeMode="CanResizeWithGrip" ShowInTaskbar="False" WindowStyle="ToolWindow" Topmost="True" + Width="280" Height="180" MinWidth="280" MinHeight="180" b:WindowState.CenterScreen="True" b:WindowState.Save="True" Title="Element bearbeiten" > - -