17 Commits

Author SHA1 Message Date
34006ba1e9 Merge branch 'release-2.0.0-alpha.5' 2015-08-04 02:46:21 +02:00
204139d16b Prepare release 2.0.0-alpha.5. 2015-08-04 02:46:12 +02:00
41b155e8be Begin implemenation of format and choose style commands. 2015-08-04 02:43:17 +02:00
b6209731ec Fix salutation regex in DanielsStyle.
- FIX: Daniels Spezial löscht nicht mehr die Unterschriften.
2015-08-04 01:19:19 +02:00
a128b76522 Implement tests for SettingsViewModel add and add child commands. 2015-08-04 01:17:14 +02:00
805da69d47 Implement passing test for ElementPickerViewModel. 2015-08-03 14:31:35 +02:00
8437f0907c Implement Demo feature.
- NEU: Eingebautes Demo-Dokument zum Ausprobieren.
2015-08-03 12:11:30 +02:00
db8f88c563 Fix SettingsViewModelTest.CannotAddChildElementToFormatElement. 2015-08-03 06:32:05 +02:00
14b09f89c5 Merge branch 'release-2.0.0-alpha.4' into develop 2015-08-02 22:05:39 +02:00
305baf2402 Merge branch 'release-2.0.0-alpha.4' 2015-08-02 22:05:08 +02:00
e4edd0f197 Prepare release 2.0.0-alpha.4. 2015-08-02 22:04:58 +02:00
23acb13019 Improve Daniel's style. 2015-08-02 22:01:51 +02:00
1e4c3681f2 Implement ElementPickerViewModel; initial SettingsViewModelTest. 2015-08-02 21:51:58 +02:00
9fd0907310 Implement unique IDs for settings. 2015-08-02 07:19:12 +02:00
286ddb1641 Fix cloning of SettingsViewModels. 2015-08-02 07:11:16 +02:00
d0be7524d3 Make some classes ICloneable; implement SettingsRepositoryViewModel. 2015-08-01 21:23:56 +02:00
5197c294b9 Merge branch 'release-2.0.0-alpha.3' into develop 2015-07-31 17:24:28 +02:00
37 changed files with 1314 additions and 97 deletions

View File

@ -1,3 +1,13 @@
Version 2.0.0-alpha.5 (2015-08-04)
========================================================================
- FIX: Daniels Spezial löscht nicht mehr die Unterschriften.
- NEU: Eingebautes Demo-Dokument zum Ausprobieren.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 2.0.0-alpha.3 (2015-07-31)
========================================================================

View File

@ -56,27 +56,5 @@ namespace Tests.Controller
Assert.AreEqual(1, sr.SettingsList.Count);
Assert.AreEqual(testName, sr.SettingsList[0].Name);
}
[Test]
public void CreateDefaultSettings()
{
SettingsRepository sr = new SettingsRepository();
sr.SettingsList.Add(new Settings("test1", null));
sr.SettingsList.Add(new Settings("test2", null));
sr.SettingsList.Add(new Settings("test3", null));
sr.ResetDefault();
// Assert that there are now only the 2 default settings
Assert.AreEqual(2, sr.SettingsList.Count);
Assert.AreEqual(
zaaReloaded2.Properties.Settings.Default.SettingsNameWard,
sr.SettingsList[0].Name,
"Settings for ward expected as #1 (index 0) in list");
Assert.AreEqual(
zaaReloaded2.Properties.Settings.Default.SettingsNameClinic,
sr.SettingsList[1].Name,
"Settings for outpatient clinic expected as #2 (index 1) in list");
}
}
}

View File

