forked from farag2/Sophia-Script-for-Windows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleButtonsGenerator.ps1
More file actions
65 lines (50 loc) · 1.99 KB
/
ToggleButtonsGenerator.ps1
File metadata and controls
65 lines (50 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
$currentDir = $MyInvocation.MyCommand.Definition | Split-Path -Parent
$outFile = "{0}\ToggleButtonsGenerator.txt"-f $currentDir
if (Test-Path -Path $outFile) {
Remove-Item -Path $outFile -Force -Confirm:$false
Write-Warning -Message "File ""ToggleButtonsGenerator.txt"" deleted!"
}
"Privacy", "Ui", "OneDrive", "System", "StartMenu", "Edge", "Uwp", "Game", "Tasks", "Defender", "ContextMenu" | ForEach-Object {
$categoryName = $_
$categoryFile = "{0}\En\{1}.txt"-f $currentDir, $categoryName
if (Test-Path -Path $categoryFile) {
$text = Get-Content -Path $categoryFile
@"
<!--#region $categoryName Toggles-->
<StackPanel Name="PanelToggle_$categoryName" Style="{StaticResource PanelToggle}">
"@ | Out-File -FilePath $outFile -Append
for ($i = 0; $i -lt $text.Count; $i++) {
$string = $text[$i]
$toggleName = "Toggle_{0}_{1}" -f $categoryName, $i
$textBlockName = "TextToggle_{0}_{1}" -f $categoryName, $i
@"
<Border Style="{StaticResource ToggleBorder}">
<DockPanel Margin="0 10 0 10">
<Grid HorizontalAlignment="Left">
<ToggleButton Name="$toggleName" Style="{StaticResource ToggleSwitchLeftStyle}" IsChecked="False"/>
<TextBlock Name="$textBlockName" Text="$string" Margin="65 0 10 0" VerticalAlignment="Center" TextWrapping="Wrap" IsHitTestVisible="False">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=$toggleName, Path=IsChecked}" Value="True">
<Setter Property="Foreground" Value="#3F51B5"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</DockPanel>
</Border>
"@ | Out-File -FilePath $outFile -Append
}
@"
</StackPanel>
<!--#endregion $categoryName Toggles-->
"@ | Out-File -FilePath $outFile -Append
Write-Warning -Message "File ""ToggleButtonsGenerator.txt"" created!"
}
else {
Write-Warning -Message "File ""$categoryFile"" not found!"
}
}