I set the conditions under which the clickcount
value changes, but when the button is pressed, the new value is not pulled into the formula.
I set the conditions under which the clickcount value changes, but when the button is pressed, the new value is not pulled into the formula.
I need the value to change every time I manipulate the checkbox, buttondef and buttonPR.
I need to limit the number of possibilities for clicking a button depending on the selected conditions
## default button action ##
$Buttdefclick = {
$checkbox.Checked = $False
$checkbox1.Checked = $False
$checkbox2.Checked = $False
$groupBox3.Controls.AddRange($checkbox)
$groupBox3.Controls.AddRange($checkbox1)
$groupBox3.Controls.AddRange($checkbox2)
$groupBox3.Controls.Remove($buttonBrowse)
$COUNT = 8
$labelcount3.Text = $COUNT
$clickCount1 = $COUNT
$Fprint2 = "Восстановлены параметры по умолчанию"
Add-OutputBoxLine -Message " $Fprint2 `n"
Add-OutputBoxLine -Message " $clickCount1 `n"
Add-OutputBoxLine -Message " $COUNT `n"
$Form.Refresh()
}
## action performed when checkbox is activated ##
$eventHandlerchk= [System.EventHandler]{
if ($checkbox.Checked -eq $True){
if ($checkbox1.Checked -eq $True){
$COUNT = 4
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
else {
$COUNT = 5
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
if ($checkbox2.Checked -eq $True){
$COUNT = 2
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
else {
$COUNT = 5
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
else {
$COUNT = 8
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
}
$Fprint = "Печать двойных штрихкодов "
Add-OutputBoxLine -Message "выбрана опция : $Fprint `n"
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
}
## action performed when checkbox1 is activated ##
$eventHandlerchk1= [System.EventHandler]{
if ($checkbox1.Checked -eq $True){
if ($checkbox.Checked -eq $True){
$COUNT = 4
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
else {
$COUNT = 5
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
$checkbox2.Checked = $False
$groupBox3.Controls.Remove($checkbox2)
$Fprint1 = "Печать Штрихкодов из нескольких Файлов "
Add-OutputBoxLine -Message "выбрана опция : $Fprint1 `n"
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
}
## action performed when checkbox2 is activated##
$eventHandlerchk2= [System.EventHandler]{
if ($checkbox2.Checked -eq $True){
if ($checkbox.Checked -eq $True){
$COUNT = 2
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
else {
$COUNT = 3
$clickCount1 = $COUNT
$labelcount3.Text = $COUNT
Add-OutputBoxLine -Message " rКоличество попыток : $COUNT`n"
}
$checkbox1.Checked = $False
$groupBox3.Controls.Remove($checkbox1)
$groupBox3.Controls.AddRange($buttonBrowse)
$Fprint2 = "Печать Штрихкодов из своего файла "
Add-OutputBoxLine -Message "выбрана опция : $Fprint2 `n"
Add-OutputBoxLine -Message " Количество попыток : $COUNT`n"
}
}
## setting the value of a variable with checkboxes disabled ##
if ($checkbox.Checked -eq $False -and $checkbox1.Checked -eq $False -and $checkbox2.Checked -eq $False){
$clickCount1 = 8
$labelcount3.Text = $clickCount1}
######### main action when pressing ButtonPR ######
$eventHandler1 = {[System.EventHandler]
$labelcount3.Text = $clickCount1
Add-OutputBoxLine -Message "$clickCount1`n"
$script:clickCount1--
$labelcount3.Text = $clickCount1
$COUNT = $clickCount1
Add-OutputBoxLine -Message " $clickCount1 "
Add-OutputBoxLine -Message " $COUNT "
if ($clickCount -ge 1){
$MYPRINTER = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true" | select - ExpandProperty name
if ($checkbox.Checked -eq $True){
$MYFILE = "C:DistribsPrintV2STRIXSHTRIX DVOINOI A4(64).btw"
}
Else {
$MYFILE = "C:DistribsPrintV2STRIXSHTRIX ODINOCH A4(64).btw"
}
if ($checkbox1.Checked -eq $True){
$sourceFolder = "C:Users$env:UserNameDownloads"
$outputFile = "C:Users$env:UserNameDownloadsmails-order-ALL.csv"
$SourceFiles = Get-ChildItem -Path $sourceFolder -Filter "mails-order*.csv"
$FirstFile = $true
ForEach ($File in $SourceFiles) {
$Content = Get-Content $File.FullName
if ($firstFile) {
$content[0] | Add-Content $outputFile
$firstFile = $false
}
$content | Select-Object -Skip 1 | Add-Content $outputFile
}
}
Else {}
if ($checkbox2.Checked -eq $True){
}
}
else {
}
};
$Buttondef.Add_Click($Buttdefclick)
$ButtonPR.Add_Click($eventHandler1)
$checkbox.Add_Click($eventHandlerchk)
$checkbox1.Add_Click($eventHandlerchk1)
$checkbox2.Add_Click($eventHandlerchk2)
артем казаков is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2