Implement styling of abnormal values.

- NEU: Auszeichnung pathologischer Werte kann eingestellt werden.
This commit is contained in:
Daniel Kraus 2015-08-24 23:17:49 +02:00
parent b8b96af9bb
commit cde32f0a7e
13 changed files with 170 additions and 11 deletions

View File

@ -81,6 +81,12 @@ namespace zaaReloaded2.Controller
/// </summary> /// </summary>
public ReferenceStyle ReferenceStyle { get; set; } public ReferenceStyle ReferenceStyle { get; set; }
/// <summary>
/// Gets or sets the style in which abnormal values
/// are formatted.
/// </summary>
public AbnormalStyle AbnormalStyle { get; set; }
/// <summary> /// <summary>
/// Gets the list of controlling elements. /// Gets the list of controlling elements.
/// </summary> /// </summary>
@ -156,6 +162,10 @@ namespace zaaReloaded2.Controller
Uid = (Guid)info.GetValue("Uid", typeof(Guid)); Uid = (Guid)info.GetValue("Uid", typeof(Guid));
Name = info.GetString("Name"); Name = info.GetString("Name");
ReferenceStyle = (ReferenceStyle)info.GetValue("ReferenceStyle", typeof(ReferenceStyle)); ReferenceStyle = (ReferenceStyle)info.GetValue("ReferenceStyle", typeof(ReferenceStyle));
if (version >= 2)
{
AbnormalStyle = (AbnormalStyle)info.GetValue("AbnormalStyle", typeof(AbnormalStyle));
}
int elementsCount = info.GetInt32("ElementsCount"); int elementsCount = info.GetInt32("ElementsCount");
Elements = new List<ElementBase>(); Elements = new List<ElementBase>();
for (int i = 0; i < elementsCount; i++) for (int i = 0; i < elementsCount; i++)
@ -190,6 +200,7 @@ namespace zaaReloaded2.Controller
Elements.Select(e => e.Clone() as ElementBase).ToList() Elements.Select(e => e.Clone() as ElementBase).ToList()
); );
clone.ReferenceStyle = ReferenceStyle; clone.ReferenceStyle = ReferenceStyle;
clone.AbnormalStyle = AbnormalStyle;
return clone; return clone;
} }
@ -203,6 +214,7 @@ namespace zaaReloaded2.Controller
info.AddValue("Uid", Uid); info.AddValue("Uid", Uid);
info.AddValue("Name", Name); info.AddValue("Name", Name);
info.AddValue("ReferenceStyle", ReferenceStyle); info.AddValue("ReferenceStyle", ReferenceStyle);
info.AddValue("AbnormalStyle", AbnormalStyle);
info.AddValue("ElementsCount", Elements.Count); info.AddValue("ElementsCount", Elements.Count);
int i = 0; int i = 0;
foreach (ElementBase e in Elements) foreach (ElementBase e in Elements)

View File

