baphomet
Goto Top

Powershell GUI Skript Filehash

Hallo Community,

da ich mich erst sehr kurzzeitig mit der PS befasse tauchen immer wieder Fragen auf.

--> Ich möchte gerne eine GUI erstellen, die es ermöglicht, über eine Pfadangabe den Filehash auszugeben.
--> Man hat die Möglichkeit einen Hash oder mehrere in der/den Checkbox(en) auszuwählen.
--> Ziel soll es sein, dass der Hash, oder die Hashes in einer Listbox angezeigt werden und man diese im Nachgang kopieren kann.

Wo es aktuell nicht klappt:
Wie bekomme ich den Dateipfad mit den Checkboxen verbunden, dass der Hash am Ende in der Listbox ankommt.

Anbei mein angefangenes Skript mit Bitte um Hilfe, Erklärung, oder Finalisierung:
<#
.SYNOPSIS    
This Script returns Checksumms from defined Filepaths. You´ll be abled to Hit the checkboxes and get one, or more
Checksumms within a Popupwindow. Just define your Filepath in the Textbox, and define the filehashs you´ll need.

.PARAMETER Computername 
Local administrative permissions are required to query this information.

.DESCRIPTION  
This script uses object Labels and Get Parameters.

.NOTES
Name: Filehash Generator
Author: xxx
DateCreated: xxx
DateUpdated: TBD 
Version: 0.0.0.1

.DISCLAIMER
The sample scripts are provided in their present condition and without any warranty.
All risks arising from the use or execution of the script and documentation are subject
completely your responsibility. In no case the author, or others at the creation, production or
Provision of the script involved parties for any damage (including, without limitation, any loss 
or damage caused by business loss, loss of business, loss of business information or other 
financial losses) resulting from the use or unsuitability to use the sample scripts or documentation.
#>



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

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

#This creates the form and sets its size, position, color, icon
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Filehash Generator"  
$objForm.Backcolor="LightGreen"  
$objForm.StartPosition = "CenterScreen"  
$objForm.Size = New-Object System.Drawing.Size(1200,350)

#This creates the key functions
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq „Enter“) { $objForm.DialogResult=“OK“;$objForm.Close()} })
$objForm.Add_KeyDown({if ($_.KeyCode -eq „Escape“) { $objForm.DialogResult=“Cancel“;$objForm.Close()} })

#This creates the Listbox
$objListbox = New-Object System.Windows.Forms.Listbox
$objListbox.Location = New-Object System.Drawing.Size(350,20)
$objListbox.Size = New-Object System.Drawing.Size(800,20)
$objListbox.SelectionMode = "MultiExtended"  
$objListbox.Height = 260
$objForm.Controls.Add($objListbox)


#This creates the Textbox1
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = „1: Wählen Sie die Checksumme aus:“
$objForm.Controls.Add($objLabel)

#This creates the Checkboxes MD5
$objTypeCheckbox = New-Object System.Windows.Forms.Checkbox 
$objTypeCheckbox.Location = New-Object System.Drawing.Size(10,40) 
$objTypeCheckbox.Size = New-Object System.Drawing.Size(500,20)
$objTypeCheckbox.Text = "MD5"  
$objTypeCheckbox.TabIndex = 4
$checkBox1.Name = "checkBox 1"  
$checkBox1.Text = "CheckBox 1"  
$objForm.Controls.Add($objTypeCheckbox)
If ($objTypeCheckbox.Checked = $true)
  {
    Get-FileHash -Algorithm MD5
  }

#This creates the Checkboxe SHA1
$objTypeCheckbox = New-Object System.Windows.Forms.Checkbox 
$objTypeCheckbox.Location = New-Object System.Drawing.Size(10,60) 
$objTypeCheckbox.Size = New-Object System.Drawing.Size(500,20)
$objTypeCheckbox.Text = "SHA1"  
$objTypeCheckbox.TabIndex = 5
$checkBox2.Name = "checkBox 2"  
$checkBox2.Text = "CheckBox 2"  
$objForm.Controls.Add($objTypeCheckbox)
If ($objTypeCheckbox.Checked = $true)
  {
    Get-FileHash -Algorithm SHA1
  }

