Skip to content

Commit

Permalink
- Improved positioning of the background images for WPF UI Dialogs
Browse files Browse the repository at this point in the history
- WIP: Added support for modern style folder selection dialog (triggered by #1734 discussion)
- Added a more convenient option to play dialogs in demo mode during development
  • Loading branch information
oleg-shilo committed Feb 1, 2025
1 parent a1ba08a commit ec24541
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using Caliburn.Micro;
using System;
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using Caliburn.Micro;
using WixSharp;
using WixSharp.UI.Forms;

using IO = System.IO;

namespace WixSharp.UI.WPF.Sequence
Expand Down Expand Up @@ -74,11 +75,23 @@ public string InstallDirPath

public void ChangeInstallDir()
{
// `OpenFolderDialog.Select` is still under development so disabling it for now

// try
// {
// var (isSelected, path) = OpenFolderDialog.Select(InstallDirPath);
// if (isSelected)
// InstallDirPath = path;
// return;
// }
// catch
// {
using (var dialog = new FolderBrowserDialog { SelectedPath = InstallDirPath })
{
if (dialog.ShowDialog() == DialogResult.OK)
InstallDirPath = dialog.SelectedPath;
}
// }
}

public void GoPrev()
Expand Down
30 changes: 30 additions & 0 deletions Source/src/WixSharp.Samples/WixSharp.UI.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Source/src/WixSharp.Suite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ Global
{91003067-7893-4DC3-B2F8-AB93D72467BD} = {DA107019-87B6-473D-8C9B-1C3A48CB8FD5}
{29DF07CE-4648-47DE-8440-3DB54D49D5D2} = {C8D0CD2D-0340-4E97-9E62-5A8334AD9E2D}
{1CFD0B87-E292-41B3-A914-FF8254D4A32C} = {DA107019-87B6-473D-8C9B-1C3A48CB8FD5}
{B8EFFF07-76BC-4E6D-9A13-4E3A0777EB0C} = {AE8877B5-88C1-4493-B70D-27DCCEA5CE39}
{18EF7DE3-5726-46CF-A2F1-B168D84328B4} = {1CFD0B87-E292-41B3-A914-FF8254D4A32C}
{C34D92EB-36E6-4405-8479-8218570D1F76} = {DA107019-87B6-473D-8C9B-1C3A48CB8FD5}
{EF42EF2C-57E0-41FD-96C8-AACC49DDDCCC} = {5D69978C-B7F0-4CCE-9BC5-B27AEF529A1D}
Expand Down
11 changes: 8 additions & 3 deletions Source/src/WixSharp.UI.WPF/Dialogs/ExitDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
VerticalAlignment="Stretch"
BorderBrush="Gray"
BorderThickness="1">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="75" />
<RowDefinition />
Expand All @@ -55,7 +58,8 @@
<Image
x:Name="Banner"
Grid.RowSpan="2"
Source="{Binding Banner}" />
Source="{Binding Banner}"
Stretch="UniformToFill" />

<TextBlock
x:Name="DialogTitleLabel"
Expand All @@ -64,7 +68,8 @@
Margin="13,25,7,0"
VerticalAlignment="Top"
FontSize="16"
FontWeight="Normal">
FontWeight="Normal"
TextWrapping="WrapWithOverflow">
[ExitDialogTitle]
</TextBlock>
<TextBlock
Expand Down
11 changes: 11 additions & 0 deletions Source/src/WixSharp.UI.WPF/Dialogs/InstallDirDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Media.Imaging;
using WixSharp;
using WixSharp.UI.Forms;
using WixToolset.Dtf.WindowsInstaller;

namespace WixSharp.UI.WPF
{
Expand Down Expand Up @@ -98,11 +99,21 @@ public string InstallDirPath

public void ChangeInstallDir()
{
// `OpenFolderDialog.Select` is still under development so disabling it for now
// try
// {
// var (isSelected, path) = OpenFolderDialog.Select(InstallDirPath);
// if (isSelected)
// InstallDirPath = path;
// }
// catch
// {
using (var dialog = new FolderBrowserDialog { SelectedPath = InstallDirPath })
{
if (dialog.ShowDialog() == DialogResult.OK)
InstallDirPath = dialog.SelectedPath;
}
// }
}

public void GoPrev()
Expand Down
15 changes: 10 additions & 5 deletions Source/src/WixSharp.UI.WPF/Dialogs/WelcomeDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
VerticalAlignment="Stretch"
BorderBrush="Gray"
BorderThickness="1">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="75" />
<RowDefinition />
Expand All @@ -33,21 +36,23 @@
<Image
x:Name="Banner"
Grid.RowSpan="2"
Source="{Binding Banner}" />
Source="{Binding Banner}"
Stretch="UniformToFill" />
<TextBlock
Grid.RowSpan="1"
Grid.Column="1"
Margin="10,25,10,10"
Margin="20,25,10,10"
VerticalAlignment="Top"
FontSize="16"
FontWeight="Normal">
FontWeight="Normal"
TextWrapping="WrapWithOverflow">
[WelcomeDlgTitle]
</TextBlock>
<TextBlock
x:Name="DialogDescription"
Grid.Row="2"
Grid.Column="1"
Margin="10"
Margin="20,10"
TextWrapping="WrapWithOverflow">
[WelcomeDlgDescription]
</TextBlock>
Expand Down
11 changes: 11 additions & 0 deletions Source/src/WixSharp.UI/ManagedUI/Forms/InstallDirDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,24 @@ void cancel_Click(object sender, EventArgs e)

void change_Click(object sender, EventArgs e)
{
// `OpenFolderDialog.Select` is still under development so disabling it for now

// try
// {
// var (isSelected, path) = OpenFolderDialog.Select(installDir.Text);
// if (isSelected)
// installDir.Text = path;
// }
// catch
// {
using (var dialog = new FolderBrowserDialog { SelectedPath = installDir.Text })
{
if (dialog.ShowDialog() == DialogResult.OK)
{
installDir.Text = dialog.SelectedPath;
}
}
// }
}
}
}
5 changes: 5 additions & 0 deletions Source/src/WixSharp.UI/ManagedUI/Forms/ShellView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class Dialogs

