From 78ceeb50178b269d1ed0e3ff40eb0a4e2a019dbf Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sat, 5 Sep 2015 19:47:58 +0200 Subject: [PATCH] Implement first-run wizard. --- zaaReloaded2/Properties/Settings.Designer.cs | 12 ++ zaaReloaded2/Properties/Settings.settings | 3 + zaaReloaded2/ThisAddIn.cs | 8 +- zaaReloaded2/ViewModels/FirstRunViewModel.cs | 140 +++++++++++++++++++ zaaReloaded2/Views/FirstRunView.xaml | 61 ++++++++ zaaReloaded2/Views/FirstRunView.xaml.cs | 33 +++++ zaaReloaded2/app.config | 3 + zaaReloaded2/zaaReloaded2.csproj | 10 +- 8 files changed, 262 insertions(+), 8 deletions(-) create mode 100755 zaaReloaded2/ViewModels/FirstRunViewModel.cs create mode 100755 zaaReloaded2/Views/FirstRunView.xaml create mode 100755 zaaReloaded2/Views/FirstRunView.xaml.cs diff --git a/zaaReloaded2/Properties/Settings.Designer.cs b/zaaReloaded2/Properties/Settings.Designer.cs index 6eb64bf..dcdaf95 100755 --- a/zaaReloaded2/Properties/Settings.Designer.cs +++ b/zaaReloaded2/Properties/Settings.Designer.cs @@ -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; + } + } } } diff --git a/zaaReloaded2/Properties/Settings.settings b/zaaReloaded2/Properties/Settings.settings index 7a1c310..559ef0f 100755 --- a/zaaReloaded2/Properties/Settings.settings +++ b/zaaReloaded2/Properties/Settings.settings @@ -68,5 +68,8 @@ False + + False + \ No newline at end of file diff --git a/zaaReloaded2/ThisAddIn.cs b/zaaReloaded2/ThisAddIn.cs index 297b63d..ab47a4b 100755 --- a/zaaReloaded2/ThisAddIn.cs +++ b/zaaReloaded2/ThisAddIn.cs @@ -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(); } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) diff --git a/zaaReloaded2/ViewModels/FirstRunViewModel.cs b/zaaReloaded2/ViewModels/FirstRunViewModel.cs new file mode 100755 index 0000000..02b0f4b --- /dev/null +++ b/zaaReloaded2/ViewModels/FirstRunViewModel.cs @@ -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 +{ + /// + /// View model for the first-run wizard + /// + class FirstRunViewModel : ViewModelBase + { + #region Static method + + /// + /// 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. + /// + /// Window to inject the view model into. + public static void InjectIntoIfNeeded() + where T: System.Windows.Window, new() + { + if (!Properties.Settings.Default.FirstRunWizardShown) + { + FirstRunViewModel vm = new FirstRunViewModel(); + vm.InjectInto().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 + + /// + /// Private constructor to enforce using the static + /// + 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 + + /// + /// Sets the FirstRunWizardShown property of the assembly properties + /// to true and calls the base function to close the associated view. + /// + 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 + } +} diff --git a/zaaReloaded2/Views/FirstRunView.xaml b/zaaReloaded2/Views/FirstRunView.xaml new file mode 100755 index 0000000..ec6e0f2 --- /dev/null +++ b/zaaReloaded2/Views/FirstRunView.xaml @@ -0,0 +1,61 @@ + + + + + + + + + Willkommen bei zaaReloaded + + + + Bitte den Arbeitsmodus auswählen: + + +