Implement first-run wizard.
This commit is contained in:
140
zaaReloaded2/ViewModels/FirstRunViewModel.cs
Executable file
140
zaaReloaded2/ViewModels/FirstRunViewModel.cs
Executable 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user