init
This commit is contained in:
286
GUIS/del/del.ps1
Normal file
286
GUIS/del/del.ps1
Normal file
@@ -0,0 +1,286 @@
|
||||
function Load_del {
|
||||
param ($root)
|
||||
|
||||
# Speichert ob gelöscht oder verschoben werden soll
|
||||
$Script:whattodo=""
|
||||
|
||||
# Arraydefinition
|
||||
## 0=Name,1=Größe,2=checked
|
||||
$Script:sortdel=@("up","up",$false)
|
||||
|
||||
# Lädt das Fenster
|
||||
[xml]$Form = Get-Content "$root/GUIS/del/del.xaml" -Encoding utf8
|
||||
$NR=(New-Object System.Xml.XmlNodeReader $Form)
|
||||
$window=[Windows.Markup.XamlReader]::Load($NR)
|
||||
|
||||
# Objekt - Variablen Verknüpfung
|
||||
$pb=$window.findName("pb")
|
||||
$Script:Delbrowser = $window.findName("browser")
|
||||
$Script:Delback = $window.findName("btnback")
|
||||
$Script:Deldel = $window.findName("btnDeleteAll")
|
||||
$Script:DelMove = $window.findName("btnMoveAll")
|
||||
$Script:Delwarning = $window.findName("warning_delete")
|
||||
$Script:Movewarning = $window.findName("warning_move")
|
||||
$Script:Delmarked = $window.findName("marked_delete")
|
||||
$Script:Movemarked = $window.findName("marked_move")
|
||||
$Script:Delstats = $window.findName("stats")
|
||||
$Script:Delsortname = $window.findName("btnsortname")
|
||||
$Script:Delsortsize = $window.findName("btnsortsize")
|
||||
$Script:Delcheckall = $window.findName("btncheckbox")
|
||||
|
||||
# Verknüpft feste Elemente
|
||||
$window.icon="$root/Source/Logo.png"
|
||||
|
||||
### GIF Sanduhr
|
||||
$file = (get-item "$root/Source/hourglas.gif")
|
||||
$img = [System.Drawing.Image]::Fromfile($file);
|
||||
$pb.Image = $img
|
||||
|
||||
return $window
|
||||
}
|
||||
|
||||
function Browser_del {
|
||||
$data = @()
|
||||
for ($i = 0; $i -lt $Script:folderdb.Count; $i++) {
|
||||
if ($Script:folderdb[$i][3]) {
|
||||
if (!$Script:folderdb[$i][4]) {
|
||||
$Length = calc_Size $Script:folderdb[$i][1]
|
||||
$data += New-Object PSObject -prop @{Source="$Script:ScriptRoot\Source\Folder.png";Name=$Script:folderdb[$i][0];Size="$Length";Tag="f$i";SourceChecked="$Script:ScriptRoot\Source\checked.png";Path=$Script:folderdb[$i][2]}
|
||||
#$logcontent = "Del: Browser f" + $i
|
||||
#Log $logcontent -clear
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
for ($i = 0; $i -lt $filedb.Count; $i++) {
|
||||
if ($Script:filedb[$i][3]) {
|
||||
if (!$Script:filedb[$i][4]) {
|
||||
$Length = calc_Size $Script:filedb[$i][1]
|
||||
$icon = $Script:icontypes[$Script:filedb[$i][5]]
|
||||
$data += New-Object PSObject -prop @{Source="$Script:ScriptRoot\icons\$icon.ico";Name=$Script:filedb[$i][0];Size="$Length";Tag=$i;SourceChecked="$Script:ScriptRoot\Source\checked.png";Path=$Script:filedb[$i][2]}
|
||||
#$logcontent = "Del: Browser " + $i
|
||||
#Log $logcontent -clear
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
$item = [System.Windows.Data.ListCollectionView]$data
|
||||
$Script:Delbrowser.Remove
|
||||
$Script:Delbrowser.ItemsSource = $item
|
||||
}
|
||||
|
||||
function Check_Del {
|
||||
param ($tag)
|
||||
$data = @()
|
||||
for ($i = 0; $i -lt $delbrowser.Items.Count; $i++) {
|
||||
if (($delbrowser.Items.Tag[$i] -eq $tag) -or ($delbrowser.Items.Count -eq 1)) {
|
||||
$item=$delbrowser.Items[$i]
|
||||
if ($tag -match "f") {
|
||||
$string=$tag.Substring(1)
|
||||
$int = [int]$string
|
||||
if ($Script:folderdb[$int][3]) {
|
||||
$Script:folderdb[$int][3]=$false
|
||||
count_element $false $Script:folderdb[$int][1]
|
||||
$data += New-Object PSObject -prop @{Source=$item.Source;Name=$item.Name;Size=$item.Size;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\unchecked.png";Path=$item.Path}
|
||||
}else {
|
||||
$Script:folderdb[$int][3]=$true
|
||||
count_element $true $Script:folderdb[$int][1]
|
||||
$data += New-Object PSObject -prop @{Source=$item.Source;Name=$item.Name;Size=$item.Size;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\checked.png";Path=$item.Path}
|
||||
}
|
||||
}else {
|
||||
if ($Script:filedb[$tag][3]) {
|
||||
$Script:filedb[$tag][3]=$false
|
||||
count_element $false $Script:filedb[$tag][1]
|
||||
$data += New-Object PSObject -prop @{Source=$item.Source;Name=$item.Name;Size=$item.Size;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\unchecked.png";Path=$item.Path}
|
||||
}else {
|
||||
$Script:filedb[$tag][3]=$true
|
||||
count_element $true $Script:filedb[$tag][1]
|
||||
$data += New-Object PSObject -prop @{Source=$item.Source;Name=$item.Name;Size=$item.Size;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\checked.png";Path=$item.Path}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
$data += $delbrowser.Items[$i]
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
$item = [System.Windows.Data.ListCollectionView]$data
|
||||
$delbrowser.Remove
|
||||
$delbrowser.ItemsSource = $item
|
||||
}
|
||||
|
||||
function del_sortname{
|
||||
#Log "### Del: sort name ###" -clear
|
||||
$data= @()
|
||||
for ($i = 0; $i -lt $delbrowser.Items.count; $i++) {
|
||||
$item = $delbrowser.Items[$i]
|
||||
$data += New-Object PSObject -prop @{Name=$item.Name;Source=$item.Source;Size=$item.Size;Checked=$item.Checked;Tag=$item.Tag;SourceChecked=$Item.SourceChecked;Path=$item.Path}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
if ($sortdel[0] -eq "up") {
|
||||
$data = $data | Sort-Object -Property Name
|
||||
$sortdel[0]="down"
|
||||
}else {
|
||||
$data = $data | Sort-Object -Property Name -Descending
|
||||
$sortdel[0]="up"
|
||||
}
|
||||
$ItemList = [System.Windows.Data.ListCollectionView]$data
|
||||
$delbrowser.ItemsSource = $ItemList
|
||||
}
|
||||
|
||||
function del_sortsize {
|
||||
#Log "### Del: sort size ###" -clear
|
||||
$data=@()
|
||||
$array=@()
|
||||
for ($i = 0; $i -lt $delbrowser.Items.Count; $i++) {
|
||||
$item = $delbrowser.Items[$i]
|
||||
if ($item.Size.EndsWith("GB")) {
|
||||
$stringtrim = $item.Size.TrimEnd(" GB")
|
||||
}else {
|
||||
$stringtrim = $item.Size.TrimEnd(" MB")
|
||||
}
|
||||
$int = [int]$stringtrim
|
||||
$array += New-Object PSObject -prop @{Tag=$item.Tag;Size=$int}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
if ($sortdel[1] -eq "up") {
|
||||
$array = $array | Sort-Object -Property Size
|
||||
$sortdel[1]="down"
|
||||
}else {
|
||||
$array = $array | Sort-Object -Property Size -Descending
|
||||
$sortdel[1]="up"
|
||||
}
|
||||
for ($i = 0; $i -lt $array.Count; $i++) {
|
||||
for ($e = 0; $e -lt $delbrowser.items.Count; $e++) {
|
||||
if ($array.Tag[$i] -eq $delbrowser.Items.Tag[$e]) {
|
||||
$item=$delbrowser.Items[$e]
|
||||
$data += New-Object PSObject -prop @{Name=$item.Name;Source=$item.Source;Size=$item.Size;Checked=$item.Checked;Tag=$item.Tag;SourceChecked=$Item.SourceChecked;Path=$item.Path}
|
||||
$e=$delbrowser.items.Count
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
$ItemList = [System.Windows.Data.ListCollectionView]$data
|
||||
$delbrowser.Remove
|
||||
$delbrowser.ItemsSource = $ItemList
|
||||
}
|
||||
|
||||
function del_checkall {
|
||||
#Log "### Del: Check all ###" -clear
|
||||
$data = @()
|
||||
$check = 0
|
||||
if ($sortdel[2]) {
|
||||
$sortdel[2]=$false
|
||||
for ($i = 0; $i -lt $delbrowser.Items.Count; $i++) {
|
||||
$item = $delbrowser.Items[$i]
|
||||
$tag=$item.Tag
|
||||
if ($tag -match "f") {
|
||||
$string=$tag.Substring(1)
|
||||
$int = [int]$string
|
||||
if ($folderdb[$int][3]) {
|
||||
$folderdb[$int][3]=$false
|
||||
count_element $false $Script:folderdb[$int][1]
|
||||
$data += New-Object PSObject -prop @{Name=$item.Name;Source=$item.Source;Size=$item.Size;Checked=$false;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\unchecked.png"}
|
||||
$check++
|
||||
}else {
|
||||
$data += $item
|
||||
}
|
||||
}else {
|
||||
if ($filedb[$tag][3]) {
|
||||
$filedb[$tag][3]=$false
|
||||
count_element $false $Script:filedb[$tag][1]
|
||||
$data += New-Object PSObject -prop @{Name=$item.Name;Source=$item.Source;Size=$item.Size;Checked=$false;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\unchecked.png"}
|
||||
$check++
|
||||
}else {
|
||||
$data += $item
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
}else {
|
||||
$sortdel[2]=$true
|
||||
for ($i = 0; $i -lt $delbrowser.Items.Count; $i++) {
|
||||
$item = $delbrowser.Items[$i]
|
||||
$tag=$item.Tag
|
||||
if ($tag -match "f") {
|
||||
$string=$tag.Substring(1)
|
||||
$int = [int]$string
|
||||
if (!$folderdb[$int][3]) {
|
||||
$folderdb[$int][3]=$true
|
||||
count_element $true $Script:folderdb[$int][1]
|
||||
$data += New-Object PSObject -prop @{Name=$item.Name;Source=$item.Source;Size=$item.Size;Checked=$true;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\checked.png"}
|
||||
$check++
|
||||
}else {
|
||||
$data += $item
|
||||
}
|
||||
}else {
|
||||
if (!$filedb[$tag][3]) {
|
||||
$filedb[$tag][3]=$true
|
||||
count_element $true $Script:filedb[$tag][1]
|
||||
$data += New-Object PSObject -prop @{Name=$item.Name;Source=$item.Source;Size=$item.Size;Checked=$true;Tag=$item.Tag;SourceChecked="$Script:ScriptRoot\Source\checked.png"}
|
||||
$check++
|
||||
}else {
|
||||
$data += $item
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
}
|
||||
if ($check -eq 0) {
|
||||
del_checkall
|
||||
}else{
|
||||
$ItemList = [System.Windows.Data.ListCollectionView]$data
|
||||
$delbrowser.ItemsSource = $ItemList
|
||||
}
|
||||
}
|
||||
|
||||
function final_action {
|
||||
if ($script:whattodo -eq "move") {
|
||||
for ($i = 0; $i -lt $filedb.Count; $i++) {
|
||||
if ($filedb[$i][3]) {
|
||||
if (!$filedb[$i][4]) {
|
||||
Move-Item -Path $filedb[$i][2] -Destination $Script:movelocation
|
||||
$filedb[$i][4] = $true
|
||||
#$logcontent = "Move: " + $filedb[$i][2] + " To: " + $Script:movelocation
|
||||
#Log $logcontent -clear
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
for ($i = 0; $i -lt $folderdb.Count; $i++) {
|
||||
if ($folderdb[$i][3]) {
|
||||
if (!$folderdb[$i][4]) {
|
||||
Move-Item -Path $folderdb[$i][2] -Destination $Script:movelocation
|
||||
$folderdb[$i][4] = $true
|
||||
#$logcontent = "Move: " + $folderdb[$i][2] + " To: " + $Script:movelocation
|
||||
#Log $logcontent -clear
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
}elseif ($Script:whattodo -eq "delete") {
|
||||
for ($i = 0; $i -lt $filedb.Count; $i++) {
|
||||
if ($filedb[$i][3]) {
|
||||
if (!$filedb[$i][4]) {
|
||||
Remove-Item $filedb[$i][2]
|
||||
$filedb[$i][4] = $true
|
||||
#$logcontent = "Removed: " + $filedb[$i][2]
|
||||
#Log $logcontent -clear
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
for ($i = 0; $i -lt $folderdb.Count; $i++) {
|
||||
if ($folderdb[$i][3]) {
|
||||
if (!$folderdb[$i][4]) {
|
||||
Remove-Item $folderdb[$i][2]
|
||||
$folderdb[$i][4] = $true
|
||||
#$logcontent = "Removed: " + $folderdb[$i][2]
|
||||
#Log $logcontent -clear
|
||||
}
|
||||
}
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Log "### Del geladen ###" -clear
|
||||
104
GUIS/del/del.xaml
Normal file
104
GUIS/del/del.xaml
Normal file
@@ -0,0 +1,104 @@
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
|
||||
xmlns:winForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
|
||||
Title="Cleaner - Auswahlbestätigung" Height="459.667" Width="800" Icon="{Binding Icon}" ResizeMode="NoResize">
|
||||
<Grid Background="#00344E">
|
||||
<Label HorizontalAlignment="Center" Margin="10,357,10,0" VerticalAlignment="Top" Height="64" Width="774" Background="#013C5A">
|
||||
<Label.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="5"/>
|
||||
</Style>
|
||||
</Label.Resources>
|
||||
</Label>
|
||||
<Button Name="btnDeleteAll" Content="Markierte löschen" BorderThickness="0" HorizontalAlignment="Left" Margin="601,366,0,0" VerticalAlignment="Top" Height="46" Width="172" FontSize="18" FontWeight="Bold" Background="#d50000" Foreground="White">
|
||||
<Button.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<Button Name="btnMoveAll" Content="Markierte verschieben" BorderThickness="0" HorizontalAlignment="Left" Margin="554,364,0,0" VerticalAlignment="Top" Height="46" Width="210" FontSize="18" FontWeight="Bold" Background="#d50000" Foreground="White">
|
||||
<Button.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<TextBox Name="stats" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Margin="276,389,282,0" Text="TextBox" TextWrapping="Wrap" VerticalAlignment="Top" Width="236" Height="23" Background="#013C5A" Foreground="White" IsReadOnly="True" FontSize="14" BorderThickness="0" IsTabStop="False"/>
|
||||
<ListView Name="browser" Margin="8,43,8,79" Background="#013C5A" Foreground="White" BorderThickness="0">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridView.ColumnHeaderContainerStyle>
|
||||
<Style TargetType="{x:Type GridViewColumnHeader}">
|
||||
<Setter Property="Background" Value="#013C5A"/>
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
</GridView.ColumnHeaderContainerStyle>
|
||||
<GridViewColumn Width="30">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader Name="btncheckbox"/>
|
||||
</GridViewColumn.Header>
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Image Name="CheckedImage" Source="{Binding SourceChecked}" Height="18"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="auto">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader Name="btnsortname" Content="Name"/>
|
||||
</GridViewColumn.Header>
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Name="Image_GridViewColumnName" Source="{Binding Source}" Height="20"/>
|
||||
<Label Name="Label_GridViewColumnName" Content="{Binding name}" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding size}" Width="auto">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader Name="btnsortsize" Content="Größe"/>
|
||||
</GridViewColumn.Header>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding path}" Width="auto">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader Name="lbpath" Content="Pfad"/>
|
||||
</GridViewColumn.Header>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListView.Resources>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="ListViewItem.IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#0082c6"></Setter>
|
||||
<Setter Property="Foreground" Value="#022335"></Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="5"/>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
</ListView>
|
||||
<Button Name="btnback" Content="Zurück" HorizontalAlignment="Left" Margin="18,366,0,0" VerticalAlignment="Top" Width="71" Height="46" FontSize="16" FontWeight="Bold" Background="#00b8d4" Foreground="White" RenderTransformOrigin="-0.018,0.517">
|
||||
<Button.Resources>
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="CornerRadius" Value="2"/>
|
||||
</Style>
|
||||
</Button.Resources>
|
||||
</Button>
|
||||
<Label Name="warning_delete" Content="Die ausgewählten Dateien werden endgültig gelöscht!" HorizontalAlignment="Center" Margin="0,2,0,0" VerticalAlignment="Top" Height="36" Width="800" FontSize="18" HorizontalContentAlignment="Center" Foreground="white" Background="#d50000" FontWeight="Bold" Visibility="Visible"/>
|
||||
<Label Name="warning_move" Content="Die ausgewählten Dateien werden endgültig gelöscht!" HorizontalAlignment="Center" Margin="0,2,0,0" VerticalAlignment="Top" Height="36" Width="800" FontSize="18" HorizontalContentAlignment="Center" Foreground="#FF9C6500" Background="#FFFFEB9C" FontWeight="Bold" Visibility="Hidden"/>
|
||||
<Label Name="marked_delete" Content="Zum löschen markiert:" HorizontalAlignment="Left" Margin="276,357,0,0" VerticalAlignment="Top" Width="236" FontWeight="Bold" Foreground="white" FontSize="16" HorizontalContentAlignment="Center"/>
|
||||
<Label Name="marked_move" Content="Zum Verschieben markiert:" HorizontalAlignment="Left" Margin="276,357,0,0" VerticalAlignment="Top" Width="236" FontWeight="Bold" Foreground="white" FontSize="16" HorizontalContentAlignment="Center"/>
|
||||
<wfi:WindowsFormsHost Name="pbLoading" Height="40" Margin="745,2,0,0" Width="40" VerticalAlignment="Top" Visibility="Hidden">
|
||||
<winForms:PictureBox x:Name="pb"></winForms:PictureBox>
|
||||
</wfi:WindowsFormsHost>
|
||||
</Grid>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user