Implement user preferences and typist mode.

- NEU: Sekretariatsmodus (siehe 'Einstellungen'), um die Nachfrage nach Zusatz-Kommentaren zu unterdrücken.
This commit is contained in:
Daniel Kraus 2015-08-31 22:01:59 +02:00
parent 5db6285a95
commit 9404d58809
11 changed files with 306 additions and 0 deletions

View File

@ -126,6 +126,9 @@ namespace zaaReloaded2.Controller.Comments
protected virtual void OnFillInComment(ItemCommentEventArgs args)
{
if (Preferences.Default.SuppressItemCommentInteraction)
return;
EventHandler<ItemCommentEventArgs> h = FillInComment;
if (h != null)
{

73
zaaReloaded2/Preferences.cs Executable file
View File

@ -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
{
/// <summary>
/// Holds user preferences.
/// </summary>
public class Preferences
{
#region Singleton
public static Preferences Default
{
get
{
return _instance;
}
}
static readonly Preferences _instance = new Preferences();
static Preferences() { }
#endregion
#region Properties
/// <summary>
/// Gets or sets whether the add-in should not ask for
/// item comments (i.e. typist mode).
/// </summary>
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
}
}

View File

@ -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;
}
}
}
}

View File

@ -65,5 +65,8 @@
<Setting Name="AbnormalStyle" Type="zaaReloaded2.Formatter.AbnormalStyle" Scope="Application">
<Value Profile="(Default)">None</Value>
</Setting>
<Setting Name="SuppressItemCommentInteraction" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -109,6 +109,10 @@ namespace zaaReloaded2
ViewModels.AboutViewModel vm = new ViewModels.AboutViewModel();
vm.InjectInto<Views.AboutView>().ShowDialog();
break;
case "zrlPreferences":
ViewModels.PreferencesViewModel.Default.InjectInto<Views.PreferencesView>()
.ShowDialog();
break;
case "zrlDaniel":
Formatter.DanielsStyle.Apply(
Globals.ThisAddIn.Application.ActiveDocument,

View File

@ -36,6 +36,9 @@
<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="zrlPreferences" label="Einstellungen" image="gear.png" onAction="Ribbon_Click" size="large"
screentip="Benutzer-Einstellungen"
supertip="Erlaubt das Einschalten des Sekretariats-Modus." />
<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

@ -0,0 +1,111 @@
/* PreferencesViewModel.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;
namespace zaaReloaded2.ViewModels
{
/// <summary>
/// View model for zaaReloaded2.Preferences.
/// </summary>
public class PreferencesViewModel : ViewModelBase
{
#region Singleton
public static PreferencesViewModel Default
{
get
{
return _instance;
}
}
static PreferencesViewModel() { }
static readonly PreferencesViewModel _instance = new PreferencesViewModel();
#endregion
#region Properties
public bool SuppressItemCommentInteraction { get; set; }
#endregion
#region Command
public DelegatingCommand SaveCommand
{
get
{
if (_saveCommand == null)
{
_saveCommand = new DelegatingCommand(
param => DoSave(),
param => CanSave());
}
return _saveCommand;
}
}
#endregion
#region Constructor
public PreferencesViewModel()
{
SuppressItemCommentInteraction = Preferences.Default.SuppressItemCommentInteraction;
}
#endregion
#region Private methods
void DoSave()
{
Preferences.Default.SuppressItemCommentInteraction = SuppressItemCommentInteraction;
DoCloseView();
}
bool CanSave()
{
return true;
}
#endregion
#region Field
DelegatingCommand _saveCommand;
#endregion
#region ViewModelBase implementation
public override object RevealModelObject()
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@ -0,0 +1,49 @@
<!--
PreferencesView.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.PreferencesView"
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"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:action="clr-namespace:Bovender.Mvvm.Actions;assembly=Bovender"
SizeToContent="WidthAndHeight" ResizeMode="NoResize" ShowInTaskbar="False"
b:WindowState.CenterScreen="True" b:WindowState.Save="True"
Title="Einstellungen"
>
<Window.Resources>
<ResourceDictionary Source="/zaaReloaded2;component/Style.xaml" />
</Window.Resources>
<DockPanel Margin="10">
<UniformGrid DockPanel.Dock="Bottom" Columns="2" Rows="1" Margin="0 10 0 0">
<Button Command="{Binding SaveCommand}" Content="OK" IsDefault="True" Margin="0 0 5 0" />
<Button Command="{Binding CloseViewCommand}" Content="Abbrechen" IsCancel="True" Margin="5 0 0 0" />
</UniformGrid>
<GroupBox Header="Sekretariatsmodus" Padding="10">
<GroupBox.InputBindings>
<KeyBinding Key="S" Modifiers="Alt" />
</GroupBox.InputBindings>
<CheckBox IsChecked="{Binding SuppressItemCommentInteraction}" Content="Keine Interaktion für Kommentare">
<CheckBox.InputBindings>
<KeyBinding Key="k" Modifiers="Alt" />
</CheckBox.InputBindings>
</CheckBox>
</GroupBox>
</DockPanel>
</Window>

View File

@ -0,0 +1,33 @@
/* PreferencesView.xaml.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.Windows;
namespace zaaReloaded2.Views
{
/// <summary>
/// Interaction logic for PreferencesView.xaml
/// </summary>
public partial class PreferencesView : Window
{
public PreferencesView()
{
InitializeComponent();
}
}
}

View File

@ -96,6 +96,9 @@
<setting name="ImportExportPath" serializeAs="String">
<value />
</setting>
<setting name="SuppressItemCommentInteraction" serializeAs="String">
<value>False</value>
</setting>
</zaaReloaded2.Properties.Settings>
</userSettings>
</configuration>

View File

@ -218,6 +218,7 @@
<Compile Include="Formatter\DanielsStyle.cs" />
<Compile Include="Formatter\DocumentWriter.cs" />
<Compile Include="Formatter\NoLaboratoryDataException.cs" />
<Compile Include="Preferences.cs" />
<Compile Include="Ribbon.cs" />
<Compile Include="Thesaurus\ThesaurusBase.cs" />
<Compile Include="Formatter\IItemFormatterDictionary.cs" />
@ -258,6 +259,7 @@
<Compile Include="ViewModels\ControlElementViewModel.cs" />
<Compile Include="ViewModels\IoErrorViewModel.cs" />
<Compile Include="ViewModels\ItemCommentViewModel.cs" />
<Compile Include="ViewModels\PreferencesViewModel.cs" />
<Compile Include="ViewModels\SettingsRepositoryViewModel.cs" />
<Compile Include="Views\ItemCommentView.xaml.cs">
<DependentUpon>ItemCommentView.xaml</DependentUpon>
@ -271,6 +273,9 @@
<Compile Include="Views\ElementView.xaml.cs">
<DependentUpon>ElementView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PreferencesView.xaml.cs">
<DependentUpon>PreferencesView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
@ -363,6 +368,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\PreferencesView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SettingsView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -423,6 +432,9 @@
<ItemGroup>
<Resource Include="Icons\icon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\gear.png" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>