@ -91,7 +91,8 @@
<Compile Include="Thesaurus\TestThesaurus.cs" />
<Compile Include="Importer\ZaaImporter\TimePointTest.cs" />
<Compile Include="TestHelpers.cs" />
<Compile Include="ViewModels\SettingsRepositoryViewModel.cs" />
<Compile Include="ViewModels\ElementPickerViewModelTest.cs" />
<Compile Include="ViewModels\SettingsRepositoryViewModelTest.cs" />
<Compile Include="ViewModels\SettingsViewModelTest.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,54 @@
/* ElementPickerViewModelTest.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 NUnit.Framework;
using Bovender.Mvvm.ViewModels;
using zaaReloaded2.ViewModels;
namespace Tests.ViewModels
{
[TestFixture]
class ElementPickerViewModelTest
{
[Test]
public void ChooseElement()
{
ElementPickerViewModel vm = new ElementPickerViewModel(true);
ViewModelBase elementVM = vm.Categories.First().Children.First();
elementVM.IsSelected = true;
string expectedLabel = elementVM.DisplayString;
Assert.IsTrue(vm.ChooseElementCommand.CanExecute(null),
"Cannot execute ChooseElementCommand");
bool messageSent = false;
vm.ElementChosenMessage.Sent += (sender, args) =>
{
messageSent = true;
ViewModelBase messageContentVM = args.Content.ViewModel as ViewModelBase;
Assert.AreEqual(expectedLabel, messageContentVM.DisplayString);
};
vm.ChooseElementCommand.Execute(null);
Assert.IsTrue(messageSent, "No message was sent when element was chosen");
}
}
}

View File

@ -0,0 +1,72 @@
/* SettingsRepositoryViewModel.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 NUnit.Framework;
using zaaReloaded2.Controller;
using zaaReloaded2.ViewModels;
namespace Tests.ViewModels
{
[TestFixture]
class SettingsRepositoryViewModelTest
{
SettingsRepositoryViewModel _vm;
const string TESTNAME = "hello world";
[SetUp]
public void SetUp()
{
SettingsRepository rep = new SettingsRepository();
rep.SettingsList.Add(new Settings(TESTNAME));
_vm = new SettingsRepositoryViewModel(rep);
}
[Test]
public void CanDeleteNonDefaultSettings()
{
_vm.SettingsList[_vm.SettingsList.Count - 1].IsSelected = true;
Assert.IsTrue(_vm.DeleteSettingsCommand.CanExecute(null));
}
[Test]
public void CannotDeleteDefaultSettings()
{
_vm.SettingsList[0].IsSelected = true;
Assert.IsFalse(_vm.DeleteSettingsCommand.CanExecute(null));
}
[Test]
public void CopySettings()
{
SettingsViewModel orig = _vm.SettingsList[0];
orig.IsSelected = true;
_vm.CopySettingsCommand.Execute(null);
SettingsViewModel copy = _vm.SettingsList[_vm.SettingsList.Count-1];
// Make sure we have a new object
Assert.AreNotSame(orig, copy);
Assert.AreNotSame(orig.RevealModelObject(), copy.RevealModelObject());
Assert.AreEqual(String.Format("Kopie von {0}", orig.Name), copy.Name);
Assert.IsTrue(copy.IsSelected);
}
}
}

View File

@ -22,6 +22,7 @@ using System.Text;
using NUnit.Framework;
using zaaReloaded2.ViewModels;
using zaaReloaded2.Controller;
using zaaReloaded2.Controller.Elements;
namespace Tests.ViewModels
{
@ -39,31 +40,79 @@ namespace Tests.ViewModels
[Test]
public void AddElement()
{
bool messageSent = false;
Settings model = _settingsVM.RevealModelObject() as Settings;
int oldViewModelElementCount = _settingsVM.Elements.Count;
int oldModelElementCount = model.Elements.Count;
_settingsVM.AddElementMessage.Sent += (sender, args) =>
{
messageSent = true;
ElementPickerViewModel picker = args.Content.ViewModel as ElementPickerViewModel;
Assert.IsNotNull(picker, "ViewModel in MessageContent is not an ElementPickerViewModel");
picker.Categories.First().Children.First().IsSelected = true;
picker.ChooseElementCommand.Execute(null);
};
_settingsVM.AddElementCommand.Execute(null);
Assert.IsTrue(messageSent, "Message was not sent");
Assert.AreEqual(oldViewModelElementCount + 1, _settingsVM.Elements.Count,
"Count of elements in ViewModel was not increased by 1");
Assert.AreEqual(oldModelElementCount + 1, model.Elements.Count,
"Count of elements in settings Model was not increased by 1");
}
[Test]
public void AddChildElement()
{
bool messageSent = false;
SelectEachDay model = new SelectEachDay();
ControlElementViewModel viewModel = new ControlElementViewModel(model);
_settingsVM.AddElementViewModel(viewModel);
viewModel.IsSelected = true;
int oldViewModelChildrenCount = viewModel.Elements.Count;
int oldModelChildrenCount = model.FormatElements.Count;
_settingsVM.AddChildElementMessage.Sent += (sender, args) =>
{
messageSent = true;
ElementPickerViewModel picker = args.Content.ViewModel as ElementPickerViewModel;
Assert.IsNotNull(picker, "ViewModel in MessageContent is not an ElementPickerViewModel");
picker.Categories.First().Children.First().IsSelected = true;
Assert.IsTrue(picker.ChooseElementCommand.CanExecute(null),
"Cannot execute element picker's ChooseElementCommand.");
picker.ChooseElementCommand.Execute(null);
};
_settingsVM.AddChildElementCommand.Execute(null);
Assert.IsTrue(messageSent, "Message was not sent");
Assert.AreEqual(oldViewModelChildrenCount + 1, viewModel.Elements.Count,
"Count of children in ViewModel was not increased by 1");
Assert.AreEqual(oldModelChildrenCount + 1, model.FormatElements.Count,
"Count of children in Model was not increased by 1");
}
[Test]
public void CannotAddChildElementToFormatElement()
{
ControlElementViewModel parent = new ControlElementViewModel(
new SelectFirstDay());
_settingsVM.AddElementViewModel(parent);
parent.IsSelected = true;
Assert.IsTrue(_settingsVM.AddChildElementCommand.CanExecute(null));
FormatElementViewModel child = new FormatElementViewModel(new Items());
_settingsVM.AddChildElementViewModel(parent, child);
parent.IsSelected = false;
child.IsSelected = true;
Assert.IsFalse(_settingsVM.AddChildElementCommand.CanExecute(null));
}
[Test]
public void DeleteElement()
{
throw new NotImplementedException();
}
[Test]
public void CopyElement()
{
throw new NotImplementedException();
}
}
}

BIN
gimp/d.xcf Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
2.0.0-alpha.3
http://zaa.nephrowiki.de/downloads/zaaReloaded-2.0.0-alpha.3.exe
c9bb1062acdf2d8181a3915e34d5cfe96d26934a publish/release/zaaReloaded-2.0.0-alpha.3.exe
2.0.0-alpha.5
http://zaa.nephrowiki.de/downloads/zaaReloaded-2.0.0-alpha.5.exe
423cbe81b42ddfc293cf5b387c1d8d269dce3f61 publish/release/zaaReloaded-2.0.0-alpha.5.exe

View File

@ -31,7 +31,9 @@ namespace zaaReloaded2.Controller.Elements
/// </summary>
public IList<FormatElementBase> FormatElements { get; private set; }
public ControlElementBase() { }
public ControlElementBase()
: this(new List<FormatElementBase>())
{ }
public ControlElementBase(IList<FormatElementBase> formatElements)
{

View File

@ -36,5 +36,12 @@ namespace zaaReloaded2.Controller.Elements
{
formatter.WriteParagraph(Content);
}
protected override ElementBase CreateInstance()
{
CustomText clone = new CustomText();
clone.Content = Content;
return clone;
}
}
}

View File

@ -28,7 +28,7 @@ namespace zaaReloaded2.Controller.Elements
/// Base class for formatting elements.
/// </summary>
[Serializable]
public abstract class ElementBase
public abstract class ElementBase : ICloneable
{
/// <summary>
/// Returns the label for this formatting element.
@ -44,5 +44,16 @@ namespace zaaReloaded2.Controller.Elements
/// Element belongs to. The Formatter object provides access
/// to the current Word document etc.</param>
abstract public void Run(zaaReloaded2.Formatter.Formatter formatter);
public object Clone()
{
return CreateInstance();
}
/// <summary>
/// Creates a new instance that can be used for cloning.
/// </summary>
/// <returns>New instance of a derived class.</returns>
protected abstract ElementBase CreateInstance();
}
}

View File

@ -43,5 +43,10 @@ namespace zaaReloaded2.Controller.Elements
public SelectEachDay(IList<FormatElementBase> formatElements)
: base(formatElements)
{ }
protected override ElementBase CreateInstance()
{
return new SelectEachDay();
}
}
}

View File

@ -47,5 +47,10 @@ namespace zaaReloaded2.Controller.Elements
public SelectFirstDay(IList<FormatElementBase> formatElements)
: base(formatElements)
{ }
protected override ElementBase CreateInstance()
{
return new SelectFirstDay();
}
}
}

View File

@ -48,5 +48,10 @@ namespace zaaReloaded2.Controller.Elements
public SelectLastDay(IList<FormatElementBase> formatElements)
: base(formatElements)
{ }
protected override ElementBase CreateInstance()
{
return new SelectLastDay();
}
}
}

View File

@ -28,7 +28,7 @@ namespace zaaReloaded2.Controller
/// Holds settings related to controlling laboratory output.
/// </summary>
[Serializable]
public class Settings
public class Settings : ICloneable
{
#region Properties
@ -47,14 +47,23 @@ namespace zaaReloaded2.Controller
/// </summary>
public IList<ElementBase> Elements { get; private set; }
/// <summary>
/// Gets the unique ID of this Settings object. The unique
/// ID is not included in deep-copying (cloning).
/// </summary>
public Guid Uid { get; private set; }
#endregion
#region Constructor
#region Constructors
public Settings()
{
Elements = new List<ElementBase>();
}
: this(string.Empty, new List<ElementBase>())
{ }
public Settings(string name)
: this(name, null)
{ }
/// <summary>
/// Creates a new Settings object with an initial
@ -63,9 +72,8 @@ namespace zaaReloaded2.Controller
/// <param name="initialElements">Set of ElementBase
/// object (or derived ones).</param>
public Settings(IList<ElementBase> initialElements)
{
Elements = initialElements;
}
: this(String.Empty, initialElements)
{ }
/// <summary>
/// Creates a new Settings object with an initial
@ -75,9 +83,10 @@ namespace zaaReloaded2.Controller
/// object (or derived ones).</param>
/// <param name="name">Name of these settings.</param>
public Settings(string name, IList<ElementBase> initialElements)
: this(initialElements)
{
Uid = Guid.NewGuid();
Name = name;
Elements = initialElements;
}
#endregion
@ -94,5 +103,19 @@ namespace zaaReloaded2.Controller
}
#endregion
#region Implementation of ICloneable
public object Clone()
{
Settings clone = new Settings(
String.Format("Kopie von {0}", Name),
Elements.Select(e => e.Clone() as ElementBase).ToList()
);
clone.ReferenceStyle = ReferenceStyle;
return clone;
}
#endregion
}
}

View File

@ -62,22 +62,42 @@ namespace zaaReloaded2.Controller
#endregion
#region Constructor
#region Constructors
/// <summary>
/// Creates a new instance of a settings repository that will
/// contain a default set of settings.
/// </summary>
public SettingsRepository()
{
SettingsList = new List<Settings>();
CreateDefault();
}
#endregion
#region Public methods
/// <summary>
/// Looks up a Settings object contained in this repository
/// by unique ID.
/// </summary>
/// <param name="uid">GUID to look for.</param>
/// <returns>Settings object with this GUID, or null if the
/// GUID was not found.</returns>
public Settings FindByGuid(Guid uid)
{
return SettingsList.FirstOrDefault(s => s.Uid == uid);
}
#endregion
#region Private methods
/// <summary>
/// Resets the Settings contained in this SettingsRepository
/// to the default set of settings.
/// </summary>
public void ResetDefault()
private void CreateDefault()
{
SettingsList.Clear();

75
zaaReloaded2/Demo/Demo.cs Executable file
View File

@ -0,0 +1,75 @@
/* Demo.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.IO;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;
namespace zaaReloaded2.Demo
{
/// <summary>
/// Static class that serves to load an embedded Word document
/// into a temporary file and open that temporary file in Word.
/// </summary>
static class Demo
{
#region Public methods
/// <summary>
/// Opens a demo document. The document's Saved property is set to
/// false so that a user who wants to save changes will be prompted
/// for a file name.
/// </summary>
public static void OpenDemoDocument()
{
string tempFile = CreateTempFileFromResource();
Document demoDoc = Globals.ThisAddIn.Application.Documents
.Add(Template: tempFile);
File.Delete(tempFile);
}
#endregion
#region Private methods
/// <summary>
/// Copies the built-in demo file from a resource stream to a
/// temporary file and returns the path to that file.
/// </summary>
/// <returns>Path to the newly created temporary file.</returns>
static string CreateTempFileFromResource()
{
string resourceName = "zaaReloaded2.Demo.Demo.docx";
Stream resourceStream = typeof(Demo).Assembly
.GetManifestResourceStream(resourceName);
if (resourceStream == null)
{
throw new IOException("Unable to open stream " + resourceName);
}
string fileName = Path.GetTempFileName() + ".docx";
Stream tempStream = File.Create(fileName);
resourceStream.CopyTo(tempStream);
tempStream.Close();
return fileName;
}
#endregion
}
}

BIN
zaaReloaded2/Demo/Demo.docx Executable file

Binary file not shown.

View File

@ -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
{
@ -32,6 +33,7 @@ namespace zaaReloaded2.Formatter
{
FixWords(document);
FormatDiagnoses(selection);
FixSalutation(document);
}
static void FormatDiagnoses(Selection selection)
@ -59,6 +61,7 @@ namespace zaaReloaded2.Formatter
static void FixWords(Document document)
{
Find find = document.Range().Find;
find.Execute2007(FindText: "Körperlicher Untersuchungsbefund", ReplaceWith: "Körperl. Untersuchung", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "Dr.D.Kraus", ReplaceWith: "Dr. D. Kraus", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "Z. n.", ReplaceWith: "Z.n.", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "Zust. n.", ReplaceWith: "Z.n.", Replace: WdReplace.wdReplaceAll);
@ -66,6 +69,23 @@ namespace zaaReloaded2.Formatter
find.Execute2007(FindText: "Assistent der Klinik", ReplaceWith: "Internist/Nephrologe", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "Professor Dr.", ReplaceWith: "Prof. Dr.", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "mmHg", ReplaceWith: "mm Hg", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "RR ", ReplaceWith: "", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "HF ", ReplaceWith: "", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "TAC-Spiegel", ReplaceWith: "Tacrolimus-Talspiegel", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "4-7", ReplaceWith: "4 bis 7", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "5-8", ReplaceWith: "5 bis 8", Replace: WdReplace.wdReplaceAll);
find.Execute2007(FindText: "8-10", ReplaceWith: "8 bis 10", Replace: WdReplace.wdReplaceAll);
}
static void FixSalutation(Document document)
{
Regex sal = new Regex(@"^Mit.*?Grüßen");
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:";
}
}
}
}

BIN
zaaReloaded2/Icons/d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

View File

@ -233,5 +233,17 @@ namespace zaaReloaded2.Properties {
return ((string)(this["DefaultItemsDrugs"]));
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("00000000-0000-0000-0000-000000000000")]
public global::System.Guid LastSettings {
get {
return ((global::System.Guid)(this["LastSettings"]));
}
set {
this["LastSettings"] = value;
}
}
}
}

View File

@ -71,5 +71,8 @@
<Setting Name="DefaultItemsDrugs" Type="System.String" Scope="Application">
<Value Profile="(Default)">Medikamente: TAC, CSA, SIR, Vancomycin, Gentamicin, Tobramicin</Value>
</Setting>
<Setting Name="LastSettings" Type="System.Guid" Scope="User">
<Value Profile="(Default)">00000000-0000-0000-0000-000000000000</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -26,6 +26,11 @@ using System.Windows;
using System.Drawing;
using System.Windows.Resources;
using Office = Microsoft.Office.Core;
using zaaReloaded2.Views;
using zaaReloaded2.ViewModels;
using zaaReloaded2.Importer.ZaaImporter;
using zaaReloaded2.Formatter;
using zaaReloaded2.Controller;
// TODO: Follow these steps to enable the Ribbon (XML) item:
@ -51,12 +56,14 @@ namespace zaaReloaded2
[ComVisible(true)]
public class Ribbon : Office.IRibbonExtensibility
{
private Office.IRibbonUI ribbon;
#region Constructor
public Ribbon()
{
}
#endregion
#region IRibbonExtensibility Members
public string GetCustomUI(string ribbonID)
@ -71,7 +78,8 @@ namespace zaaReloaded2
public void Ribbon_Load(Office.IRibbonUI ribbonUI)
{
this.ribbon = ribbonUI;
_ribbon = ribbonUI;
Globals.ThisAddIn.Application.WindowSelectionChange += Application_WindowSelectionChange;
}
/// <summary>
@ -86,6 +94,12 @@ namespace zaaReloaded2
{
switch (control.Id)
{
case "zrlFormat":
DoFormat();
break;
case "zrlSettings":
DoChooseSettings();
break;
case "zrlAbout":
ViewModels.AboutViewModel vm = new ViewModels.AboutViewModel();
vm.InjectInto<Views.AboutView>().ShowDialog();
@ -95,6 +109,9 @@ namespace zaaReloaded2
Globals.ThisAddIn.Application.ActiveDocument,
Globals.ThisAddIn.Application.Selection);
break;
case "zrlDemo":
Demo.Demo.OpenDemoDocument();
break;
default:
throw new InvalidOperationException("No operation defined for " + control.Id);
}
@ -135,6 +152,67 @@ namespace zaaReloaded2
}
}
public bool CanFormat(Office.IRibbonControl control)
{
return Globals.ThisAddIn.Application.Selection.Paragraphs.Count > 0;
}
#endregion
#region Private methods
void DoFormat()
{
if (CanFormat(null))
{
SettingsRepository repository = SettingsRepository.Load();
Guid lastSettingsUid = Properties.Settings.Default.LastSettings;
Settings lastSettings = repository.FindByGuid(lastSettingsUid);
if (lastSettings != null)
{
DoFormat(lastSettings);
}
else
{
DoChooseSettings();
}
}
}
void DoFormat(Settings settings)
{
ZaaImporter importer = new ZaaImporter();
importer.Import(Globals.ThisAddIn.Application.Selection.Text);
Formatter.Formatter formatter =new Formatter.Formatter(
Globals.ThisAddIn.Application.ActiveDocument);
formatter.Settings = settings;
formatter.Laboratory = importer.Laboratory;
formatter.Run();
}
void DoChooseSettings()
{
SettingsRepository repository = SettingsRepository.Load();
SettingsRepositoryViewModel vm = new SettingsRepositoryViewModel(repository);
vm.UseSettingsMessage.Sent += (sender, args) =>
{
SettingsViewModel settingsVM = args.Content.ViewModel as SettingsViewModel;
Settings settings = settingsVM.RevealModelObject() as Settings;
DoFormat(settings);
Properties.Settings.Default.LastSettings = settings.Uid;
};
vm.RequestCloseView += (sender, args) =>
{
repository.Save();
};
vm.InjectInto<SettingsRepositoryView>().ShowDialog();
}
public void Application_WindowSelectionChange(Microsoft.Office.Interop.Word.Selection Sel)
{
_ribbon.Invalidate();
}
#endregion
#region Helpers
@ -160,5 +238,11 @@ namespace zaaReloaded2
}
#endregion
#region Fields
private Office.IRibbonUI _ribbon;
#endregion
}
}

View File

@ -25,13 +25,17 @@
<tab id="zaaReloaded2" label="zaaReloaded2">
<group id="zrlFormatGroup" label="Formatieren">
<button id="zrlFormat" label="Formatieren" image="f.png" onAction="Ribbon_Click" size="large"
supertip="Formatiert den ausgewählten Bereich mit dem zuletzt verwendeten Stil." />
<button id="zrlChooseFormat" label="Stilauswahl" image="fff.png" onAction="Ribbon_Click" size="large"
supertip="Formatiert den ausgewählten Bereich mit dem zuletzt verwendeten Stil."
getEnabled="CanFormat" />
<button id="zrlSettings" label="Stilauswahl" image="fff.png" onAction="Ribbon_Click" size="large"
supertip="Zeigt eine Liste vorhandener Stile an. Stile können bearbeitet, hinzugefügt, gelöscht werden." />
<button id="zrlDaniel" label="Daniels Spezial" image="dk.png" onAction="Ribbon_Click" size="large"
getVisible="Daniel_GetVisible"/>
</group>
<group id="zrlInfoGroup" label="Info">
<button id="zrlDemo" label="Demo" image="d.png" onAction="Ribbon_Click" size="large"
screentip="Demo-Dokument öffnen"
supertip="Öffnet ein eingebautes Demo-Dokument, das zum Ausprobieren verwendet werden kann." />
<button id="zrlAbout" label="Über..." image="i.png" onAction="Ribbon_Click" size="large"
screentip="Über zaaReloaded"
supertip="Zeigt Informationen über das Add-in an." />

View File

@ -119,6 +119,7 @@ namespace zaaReloaded2
ExceptionViewModel vm = new ExceptionViewModel(e.Exception);
vm.InjectInto<ExceptionView>().ShowDialog();
}
#endregion
#region Private fields

View File

@ -1,2 +1,2 @@
2.0.0-alpha.3
2.0.0.3
2.0.0-alpha.5
2.0.0.5

View File

@ -0,0 +1,46 @@
/* CategoryViewModel.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 Bovender.Mvvm.ViewModels;
namespace zaaReloaded2.ViewModels
{
/// <summary>
/// A simple view model that can be used to categorize items
/// in a tree view. It has a custom DisplayString and holds
/// a collection of child view model items.
/// </summary>
class CategoryViewModel : ViewModelBase
{
public IEnumerable<ViewModelBase> Children { get; private set; }
public CategoryViewModel(string name, IEnumerable<ViewModelBase> children)
{
DisplayString = name;
Children = children;
}
public override object RevealModelObject()
{
throw new NotImplementedException();
}
}
}

View File

@ -26,24 +26,45 @@ using System.Collections.ObjectModel;
namespace zaaReloaded2.ViewModels
{
class ControlElementViewModel : ElementViewModel
public class ControlElementViewModel : ElementViewModel
{
#region Properties
public ObservableCollection<ElementViewModel> Elements
{
get { return null; }
}
/// <summary>
/// Gets a collection of child ElementViewModels.
/// </summary>
public ObservableCollection<ElementViewModel> Elements { get; protected set; }
#endregion
#region Constructors
public ControlElementViewModel() : base() { }
public ControlElementViewModel() : this(null) { }
public ControlElementViewModel(ControlElementBase controlElement)
: base(controlElement)
{ }
{
Elements = new ObservableCollection<ElementViewModel>();
if (controlElement != null)
{
foreach (FormatElementBase childElement in controlElement.FormatElements)
{
FormatElementViewModel childVM = new FormatElementViewModel(childElement);
Elements.Add(childVM);
}
}
}
#endregion
#region Public methods
public void AddChildElement(FormatElementViewModel viewModel)
{
Elements.Add(viewModel);
ControlElementBase e = Element as ControlElementBase;
e.FormatElements.Add(viewModel.RevealModelObject() as FormatElementBase);
}
#endregion
}

View File

@ -0,0 +1,196 @@
/* ElementPickerViewModel.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 Bovender.Mvvm;
using Bovender.Mvvm.Messaging;
using Bovender.Mvvm.ViewModels;
using System.Collections.ObjectModel;
using zaaReloaded2.Controller.Elements;
namespace zaaReloaded2.ViewModels
{
/// <summary>
/// View model that presents a list of zaaReloaded2.Contorller.Elements.ElementBase
/// classes to choose from.
/// </summary>
class ElementPickerViewModel : ViewModelBase
{
#region Properties
/// <summary>
/// A two-dimensional tree
/// </summary>
public IList<CategoryViewModel> Categories { get; private set; }
/// <summary>
/// Gets the currently selected element, or null if no element is selected.
/// </summary>
/// <remarks>
/// TODO: Raise PropertyChanged event.
/// </remarks>
public ElementViewModel Selected { get; private set; }
#endregion
#region Commands
public DelegatingCommand ChooseElementCommand
{
get
{
if (_chooseElementCommand == null)
{
_chooseElementCommand = new DelegatingCommand(
param => DoChooseElement(),
param => CanChooseElement());
}
return _chooseElementCommand;
}
}
#endregion
#region Messages
/// <summary>
/// A message that is sent out when an element has been chosen;
/// the message content is the element's view model with the element
/// wrapped inside.
/// </summary>
public Message<ViewModelMessageContent> ElementChosenMessage
{
get
{
if (_elementChosenMessage == null)
{
_elementChosenMessage = new Message<ViewModelMessageContent>();
}
return _elementChosenMessage;
}
}
#endregion
#region Constructors
public ElementPickerViewModel(bool allowControlElements)
{
Categories = new List<CategoryViewModel>();
if (allowControlElements)
{
Categories.Add(
new CategoryViewModel(
"Kontroll-Elemente",
new Collection<ViewModelBase>()
{
CreateControlElementViewModel(new SelectFirstDay()),
CreateControlElementViewModel(new SelectLastDay()),
CreateControlElementViewModel(new SelectEachDay())
}
)
);
}
Categories.Add(
new CategoryViewModel(
"Ausgabe-Elemente",
new Collection<ViewModelBase>()
{
CreateFormatElementViewModel("Laborparameter", new Items()),
CreateFormatElementViewModel("Beliebiger Text", new CustomText()),
}
)
);
}
#endregion
#region Private methods
/// <summary>
/// Creates a new ControlElementViewModel that wraps a ControlElementBase
/// object. The display string of the ControlElementViewModel is taken
/// from the canonical Label of the control element.
/// </summary>
ViewModelBase CreateControlElementViewModel(ControlElementBase element)
{
ControlElementViewModel vm = new ControlElementViewModel(element);
vm.DisplayString = element.Label;
vm.PropertyChanged += ElementViewModel_PropertyChanged;
return vm;
}
/// <summary>
/// Creates a new FormatElementViewModel that wraps a FormatElementBase
/// object and has a custom display string. The custom display string
/// is necessary because format elements do not have a canonical label.
/// </summary>
ViewModelBase CreateFormatElementViewModel(string name, FormatElementBase element)
{
FormatElementViewModel vm = new FormatElementViewModel(element);
vm.DisplayString = name;
vm.PropertyChanged += ElementViewModel_PropertyChanged;
return vm;
}
void ElementViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsSelected")
{
// Casting sender as ElementViewModel may result in Null, but this
// is a desired effect because category headings may be selected
// in a view, but are not valid ElementViewModels that we could
// 'choose'.
Selected = sender as ElementViewModel;
}
}
void DoChooseElement()
{
if (CanChooseElement())
{
ElementChosenMessage.Send(new ViewModelMessageContent(Selected));
}
}
bool CanChooseElement()
{
return Selected != null;
}
#endregion
#region Implementation ov ViewModelBase
public override object RevealModelObject()
{
throw new NotImplementedException();
}
#endregion
#region Fields
DelegatingCommand _chooseElementCommand;
Message<ViewModelMessageContent> _elementChosenMessage;
#endregion
}
}

View File

@ -26,7 +26,7 @@ using System.Collections.ObjectModel;
namespace zaaReloaded2.ViewModels
{
abstract class ElementViewModel : ViewModelBase
public abstract class ElementViewModel : ViewModelBase
{
#region Properties

View File

@ -24,7 +24,7 @@ using zaaReloaded2.Controller.Elements;
namespace zaaReloaded2.ViewModels
{
class FormatElementViewModel : ElementViewModel
public class FormatElementViewModel : ElementViewModel
{
#region Public properties

View File

@ -0,0 +1,343 @@
/* SettingsRepositoryViewModel.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 Bovender.Mvvm;
using Bovender.Mvvm.ViewModels;
using Bovender.Mvvm.Messaging;
using zaaReloaded2.Controller;
using System.Collections.ObjectModel;
namespace zaaReloaded2.ViewModels
{
public class SettingsRepositoryViewModel : ViewModelBase
{
#region Properties
public ObservableCollection<SettingsViewModel> SettingsList { get; private set; }
public SettingsViewModel Selected { get; private set; }
#endregion
#region Commands
public DelegatingCommand AddSettingsCommand
{
get
{
if (_addSettingsCommand == null)
{
_addSettingsCommand = new DelegatingCommand(
param => DoAddSettings());
}
return _addSettingsCommand;
}
}
public DelegatingCommand EditSettingsCommand
{
get
{
if (_editSettingsCommand == null)
{
_editSettingsCommand = new DelegatingCommand(
param => DoEditSettings(),
param => CanEditSettings());
}
return _editSettingsCommand;
}
}
public DelegatingCommand UseSettingsCommand
{
get
{
if (_useSettingsCommand == null)
{
_useSettingsCommand = new DelegatingCommand(
param => DoUseSettings(),
param => CanUseSettings());
}
return _useSettingsCommand;
}
}
public DelegatingCommand DeleteSettingsCommand
{
get
{
if (_deleteSettingsCommand == null)
{
_deleteSettingsCommand = new DelegatingCommand(
param => DoDeleteSettings(),
param => CanDeleteSettings());
}
return _deleteSettingsCommand;
}
}
public DelegatingCommand CopySettingsCommand
{
get
{
if (_copySettingsCommand == null)
{
_copySettingsCommand = new DelegatingCommand(
param => DoCopySettings());
}
return _copySettingsCommand;
}
}
public DelegatingCommand ResetSettingsCommand
{
get
{
if (_resetSettingsCommand == null)
{
_resetSettingsCommand = new DelegatingCommand(
param => DoResetSettings());
}
return _resetSettingsCommand;
}
}
#endregion
#region Messages
public Message<ViewModelMessageContent> EditSettingsMessage
{
get
{
if (_editSettingsMessage == null)
{
_editSettingsMessage = new Message<ViewModelMessageContent>();
}
return _editSettingsMessage;
}
}
public Message<ViewModelMessageContent> UseSettingsMessage
{
get
{
if (_useSettingsMessage == null)
{
_useSettingsMessage = new Message<ViewModelMessageContent>();
}
return _useSettingsMessage;
}
}
public Message<ViewModelMessageContent> ConfirmDeleteSettingsMessage
{
get
{
if (_confirmDeleteSettingsMessage == null)
{
_confirmDeleteSettingsMessage = new Message<ViewModelMessageContent>();
}
return _confirmDeleteSettingsMessage;
}
}
public Message<ViewModelMessageContent> ConfirmResetSettingsMessage
{
get
{
if (_confirmResetSettingsMessage == null)
{
_confirmResetSettingsMessage = new Message<ViewModelMessageContent>();
}
return _confirmResetSettingsMessage;
}
}
#endregion
#region Constructors
public SettingsRepositoryViewModel(SettingsRepository repository)
{
_repository = repository;
SettingsList = new ObservableCollection<SettingsViewModel>();
foreach (Settings s in repository.SettingsList)
{
SettingsViewModel vm = new SettingsViewModel(s);
AddSettingsViewModel(vm);
}
}
#endregion
#region Private methods
void DoEditSettings()
{
if (CanEditSettings())
{
EditSettingsMessage.Send(new ViewModelMessageContent(Selected));
}
}
bool CanEditSettings()
{
return Selected != null && !IsDefaultSettings();
}
void DoUseSettings()
{
UseSettingsMessage.Send(new ViewModelMessageContent(Selected));
}
bool CanUseSettings()
{
return Selected != null;
}
void DoAddSettings()
{
Settings s = new Settings("Neu");
SettingsViewModel vm = new SettingsViewModel(s);
_repository.SettingsList.Add(s);
SettingsList.Add(vm);
vm.IsSelected = true;
}
bool CanDeleteSettings()
{
return Selected != null && !IsDefaultSettings();
}
void DoDeleteSettings()
{
if (CanDeleteSettings())
{
ConfirmDeleteSettingsMessage.Send(
new ViewModelMessageContent(Selected),
param => ConfirmDeleteSettings(param));
}
}
void ConfirmDeleteSettings(ViewModelMessageContent content)
{
SettingsViewModel vm = content.ViewModel as SettingsViewModel;
if (CanDeleteSettings() && content.Confirmed)
{
_repository.SettingsList.Remove(vm.RevealModelObject() as Settings);
SettingsList.Remove(vm);
}
}
void DoResetSettings()
{
ConfirmResetSettingsMessage.Send(
new ViewModelMessageContent(this),
param => ConfirmResetSettings(param));
}
void ConfirmResetSettings(ViewModelMessageContent content)
{
if (content.Confirmed)
{
}
}
void DoCopySettings()
{
if (Selected != null)
{
SettingsViewModel copy = Selected.Clone() as SettingsViewModel;
_repository.SettingsList.Add(copy.RevealModelObject() as Settings);
AddSettingsViewModel(copy);
Selected.IsSelected = false;
copy.IsSelected = true;
}
}
void SettingsViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
SettingsViewModel vm = sender as SettingsViewModel;
if (vm != null && e.PropertyName == "IsSelected")
{
Selected = vm.IsSelected ? vm : null;
}
}
/// <summary>
/// Determines whether the selected SettingsViewModel belongs
/// to one of the default settings.
/// </summary>
bool IsDefaultSettings()
{
if (Selected != null)
{
return
(Selected.Name == zaaReloaded2.Properties.Settings.Default.SettingsNameClinic
|| Selected.Name == zaaReloaded2.Properties.Settings.Default.SettingsNameWard);
}
else
{
return false;
}
}
/// <summary>
/// Adds a settings view model to the collection and wires the
/// PropertyChanged event.
/// </summary>
/// <param name="settingsViewModel">SettingsViewModel to add.</param>
void AddSettingsViewModel(SettingsViewModel settingsViewModel)
{
settingsViewModel.PropertyChanged += SettingsViewModel_PropertyChanged;
SettingsList.Add(settingsViewModel);
}
#endregion
#region Implementation of ViewModelBase
public override object RevealModelObject()
{
return _repository;
}
#endregion
#region Fields
SettingsRepository _repository;
DelegatingCommand _useSettingsCommand;
DelegatingCommand _addSettingsCommand;
DelegatingCommand _editSettingsCommand;
DelegatingCommand _deleteSettingsCommand;
DelegatingCommand _resetSettingsCommand;
DelegatingCommand _copySettingsCommand;
Message<ViewModelMessageContent> _confirmDeleteSettingsMessage;
Message<ViewModelMessageContent> _confirmResetSettingsMessage;
Message<ViewModelMessageContent> _editSettingsMessage;
Message<ViewModelMessageContent> _useSettingsMessage;
#endregion
}
}

View File

@ -22,6 +22,7 @@ using System.Linq;
using System.Text;
using Bovender.Mvvm;
using Bovender.Mvvm.ViewModels;
using Bovender.Mvvm.Messaging;
using zaaReloaded2.Controller;
using zaaReloaded2.Controller.Elements;
using zaaReloaded2.Formatter;
@ -31,7 +32,7 @@ namespace zaaReloaded2.ViewModels
/// <summary>
/// View model for the zaaReloaded2.Controller.Settings class.
/// </summary>
class SettingsViewModel : ViewModelBase
public class SettingsViewModel : ViewModelBase, ICloneable
{
#region Properties
@ -70,14 +71,7 @@ namespace zaaReloaded2.ViewModels
/// <summary>
/// Gets a list of element view models.
/// </summary>
public IList<ElementViewModel> Elements
{
get
{
if (_elements == null) { _elements = new List<ElementViewModel>(); }
return _elements;
}
}
public IList<ElementViewModel> Elements { get; private set; }
/// <summary>
/// Gets or sets the currently selected element.
@ -119,7 +113,7 @@ namespace zaaReloaded2.ViewModels
: base()
{
_settings = settings;
_elements = new List<ElementViewModel>();
Elements = new List<ElementViewModel>();
foreach (ElementBase element in settings.Elements)
{
ElementViewModel vm;
@ -130,13 +124,18 @@ namespace zaaReloaded2.ViewModels
else if (element is ControlElementBase)
{
vm = new ControlElementViewModel(element as ControlElementBase);
foreach (FormatElementViewModel childVM in ((ControlElementViewModel)vm).Elements)
{
childVM.PropertyChanged += ElementViewModel_PropertyChanged;
}
}
else
{
throw new InvalidOperationException(
"Cannot create ViewModel for " + element.GetType().ToString());
}
AddElementViewModel(vm);
vm.PropertyChanged += ElementViewModel_PropertyChanged;
Elements.Add(vm);
}
}
@ -144,6 +143,30 @@ namespace zaaReloaded2.ViewModels
#region Messages
public Message<ViewModelMessageContent> AddElementMessage
{
get
{
if (_addElementMessage == null)
{
_addElementMessage = new Message<ViewModelMessageContent>();
}
return _addElementMessage;
}
}
public Message<ViewModelMessageContent> AddChildElementMessage
{
get
{
if (_addChildElementMessage == null)
{
_addChildElementMessage = new Message<ViewModelMessageContent>();
}
return _addChildElementMessage;
}
}
#endregion
#region Commands
@ -161,6 +184,20 @@ namespace zaaReloaded2.ViewModels
}
}
public DelegatingCommand AddChildElementCommand
{
get
{
if (_addChildElementCommand == null)
{
_addChildElementCommand = new DelegatingCommand(
param => DoAddChildElement(),
param => CanAddChildElement());
}
return _addChildElementCommand;
}
}
public DelegatingCommand DeleteElementCommand
{
get
@ -191,9 +228,67 @@ namespace zaaReloaded2.ViewModels
#endregion
#region Public methods
/// <summary>
/// Wires the OnProperty changed event of an ElementViewModel's
/// wrapped model and adds the view model to the Elements collection.
/// </summary>
public void AddElementViewModel(ElementViewModel elementViewModel)
{
elementViewModel.PropertyChanged += ElementViewModel_PropertyChanged;
Elements.Add(elementViewModel);
_settings.Elements.Add(elementViewModel.RevealModelObject() as ElementBase);
}
/// <summary>
/// Wires the OnProperty changed event of an ElementViewModel's
/// wrapped model and adds the view model as a child of another
/// view model.
/// </summary>
public void AddChildElementViewModel(ControlElementViewModel parent, FormatElementViewModel child)
{
child.PropertyChanged += ElementViewModel_PropertyChanged;
parent.AddChildElement(child);
}
#endregion
#region Private methods
void DoAddElement() { }
void DoAddElement()
{
// Create a new element picker; it will automatically create and
// send us a new element view model if one is chosen by the view.
ElementPickerViewModel picker = new ElementPickerViewModel(true);
picker.ElementChosenMessage.Sent += (sender, args) =>
{
ElementViewModel newVM = args.Content.ViewModel as ElementViewModel;
AddElementViewModel(newVM);
};
AddElementMessage.Send(new ViewModelMessageContent(picker));
}
void DoAddChildElement()
{
if (CanAddChildElement())
{
// Create a new element picker; it will automatically create and
// send us a new element view model if one is chosen by the view.
ElementPickerViewModel picker = new ElementPickerViewModel(false);
picker.ElementChosenMessage.Sent += (sender, args) =>
{
FormatElementViewModel newVM = args.Content.ViewModel as FormatElementViewModel;
AddChildElementViewModel(SelectedElement as ControlElementViewModel, newVM);
};
AddChildElementMessage.Send(new ViewModelMessageContent(picker));
}
}
bool CanAddChildElement()
{
return SelectedElement is ControlElementViewModel;
}
void DoDeleteElement() { }
@ -203,17 +298,6 @@ namespace zaaReloaded2.ViewModels
bool CanCopyElement() { return _selectedElement != null; }
/// <summary>
/// Internal function that creates wires the OnProperty changed event
/// of an ElementViewModel's wrapped model and adds the view model
/// to the Elements collection.
/// </summary>
void AddElementViewModel(ElementViewModel elementViewModel)
{
elementViewModel.PropertyChanged += ElementViewModel_PropertyChanged;
Elements.Add(elementViewModel);
}
/// <summary>
/// Sets or unsets the SelectedElement property whenever the IsSelected
/// property of an ElementViewModel changes.
@ -221,7 +305,7 @@ namespace zaaReloaded2.ViewModels
void ElementViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
ElementViewModel vm = sender as ElementViewModel;
if (vm != null)
if (vm != null && e.PropertyName == "IsSelected")
{
SelectedElement = vm.IsSelected ? vm : null;
}
@ -238,13 +322,24 @@ namespace zaaReloaded2.ViewModels
#endregion
#region Implementation of ICloneable
public object Clone()
{
return new SettingsViewModel(_settings.Clone() as Settings);
}
#endregion
#region Fields
Settings _settings;
DelegatingCommand _addElementCommand;
DelegatingCommand _addChildElementCommand;
DelegatingCommand _deleteElementCommand;
DelegatingCommand _copyElementCommand;
List<ElementViewModel> _elements;
Message<ViewModelMessageContent> _addElementMessage;
Message<ViewModelMessageContent> _addChildElementMessage;
ElementViewModel _selectedElement;
EnumProvider<ReferenceStyle> _referenceStyle;

View File

@ -0,0 +1,60 @@
<!--
AboutView - Copy.xaml
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.
-->
<Window x:Class="zaaReloaded2.Views.SettingsRepositoryView"
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"
b:WindowState.CenterScreen="True" b:WindowState.Save="True"
Title="Stil auswählen"
>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/zaaReloaded2;component/style.xaml" />
<ResourceDictionary>
<Style x:Key="settingsListItem" TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<StackPanel Margin="10">
<Label Target="{Binding ElementName=settingsList}">Bitte Stil auswählen:</Label>
<DockPanel Margin="0 5 0 0">
<StackPanel DockPanel.Dock="Right" Margin="10 0 0 0">
<Button Command="{Binding UseSettingsCommand}" Content="Wählen" Margin="0 0 0 5" />
<Button Command="{Binding AddSettingsCommand}" Content="Hinzufügen" Margin="0 10 0 5" />
<Button Command="{Binding EditSettingsCommand}" Content="Bearbeiten" Margin="0 0 0 5" />
<Button Command="{Binding DeleteSettingsCommand}" Content="Entfernen" Margin="0 0 0 5" />
<Button Command="{Binding CopySettingsCommand}" Content="Kopieren" Margin="0 0 0 5" />
<Button Command="{Binding CloseViewCommand}" Content="Abbruch" Margin="0 10 0 0" IsCancel="True" />
</StackPanel>
<StackPanel>
<ListBox ItemsSource="{Binding SettingsList}"
DisplayMemberPath="Name"
ItemContainerStyle="{StaticResource settingsListItem}"
x:Name="settingsList"
MinWidth="240" MinHeight="240" />
</StackPanel>
</DockPanel>
</StackPanel>
</Window>

View File

@ -1,4 +1,4 @@
/* SettingsRepositoryViewModel.cs
/* SettingsRepositoryView.xaml.cs
* part of zaaReloaded2
*
* Copyright 2015 Daniel Kraus
@ -15,22 +15,19 @@
* 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 NUnit.Framework;
using zaaReloaded2.Controller;
namespace Tests.ViewModels
{
[TestFixture]
class SettingsRepositoryViewModel
{
[Test]
public void CannotDeleteDefaultSettings()
{
using System.Windows;
namespace zaaReloaded2.Views
{
/// <summary>
/// Interaction logic for SettingsRepositoryView.xaml
/// </summary>
public partial class SettingsRepositoryView : Window
{
public SettingsRepositoryView()
{
InitializeComponent();
}
}
}

View File

@ -99,6 +99,9 @@
<setting name="LastUpdateCheck" serializeAs="String">
<value />
</setting>
<setting name="LastSettings" serializeAs="String">
<value>00000000-0000-0000-0000-000000000000</value>
</setting>
</zaaReloaded2.Properties.Settings>
</userSettings>
</configuration>

View File

@ -176,6 +176,7 @@
<Compile Include="Controller\Elements\CustomText.cs" />
<Compile Include="Controller\Settings.cs" />
<Compile Include="Controller\SettingsRepository.cs" />
<Compile Include="Demo\Demo.cs" />
<Compile Include="ExceptionHandler\ExceptionDetailView.xaml.cs" />
<Compile Include="ExceptionHandler\ExceptionView.xaml.cs" />
<Compile Include="ExceptionHandler\ExceptionViewModel.cs" />
@ -219,9 +220,15 @@
</Compile>
<Compile Include="Updater\Updater.cs" />
<Compile Include="ViewModels\AboutViewModel.cs" />
<Compile Include="ViewModels\CategoryViewModel.cs" />
<Compile Include="ViewModels\ElementPickerViewModel.cs" />
<Compile Include="ViewModels\ElementViewModel.cs" />
<Compile Include="ViewModels\FormatElementViewModel.cs" />
<Compile Include="ViewModels\ControlElementViewModel.cs" />
<Compile Include="ViewModels\SettingsRepositoryViewModel.cs" />
<Compile Include="Views\SettingsRepositoryView.xaml.cs">
<DependentUpon>SettingsRepositoryView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\AboutView.xaml.cs">
<DependentUpon>AboutView.xaml</DependentUpon>
</Compile>
@ -237,6 +244,7 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="app.config" />
<EmbeddedResource Include="Demo\Demo.docx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
@ -289,6 +297,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
<Page Include="Views\SettingsRepositoryView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\AboutView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -314,6 +326,9 @@
<ItemGroup>
<Resource Include="Icons\fff.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\d.png" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>