Merge branch 'item-comments' into develop

Conflicts:
	zaaReloaded2/Formatter/Formatter.cs
	zaaReloaded2/zaaReloaded2.csproj
This commit is contained in:
Daniel Kraus
2015-09-04 17:08:13 +02:00
30 changed files with 1259 additions and 16 deletions

View File

@ -34,6 +34,9 @@ namespace zaaReloaded2.Formatter
{
#region Properties
/// <summary>
/// Gets or sets the Settings that this Formatter works with.
/// </summary>
public Settings Settings { get; set; }
/// <summary>
@ -66,9 +69,17 @@ namespace zaaReloaded2.Formatter
/// <summary>
/// Is true if this Formatter object carries a Laboratory with
/// at least one time point.
/// at least one time point, and if there are Settings to work with.
/// </summary>
public bool CanRun { get { return Laboratory.TimePoints.Count > 0; } }
public bool CanRun
{
get
{
return (Settings != null)
&& (Laboratory != null)
&& (Laboratory.TimePoints.Count > 0);
}
}
#endregion
@ -119,7 +130,14 @@ namespace zaaReloaded2.Formatter
/// current position of the cursor).</param>
public void Run()
{
if (!CanRun) throw new NoLaboratoryDataException("No laboratory data to format.");
if (!CanRun)
{
if (Settings == null)
throw new InvalidOperationException("No settings data to work with.");
if ((Laboratory == null) || Laboratory.TimePoints.Count == 0)
throw new NoLaboratoryDataException("No laboratory data to format.");
throw new InvalidOperationException("Cannot run formatter.");
}
// Create undo record and styles prior to iterating over the elements
// because a column switching element might trigger output to the
@ -154,8 +172,20 @@ namespace zaaReloaded2.Formatter
}
}
// Write everything to the Word document
bool hasAddin = Globals.ThisAddIn != null;
if (hasAddin)
{
Globals.ThisAddIn.Application.UndoRecord.StartCustomRecord(
String.Format("Laborformatierung ({0})", Properties.Settings.Default.AddinName)
);
}
CreateStyles();
_secondaryBuffer.Flush();
Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord();
if (hasAddin)
{
Globals.ThisAddIn.Application.UndoRecord.EndCustomRecord();
}
}
/// <summary>