2020-09-04 08:02:47 -05:00
|
|
|
using WixSharp;
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
namespace Symphony
|
|
|
|
{
|
|
|
|
public partial class WelcomeDlg : WixSharp.UI.Forms.ManagedForm, IManagedDialog
|
|
|
|
{
|
2020-09-04 08:19:15 -05:00
|
|
|
// Helper function to retrive the user name of the current user. The user name returned from
|
|
|
|
// windows can be on the form DOMAIN\USER or USER@DOMAIN. This function strips away the domain
|
|
|
|
// name and separator, and returns the undecorated user name only.
|
2020-09-04 08:02:47 -05:00
|
|
|
private string getUserName()
|
|
|
|
{
|
|
|
|
var name = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
|
|
|
|
var slashIndex = name.IndexOf("\\");
|
|
|
|
return slashIndex > -1 ? name.Substring(slashIndex + 1) : name.Substring(0, name.IndexOf("@"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public WelcomeDlg()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dialog_Load(object sender, System.EventArgs e)
|
|
|
|
{
|
2020-09-10 02:15:10 -05:00
|
|
|
// Populate the dynamic UI elements that can't be set at compile time (background image and
|
2020-09-04 08:19:15 -05:00
|
|
|
// the label containing user name)
|
|
|
|
this.backgroundPanel.BackgroundImage = Runtime.Session.GetResourceBitmap("WixUI_Bmp_Dialog");
|
2020-09-04 08:02:47 -05:00
|
|
|
this.radioButtonCurrentUser.Text = "Only for me (" + getUserName() + ")";
|
2020-09-10 02:15:10 -05:00
|
|
|
if( Runtime.Session["ALLUSERS"] != "" )
|
|
|
|
{
|
|
|
|
this.radioButtonAllUsers.Checked = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.radioButtonCurrentUser.Checked = true;
|
|
|
|
}
|
2020-09-04 08:02:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void next_Click(object sender, System.EventArgs e)
|
|
|
|
{
|
2020-09-04 08:19:15 -05:00
|
|
|
// To enable Wix to use the "MSIINSTALLPERUSER" property being set below, ALLUSERS must be set to 2
|
2020-09-10 02:15:10 -05:00
|
|
|
Runtime.Session["ALLUSERS"] = "2";
|
|
|
|
|
|
|
|
|
2020-09-04 08:02:47 -05:00
|
|
|
if (radioButtonCurrentUser.Checked)
|
|
|
|
{
|
2020-09-04 08:19:15 -05:00
|
|
|
// Install for current user
|
2020-09-04 08:02:47 -05:00
|
|
|
Runtime.Session["MSIINSTALLPERUSER"] = "1"; // per-user
|
2020-10-15 01:02:04 -05:00
|
|
|
Runtime.Session["INSTALLDIR"] = System.Environment.ExpandEnvironmentVariables(@"%LOCALAPPDATA%\Apps\Symphony\" + Runtime.ProductName);
|
2020-09-04 08:02:47 -05:00
|
|
|
} else if (radioButtonAllUsers.Checked)
|
|
|
|
{
|
2020-09-04 08:19:15 -05:00
|
|
|
// Install for all users
|
2020-09-10 02:15:10 -05:00
|
|
|
Runtime.Session["MSIINSTALLPERUSER"] = ""; // per-machine
|
2020-10-15 01:02:04 -05:00
|
|
|
Runtime.Session["INSTALLDIR"] = Runtime.Session["PROGRAMSFOLDER"] + @"\Symphony\" + Runtime.ProductName;
|
2020-09-04 08:02:47 -05:00
|
|
|
}
|
2020-09-10 02:15:10 -05:00
|
|
|
|
2020-09-04 08:02:47 -05:00
|
|
|
Shell.GoNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cancel_Click(object sender, System.EventArgs e)
|
|
|
|
{
|
|
|
|
Shell.Cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|