Я создал некоторый код здесь, чтобы сделать водяной знак, но он не работает.Мне нужно знать функции и способы контроля водяных знаков.Я пытаюсь создать форму с водяным знаком.
Мы только начинающие с точки зрения powershell.
$TextBox1 = New-Object system.Windows.Forms.TextBox
$TextBox1.multiline = $false
$TextBox1.Name = "TextBox1"
$TextBox1.width = 100
$TextBox1.height = 20
$TextBox1.location = New-Object System.Drawing.Point(141,170)
$TextBox1.Font = 'Microsoft Sans Serif,10'
$WatermarkText = 'Enter Username'
$TextBox1.ForeColor = 'LightGray'
$TextBox1.Text = $WatermarkText
$TextBox1_Enter={
if($TextBox1.Text -eq $WatermarkText)
{
#Clear the text
$TextBox1.Text = ""
$TextBox1.ForeColor = 'WindowText'
}
}
$TextBox1_Leave={
if($TextBox1.Text -eq "")
{
#Display the watermark
$TextBox1.Text = $WatermarkText
$TextBox1.ForeColor = 'LightGray'
}
}
$TextBox1_VisibleChanged={
if($TextBox1.Visible -and $TextBox1.Tag -eq $null)
{
#Initialize the watermark and save it in the Tag property
$TextBox1.Tag = $TextBox1.Text;
$TextBox1.ForeColor = 'LightGray'
#If we have focus then clear out the text
if($TextBox1.Focused)
{
$TextBox1.Text = ""
$TextBox1.ForeColor = 'WindowText'
}
}
}