@ -0,0 +1,62 @@
/* AbnormalStyle.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.ComponentModel;
using System.Linq;
using System.Text;
namespace zaaReloaded2.Formatter
{
/// <summary>
/// Defines styling for abnormal laboratory values
/// </summary>
[Flags]
public enum AbnormalStyle
{
[Description("Keine Auszeichnung")]
None = 0x00,
[Description("Fett")]
Bold = 0x01,
[Description("Kursiv")]
Italics = 0x02
}
public static class AbnormalStyleExtensions
{
/// <summary>
/// Converts an AbnormalStyle value to textual markup.
/// </summary>
/// <param name="style">AbnormalStyle value.</param>
/// <param name="close">Indicates whether to return an opening or a closing
/// tag.</param>
/// <returns>Markup that is understood by a DocumentWriter.</returns>
public static string ToMarkup(this AbnormalStyle style, bool close)
{
string markup = String.Empty;
string dash = close ? "/" : String.Empty;
if (style.HasFlag(AbnormalStyle.Bold))
markup += String.Format("<{0}b>", dash);
if (style.HasFlag(AbnormalStyle.Italics))
markup += String.Format("<{0}i>", dash);
return markup;
}
}
}

View File

@ -202,6 +202,12 @@ namespace zaaReloaded2.Formatter
case "</b>": case "</b>":
sel.Font.Bold = 0; sel.Font.Bold = 0;
break; break;
case "<i>":
sel.Font.Italic = 1;
break;
case "</i>":
sel.Font.Italic = 0;
break;
case "</style>": case "</style>":
sel.ClearCharacterStyle(); sel.ClearCharacterStyle();
break; break;

View File

@ -54,7 +54,7 @@ namespace zaaReloaded2.Formatter
foreach (TimePoint tp in _laboratory.TimePoints.Values) foreach (TimePoint tp in _laboratory.TimePoints.Values)
{ {
_timePointFormatters[tp.TimeStamp] = _timePointFormatters[tp.TimeStamp] =
new TimePointFormatter(tp, Settings.ReferenceStyle); new TimePointFormatter(tp, Settings.ReferenceStyle, Settings.AbnormalStyle);
} }
} }
} }

View File

@ -41,6 +41,11 @@ namespace zaaReloaded2.Formatter
/// </summary> /// </summary>
public ReferenceStyle ReferenceStyle { get; set; } public ReferenceStyle ReferenceStyle { get; set; }
/// <summary>
/// Gets or sets the style to use for abnormal values.
/// </summary>
public AbnormalStyle AbnormalStyle { get; set; }
/// <summary> /// <summary>
/// Gets or sets a flag that indicates whether this ItemFormatter /// Gets or sets a flag that indicates whether this ItemFormatter
/// has been used, i.e. whether the LabItem was written to a /// has been used, i.e. whether the LabItem was written to a
@ -73,11 +78,14 @@ namespace zaaReloaded2.Formatter
/// Creates a new ItemFormatter that wraps a <paramref name="labItem"/>. /// Creates a new ItemFormatter that wraps a <paramref name="labItem"/>.
/// </summary> /// </summary>
/// <param name="labItem">LabItem to wrap in this ItemFormatter.</param> /// <param name="labItem">LabItem to wrap in this ItemFormatter.</param>
public ItemFormatter(LabItem labItem, ReferenceStyle referenceStyle) public ItemFormatter(LabItem labItem,
ReferenceStyle referenceStyle,
AbnormalStyle abnormalStyle)
{ {
IncludeMaterial = true; IncludeMaterial = true;
LabItem = labItem; LabItem = labItem;
ReferenceStyle = referenceStyle; ReferenceStyle = referenceStyle;
AbnormalStyle = abnormalStyle;
} }
#endregion #endregion
@ -164,9 +172,7 @@ namespace zaaReloaded2.Formatter
); );
if (!LabItem.IsNormal) if (!LabItem.IsNormal)
{ {
output = String.Format( output = AbnormalStyle.ToMarkup(false) + output + AbnormalStyle.ToMarkup(true);
"<b>{0}</b>",
output);
} }
formatter.Write(output); formatter.Write(output);

View File

@ -103,13 +103,16 @@ namespace zaaReloaded2.Formatter
/// </summary> /// </summary>
/// <param name="timePoint">TimePoint whose LabItems will be /// <param name="timePoint">TimePoint whose LabItems will be
/// used to create ItemFormatter objects.</param> /// used to create ItemFormatter objects.</param>
public TimePointFormatter(TimePoint timePoint, ReferenceStyle referenceStyle) public TimePointFormatter(TimePoint timePoint,
ReferenceStyle referenceStyle,
AbnormalStyle abnormalStyle)
{ {
TimeStamp = timePoint.TimeStamp; TimeStamp = timePoint.TimeStamp;
ItemFormatters = new ItemFormatterDictionary(); ItemFormatters = new ItemFormatterDictionary();
foreach (LabItem item in timePoint.Items.Values) foreach (LabItem item in timePoint.Items.Values)
{ {
ItemFormatters[item.QualifiedName] = new ItemFormatter(item, referenceStyle); ItemFormatters[item.QualifiedName] = new ItemFormatter(
item, referenceStyle, abnormalStyle);
} }
} }

View File

@ -177,7 +177,7 @@ namespace zaaReloaded2.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("1")] [global::System.Configuration.DefaultSettingValueAttribute("2")]
public int SerializationVersion { public int SerializationVersion {
get { get {
return ((int)(this["SerializationVersion"])); return ((int)(this["SerializationVersion"]));
@ -213,5 +213,14 @@ namespace zaaReloaded2.Properties {
return ((string)(this["StyleAbnormal"])); return ((string)(this["StyleAbnormal"]));
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("None")]
public global::zaaReloaded2.Formatter.AbnormalStyle AbnormalStyle {
get {
return ((global::zaaReloaded2.Formatter.AbnormalStyle)(this["AbnormalStyle"]));
}
}
} }
} }

View File

@ -51,7 +51,7 @@
<Value Profile="(Default)">Steuerungs-Elemente</Value> <Value Profile="(Default)">Steuerungs-Elemente</Value>
</Setting> </Setting>
<Setting Name="SerializationVersion" Type="System.Int32" Scope="Application"> <Setting Name="SerializationVersion" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">1</Value> <Value Profile="(Default)">2</Value>
</Setting> </Setting>
<Setting Name="ImportExportPath" Type="System.String" Scope="User"> <Setting Name="ImportExportPath" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
@ -62,5 +62,8 @@
<Setting Name="StyleAbnormal" Type="System.String" Scope="Application"> <Setting Name="StyleAbnormal" Type="System.String" Scope="Application">
<Value Profile="(Default)">zaaReloaded2-Pathologisch</Value> <Value Profile="(Default)">zaaReloaded2-Pathologisch</Value>
</Setting> </Setting>
<Setting Name="AbnormalStyle" Type="zaaReloaded2.Formatter.AbnormalStyle" Scope="Application">
<Value Profile="(Default)">None</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -116,6 +116,52 @@ namespace zaaReloaded2.ViewModels
} }
} }
/// <summary>
/// Gets or sets whether abnormal values shall be formatted in bold.
/// </summary>
public bool AbnormalBold
{
get
{
return _settings.AbnormalStyle.HasFlag(AbnormalStyle.Bold);
}
set
{
if (value)
{
_settings.AbnormalStyle |= AbnormalStyle.Bold;
}
else
{
_settings.AbnormalStyle &= ~AbnormalStyle.Bold;
}
OnPropertyChanged("AbnormalBold");
}
}
/// <summary>
/// Gets or sets whether abnormal values shall be formatted in italics.
/// </summary>
public bool AbnormalItalics
{
get
{
return _settings.AbnormalStyle.HasFlag(AbnormalStyle.Italics);
}
set
{
if (value)
{
_settings.AbnormalStyle |= AbnormalStyle.Italics;
}
else
{
_settings.AbnormalStyle &= ~AbnormalStyle.Italics;
}
OnPropertyChanged("AbnormalItalics");
}
}
#endregion #endregion
#region Constructors #region Constructors

View File

@ -91,7 +91,7 @@
Margin="0 5 5 5"> Margin="0 5 5 5">
<Image Source="/zaaReloaded2;component/Icons/reset.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/reset.png" Width="24" />
</Button> </Button>
<Button Command="{Binding CloseViewCommand}" ToolTip="Schließen" Margin="5 5 0 5"> <Button Command="{Binding CloseViewCommand}" ToolTip="Schließen" IsCancel="True" Margin="5 5 0 5">
<Image Source="/zaaReloaded2;component/Icons/exit.png" Width="24" /> <Image Source="/zaaReloaded2;component/Icons/exit.png" Width="24" />
</Button> </Button>
</UniformGrid> </UniformGrid>

View File

@ -60,6 +60,14 @@
SelectedItem="{Binding ReferenceStyle.SelectedItem}" SelectedItem="{Binding ReferenceStyle.SelectedItem}"
x:Name="ReferenceStyleChooser" HorizontalAlignment="Stretch" /> x:Name="ReferenceStyleChooser" HorizontalAlignment="Stretch" />
</DockPanel> </DockPanel>
<DockPanel DockPanel.Dock="Top">
<Label DockPanel.Dock="Left" Content="Auszeichnung pathologischer Werte:" Margin="0 0 10 0"
Target="{Binding ElementName=AbnormalStyleChooser}" />
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<CheckBox IsChecked="{Binding AbnormalBold}" Content="Fett" />
<CheckBox IsChecked="{Binding AbnormalItalics}" Content="Kursiv" Margin="10 0 0 0" />
</StackPanel>
</DockPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Command="{Binding CloseViewCommand}" Content="Schließen" IsDefault="True" IsCancel="True" <Button Command="{Binding CloseViewCommand}" Content="Schließen" IsDefault="True" IsCancel="True"
Margin="0 10 0 0" /> Margin="0 10 0 0" />

View File

@ -69,7 +69,7 @@
<value>Steuerungs-Elemente</value> <value>Steuerungs-Elemente</value>
</setting> </setting>
<setting name="SerializationVersion" serializeAs="String"> <setting name="SerializationVersion" serializeAs="String">
<value>1</value> <value>2</value>
</setting> </setting>
<setting name="StyleHeader" serializeAs="String"> <setting name="StyleHeader" serializeAs="String">
<value>zaaReloaded2-Überschrift</value> <value>zaaReloaded2-Überschrift</value>
@ -77,6 +77,9 @@
<setting name="StyleAbnormal" serializeAs="String"> <setting name="StyleAbnormal" serializeAs="String">
<value>zaaReloaded2-Pathologisch</value> <value>zaaReloaded2-Pathologisch</value>
</setting> </setting>
<setting name="AbnormalStyle" serializeAs="String">
<value>None</value>
</setting>
</zaaReloaded2.Properties.Settings> </zaaReloaded2.Properties.Settings>
</applicationSettings> </applicationSettings>
<userSettings> <userSettings>

View File

@ -211,6 +211,7 @@
<Compile Include="ExceptionHandler\SubmissionProcessAction.cs" /> <Compile Include="ExceptionHandler\SubmissionProcessAction.cs" />
<Compile Include="ExceptionHandler\SubmissionProcessView.xaml.cs" /> <Compile Include="ExceptionHandler\SubmissionProcessView.xaml.cs" />
<Compile Include="ExceptionHandler\SubmissionSuccessView.xaml.cs" /> <Compile Include="ExceptionHandler\SubmissionSuccessView.xaml.cs" />
<Compile Include="Formatter\AbnormalStyle.cs" />
<Compile Include="Formatter\DanielsStyle.cs" /> <Compile Include="Formatter\DanielsStyle.cs" />
<Compile Include="Formatter\DocumentWriter.cs" /> <Compile Include="Formatter\DocumentWriter.cs" />
<Compile Include="Formatter\NoLaboratoryDataException.cs" /> <Compile Include="Formatter\NoLaboratoryDataException.cs" />