diff --git a/ToggleButtonsGenerator.ps1 b/ToggleButtonsGenerator.ps1 index 0f68b948..a9238a99 100644 --- a/ToggleButtonsGenerator.ps1 +++ b/ToggleButtonsGenerator.ps1 @@ -13,19 +13,10 @@ if (Test-Path -Path $outFile) { if (Test-Path -Path $categoryFile) { -#region Write Header -@" -######################### $categoryName ######################### - - - -"@ | Out-File -FilePath $outFile -Append -#endregion Write Header - $text = Get-Content -Path $categoryFile for ($i = 0; $i -lt $text.Count; $i++) { - + $string = $text[$i] if ($string.Contains('"')) { @@ -36,21 +27,30 @@ if (Test-Path -Path $outFile) { $string = $text[$i].Replace('&', '&') } - $toggleName = "ToggleSwitch_{0}_{1}"-f $categoryName, $i - $textBlockName = "TextBlock_{0}_{1}"-f $categoryName, $i + $toggleName = "Toggle_{0}_{1}" -f $categoryName, $i + $textBlockName = "TextToggle_{0}_{1}" -f $categoryName, $i + + if ($i -eq 0) { +@" + + +"@ | Out-File -FilePath $outFile -Append + } #region Write Toggle Buttons @" - - + - - + + - + + + + + + + - + - + - - - - - - + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + @@ -109,50 +368,50 @@ - + - - - + + - - - - - - - - - - - + + + + + + + + + + + @@ -164,7 +423,7 @@ - + @@ -705,7 +964,62 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -721,7 +1035,7 @@ - + @@ -764,13 +1078,3199 @@ - - + + + + + + + + + + + + + + + - + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Win-10-Setup-Script-GUI.ps1 b/Win-10-Setup-Script-GUI.ps1 index c8dca380..3c56afe2 100644 --- a/Win-10-Setup-Script-GUI.ps1 +++ b/Win-10-Setup-Script-GUI.ps1 @@ -6,19 +6,51 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - Name="Window" Title="Windows 10 Setup Script" MinHeight="745" MinWidth="1165" Height="745" Width="1165" + Name="Window" Title="Windows 10 Setup Script" MinHeight="855" MinWidth="0" Height="855" Width="1165" FontFamily="Calibri" FontSize="14" TextOptions.TextFormattingMode="Display" WindowStartupLocation="CenterScreen" SnapsToDevicePixels="True" ResizeMode="CanResize" ShowInTaskbar="True" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Foreground="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"> - + + + + + + + - + - + - - - - - - + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + @@ -110,50 +369,50 @@ - + - - - + + - - - - - - - - - - - + + + + + + + + + + + @@ -165,7 +424,7 @@ - + @@ -706,7 +965,62 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -722,7 +1036,7 @@ - + @@ -765,86 +1079,3297 @@ - - - - + + + + + + - - + + + + + + + + - -'@ + + + + + + + + -$xamlGui = [System.Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $xamlMarkup)) -$xamlMarkup.SelectNodes('//*[@Name]') | ForEach-Object { - New-Variable -Name $_.Name -Value $xamlGui.FindName($_.Name) + + + + + + + + -} + + + + + + + + -#region Script Functions -function Hide-Console { - <# - .SYNOPSIS - Hide Powershell console before show WPF GUI. - #> + + + + + + + + - [CmdletBinding()] - param () + + + + + + + + - Add-Type -Name Window -Namespace Console -MemberDefinition ' - [DllImport("Kernel32.dll")] - public static extern IntPtr GetConsoleWindow(); + + + + + + + + - [DllImport("user32.dll")] - public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); -' - [Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0) -} + + + + + + + + -function Use-HamburgerMenu { - <# - .SYNOPSIS - Show or hide hamburger menu. - #> + + + + + + + + - [CmdletBinding()] - param () + + + + + + + + - $minWidth = 50 - $maxWidth = 250 - $duration = New-Object System.Windows.Duration([timespan]::FromSeconds(1)) - $widthProperty = New-Object System.Windows.PropertyPath([System.Windows.Controls.Canvas]::WidthProperty) + + + + + + + + - if ($HamburgerMenu.ActualWidth -eq $minWidth) { - $animation = New-Object System.Windows.Media.Animation.DoubleAnimation($minWidth, $maxWidth, $duration) - } + + + + + + + + - else { - $animation = New-Object System.Windows.Media.Animation.DoubleAnimation($maxWidth, $minWidth, $duration) - } + + + + + + + + - $animation.SpeedRatio ="3" - $storyboard = New-Object System.Windows.Media.Animation.Storyboard - [System.Windows.Media.Animation.Storyboard]::SetTargetProperty($animation, $widthProperty) - $storyboard.Children.Add($animation) - $storyboard.Begin($HamburgerMenu) -} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +'@ + +$xamlGui = [System.Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $xamlMarkup)) +$xamlMarkup.SelectNodes('//*[@Name]') | ForEach-Object { + New-Variable -Name $_.Name -Value $xamlGui.FindName($_.Name) +} + +#region Script Functions +function Hide-Console { + <# + .SYNOPSIS + Hide Powershell console before show WPF GUI. + #> + + [CmdletBinding()] + param () + + Add-Type -Name Window -Namespace Console -MemberDefinition ' + [DllImport("Kernel32.dll")] + public static extern IntPtr GetConsoleWindow(); + + [DllImport("user32.dll")] + public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); +' + [Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0) +} + +function Use-HamburgerMenu { + <# + .SYNOPSIS + Show or hide hamburger menu. + #> + + [CmdletBinding()] + param () + + $minWidth = 50 + $maxWidth = 250 + $duration = New-Object System.Windows.Duration([timespan]::FromSeconds(1)) + $widthProperty = New-Object System.Windows.PropertyPath([System.Windows.Controls.Canvas]::WidthProperty) + + if ($HamburgerMenu.ActualWidth -eq $minWidth) { + $animation = New-Object System.Windows.Media.Animation.DoubleAnimation($minWidth, $maxWidth, $duration) + } + + else { + $animation = New-Object System.Windows.Media.Animation.DoubleAnimation($maxWidth, $minWidth, $duration) + } + + $animation.SpeedRatio ="3" + $storyboard = New-Object System.Windows.Media.Animation.Storyboard + [System.Windows.Media.Animation.Storyboard]::SetTargetProperty($animation, $widthProperty) + $storyboard.Children.Add($animation) + $storyboard.Begin($HamburgerMenu) +} + +function Set-HamburgerHover { + <# + .SYNOPSIS + Mouse hover effect for hamburger button. + #> + + [CmdletBinding()] + param + ( + [Parameter(Mandatory=$false)] + [switch]$Active + ) + + + if ($Active) + { + $Button_Hamburger.Background = "#2196F3" + } + + else + { + $Button_Hamburger.Background = "#3F51B5" + } +} #endregion #region Controls Events -$ButtonHamburger.Add_MouseLeftButtonDown({ +$Button_Hamburger.Add_MouseLeftButtonDown({ Use-HamburgerMenu }) -$ButtonHamburger.Add_MouseEnter({ - +$Button_Hamburger.Add_MouseEnter({ + Set-HamburgerHover -Active }) -$ButtonHamburger.Add_MouseLeave({ +$Button_Hamburger.Add_MouseLeave({ + Set-HamburgerHover })