wpfDialogBox is a Dyalog namespace containing methods to show dialog boxes in a WPF application. Check the comments of each method for more information.
Typical Usage
To Query for a Folder
path←DialogFolder
To Query for a File Name to Open
path←DialogOpenFile
To Query for a File Name to Save
path←DialogSaveFile
To Show an Error Message
response←ShowError 'This is an Error Message' 'My Program Name - Error' 'YesNoCancel'
To Show an Information Message
response←ShowInfo 'This is an Information Message' 'My Program Name - Info' 'YesNoCancel'
To Show a Warning Message
response←ShowWarning 'This is a Warning Message' 'My Program Name - Warning' 'YesNoCancel'
Custom WPF Dialog Box
For a custom WPF dialog box you can consult the function CustomMessageBox((ShowHide the code) the code)
CustomMessageBox;bitmap;icon;⎕USING
⍝ Prepare a Custom WPF Message Box
⎕USING,←⊂'System.Windows.Markup,WPF/PresentationFramework.dll'
⍝ Edit the wMsgBoxCustom_xaml file to suit your needs.
MsgBox_obj←XamlReader.Parse(⊂wMsgBoxCustom_xaml)
⍝ Set the Custom Error Text
(MsgBox_obj.FindName⊂'tbError').Text←'custom error text'
⍝ Set the Error Icon of the message box
⎕USING←'System.Drawing,System.Drawing.dll' 'System.Windows,WPF/PresentationCore.dll' 'System.Windows,WPF/WindowsBase.dll'
⍝ Possible choices are: Application Asterisk Error Exclamation Hand Information Question Shield Warning WinLogo
icon←SystemIcons.Error
⍝ Change the Icon to a WPF bitmap
bitmap←Interop.Imaging.CreateBitmapSourceFromHIcon(icon.Handle)(Int32Rect.Empty)(Media.Imaging.BitmapSizeOptions.FromEmptyOptions)
(MsgBox_obj.FindName⊂'imgIcon').Source←bitmap
⍝ Show the Custom Message Box
MsgBox_obj.ShowDialog
wMsgBoxCustom_xaml
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MaxWidth="800"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
Title="Execution Error"
UseLayoutRounding="True"
WindowStartupLocation="CenterOwner">
<StackPanel>
<Grid Margin="0,-1,0,0" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image
x:Name="imgIcon"
Grid.ColumnSpan="1"
Grid.Row="0"
HorizontalAlignment="Left"
Margin="10,10,16,10"
VerticalAlignment="Top"/>
<ScrollViewer
Name="Scroller"
MaxHeight="600"
MinWidth="200"
Grid.Column="1"
Grid.ColumnSpan="1"
Grid.RowSpan="1"
Margin="8,18,12,8"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<TextBlock
x:Name="tbError"
Width="{Binding ElementName=Scroller}"
FontFamily="APL385 Unicode"
FontSize="14"
Text="TextBlock"/>
</ScrollViewer>
<Border
Grid.ColumnSpan="2"
Grid.Row="1"
Margin="0,10,0,0"
VerticalAlignment="Top"
Background="#FFECECEC"
BorderBrush="#FFC9C9C9"
BorderThickness="0,1,0,0"
Padding="8,0,0,0">
<StackPanel>
<Button
x:Name="bnOK"
Height="24"
Width="86"
HorizontalAlignment="Right"
Margin="0,8,12,8"
VerticalAlignment="Center"
Content="OK"
IsCancel="True"
IsDefault="True"/>
</StackPanel>
</Border>
</Grid>
</StackPanel>
</Window>