#This creates the Checkboxe SHA256
$objTypeCheckbox = New-Object System.Windows.Forms.Checkbox 
$objTypeCheckbox.Location = New-Object System.Drawing.Size(10,80) 
$objTypeCheckbox.Size = New-Object System.Drawing.Size(500,20)
$objTypeCheckbox.Text = "SHA256"  
$objTypeCheckbox.TabIndex = 6
$checkBox3.Name = "checkBox 3"  
$checkBox3.Text = "CheckBox 3"  
$objForm.Controls.Add($objTypeCheckbox)
If ($objTypeCheckbox.Checked = $true)
  {
    Get-FileHash -Algorithm SHA256
  }

#This creates the Checkboxe SHA384
$objTypeCheckbox = New-Object System.Windows.Forms.Checkbox 
$objTypeCheckbox.Location = New-Object System.Drawing.Size(10,100) 
$objTypeCheckbox.Size = New-Object System.Drawing.Size(500,20)
$objTypeCheckbox.Text = "SHA384"  
$objTypeCheckbox.TabIndex = 7
$checkBox4.Name = "checkBox 4"  
$checkBox4.Text = "CheckBox 4"  
$objForm.Controls.Add($objTypeCheckbox)
If ($objTypeCheckbox.Checked = $true)
  {
    Get-FileHash -Algorithm SHA384
  }

#This creates the Checkboxe SHA512
$objTypeCheckbox = New-Object System.Windows.Forms.Checkbox 
$objTypeCheckbox.Location = New-Object System.Drawing.Size(10,120) 
$objTypeCheckbox.Size = New-Object System.Drawing.Size(500,20)
$objTypeCheckbox.Text = "SHA512"  
$objTypeCheckbox.TabIndex = 8
$checkBox5.Name = "checkBox 5"  
$checkBox5.Text = "CheckBox 5"  
$objForm.Controls.Add($objTypeCheckbox)
If ($objTypeCheckbox.Checked = $true)
  {
    Get-FileHash -Algorithm SHA512
  }

#This creates the Textbox2
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,200)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = „2: Bitte geben Sie den Dateipfad ein:“
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,220)
$objTextBox.Size = New-Object System.Drawing.Size(300,20)
$objTextBox.Text = „Dateipfad“
$objForm.Controls.Add($objTextBox)

#This creates the OK Button
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(10,250)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = „OK“
$OKButton.DialogResult = „OK“
$OKButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($OKButton)

#This creates the Cancel Button
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(100,250)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = „Cancel“
$CancelButton.DialogResult = „Cancel“
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
  
[void] $objForm.ShowDialog()

Vielen Dank im Voraus!!

Content-Key: 385994

Url: https://administrator.de/contentid/385994

Printed on: May 9, 2024 at 04:05 o'clock

Member: erikro
erikro Sep 10, 2018 at 07:32:01 (UTC)
Goto Top
Moin,

das sieht ja schon gut aus. Die Checkboxen sind aber nicht richtig. Guck mal hier:

https://stackoverflow.com/questions/14527832/powershell-how-to-invoke-a- ...

Bei den Hashes fehlt noch die Pfadangabe, woraus der Hash errechnet werden soll. Guckst Du hier:

https://docs.microsoft.com/de-de/powershell/scripting/getting-started/co ...

Das Ergebnis schreibst Du Dir dann am Besten in ein Array. Dann kannst Dud ei Höhe der Ausgabebox anhand der Länge berechnen.

hth

Erik
Member: colinardo
Solution colinardo Sep 10, 2018 updated at 13:37:01 (UTC)
Goto Top
Servus @Baphomet ,
hier mal ein bißchen was zum Abgucken und Lernen:

Die Form implementiert eine Textbox zur Eingabe des Pfades zu einer Datei, außerdem kannst du den Pfad über einen FileSystem Dialog auswählen, oder auch als Gimmick per Drag n' Drop eine Datei aus dem Explorer oder sonst wo auf das Textfeld fallen lassen, der Pfad wird dann automatisch eingetragen.
Die Berechnung der Hashes sind in einen anderen Thread ausgelagert da ja je nach Größe der Datei die Berechnung einige Zeit dauern kann und die Form sonst nicht mehr auf Benutzereingaben reagiert.
In die Zwischenablage kopiert werden können die Hashes entweder durch markieren (mehrfachauswahl erlaubt), oder durch Doppelklick auf die Zeilen.