class ShellView : Form, IShellView
{
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}

public ShellView()
{
InitializeComponent();
Expand Down
21 changes: 21 additions & 0 deletions Source/src/WixSharp.UI/ManagedUI/UIExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,26 @@ public static string LocalizeWith(this string textToLocalize, Func<string, strin
}
return cleanRegex.Replace(result.ToString(), "");
}

/// <summary>
/// Plays the specified dialogs in demo mode.
/// </summary>
/// <param name="dialogs">The dialogs.</param>
public static void Play(this ManagedDialogs dialogs)
{
UIShell.Play(dialogs);
}

/// <summary>
/// Plays the install dialogs in demo mode.
/// </summary>
/// <param name="ui">The UI.</param>
public static void PlayInstallDialogs(this IManagedUI ui) => UIShell.Play(ui.InstallDialogs);

/// <summary>
/// Plays the modify dialogs in demo mode.
/// </summary>
/// <param name="ui">The UI.</param>
public static void PlayModifyDialogs(this IManagedUI ui) => UIShell.Play(ui.ModifyDialogs);
}
}
8 changes: 8 additions & 0 deletions Source/src/WixSharp.UI/ManagedUI/UIShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ public int CurrentDialogIndex
ManagedProject.InvokeClientHandlers("UnhandledException", msiSession, e);
msiSession.Log("Managed Dialog unhandled Exception: " + e);

try
{
// it's useful to print in console (if available) for troubleshooting
Console.WriteLine("Managed Dialog unhandled Exception: " + e.InnerException?.Message ?? e.Message);
}
catch { }
this.Cancel();
}
}
Expand Down Expand Up @@ -433,6 +439,8 @@ void DemoPlay(ManagedDialogs dialogs, string demoProperties = "")
var resourcesMsi = BuildUiPlayerResources();
var dummySession = Installer.OpenPackage(resourcesMsi, true);

dummySession["WixSharp_UI_INSTALLDIR"] = "INSTALLDIR";

foreach (var pair in demoProperties.ToDictionary())
dummySession[pair.Key] = pair.Value;

Expand Down
1 change: 1 addition & 0 deletions Source/src/WixSharp.UI/WixSharp.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
</None>
<Compile Include="ManagedUI\ISession.cs" />
<Compile Include="ManagedUI\MsiSessionAdapter.cs" />
<Compile Include="ManagedUI\OpenFolderDialog.cs" />
<Compile Include="ManagedUI\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down
2 changes: 1 addition & 1 deletion Source/src/WixSharp/CommonTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ static public XElement SetConfigAttribute(this XElement config, string elementPa
}

/// <summary>
/// Creates the parent XElement component for a given <see cref="WixSharp.WixEntity"/> and adds the specified XElement to it.
/// Creates the parent XElement component for a given <see cref="WixSharp.WixEntity"/> and adds the specified XElement to it.
/// </summary>
/// <param name="entity"></param>
/// <param name="element"></param>
Expand Down

0 comments on commit ec24541

Please sign in to comment.