diff --git a/zaaReloaded2/Controller/Elements/ControlElementBase.cs b/zaaReloaded2/Controller/Elements/ControlElementBase.cs
index a575b81..ef58c9c 100755
--- a/zaaReloaded2/Controller/Elements/ControlElementBase.cs
+++ b/zaaReloaded2/Controller/Elements/ControlElementBase.cs
@@ -26,12 +26,23 @@ namespace zaaReloaded2.Controller.Elements
///
public abstract class ControlElementBase : ElementBase
{
+ #region Propertis
+
///
/// Gets a list of child elements, all of which must be derived
/// from FormatElementBase.
///
public IList Children { get; internal set; }
+ ///
+ /// Informs whether this control element can have child elements.
+ ///
+ public virtual bool CanHaveChildren { get { return true; } }
+
+ #endregion
+
+ #region Constructors
+
public ControlElementBase()
: this(new List())
{ }
@@ -45,6 +56,10 @@ namespace zaaReloaded2.Controller.Elements
: this(new List() { children })
{ }
+ #endregion
+
+ #region Protected methods
+
///
/// Creates a clone of the Children list (for use in cloning
/// derived classes).
@@ -54,5 +69,7 @@ namespace zaaReloaded2.Controller.Elements
{
return Children.Select(child => child.Clone() as FormatElementBase).ToList();
}
+
+ #endregion
}
}
diff --git a/zaaReloaded2/Controller/Elements/FormatElementBase.cs b/zaaReloaded2/Controller/Elements/FormatElementBase.cs
index c47d4ad..b28c523 100755
--- a/zaaReloaded2/Controller/Elements/FormatElementBase.cs
+++ b/zaaReloaded2/Controller/Elements/FormatElementBase.cs
@@ -32,7 +32,6 @@ namespace zaaReloaded2.Controller.Elements
set
{
_content = value;
-
}
}
diff --git a/zaaReloaded2/Controller/Elements/NextColumn.cs b/zaaReloaded2/Controller/Elements/NextColumn.cs
new file mode 100755
index 0000000..a3e534c
--- /dev/null
+++ b/zaaReloaded2/Controller/Elements/NextColumn.cs
@@ -0,0 +1,54 @@
+/* NextColumn.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.Controller.Elements
+{
+ ///
+ /// Format element that causes a Formatter object to move the
+ /// insertion point to the next colum in a layout table.
+ ///
+ class NextColumn : ControlElementBase
+ {
+ public override string Label
+ {
+ get { return "Nächste Spalte"; }
+ }
+
+ public override bool CanHaveChildren
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override void Run(Formatter.Formatter formatter)
+ {
+ formatter.NextColumn();
+ }
+
+ protected override ElementBase CreateInstance()
+ {
+ return new NextColumn();
+ }
+ }
+}
diff --git a/zaaReloaded2/Controller/Elements/TwoColumns.cs b/zaaReloaded2/Controller/Elements/TwoColumns.cs
new file mode 100755
index 0000000..0b9ab12
--- /dev/null
+++ b/zaaReloaded2/Controller/Elements/TwoColumns.cs
@@ -0,0 +1,54 @@
+/* TwoColumns.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.Controller.Elements
+{
+ ///
+ /// Format element that causes a Formatter object to insert a table with
+ /// two columns and one row into the documents.
+ ///
+ class TwoColumns : ControlElementBase
+ {
+ public override string Label
+ {
+ get { return "Zwei Spalten einfügen"; }
+ }
+
+ public override bool CanHaveChildren
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override void Run(Formatter.Formatter formatter)
+ {
+ formatter.InsertTwoColumns();
+ }
+
+ protected override ElementBase CreateInstance()
+ {
+ return new TwoColumns();
+ }
+ }
+}
diff --git a/zaaReloaded2/Controller/SettingsRepository.cs b/zaaReloaded2/Controller/SettingsRepository.cs
index a8e55cb..37402c2 100755
--- a/zaaReloaded2/Controller/SettingsRepository.cs
+++ b/zaaReloaded2/Controller/SettingsRepository.cs
@@ -89,6 +89,7 @@ namespace zaaReloaded2.Controller
{
return SettingsList.FirstOrDefault(s => s.Uid == uid);
}
+
#endregion
#region Private methods
@@ -127,7 +128,9 @@ namespace zaaReloaded2.Controller
def.SettingsNameWard,
new List()
{
+ new TwoColumns(),
new SelectFirstDay(defaultItems),
+ new NextColumn(),
new SelectLastDay(defaultItems)
}
)
diff --git a/zaaReloaded2/Formatter/DocumentWriter.cs b/zaaReloaded2/Formatter/DocumentWriter.cs
index 51dad02..2c11113 100755
--- a/zaaReloaded2/Formatter/DocumentWriter.cs
+++ b/zaaReloaded2/Formatter/DocumentWriter.cs
@@ -119,13 +119,14 @@ namespace zaaReloaded2.Formatter
if (Document != null)
{
- Document.ActiveWindow.Selection.ClearCharacterDirectFormatting();
- Document.ActiveWindow.Selection.ClearParagraphDirectFormatting();
+ Selection s = Document.ActiveWindow.Selection;
+ s.ClearCharacterDirectFormatting();
+ s.ClearParagraphDirectFormatting();
if (!string.IsNullOrEmpty(ParagraphStyle))
{
- Document.ActiveWindow.Selection.set_Style(ParagraphStyle);
+ s.set_Style(ParagraphStyle);
}
- Document.ActiveWindow.Selection.Range.Text = _buffer.ToString();
+ s.Range.Text = _buffer.ToString();
}
if (Parent != null)
{
diff --git a/zaaReloaded2/Formatter/Formatter.cs b/zaaReloaded2/Formatter/Formatter.cs
index 5ef0276..83c2d02 100755
--- a/zaaReloaded2/Formatter/Formatter.cs
+++ b/zaaReloaded2/Formatter/Formatter.cs
@@ -121,6 +121,8 @@ namespace zaaReloaded2.Formatter
{
if (!CanRun) throw new InvalidOperationException("No laboratory data to format.");
+ CreateParagraphStyle();
+ _secondaryBuffer.ParagraphStyle = zaaReloaded2.Properties.Settings.Default.ParagraphStyleName;
int current = 0;
while (current < Settings.Elements.Count)
{
@@ -145,8 +147,6 @@ namespace zaaReloaded2.Formatter
current++;
}
}
- CreateParagraphStyle();
- _secondaryBuffer.ParagraphStyle = zaaReloaded2.Properties.Settings.Default.ParagraphStyleName;
_secondaryBuffer.Flush();
}
@@ -208,6 +208,39 @@ namespace zaaReloaded2.Formatter
ProcessAllTimePoints(controlElement.Children);
}
+ ///
+ /// Inserts a table with two columns into the document.
+ ///
+ public void InsertTwoColumns()
+ {
+ _secondaryBuffer.Flush();
+ if (Document != null)
+ {
+ Range r = Document.ActiveWindow.Selection.Range;
+ _table = Document.Tables.Add(r, NumRows: 1, NumColumns: 2);
+ _table.AllowAutoFit = true;
+ _table.AutoFitBehavior(WdAutoFitBehavior.wdAutoFitWindow);
+ _table.PreferredWidthType = WdPreferredWidthType.wdPreferredWidthPercent;
+ _table.PreferredWidth = 100;
+ _table.Borders.Enable = 0;
+ }
+ }
+
+ ///
+ /// Moves the insertion point to the next column in a layout
+ /// table.
+ ///
+ public void NextColumn()
+ {
+ if (_table == null)
+ {
+ throw new InvalidOperationException(
+ "Kann nicht zur nächsten Spalte wechseln, da bislang keine Tabelle eingefügt wurde.");
+ }
+ _secondaryBuffer.Flush();
+ Document.ActiveWindow.Selection.MoveRight(WdUnits.wdCell);
+ }
+
///
/// Creates a zaaReloaded2 paragraph style in the document.
///
@@ -324,6 +357,7 @@ namespace zaaReloaded2.Formatter
Laboratory _laboratory;
DocumentWriter _primaryBuffer;
DocumentWriter _secondaryBuffer;
+ Table _table;
#endregion
}
diff --git a/zaaReloaded2/ViewModels/ControlElementViewModel.cs b/zaaReloaded2/ViewModels/ControlElementViewModel.cs
index 826968a..c0c09eb 100755
--- a/zaaReloaded2/ViewModels/ControlElementViewModel.cs
+++ b/zaaReloaded2/ViewModels/ControlElementViewModel.cs
@@ -35,6 +35,18 @@ namespace zaaReloaded2.ViewModels
///
public ObservableCollection Elements { get; protected set; }
+ ///
+ /// Gets information whether this control element view model can
+ /// have child elements;
+ ///
+ public virtual bool CanHaveChildren
+ {
+ get
+ {
+ return ((ControlElementBase)Element).CanHaveChildren;
+ }
+ }
+
#endregion
#region Constructors
diff --git a/zaaReloaded2/ViewModels/ElementPickerViewModel.cs b/zaaReloaded2/ViewModels/ElementPickerViewModel.cs
index a54c550..e00ff57 100755
--- a/zaaReloaded2/ViewModels/ElementPickerViewModel.cs
+++ b/zaaReloaded2/ViewModels/ElementPickerViewModel.cs
@@ -105,7 +105,9 @@ namespace zaaReloaded2.ViewModels
{
CreateControlElementViewModel(new SelectFirstDay()),
CreateControlElementViewModel(new SelectLastDay()),
- CreateControlElementViewModel(new SelectEachDay())
+ CreateControlElementViewModel(new SelectEachDay()),
+ CreateControlElementViewModel(new TwoColumns()),
+ CreateControlElementViewModel(new NextColumn()),
}
)
);
@@ -130,7 +132,9 @@ namespace zaaReloaded2.ViewModels
{
CreateControlElementViewModel(new SelectFirstDay(), copyFromViewModel),
CreateControlElementViewModel(new SelectLastDay(), copyFromViewModel),
- CreateControlElementViewModel(new SelectEachDay(), copyFromViewModel)
+ CreateControlElementViewModel(new SelectEachDay(), copyFromViewModel),
+ CreateControlElementViewModel(new TwoColumns()),
+ CreateControlElementViewModel(new NextColumn()),
}
)
);
diff --git a/zaaReloaded2/ViewModels/ElementViewModel.cs b/zaaReloaded2/ViewModels/ElementViewModel.cs
index f8b4c7c..f67274c 100755
--- a/zaaReloaded2/ViewModels/ElementViewModel.cs
+++ b/zaaReloaded2/ViewModels/ElementViewModel.cs
@@ -30,23 +30,11 @@ namespace zaaReloaded2.ViewModels
{
#region Properties
- ///
- /// Gets the label of the wrapped element.
- ///
- public virtual string Label
- {
- [DebuggerStepThrough]
- get
- {
- return Element.Label;
- }
- }
-
public override string DisplayString
{
get
{
- return Label;
+ return Element.Label;
}
}
diff --git a/zaaReloaded2/ViewModels/FormatElementViewModel.cs b/zaaReloaded2/ViewModels/FormatElementViewModel.cs
index 373e79e..fef5d4b 100755
--- a/zaaReloaded2/ViewModels/FormatElementViewModel.cs
+++ b/zaaReloaded2/ViewModels/FormatElementViewModel.cs
@@ -89,25 +89,6 @@ namespace zaaReloaded2.ViewModels
return clone;
}
- public override string DisplayString
- {
- get
- {
- if (String.IsNullOrEmpty(Content))
- {
- return _displayString;
- }
- else
- {
- return base.DisplayString;
- }
- }
- set
- {
- _displayString = value;
- }
- }
-
#endregion
#region Private methods
diff --git a/zaaReloaded2/ViewModels/SettingsViewModel.cs b/zaaReloaded2/ViewModels/SettingsViewModel.cs
index 3308203..fdf149b 100755
--- a/zaaReloaded2/ViewModels/SettingsViewModel.cs
+++ b/zaaReloaded2/ViewModels/SettingsViewModel.cs
@@ -345,7 +345,8 @@ namespace zaaReloaded2.ViewModels
bool CanAddChildElement()
{
- return LastSelectedElement is ControlElementViewModel;
+ return LastSelectedElement is ControlElementViewModel &&
+ ((ControlElementViewModel)LastSelectedElement).CanHaveChildren;
}
void DoEditElement()
diff --git a/zaaReloaded2/zaaReloaded2.csproj b/zaaReloaded2/zaaReloaded2.csproj
index e73c60c..fb816a0 100755
--- a/zaaReloaded2/zaaReloaded2.csproj
+++ b/zaaReloaded2/zaaReloaded2.csproj
@@ -193,10 +193,12 @@
+
+