Weiterhin viel Spaß bei deinen Übungen.

Jetzt darfst du gerne selbst das ganze noch auf mehrere Dateien oder sonstige Dinge ausweiten. Das wollte ich dir aber noch als Übungsaufgabe lassen sonst ist's ja langweilig face-wink.

Die essentiellen Zeilen sind alle kommentiert.
if ($PSVersionTable.PSVersion.Major -lt 3){write-host "ERROR: Minimum Powershell Version 3.0 is required!" -F Yellow; return}  
function GenerateForm {

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null  
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null  
#endregion

#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$statusBar = New-Object System.Windows.Forms.StatusBar
$grpAlgorithm = New-Object System.Windows.Forms.GroupBox
$SHA384 = New-Object System.Windows.Forms.CheckBox
$SHA512 = New-Object System.Windows.Forms.CheckBox
$MD5 = New-Object System.Windows.Forms.CheckBox
$SHA1 = New-Object System.Windows.Forms.CheckBox
$SHA256 = New-Object System.Windows.Forms.CheckBox
$dgvOutput = New-Object System.Windows.Forms.DataGridView
$btnBrowseFile = New-Object System.Windows.Forms.Button
$label1 = New-Object System.Windows.Forms.Label
$txtPath = New-Object System.Windows.Forms.TextBox
$statusProgress = New-Object System.Windows.Forms.StatusBarPanel
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

# Multifunktionelle Funktion für Dateisystem-Dialoge
function Show-FileSystemDialog{
    param(
        [parameter(mandatory=$true)][ValidateSet("OpenFileDialog","SaveFileDialog","FolderBrowserDialog")][string]$DialogType,  
        [string]$InitialDirectory = "",  
        [System.Environment+SpecialFolder]$RootFolder = [System.Environment+SpecialFolder]::Desktop,
        [string]$FileFilter = "Alle Dateien | *.*",  
        [switch]$MultiSelect
    )
    [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")  
    switch ($DialogType){
        "OpenFileDialog"{  
            $dlg = New-Object System.Windows.Forms.OpenFileDialog
            if ($MultiSelect.IsPresent){$dlg.Multiselect = $true}
            $dlg.InitialDirectory = $InitialDirectory
            $dlg.Filter = $FileFilter
            if($dlg.ShowDialog() -eq 'OK'){  
                return $dlg.FileNames
            }else{return $false}
        }
        "SaveFileDialog"{  
            $dlg = New-Object System.Windows.Forms.SaveFileDialog
            $dlg.InitialDirectory = $InitialDirectory
            $dlg.Filter = $FileFilter
            if($dlg.ShowDialog() -eq 'OK'){  
                return $dlg.FileName
            }else{return $false}
        }
        "FolderBrowserDialog"{  
            $dlg = New-Object System.Windows.Forms.FolderBrowserDialog
            $dlg.ShowNewFolderButton = $true
            $dlg.RootFolder = $RootFolder
            if($dlg.ShowDialog() -eq 'OK'){  
                return $dlg.SelectedPath
            }else{return $false}
        }
    }
}

# Funktion berechnet den Hash
function Calculate-Hashes([object]$box) {
    # wenn die Checkbox nicht aktiviert ist entferne Hash-Einträge aus dem DataGridview
    if (!$box.Checked){
        $dgvOutput.Rows | ?{$_.Cells.Value -eq $box.Name} | %{$dgvOutput.Rows.Remove($_)}
        return
    }
    # ändere den Status in der Statuszeile
    $statusProgress.Text = "Berechne $($box.Name) Hash ..."  
    
    # Argumente die an den Sub-Thread übermittelt werden Pfad, Algorithmus und 
    $arg = @{Path=$txtPath.Text;Algorithm=$box.Name}

    # Sub-Thread erstellen in dem die Berechnung des File-Hashes stattfindet (kann ja je nach Dateigröße einige Zeit in Anspruch nehmen)
    $myjob = [Powershell]::Create().AddScript({
        param($arg)
        $arg.Result = Get-FileHash $arg.Path -Algorithm $arg.Algorithm
    }).AddArgument($arg)
    
    # Thread starten
    $myjob.BeginInvoke()| out-null

    # während die Berechnung läuft die Eingabe an den User zurückgeben (Form wird nicht unresponsive)
    while($myjob.InvocationStateInfo.State -eq "Running"){  
        [System.Windows.Forms.Application]::DoEvents()
    }
    # Ergebnisse der Berechnung in das DataGridView schreiben
    if ($arg.Result -ne $null){
        $dgvOutput.Rows.Add(($arg.Result.Algorithm,$arg.Result.Hash))
    }
    # Status abschließend setzen
    $statusProgress.Text = 'Finished'  
}

#----------------------------------------------
# Event Script Blocks
#----------------------------------------------
# Event Handler der Checkboxen
$handler_MD5_Click = {Calculate-Hashes $this}
$handler_SHA1_Click = {Calculate-Hashes $this}
$handler_SHA256_Click = {Calculate-Hashes $this}
$handler_SHA384_Click = {Calculate-Hashes $this}
$handler_SHA512_Click = {Calculate-Hashes $this}

# Changed Handler wenn der Pfad in der Textbox geändert wird
$handler_txtPath_TextChanged = 
{
    # wenn der Pfad in der Textbox eine existente Datei ist ...
    if ([IO.File]::Exists($txtPath.Text)){
        # aktiviere die Hash-Checkbox-Gruppe
        $grpAlgorithm.Enabled = $true
        # DatagridView leeren
        $dgvOutput.Rows.Clear()
    }else{
        # deaktiviere die Hash-Checkbox-Gruppe (es gibt ja keine gültige Dateiangabe)
        $grpAlgorithm.Enabled = $false
    }

}

# Click-Handler des Buttons zur Auswahl einer Datei
$handler_btnBrowseFile_Click= 
{
    $path = Show-FileSystemDialog -DialogType OpenFileDialog
    if ($path -ne $false){
        $txtPath.Text = $path
    }
}

# Double-Click Handler kopiert Hashes in die Zwischenablage
$handler_dgvOutput_CellContentDoubleClick = {
    Set-Clipboard -Value $dgvOutput.SelectedRows.Cells[1].Value
    $statusProgress.text = "$($dgvOutput.SelectedRows.Cells.Value) Hash kopiert."  
}

# DragEnter Handler der Pfad-Textbox zum prüfen ob eine Datei auf die Textbox gezogen wird
$handler_txtPath_DragEnter = {
    if ($_.Data.GetDataPresent([System.Windows.DataFormats]::FileDrop)){
        if ([IO.File]::Exists($_.Data.GetData("FileDrop",$false))){  
            $_.Effect = [System.Windows.Forms.DragDropEffects]::Link
        }else{
            $_.Effect = [System.Windows.Forms.DragDropEffects]::None
        }
    }else{
        $_.Effect = [System.Windows.Forms.DragDropEffects]::None
    }
}

# DragDrop Handler der Textbox extrahiert den Pfad der gedroppten Datei
$handler_txtPath_DragDrop = {
    $txtPath.Text = $_.Data.GetData("FileDrop",$false)  
}

$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
	$form1.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Form Code
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 264
$System_Drawing_Size.Width = 405
$form1.ClientSize = $System_Drawing_Size
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$form1.MaximizeBox = $False
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 292
$System_Drawing_Size.Width = 413
$form1.MinimumSize = $System_Drawing_Size
$form1.Name = "form1"  
$form1.Text = "Hash-Calculator"  

$statusBar.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 0
$System_Drawing_Point.Y = 242
$statusBar.Location = $System_Drawing_Point
$statusBar.Name = "statusBar"  
$statusBar.Panels.Add($statusProgress)|Out-Null
$statusBar.ShowPanels = $True
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 22
$System_Drawing_Size.Width = 405
$statusBar.Size = $System_Drawing_Size
$statusBar.TabIndex = 10

$form1.Controls.Add($statusBar)

$grpAlgorithm.Anchor = 13

$grpAlgorithm.DataBindings.DefaultDataSourceUpdateMode = 0
$grpAlgorithm.Enabled = $False
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 14
$System_Drawing_Point.Y = 41
$grpAlgorithm.Location = $System_Drawing_Point
$grpAlgorithm.Name = "grpAlgorithm"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 55
$System_Drawing_Size.Width = 379
$grpAlgorithm.Size = $System_Drawing_Size
$grpAlgorithm.TabIndex = 9
$grpAlgorithm.TabStop = $False
$grpAlgorithm.Text = "Algorithmus"  

$form1.Controls.Add($grpAlgorithm)

$SHA384.DataBindings.DefaultDataSourceUpdateMode = 0

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 200
$System_Drawing_Point.Y = 19
$SHA384.Location = $System_Drawing_Point
$SHA384.Name = "SHA384"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 24
$System_Drawing_Size.Width = 76
$SHA384.Size = $System_Drawing_Size
$SHA384.TabIndex = 7
$SHA384.Text = "SHA384"  
$SHA384.UseVisualStyleBackColor = $True
$SHA384.add_Click($handler_SHA384_Click)

$grpAlgorithm.Controls.Add($SHA384)


$SHA512.DataBindings.DefaultDataSourceUpdateMode = 0

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 282
$System_Drawing_Point.Y = 19
$SHA512.Location = $System_Drawing_Point
$SHA512.Name = "SHA512"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 24
$System_Drawing_Size.Width = 74
$SHA512.Size = $System_Drawing_Size
$SHA512.TabIndex = 8
$SHA512.Text = "SHA512"  
$SHA512.UseVisualStyleBackColor = $True
$SHA512.add_Click($handler_SHA512_Click)

$grpAlgorithm.Controls.Add($SHA512)


$MD5.DataBindings.DefaultDataSourceUpdateMode = 0

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 10
$System_Drawing_Point.Y = 18
$MD5.Location = $System_Drawing_Point
$MD5.Name = "MD5"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 24
$System_Drawing_Size.Width = 49
$MD5.Size = $System_Drawing_Size
$MD5.TabIndex = 4
$MD5.Text = "MD5"  
$MD5.UseVisualStyleBackColor = $True
$MD5.add_Click($handler_MD5_Click)

$grpAlgorithm.Controls.Add($MD5)


$SHA1.DataBindings.DefaultDataSourceUpdateMode = 0

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 65
$System_Drawing_Point.Y = 18
$SHA1.Location = $System_Drawing_Point
$SHA1.Name = "SHA1"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 24
$System_Drawing_Size.Width = 59
$SHA1.Size = $System_Drawing_Size
$SHA1.TabIndex = 5
$SHA1.Text = "SHA1"  
$SHA1.UseVisualStyleBackColor = $True
$SHA1.add_Click($handler_SHA1_Click)

$grpAlgorithm.Controls.Add($SHA1)


$SHA256.DataBindings.DefaultDataSourceUpdateMode = 0

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 126
$System_Drawing_Point.Y = 18
$SHA256.Location = $System_Drawing_Point
$SHA256.Name = "SHA256"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 24
$System_Drawing_Size.Width = 68
$SHA256.Size = $System_Drawing_Size
$SHA256.TabIndex = 6
$SHA256.Text = "SHA256"  
$SHA256.UseVisualStyleBackColor = $True
$SHA256.add_Click($handler_SHA256_Click)

$grpAlgorithm.Controls.Add($SHA256)


$dgvOutput.AllowUserToAddRows = $False
$dgvOutput.AllowUserToDeleteRows = $False
$dgvOutput.AllowUserToResizeRows = $False
$dgvOutput.Anchor = 15
$dgvOutput.ClipboardCopyMode = 2
$System_Windows_Forms_DataGridViewTextBoxColumn_13 = New-Object System.Windows.Forms.DataGridViewTextBoxColumn
$System_Windows_Forms_DataGridViewTextBoxColumn_13.AutoSizeMode = 6
$System_Windows_Forms_DataGridViewTextBoxColumn_13.HeaderText = "Algorithmus"  
$System_Windows_Forms_DataGridViewTextBoxColumn_13.Name = ""  
$System_Windows_Forms_DataGridViewTextBoxColumn_13.ReadOnly = $True
$System_Windows_Forms_DataGridViewTextBoxColumn_13.Width = 86
$dgvOutput.Columns.Add($System_Windows_Forms_DataGridViewTextBoxColumn_13)|Out-Null
$System_Windows_Forms_DataGridViewTextBoxColumn_14 = New-Object System.Windows.Forms.DataGridViewTextBoxColumn
$System_Windows_Forms_DataGridViewTextBoxColumn_14.AutoSizeMode = 16
$System_Windows_Forms_DataGridViewTextBoxColumn_14.HeaderText = "Hash"  
$System_Windows_Forms_DataGridViewTextBoxColumn_14.Name = ""  
$System_Windows_Forms_DataGridViewTextBoxColumn_14.ReadOnly = $True
$System_Windows_Forms_DataGridViewTextBoxColumn_14.Width = 290
$dgvOutput.Columns.Add($System_Windows_Forms_DataGridViewTextBoxColumn_14)|Out-Null
$dgvOutput.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 14
$System_Drawing_Point.Y = 102
$dgvOutput.Location = $System_Drawing_Point
$dgvOutput.Name = "dgvOutput"  
$dgvOutput.ReadOnly = $True
$dgvOutput.RowHeadersVisible = $False
$dgvOutput.SelectionMode = 1
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 125
$System_Drawing_Size.Width = 379
$dgvOutput.Size = $System_Drawing_Size
$dgvOutput.TabIndex = 3
$dgvOutput.add_CellContentDoubleClick($handler_dgvOutput_CellContentDoubleClick)

$form1.Controls.Add($dgvOutput)

$btnBrowseFile.Anchor = 9

$btnBrowseFile.DataBindings.DefaultDataSourceUpdateMode = 0

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 353
$System_Drawing_Point.Y = 10
$btnBrowseFile.Location = $System_Drawing_Point
$btnBrowseFile.Name = "btnBrowseFile"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 40
$btnBrowseFile.Size = $System_Drawing_Size
$btnBrowseFile.TabIndex = 2
$btnBrowseFile.Text = "..."  
$btnBrowseFile.UseVisualStyleBackColor = $True
$btnBrowseFile.add_Click($handler_btnBrowseFile_Click)

$form1.Controls.Add($btnBrowseFile)

$label1.DataBindings.DefaultDataSourceUpdateMode = 0

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 15
$label1.Location = $System_Drawing_Point
$label1.Name = "label1"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 37
$label1.Size = $System_Drawing_Size
$label1.TabIndex = 1
$label1.Text = "Pfad"  

$form1.Controls.Add($label1)

$txtPath.Anchor = 13
$txtPath.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 55
$System_Drawing_Point.Y = 12
$txtPath.Location = $System_Drawing_Point
$txtPath.Name = "txtPath"  
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 292
$txtPath.Size = $System_Drawing_Size
$txtPath.TabIndex = 0
$txtPath.AllowDrop = $true
$txtPath.add_DragEnter($handler_txtPath_DragEnter)
$txtPath.add_DragDrop($handler_txtPath_DragDrop)
$txtPath.add_TextChanged($handler_txtPath_TextChanged)

$form1.Controls.Add($txtPath)

$statusProgress.Name = "statusProgress"  
$statusProgress.Width = 200

#endregion Form Code

#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null

} #End Function
GenerateForm
Grüße Uwe
Member: Baphomet
Baphomet Sep 10, 2018 at 17:53:04 (UTC)
Goto Top
Hallo Uwe,

vielen Dank dafür.
Mit Sicherheit werde ich hier einiges Kupfern, zumal Du hier auch Ansätze hast, die ich nicht bedacht habe!

Vorab gesagt, meine derzeitige Schwierigkeit liegt darin, dass ich einfach die Funktionen noch nicht so ganz raus habe.
Siehe mein Beispiel, die GUI wird zwar von oben nach unten geladen, aber das wars dann auch.
Manchmal bin ich einfach noch zu Spaghetti Code unterwegs, aber wie Du schon sagst, übern, üben, üben....

THX
Frank
Member: Baphomet
Baphomet Sep 10, 2018 at 18:00:53 (UTC)
Goto Top
Hallo Erik,

vielen Dank für die beiden Links. Diese hatte ich bereits bei meinem ersten Konstrukt schon angesehen und mir so manche Zeile kopiert.
Es hängt bei: Input -> Hash -> Ausgabe...

Aber das wird schon...

Danke!