:Namespace wpfDialogBox ⍝ Namespace to show Dialog and Message Boxes ⍝ Check The Comments of Each Methods For More Information. (⎕IO ⎕ML ⎕WX)←1 3 3 ∇ path←DialogFolder;DR;FBD;⎕USING :Access Public Shared ⍝ Selects a Directory with FolderBrowserDialog. :Trap 0 ⎕USING←',System.Windows.Forms.dll' FBD←⎕NEW System.Windows.Forms.FolderBrowserDialog DR←System.Windows.Forms.DialogResult ⍝ Shows the Dialog as Modal and Owned by the Current APL Process :If DR.OK=FBD.ShowDialog ⍬ path←FBD.SelectedPath :Else path←'' :End FBD.Dispose ⍝ With ShowDialog the form is not dispose automatically. :Else ⍝ Unexpected Error ⎕←GetLastError path←'' :EndTrap ∇ ∇ file_name←DialogOpenFile;DR;OFD;⎕USING :Access Public Shared ⍝ Selects a File to Open With OpenFileDialog. :Trap 0 ⎕USING←',System.Windows.Forms.dll' OFD←⎕NEW System.Windows.Forms.OpenFileDialog DR←System.Windows.Forms.DialogResult OFD.Title←'Select a File' OFD.CheckFileExists←0 OFD.InitialDirectory←'::{20D04FE0-3AEA-1069-A2D8-08002B30309D}' ⍝ My Computer ⍝ OFD.InitialDirectory←'::{450D8FBA-AD25-11D0-98A8-0800361B1103}' ⍝ My Documents ⍝ OFD.InitialDirectory←'::{208D2C60-3AEA-1069-A2D7-08002B30309D}' ⍝ My Network Places ⍝ Shows the Dialog as Modal and Owned by the Current APL Process :If DR.OK=OFD.ShowDialog ⍬ file_name←OFD.FileName :Else file_name←'' :End OFD.Dispose ⍝ With ShowDialog the form is not dispose automatically. :Else ⍝ Unexpected Error ⎕←GetLastError file_name←'' :EndTrap ∇ ∇ file_name←DialogSaveFile;DR;SFD;⎕USING :Access Public Shared ⍝ Selects a File to Save With SaveFileDialog. :Trap 0 ⎕USING←',System.Windows.Forms.dll' SFD←⎕NEW System.Windows.Forms.SaveFileDialog DR←System.Windows.Forms.DialogResult SFD.Title←'Save As' SFD.OverwritePrompt←1 SFD.InitialDirectory←'::{20D04FE0-3AEA-1069-A2D8-08002B30309D}' ⍝ My Computer ⍝ OFD.InitialDirectory←'::{450D8FBA-AD25-11D0-98A8-0800361B1103}' ⍝ My Documents ⍝ OFD.InitialDirectory←'::{208D2C60-3AEA-1069-A2D7-08002B30309D}' ⍝ My Network Places ⍝ Shows the Dialog as Modal and Owned by the Current APL Process :If DR.OK=SFD.ShowDialog ⍬ file_name←SFD.FileName :Else file_name←'' :End SFD.Dispose ⍝ With ShowDialog the form is not dispose automatically. :Else ⍝ Unexpected Error ⎕←GetLastError file_name←'' :EndTrap ∇ ∇ r←{ownerwindow}ShowError(message caption button);⎕USING :Access Public Shared ⍝ Show an Error Message. ⍝ By default, the message box appears in front of the window that is currently active. ⍝ If {ownerwindow} is supplied it will displays the message box in front of the specified window ⍝ ⍝ message = Error Message to Display (insert a ⎕UCS 13 in text to force a new line) ⍝ caption = Title Bar Caption (ex. 'ProgramName Error') ⍝ button = Button Value (ex. 'OK', 'OKCancel' 'YesNo' 'YesNoCancel') ⍝ ownerwindow = WPF window [optional] ⍝ ⍝ r = Button Clicked. OK=1, Cancel=2, Yes=6, No=7, Program Error=0 ⎕USING←'System.Windows,WPF/PresentationFramework.dll' :Trap 0 :If 0≠⎕NC'ownerwindow' :AndIf 'Window'≡ownerwindow.GetType.Name r←MessageBox.Show ownerwindow message caption(⍎'MessageBoxButton.',button)(MessageBoxImage.Error) :Else r←MessageBox.Show message caption(⍎'MessageBoxButton.',button)(MessageBoxImage.Error) :End r←r.value__ ⍝ To obtain a numeric value, otherwise it will be litteral :Else ⍝ Unexpected Error ⎕←GetLastError r←0 :EndTrap ∇ ∇ r←{ownerwindow}ShowInfo(message caption button);⎕USING :Access Public Shared ⍝ Show an Information Message. ⍝ By default, the message box appears in front of the window that is currently active. ⍝ If {ownerwindow} is supplied it will displays the message box in front of the specified window ⍝ ⍝ message = Information Message to Display (insert a ⎕UCS 13 in text to force a new line) ⍝ caption = Title Bar Caption (ex. 'ProgramName Info') ⍝ button = Button Value (ex. 'OK', 'OKCancel' 'YesNo' 'YesNoCancel') ⍝ ownerwindow = WPF window [optional] ⍝ ⍝ r = Button Clicked. OK=1, Cancel=2, Yes=6, No=7, Program Error=0 ⎕USING←'System.Windows,WPF/PresentationFramework.dll' :Trap 0 :If 0≠⎕NC'ownerwindow' :AndIf 'Window'≡ownerwindow.GetType.Name r←MessageBox.Show ownerwindow message caption(⍎'MessageBoxButton.',button)(MessageBoxImage.Information) :Else r←MessageBox.Show message caption(⍎'MessageBoxButton.',button)(MessageBoxImage.Information) :End r←r.value__ ⍝ To obtain a numeric value, otherwise it will be litteral :Else ⍝ Unexpected Error ⎕←GetLastError r←0 :EndTrap ∇ ∇ r←{ownerwindow}ShowWarning(message caption button);⎕USING :Access Public Shared ⍝ Show an Information Message. ⍝ By default, the message box appears in front of the window that is currently active. ⍝ If {ownerwindow} is supplied it will displays the message box in front of the specified window ⍝ ⍝ message = Information Message to Display (insert a ⎕UCS 13 in text to force a new line) ⍝ caption = Title Bar Caption (ex. 'ProgramName Warning') ⍝ button = Button Value (ex. 'OK', 'OKCancel' 'YesNo' 'YesNoCancel') ⍝ ownerwindow = WPF window [optional] ⍝ ⍝ r = Button Clicked. OK=1, Cancel=2, Yes=6, No=7, Program Error=0 ⎕USING←'System.Windows,WPF/PresentationFramework.dll' :Trap 0 :If 0≠⎕NC'ownerwindow' :AndIf 'Window'≡ownerwindow.GetType.Name r←MessageBox.Show ownerwindow message caption(⍎'MessageBoxButton.',button)(MessageBoxImage.Warning) :Else r←MessageBox.Show message caption(⍎'MessageBoxButton.',button)(MessageBoxImage.Warning) :End r←r.value__ ⍝ To obtain a numeric value, otherwise it will be litteral :Else ⍝ Unexpected Error ⎕←GetLastError r←0 :EndTrap ∇ ∇ r←GetLastError ⍝ Returns the Last Error :If 90=⎕EN r←'EXCEPTION: ',⎕EXCEPTION.Message :Else r←(1⊃⎕DM),': ',{(~(∧\' '=⍵)∨(⌽∧\⌽' '=⍵))/⍵}(2⊃⎕DM) :EndIf ∇ :EndNamespace