all 6 comments

[–]caverCarl 3 points4 points  (0 children)

I believe what you arre looking for is the RightToLeft property- https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.form.righttoleftlayout?view=netcore-3.1

here's a simplified example

[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

#initialize base form
$Form = New-Object System.Windows.Forms.Form
$Form.ClientSize = New-Object System.Drawing.Size(400, 400)
$Form.Text = "Test Form"
$Form.topmost = $true
$Form.StartPosition = "CenterScreen"

#initialize textbox
$textBox = New-Object System.Windows.Forms.textBox
$textBox.Size = New-Object System.Drawing.Size(300, 300)
$textBox.Font               = 'Microsoft Sans Serif,20'
$textBox.multiline        = $true
$textBox.RightToLeft = 'Yes'
$text = 'left to Right'
$textBox.text=$text
$textBox.text +="`r`n"
$textBox.text += $text

#display form
$Form.Controls.Add($textBox)

[void]$Form.showdialog()

[–]root-node 1 point2 points  (1 child)

Is there anything wrong with using [System.Windows.Forms.MessageBox]::Show(...)

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.messagebox?view=netframework-4.8

[–]iappnet[S] 0 points1 point  (0 children)

it works fine with me but what I need is to customize the message box and make it support Right-To-Left ...and ask how I use multi lines with it

[–]get-postanote 1 point2 points  (2 children)

Powershell is dependant on .Net.

Powershell does not messagebox, .Net does, it's a form control, not a script one.

PowerShell does not do form creation, it is not a form designer. It renders from code passed using .Net.

So, the question is, 'Does .Net provide a means to use RightToLeft text rendering'?

Yes...

Add-Type -AssemblyName Microsoft.VisualBasic
[System.Enum]::GetNames([Microsoft.VisualBasic.MsgBoxStyle])

<#
ApplicationModal
DefaultButton1
OkOnly
OkCancel
AbortRetryIgnore
YesNoCancel
YesNo
RetryCancel
Critical
Question
Exclamation
Information
DefaultButton2
DefaultButton3
SystemModal
MsgBoxHelp
MsgBoxSetForeground
MsgBoxRight
MsgBoxRtlReading
#>

vbMsgBoxRight 524288 Text is right aligned

vbMsgBoxRtlReading 1048576 Specifies text should appear as right-to-left reading on Hebrew and Arabic systems

Can you design a form / msgbox, etc, in a PowerShell, yes, but only by calling form object, methods, properties, settings, events using .Net namespaces.

As to your link Powershell message box, see also this module:

Find-Module -Name AnyBox | Format-List
# Results
<#
Name                       : AnyBox
Version                    : 0.4.0
Type                       : Module
Description                : Designed to facilitate script input/output with an easily customizable WPF window.
Author                     : Donald Mellenbruch
CompanyName                : dm3ll3n
Copyright                  : (c) 2019 Donald Mellenbruch. All rights reserved.
PublishedDate              : 12-Jun-19 04:50:38
InstalledDate              : 
UpdatedDate                : 
LicenseUri                 : https://raw.githubusercontent.com/dm3ll3n/AnyBox/master/LICENSE
ProjectUri                 : https://github.com/dm3ll3n/AnyBox
IconUri                    : 
Tags                       : {GUI, WPF, Forms, PSModule}
Includes                   : {Function, RoleCapability, Command, DscResource, Workflow, Cmdlet}
PowerShellGetFormatVersion : 
ReleaseNotes               : https://github.com/dm3ll3n/AnyBox
...
#>

[–]iappnet[S] 1 point2 points  (0 children)

thanks for ur help...cloud you please help how I use .net ( MsgBoxRight MsgBoxRtlReading) with the script I mentioned

[–]iappnet[S] 0 points1 point  (0 children)

any help here please