Implement first-run wizard.

This commit is contained in:
Daniel Kraus 2015-09-05 19:47:58 +02:00
parent c141fcff58
commit 78ceeb5017
8 changed files with 262 additions and 8 deletions

View File

@ -234,5 +234,17 @@ namespace zaaReloaded2.Properties {
this["SuppressItemCommentInteraction"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool FirstRunWizardShown {
get {
return ((bool)(this["FirstRunWizardShown"]));
}
set {
this["FirstRunWizardShown"] = value;
}
}
}
}

View File

@ -68,5 +68,8 @@
<Setting Name="SuppressItemCommentInteraction" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="FirstRunWizardShown" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -16,14 +16,7 @@
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.IO;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
using Bovender.Versioning;
using Bovender.Mvvm.Messaging;
using zaaReloaded2.ExceptionHandler;
@ -62,6 +55,7 @@ namespace zaaReloaded2
Properties.Settings.Default.AddinName,
Updater.Version.CurrentVersion().ToString()
);
ViewModels.FirstRunViewModel.InjectIntoIfNeeded<Views.FirstRunView>();
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)

View File

@ -0,0 +1,140 @@
/* FirstRunViewModel.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 the first-run wizard
/// </summary>
class FirstRunViewModel : ViewModelBase
{
#region Static method
/// <summary>
/// If the first-run wizard hasn't been shown to this user
/// yet, creates a new instance of FirstRunViewModel,
/// injects it into the view T and shows the view.
/// </summary>
/// <typeparam name="T">Window to inject the view model into.</typeparam>
public static void InjectIntoIfNeeded<T>()
where T: System.Windows.Window, new()
{
if (!Properties.Settings.Default.FirstRunWizardShown)
{
FirstRunViewModel vm = new FirstRunViewModel();
vm.InjectInto<T>().Show();
}
}
#endregion
#region Commands
public DelegatingCommand SelectDoctorsModeCommand
{
get
{
if (_selectDoctorsModeCommand == null)
{
_selectDoctorsModeCommand = new DelegatingCommand(
param => DoSelectDoctorsMode());
}
return _selectDoctorsModeCommand;
}
}
public DelegatingCommand SelectTypistsModeCommand
{
get
{
if (_selectTypistsModeCommand == null)
{
_selectTypistsModeCommand = new DelegatingCommand(
param => DoSelectTypistsMode());
}
return _selectTypistsModeCommand;
}
}
#endregion
#region Constructor
/// <summary>
/// Private constructor to enforce using the static
/// </summary>
private FirstRunViewModel() : base() { }
#endregion
#region Private methods
void DoSelectDoctorsMode()
{
// Properties will be saved by the DoCloseView override.
Properties.Settings.Default.SuppressItemCommentInteraction = false;
CloseViewCommand.Execute(null);
}
void DoSelectTypistsMode()
{
// Properties will be saved by the DoCloseView override.
Properties.Settings.Default.SuppressItemCommentInteraction = true;
CloseViewCommand.Execute(null);
}
#endregion
#region Overrides
/// <summary>
/// Sets the FirstRunWizardShown property of the assembly properties
/// to true and calls the base function to close the associated view.
/// </summary>
protected override void DoCloseView()
{
Properties.Settings.Default.FirstRunWizardShown = true;
Properties.Settings.Default.Save();
base.DoCloseView();
}
#endregion
#region Implementation of ViewModelBase
public override object RevealModelObject()
{
throw new NotImplementedException();
}
#endregion
#region Fields
DelegatingCommand _selectDoctorsModeCommand;
DelegatingCommand _selectTypistsModeCommand;
#endregion
}
}

View File

@ -0,0 +1,61 @@
<!--
FirstRunView.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.FirstRunView"
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"
ResizeMode="NoResize" ShowInTaskbar="False" Topmost="True"
SizeToContent="Height" Width="480"
b:WindowState.CenterScreen="True"
Title="Willkommen bei zaaReloaded"
>
<Window.Resources>
<ResourceDictionary Source="/zaaReloaded2;component/Style.xaml" />
</Window.Resources>
<StackPanel Margin="10">
<TextBlock FontWeight="Bold" FontSize="20" Margin="0 0 0 5">
Willkommen bei zaaReloaded
</TextBlock>
<Rectangle Fill="Navy" Height="1.5" HorizontalAlignment="Stretch" />
<TextBlock Margin="0 10 0 0">
Bitte den Arbeitsmodus auswählen:
</TextBlock>
<DockPanel Margin="0 10 0 5">
<Button Height="40" DockPanel.Dock="Left" Command="{Binding SelectDoctorsModeCommand}" Content="Ärztemodus"
Width="160" Margin="0 0 10 0" VerticalAlignment="Center" />
<TextBlock TextWrapping="Wrap" VerticalAlignment="Center">
Im Ärztemodus werden beim Formatieren bei Bedarf Zusatzinformationen zu Laborparametern
abgefragt (z.B. Medikamenten-Zielspiegel).
</TextBlock>
</DockPanel>
<DockPanel Margin="0 5 0 10">
<Button Height="40" DockPanel.Dock="Left" Command="{Binding SelectTypistsModeCommand}" Content="Sekretariatsmodus"
Width="160" Margin="0 0 10 0" VerticalAlignment="Center" />
<TextBlock TextWrapping="Wrap" VerticalAlignment="Center">
Im Ärztemodus werden beim Formatieren grundsätzlich keine Zusatzinformationen abgefragt.
</TextBlock>
</DockPanel>
<TextBlock TextWrapping="Wrap" Foreground="Gray">
Die Einstellungen können jederzeit unter "Einstellungen" wieder geändert werden.
</TextBlock>
</StackPanel>
</Window>

View File

@ -0,0 +1,33 @@
/* FirstRunView.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 FirstRunView.xaml
/// </summary>
public partial class FirstRunView : Window
{
public FirstRunView()
{
InitializeComponent();
}
}
}

View File

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

View File

@ -256,6 +256,7 @@
<Compile Include="ViewModels\CategoryViewModel.cs" />
<Compile Include="ViewModels\ElementPickerViewModel.cs" />
<Compile Include="ViewModels\ElementViewModel.cs" />
<Compile Include="ViewModels\FirstRunViewModel.cs" />
<Compile Include="ViewModels\FormatElementViewModel.cs" />
<Compile Include="ViewModels\ControlElementViewModel.cs" />
<Compile Include="ViewModels\IoErrorViewModel.cs" />
@ -274,6 +275,9 @@
<Compile Include="Views\ElementView.xaml.cs">
<DependentUpon>ElementView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\FirstRunView.xaml.cs">
<DependentUpon>FirstRunView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\PreferencesView.xaml.cs">
<DependentUpon>PreferencesView.xaml</DependentUpon>
</Compile>
@ -369,6 +373,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\FirstRunView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\PreferencesView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -470,4 +478,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>