From 9404d588094a9ed0ad6db9e0034db74f2d90dee2 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Mon, 31 Aug 2015 22:01:59 +0200 Subject: [PATCH] Implement user preferences and typist mode. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - NEU: Sekretariatsmodus (siehe 'Einstellungen'), um die Nachfrage nach Zusatz-Kommentaren zu unterdrücken. --- .../Controller/Comments/CommentPool.cs | 3 + zaaReloaded2/Preferences.cs | 73 ++++++++++++ zaaReloaded2/Properties/Settings.Designer.cs | 12 ++ zaaReloaded2/Properties/Settings.settings | 3 + zaaReloaded2/Ribbon.cs | 4 + zaaReloaded2/Ribbon.xml | 3 + .../ViewModels/PreferencesViewModel.cs | 111 ++++++++++++++++++ zaaReloaded2/Views/PreferencesView.xaml | 49 ++++++++ zaaReloaded2/Views/PreferencesView.xaml.cs | 33 ++++++ zaaReloaded2/app.config | 3 + zaaReloaded2/zaaReloaded2.csproj | 12 ++ 11 files changed, 306 insertions(+) create mode 100755 zaaReloaded2/Preferences.cs create mode 100755 zaaReloaded2/ViewModels/PreferencesViewModel.cs create mode 100755 zaaReloaded2/Views/PreferencesView.xaml create mode 100755 zaaReloaded2/Views/PreferencesView.xaml.cs diff --git a/zaaReloaded2/Controller/Comments/CommentPool.cs b/zaaReloaded2/Controller/Comments/CommentPool.cs index 69775e6..21214bf 100755 --- a/zaaReloaded2/Controller/Comments/CommentPool.cs +++ b/zaaReloaded2/Controller/Comments/CommentPool.cs @@ -126,6 +126,9 @@ namespace zaaReloaded2.Controller.Comments protected virtual void OnFillInComment(ItemCommentEventArgs args) { + if (Preferences.Default.SuppressItemCommentInteraction) + return; + EventHandler h = FillInComment; if (h != null) { diff --git a/zaaReloaded2/Preferences.cs b/zaaReloaded2/Preferences.cs new file mode 100755 index 0000000..87146fe --- /dev/null +++ b/zaaReloaded2/Preferences.cs @@ -0,0 +1,73 @@ +/* Preferences.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 +{ + /// + /// Holds user preferences. + /// + public class Preferences + { + #region Singleton + + public static Preferences Default + { + get + { + return _instance; + } + } + + static readonly Preferences _instance = new Preferences(); + + static Preferences() { } + + #endregion + + #region Properties + + /// + /// Gets or sets whether the add-in should not ask for + /// item comments (i.e. typist mode). + /// + public bool SuppressItemCommentInteraction + { + get + { + return Properties.Settings.Default.SuppressItemCommentInteraction; + } + set + { + Properties.Settings.Default.SuppressItemCommentInteraction = value; + Properties.Settings.Default.Save(); + } + } + + #endregion + + #region Constructors + + protected Preferences() { } + + #endregion + } +} diff --git a/zaaReloaded2/Properties/Settings.Designer.cs b/zaaReloaded2/Properties/Settings.Designer.cs index 735da12..6eb64bf 100755 --- a/zaaReloaded2/Properties/Settings.Designer.cs +++ b/zaaReloaded2/Properties/Settings.Designer.cs @@ -222,5 +222,17 @@ namespace zaaReloaded2.Properties { return ((global::zaaReloaded2.Formatter.AbnormalStyle)(this["AbnormalStyle"])); } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool SuppressItemCommentInteraction { + get { + return ((bool)(this["SuppressItemCommentInteraction"])); + } + set { + this["SuppressItemCommentInteraction"] = value; + } + } } } diff --git a/zaaReloaded2/Properties/Settings.settings b/zaaReloaded2/Properties/Settings.settings index ebde00b..7a1c310 100755 --- a/zaaReloaded2/Properties/Settings.settings +++ b/zaaReloaded2/Properties/Settings.settings @@ -65,5 +65,8 @@ None + + False + \ No newline at end of file diff --git a/zaaReloaded2/Ribbon.cs b/zaaReloaded2/Ribbon.cs index 99412c6..31c1211 100755 --- a/zaaReloaded2/Ribbon.cs +++ b/zaaReloaded2/Ribbon.cs @@ -109,6 +109,10 @@ namespace zaaReloaded2 ViewModels.AboutViewModel vm = new ViewModels.AboutViewModel(); vm.InjectInto().ShowDialog(); break; + case "zrlPreferences": + ViewModels.PreferencesViewModel.Default.InjectInto() + .ShowDialog(); + break; case "zrlDaniel": Formatter.DanielsStyle.Apply( Globals.ThisAddIn.Application.ActiveDocument, diff --git a/zaaReloaded2/Ribbon.xml b/zaaReloaded2/Ribbon.xml index 6c83da5..0fb6d2e 100755 --- a/zaaReloaded2/Ribbon.xml +++ b/zaaReloaded2/Ribbon.xml @@ -36,6 +36,9 @@