diff --git a/Tests/Formatter/Elements/ItemsTest.cs b/Tests/Formatter/Elements/ItemsTest.cs index 56f49fb..4a6cce7 100755 --- a/Tests/Formatter/Elements/ItemsTest.cs +++ b/Tests/Formatter/Elements/ItemsTest.cs @@ -23,7 +23,7 @@ using NUnit.Framework; using Microsoft.Office.Interop.Word; using zaaReloaded2.LabModel; using zaaReloaded2.Formatter; -using zaa = zaaReloaded2.Formatter.Elements; +using zaa = zaaReloaded2.Controller.Elements; namespace Tests.Formatter.Elements { @@ -55,9 +55,9 @@ namespace Tests.Formatter.Elements // We do not add a 'Cl' item, and it should not appear in output. lab.AddTimePoint(tp); - _formatter.ReferenceStyle = ReferenceStyle.IfAbnormal; + _formatter.Settings.ReferenceStyle = ReferenceStyle.IfAbnormal; _formatter.Laboratory = lab; - _formatter.Elements.Add(new zaa.Items("Na, K, Cl")); + _formatter.Settings.Elements.Add(new zaa.Items("Na, K, Cl")); _formatter.Run(); Assert.AreEqual("Na 133, K 6 (5)\r", _formatter.Document.Range().Text); } @@ -73,9 +73,9 @@ namespace Tests.Formatter.Elements // We do not add a 'Cl' item, and it should not appear in output. lab.AddTimePoint(tp); - _formatter.ReferenceStyle = ReferenceStyle.IfAbnormal; + _formatter.Settings.ReferenceStyle = ReferenceStyle.IfAbnormal; _formatter.Laboratory = lab; - _formatter.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl")); + _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: Na, K, Cl")); _formatter.Run(); Assert.AreEqual("Klinische Chemie: Na 133, K 6 (5)\r", _formatter.Document.Range().Text); } @@ -91,9 +91,9 @@ namespace Tests.Formatter.Elements // We do not add a 'Cl' item, and it should not appear in output. lab.AddTimePoint(tp); - _formatter.ReferenceStyle = ReferenceStyle.IfAbnormal; + _formatter.Settings.ReferenceStyle = ReferenceStyle.IfAbnormal; _formatter.Laboratory = lab; - _formatter.Elements.Add(new zaa.Items("Klinische Chemie: this, does, not, exist")); + _formatter.Settings.Elements.Add(new zaa.Items("Klinische Chemie: this, does, not, exist")); _formatter.Run(); Assert.AreEqual("\r", _formatter.Document.Range().Text); } diff --git a/Tests/Formatter/FormatterTest.cs b/Tests/Formatter/FormatterTest.cs index eb150c5..18fb188 100755 --- a/Tests/Formatter/FormatterTest.cs +++ b/Tests/Formatter/FormatterTest.cs @@ -23,6 +23,7 @@ using NUnit.Framework; using f = zaaReloaded2.Formatter; using zaaReloaded2.LabModel; using zaaReloaded2.Importer.ZaaImporter; +using zaaReloaded2.Controller.Elements; using Microsoft.Office.Interop.Word; namespace Tests.Formatter @@ -37,7 +38,7 @@ namespace Tests.Formatter ZaaImporter importer = TestHelpers.ZaaImporterFromResource(); f.Formatter formatter = new f.Formatter(document); formatter.Laboratory = importer.Laboratory; - formatter.Elements.Add(new f.Elements.Items("Klinische Chemie: Na, K, Cl")); + formatter.Settings.Elements.Add(new Items("Klinische Chemie: Na, K, Cl")); formatter.Run(); Assert.AreEqual("Klinische Chemie: Na 144 mM, K 4,3 mM\r", document.Range().Text); ((_Document)document).Close(WdSaveOptions.wdDoNotSaveChanges); diff --git a/zaaReloaded2/Formatter/Elements/ElementBase.cs b/zaaReloaded2/Controller/Elements/ElementBase.cs similarity index 90% rename from zaaReloaded2/Formatter/Elements/ElementBase.cs rename to zaaReloaded2/Controller/Elements/ElementBase.cs index 82d62c3..ae91011 100755 --- a/zaaReloaded2/Formatter/Elements/ElementBase.cs +++ b/zaaReloaded2/Controller/Elements/ElementBase.cs @@ -22,13 +22,13 @@ using System.Text; using Microsoft.Office.Interop.Word; using zaaReloaded2.LabModel; -namespace zaaReloaded2.Formatter.Elements +namespace zaaReloaded2.Controller.Elements { /// /// Base class for formatting elements. /// [Serializable] - abstract class ElementBase + public abstract class ElementBase { /// /// Returns the label for this formatting element. @@ -43,6 +43,6 @@ namespace zaaReloaded2.Formatter.Elements /// Formatter object that this /// Element belongs to. The Formatter object provides access /// to the current Word document etc. - abstract public void Run(Formatter formatter); + abstract public void Run(zaaReloaded2.Formatter.Formatter formatter); } } diff --git a/zaaReloaded2/Formatter/Elements/Items.cs b/zaaReloaded2/Controller/Elements/Items.cs similarity index 96% rename from zaaReloaded2/Formatter/Elements/Items.cs rename to zaaReloaded2/Controller/Elements/Items.cs index b4f2664..1b6702e 100755 --- a/zaaReloaded2/Formatter/Elements/Items.cs +++ b/zaaReloaded2/Controller/Elements/Items.cs @@ -20,16 +20,18 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; +using System.Diagnostics; using Microsoft.Office.Interop.Word; using zaaReloaded2.LabModel; -using System.Diagnostics; +using zaaReloaded2.Formatter; -namespace zaaReloaded2.Formatter.Elements +namespace zaaReloaded2.Controller.Elements { /// /// This formatting element is concerned with writing s /// to a Word document. /// + [Serializable] class Items : ElementBase { #region ElementBase implementation @@ -39,7 +41,7 @@ namespace zaaReloaded2.Formatter.Elements get { return Line; } } - public override void Run(Formatter formatter) + public override void Run(zaaReloaded2.Formatter.Formatter formatter) { bool _needComma = false; diff --git a/zaaReloaded2/Controller/Settings.cs b/zaaReloaded2/Controller/Settings.cs new file mode 100755 index 0000000..e3d947d --- /dev/null +++ b/zaaReloaded2/Controller/Settings.cs @@ -0,0 +1,56 @@ +/* Settings.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.Collections.Generic; +using System.Linq; +using System.Text; +using zaaReloaded2.Formatter; +using zaaReloaded2.Controller.Elements; + +namespace zaaReloaded2.Controller +{ + /// + /// Holds settings related to controlling laboratory output. + /// + [Serializable] + public class Settings + { + #region Properties + + /// + /// Gets or sets the reference style. + /// + public ReferenceStyle ReferenceStyle { get; set; } + + /// + /// Gets the list of controlling elements. + /// + public IList Elements { get; private set; } + + #endregion + + #region Constructor + + public Settings() + { + Elements = new List(); + } + + #endregion + } +} diff --git a/zaaReloaded2/Formatter/Elements/ElementsList.cs b/zaaReloaded2/Formatter/Elements/ElementsList.cs deleted file mode 100755 index 966122e..0000000 --- a/zaaReloaded2/Formatter/Elements/ElementsList.cs +++ /dev/null @@ -1,29 +0,0 @@ -/* ElementsList.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.Collections.Generic; -using System.Linq; -using System.Text; - -namespace zaaReloaded2.Formatter.Elements -{ - [Serializable] - class ElementsList : List - { - } -} diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs index f8f65c5..cf15cc7 100755 --- a/zaaReloaded2/Formatter/Formatter.cs +++ b/zaaReloaded2/Formatter/Formatter.cs @@ -19,37 +19,28 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using Microsoft.Office.Interop.Word; -using zaaReloaded2.Formatter.Elements; -using zaaReloaded2.LabModel; using System.Diagnostics; +using Microsoft.Office.Interop.Word; +using zaaReloaded2.LabModel; +using zaaReloaded2.Controller; +using zaaReloaded2.Controller.Elements; namespace zaaReloaded2.Formatter { /// /// Formats and writes a to a Word document. /// - [Serializable] - class Formatter + public class Formatter { #region Properties - /// - /// Gets a list of formatting elements (derived from - /// ). - /// - public ElementsList Elements { get; private set; } + public Settings Settings { get; set; } /// /// Gets the working Word document. /// public Document Document { get; private set; } - /// - /// Gets or sets the style of the normal range reference. - /// - public ReferenceStyle ReferenceStyle { get; set; } - /// /// Gets or sets the that shall be /// formatted. @@ -67,7 +58,8 @@ namespace zaaReloaded2.Formatter _timePointFormatters = new TimePointFormatterDictionary(); foreach (TimePoint tp in _laboratory.TimePoints.Values) { - _timePointFormatters[tp.TimeStamp] = new TimePointFormatter(tp, ReferenceStyle); + _timePointFormatters[tp.TimeStamp] = + new TimePointFormatter(tp, Settings.ReferenceStyle); } } } @@ -83,7 +75,7 @@ namespace zaaReloaded2.Formatter public Formatter() { - Elements = new ElementsList(); + Settings = new Settings(); } public Formatter(Document document) @@ -104,7 +96,7 @@ namespace zaaReloaded2.Formatter public void Run() { WorkingTimePoints = _timePointFormatters; - foreach (ElementBase element in Elements) + foreach (ElementBase element in Settings.Elements) { element.Run(this); } diff --git a/zaaReloaded2/zaaReloaded2.csproj b/zaaReloaded2/zaaReloaded2.csproj index d4f42e9..86f2fd1 100755 --- a/zaaReloaded2/zaaReloaded2.csproj +++ b/zaaReloaded2/zaaReloaded2.csproj @@ -163,8 +163,8 @@ can be found. --> + - @@ -176,8 +176,8 @@ - - + +