using System.Windows.Media.Imaging;
using Caliburn.Micro;
using WixSharp;
using WixSharp.UI.Forms;
using WixSharp.UI.WPF;
namespace Sai.RvKits_Setup
{
///
/// The standard MaintenanceTypeDialog.
/// Follows the design of the canonical Caliburn.Micro View (MVVM).
/// See https://caliburnmicro.com/documentation/cheat-sheet
///
///
///
///
public partial class MaintenanceTypeDialog : WpfDialog, IWpfDialog
{
///
/// Initializes a new instance of the class.
///
public MaintenanceTypeDialog()
{
InitializeComponent();
}
///
/// This method is invoked by WixSHarp runtime when the custom dialog content is internally fully initialized.
/// This is a convenient place to do further initialization activities (e.g. localization).
///
public void Init()
{
ViewModelBinder.Bind(new MaintenanceTypeDialogModel { Host = ManagedFormHost, }, this, null);
}
}
///
/// ViewModel for standard MaintenanceTypeDialog.
/// Follows the design of the canonical Caliburn.Micro ViewModel (MVVM).
/// See https://caliburnmicro.com/documentation/cheat-sheet
///
///
internal class MaintenanceTypeDialogModel : Caliburn.Micro.Screen
{
public ManagedForm Host;
ISession session => Host?.Runtime.Session;
IManagedUIShell shell => Host?.Shell;
public BitmapImage Banner => session?.GetResourceBitmap("WixSharpUI_Bmp_Banner").ToImageSource();
///
/// Initializes a new instance of the class.
///
void JumpToProgressDialog()
{
int index = shell.Dialogs.IndexOfDialogImplementing();
if (index != -1)
shell.GoTo(index);
else
shell.GoNext(); // if user did not supply progress dialog then simply go next
}
public void Change()
{
if (session != null)
{
session["MODIFY_ACTION"] = "Change";
shell.GoNext();
}
}
public void Repair()
{
if (session != null)
{
session["MODIFY_ACTION"] = "Repair";
JumpToProgressDialog();
}
}
public void Remove()
{
if (session != null)
{
session["REMOVE"] = "ALL";
session["MODIFY_ACTION"] = "Remove";
JumpToProgressDialog();
}
}
public void GoPrev()
=> shell?.GoPrev();
public void Cancel()
=> Host?.Shell.Cancel();
}
}