mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-24 11:55:31 +00:00
Compare commits
15 Commits
86f22591a7
...
16047c2bdf
Author | SHA1 | Date | |
---|---|---|---|
|
16047c2bdf | ||
|
6e708bfe95 | ||
|
fc53ca802b | ||
|
e6c1394b5d | ||
|
fb21479531 | ||
|
411bc66d7e | ||
|
2b2b11e4f2 | ||
|
0e7a34c5e5 | ||
|
d535e7ebca | ||
|
15024434d9 | ||
|
46e457dde8 | ||
|
12446c5b83 | ||
|
ce5ebca87a | ||
|
cb21a39f62 | ||
|
b001842a61 |
@ -52,7 +52,7 @@ If you have Issues, refer to [Known Issues](https://christitustech.github.io/win
|
||||
|
||||
These are the sponsors that help keep this project alive with monthly contributions.
|
||||
|
||||
<!-- sponsors --><a href="https://github.com/ysaito8015"><img src="https://avatars.githubusercontent.com/u/3502978?u=ca98bf67f04d67080df0feeaa6f007fad51d273f&v=4" width="60px" alt="Yusuke Saito" /></a><a href="https://github.com/TriHydera"><img src="https://avatars.githubusercontent.com/u/39857764?u=5dbda638f45530582eee1703b4473f2a5e229e28&v=4" width="60px" alt="TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https://avatars.githubusercontent.com/u/3272468?u=4391ed4655e4fd8b56e23b4169e44e2ac9b6cd97&v=4" width="60px" alt="" /></a><a href="https://github.com/DelDongo"><img src="https://avatars.githubusercontent.com/u/127976398?v=4" width="60px" alt="" /></a><a href="https://github.com/markamos"><img src="https://avatars.githubusercontent.com/u/9561861?u=3cca179dcff0413538591e57a3abea116d65ce56&v=4" width="60px" alt="Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https://avatars.githubusercontent.com/u/54533224?u=a49ea000a8f52adb31382ea69a1a7501b27fefdd&v=4" width="60px" alt="" /></a><a href="https://github.com/mews-se"><img src="https://avatars.githubusercontent.com/u/58894405?v=4" width="60px" alt="" /></a><a href="https://github.com/jdiegmueller"><img src="https://avatars.githubusercontent.com/u/18660571?u=601d0a23040a271c86b5d40339f899a6dbf27086&v=4" width="60px" alt="Jason A. Diegmueller" /></a><a href="https://github.com/AlanTristar"><img src="https://avatars.githubusercontent.com/u/105566568?v=4" width="60px" alt="" /></a><a href="https://github.com/zepled112"><img src="https://avatars.githubusercontent.com/u/65176625?v=4" width="60px" alt="wyatt" /></a><a href="https://github.com/altugtekiner"><img src="https://avatars.githubusercontent.com/u/105917451?u=ee73ff639c7bd9feb4708ab4ba7b14eff80196f7&v=4" width="60px" alt="" /></a><a href="https://github.com/robertsandrock"><img src="https://avatars.githubusercontent.com/u/12015331?v=4" width="60px" alt="RMS" /></a><a href="https://github.com/mmomega"><img src="https://avatars.githubusercontent.com/u/71956566?v=4" width="60px" alt="" /></a><a href="https://github.com/KenichiQaz"><img src="https://avatars.githubusercontent.com/u/31177857?u=efdbae734a4c60a7bb95df4659d0535e60a6fd57&v=4" width="60px" alt="Stefan" /></a><a href="https://github.com/paulsheets"><img src="https://avatars.githubusercontent.com/u/45240946?u=d4db66f8e8d7a2606fe7a5521daf48ca9f097105&v=4" width="60px" alt="Paul" /></a><a href="https://github.com/djones369"><img src="https://avatars.githubusercontent.com/u/4107092?v=4" width="60px" alt="Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https://avatars.githubusercontent.com/u/19240897?u=f82b4be098cac65c8421421b70ebd2d1da85c67e&v=4" width="60px" alt="Anthony Mendez" /></a><a href="https://github.com/xBandaku"><img src="https://avatars.githubusercontent.com/u/142067112?u=0c9a1edee45ac2a0a42827d418a12b1791d52350&v=4" width="60px" alt="xPandaku" /></a><a href="https://github.com/claudemods"><img src="https://avatars.githubusercontent.com/u/73653396?u=d64c656fb8db24ef56bb000197532df9b618d06c&v=4" width="60px" alt="Claudemods" /></a><a href="https://github.com/FatBastard0"><img src="https://avatars.githubusercontent.com/u/173957728?v=4" width="60px" alt="" /></a><a href="https://github.com/Ascent7910"><img src="https://avatars.githubusercontent.com/u/118260621?v=4" width="60px" alt="Max" /></a><a href="https://github.com/DursleyGuy"><img src="https://avatars.githubusercontent.com/u/140165544?v=4" width="60px" alt="DursleyGuy" /></a><a href="https://github.com/YamiSandman616"><img src="https://avatars.githubusercontent.com/u/183505690?u=c3bd20157058b6215e28f7568d4f8c4fbbe92838&v=4" width="60px" alt="Sandman616" /></a><a href="https://github.com/realmuddy"><img src="https://avatars.githubusercontent.com/u/30978236?v=4" width="60px" alt="Phillip Waters" /></a><a href="https://github.com/Tariq-Al-Zahrani"><img src="https://avatars.githubusercontent.com/u/187593049?v=4" width="60px" alt="" /></a><!-- sponsors -->
|
||||
<!-- sponsors --><a href="https://github.com/ysaito8015"><img src="https://avatars.githubusercontent.com/u/3502978?u=ca98bf67f04d67080df0feeaa6f007fad51d273f&v=4" width="60px" alt="Yusuke Saito" /></a><a href="https://github.com/TriHydera"><img src="https://avatars.githubusercontent.com/u/39857764?u=5dbda638f45530582eee1703b4473f2a5e229e28&v=4" width="60px" alt="TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https://avatars.githubusercontent.com/u/3272468?u=4391ed4655e4fd8b56e23b4169e44e2ac9b6cd97&v=4" width="60px" alt="" /></a><a href="https://github.com/DelDongo"><img src="https://avatars.githubusercontent.com/u/127976398?v=4" width="60px" alt="" /></a><a href="https://github.com/markamos"><img src="https://avatars.githubusercontent.com/u/9561861?u=3cca179dcff0413538591e57a3abea116d65ce56&v=4" width="60px" alt="Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https://avatars.githubusercontent.com/u/54533224?u=a49ea000a8f52adb31382ea69a1a7501b27fefdd&v=4" width="60px" alt="" /></a><a href="https://github.com/mews-se"><img src="https://avatars.githubusercontent.com/u/58894405?v=4" width="60px" alt="" /></a><a href="https://github.com/jdiegmueller"><img src="https://avatars.githubusercontent.com/u/18660571?u=601d0a23040a271c86b5d40339f899a6dbf27086&v=4" width="60px" alt="Jason A. Diegmueller" /></a><a href="https://github.com/AlanTristar"><img src="https://avatars.githubusercontent.com/u/105566568?v=4" width="60px" alt="" /></a><a href="https://github.com/zepled112"><img src="https://avatars.githubusercontent.com/u/65176625?v=4" width="60px" alt="wyatt" /></a><a href="https://github.com/altugtekiner"><img src="https://avatars.githubusercontent.com/u/105917451?u=ee73ff639c7bd9feb4708ab4ba7b14eff80196f7&v=4" width="60px" alt="" /></a><a href="https://github.com/robertsandrock"><img src="https://avatars.githubusercontent.com/u/12015331?v=4" width="60px" alt="RMS" /></a><a href="https://github.com/mmomega"><img src="https://avatars.githubusercontent.com/u/71956566?v=4" width="60px" alt="" /></a><a href="https://github.com/KenichiQaz"><img src="https://avatars.githubusercontent.com/u/31177857?u=efdbae734a4c60a7bb95df4659d0535e60a6fd57&v=4" width="60px" alt="Stefan" /></a><a href="https://github.com/paulsheets"><img src="https://avatars.githubusercontent.com/u/45240946?u=d4db66f8e8d7a2606fe7a5521daf48ca9f097105&v=4" width="60px" alt="Paul" /></a><a href="https://github.com/djones369"><img src="https://avatars.githubusercontent.com/u/4107092?v=4" width="60px" alt="Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https://avatars.githubusercontent.com/u/19240897?u=f82b4be098cac65c8421421b70ebd2d1da85c67e&v=4" width="60px" alt="Anthony Mendez" /></a><a href="https://github.com/claudemods"><img src="https://avatars.githubusercontent.com/u/73653396?u=d64c656fb8db24ef56bb000197532df9b618d06c&v=4" width="60px" alt="Claudemods" /></a><a href="https://github.com/FatBastard0"><img src="https://avatars.githubusercontent.com/u/173957728?v=4" width="60px" alt="" /></a><a href="https://github.com/Ascent7910"><img src="https://avatars.githubusercontent.com/u/118260621?v=4" width="60px" alt="Max" /></a><a href="https://github.com/DursleyGuy"><img src="https://avatars.githubusercontent.com/u/140165544?v=4" width="60px" alt="DursleyGuy" /></a><a href="https://github.com/YamiSandman616"><img src="https://avatars.githubusercontent.com/u/183505690?u=c3bd20157058b6215e28f7568d4f8c4fbbe92838&v=4" width="60px" alt="Sandman616" /></a><a href="https://github.com/realmuddy"><img src="https://avatars.githubusercontent.com/u/30978236?v=4" width="60px" alt="Phillip Waters" /></a><a href="https://github.com/Tariq-Al-Zahrani"><img src="https://avatars.githubusercontent.com/u/187593049?v=4" width="60px" alt="" /></a><!-- sponsors -->
|
||||
|
||||
## 🏅 Thanks to all Contributors
|
||||
Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻.
|
||||
|
@ -2,12 +2,12 @@
|
||||
"shared":{
|
||||
"CustomDialogFontSize": "12",
|
||||
"CustomDialogFontSizeHeader": "14",
|
||||
"CustomDialogIconSize": "25",
|
||||
"CustomDialogLogoSize": "25",
|
||||
"CustomDialogWidth": "400",
|
||||
"CustomDialogHeight": "200",
|
||||
"FontSize": "12",
|
||||
"FontFamily": "Arial",
|
||||
"FontSizeHeading": "16",
|
||||
"HeadingFontSize": "16",
|
||||
"HeaderFontFamily": "Consolas, Monaco",
|
||||
"CheckBoxBulletDecoratorSize": "14",
|
||||
"CheckBoxMargin": "15,0,0,2",
|
||||
@ -27,7 +27,7 @@
|
||||
"ButtonFontFamily": "Arial",
|
||||
"ButtonWidth": "200",
|
||||
"ButtonHeight": "25",
|
||||
"ConfigTabButtonFontSize": "16",
|
||||
"ConfigUpdateButtonFontSize": "14",
|
||||
"SearchBarWidth": "200",
|
||||
"SearchBarHeight": "26",
|
||||
"SearchBarTextBoxFontSize": "12",
|
||||
@ -44,7 +44,7 @@
|
||||
"MainForegroundColor": "#232629",
|
||||
"MainBackgroundColor": "#F7F7F7",
|
||||
"LabelBackgroundColor": "#F7F7F7",
|
||||
"LinkForegroundColor": "#232629",
|
||||
"LinkForegroundColor": "#484848",
|
||||
"LinkHoverForegroundColor": "#232629",
|
||||
"ScrollBarBackgroundColor": "#4A4D52",
|
||||
"ScrollBarHoverColor": "#5A5D62",
|
||||
|
@ -6,6 +6,9 @@ function Show-CustomDialog {
|
||||
.DESCRIPTION
|
||||
This function creates a custom dialog box with the specified message and additional elements such as an image, heading, and an OK button. The dialog box is designed with a green border, rounded corners, and a black background.
|
||||
|
||||
.PARAMETER Title
|
||||
The Title to use for the dialog window's Title Bar, this will not be visible by the user, as window styling is set to None.
|
||||
|
||||
.PARAMETER Message
|
||||
The message to be displayed in the dialog box.
|
||||
|
||||
@ -16,60 +19,102 @@ function Show-CustomDialog {
|
||||
The height of the custom dialog window.
|
||||
|
||||
.PARAMETER FontSize
|
||||
The Font Size for text shown inside the custom dialog window.
|
||||
The Font Size of message shown inside custom dialog window.
|
||||
|
||||
.PARAMETER HeaderFontSize
|
||||
The Font Size for the Header of the custom dialog window.
|
||||
The Font Size for the Header of custom dialog window.
|
||||
|
||||
.PARAMETER IconSize
|
||||
The Size to use for Icon inside the custom dialog window.
|
||||
.PARAMETER LogoSize
|
||||
The Size of the Logo used inside the custom dialog window.
|
||||
|
||||
.PARAMETER ForegroundColor
|
||||
The Foreground Color of dialog window title & message.
|
||||
|
||||
.PARAMETER BackgroundColor
|
||||
The Background Color of dialog window.
|
||||
|
||||
.PARAMETER BorderColor
|
||||
The Color for dialog window border.
|
||||
|
||||
.PARAMETER ButtonBackgroundColor
|
||||
The Background Color for Buttons in dialog window.
|
||||
|
||||
.PARAMETER ButtonForegroundColor
|
||||
The Foreground Color for Buttons in dialog window.
|
||||
|
||||
.PARAMETER ShadowColor
|
||||
The Color used when creating the Drop-down Shadow effect for dialog window.
|
||||
|
||||
.PARAMETER LogoColor
|
||||
The Color of WinUtil Text found next to WinUtil's Logo inside dialog window.
|
||||
|
||||
.PARAMETER LinkForegroundColor
|
||||
The Foreground Color for Links inside dialog window.
|
||||
|
||||
.PARAMETER LinkHoverForegroundColor
|
||||
The Foreground Color for Links when the mouse pointer hovers over them inside dialog window.
|
||||
|
||||
.PARAMETER EnableScroll
|
||||
A flag indicating whether to enable scrolling if the content exceeds the window size.
|
||||
|
||||
.EXAMPLE
|
||||
Show-CustomDialog -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
|
||||
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
|
||||
|
||||
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels.
|
||||
Other styling options are grabbed from '$sync.Form.Resources' global variable.
|
||||
|
||||
.EXAMPLE
|
||||
$foregroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
|
||||
$backgroundColor = New-Object System.Windows.Media.SolidColorBrush("#1e1e1e")
|
||||
$linkForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#0088e5")
|
||||
$linkHoverForegroundColor = New-Object System.Windows.Media.SolidColorBrush("#005289")
|
||||
Show-CustomDialog -Title "My Custom Dialog" -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200 -ForegroundColor $foregroundColor -BackgroundColor $backgroundColor -LinkForegroundColor $linkForegroundColor -LinkHoverForegroundColor $linkHoverForegroundColor
|
||||
|
||||
Makes a new Custom Dialog with the title 'My Custom Dialog' and a message 'This is a custom dialog with a message and an image above.', with dimensions of 300 by 200 pixels, with a link foreground (and general foreground) colors of '#0088e5', background color of '#1e1e1e', and Link Color on Hover of '005289', all of which are in Hexadecimal (the '#' Symbol is required by SolidColorBrush Constructor).
|
||||
Other styling options are grabbed from '$sync.Form.Resources' global variable.
|
||||
|
||||
#>
|
||||
param(
|
||||
[string]$Title,
|
||||
[string]$Message,
|
||||
[int]$Width = $sync.Form.Resources.CustomDialogWidth,
|
||||
[int]$Height = $sync.Form.Resources.CustomDialogHeight,
|
||||
|
||||
[System.Windows.Media.FontFamily]$FontFamily = $sync.Form.Resources.FontFamily,
|
||||
[int]$FontSize = $sync.Form.Resources.CustomDialogFontSize,
|
||||
[int]$HeaderFontSize = $sync.Form.Resources.CustomDialogFontSizeHeader,
|
||||
[int]$IconSize = $sync.Form.Resources.CustomDialogLogoSize,
|
||||
[int]$LogoSize = $sync.Form.Resources.CustomDialogLogoSize,
|
||||
|
||||
[System.Windows.Media.Color]$ShadowColor = "#AAAAAAAA",
|
||||
[System.Windows.Media.SolidColorBrush]$LogoColor = $sync.Form.Resources.LabelboxForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$BorderColor = $sync.Form.Resources.BorderColor,
|
||||
[System.Windows.Media.SolidColorBrush]$ForegroundColor = $sync.Form.Resources.MainForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$BackgroundColor = $sync.Form.Resources.MainBackgroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$ButtonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$ButtonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$LinkForegroundColor = $sync.Form.Resources.LinkForegroundColor,
|
||||
[System.Windows.Media.SolidColorBrush]$LinkHoverForegroundColor = $sync.Form.Resources.LinkHoverForegroundColor,
|
||||
|
||||
[bool]$EnableScroll = $false
|
||||
)
|
||||
|
||||
Add-Type -AssemblyName PresentationFramework
|
||||
|
||||
# Define theme colors
|
||||
$foregroundColor = $sync.Form.Resources.MainForegroundColor
|
||||
$backgroundColor = $sync.Form.Resources.MainBackgroundColor
|
||||
$font = New-Object Windows.Media.FontFamily("Consolas")
|
||||
$borderColor = $sync.Form.Resources.BorderColor # ButtonInstallBackgroundColor
|
||||
$buttonBackgroundColor = $sync.Form.Resources.ButtonInstallBackgroundColor
|
||||
$buttonForegroundColor = $sync.Form.Resources.ButtonInstallForegroundColor
|
||||
$shadowColor = [Windows.Media.ColorConverter]::ConvertFromString("#AAAAAAAA")
|
||||
$logocolor = $sync.Form.Resources.LabelboxForegroundColor
|
||||
|
||||
# Create a custom dialog window
|
||||
$dialog = New-Object Windows.Window
|
||||
$dialog.Title = "About"
|
||||
$dialog.Title = $Title
|
||||
$dialog.Height = $Height
|
||||
$dialog.Width = $Width
|
||||
$dialog.Margin = New-Object Windows.Thickness(10) # Add margin to the entire dialog box
|
||||
$dialog.WindowStyle = [Windows.WindowStyle]::None # Remove title bar and window controls
|
||||
$dialog.ResizeMode = [Windows.ResizeMode]::NoResize # Disable resizing
|
||||
$dialog.WindowStartupLocation = [Windows.WindowStartupLocation]::CenterScreen # Center the window
|
||||
$dialog.Foreground = $foregroundColor
|
||||
$dialog.Background = $backgroundColor
|
||||
$dialog.FontFamily = $font
|
||||
$dialog.Foreground = $ForegroundColor
|
||||
$dialog.Background = $BackgroundColor
|
||||
$dialog.FontFamily = $FontFamily
|
||||
$dialog.FontSize = $FontSize
|
||||
|
||||
# Create a Border for the green edge with rounded corners
|
||||
$border = New-Object Windows.Controls.Border
|
||||
$border.BorderBrush = $borderColor
|
||||
$border.BorderBrush = $BorderColor
|
||||
$border.BorderThickness = New-Object Windows.Thickness(1) # Adjust border thickness as needed
|
||||
$border.CornerRadius = New-Object Windows.CornerRadius(10) # Adjust the radius for rounded corners
|
||||
|
||||
@ -89,7 +134,7 @@ function Show-CustomDialog {
|
||||
$grid = New-Object Windows.Controls.Grid
|
||||
$border.Child = $grid
|
||||
|
||||
# Add the following line to show gridlines
|
||||
# Uncomment the following line to show gridlines
|
||||
#$grid.ShowGridLines = $true
|
||||
|
||||
# Add the following line to set the background color of the grid
|
||||
@ -102,7 +147,6 @@ function Show-CustomDialog {
|
||||
$border.HorizontalAlignment = [Windows.HorizontalAlignment]::Stretch
|
||||
$border.VerticalAlignment = [Windows.VerticalAlignment]::Stretch
|
||||
|
||||
|
||||
# Set up Row Definitions
|
||||
$row0 = New-Object Windows.Controls.RowDefinition
|
||||
$row0.Height = [Windows.GridLength]::Auto
|
||||
@ -129,17 +173,18 @@ function Show-CustomDialog {
|
||||
[Windows.Controls.Grid]::SetRow($stackPanel, 0) # Set the row to the second row (0-based index)
|
||||
|
||||
# Add SVG path to the stack panel
|
||||
$stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size 25))
|
||||
$stackPanel.Children.Add((Invoke-WinUtilAssets -Type "logo" -Size $LogoSize))
|
||||
|
||||
# Add "Winutil" text
|
||||
$winutilTextBlock = New-Object Windows.Controls.TextBlock
|
||||
$winutilTextBlock.Text = "Winutil"
|
||||
$winutilTextBlock.FontSize = $HeaderFontSize
|
||||
$winutilTextBlock.Foreground = $logocolor
|
||||
$winutilTextBlock.Foreground = $LogoColor
|
||||
$winutilTextBlock.Margin = New-Object Windows.Thickness(10, 10, 10, 5) # Add margins around the text block
|
||||
$stackPanel.Children.Add($winutilTextBlock)
|
||||
# Add TextBlock for information with text wrapping and margins
|
||||
$messageTextBlock = New-Object Windows.Controls.TextBlock
|
||||
$messageTextBlock.FontSize = $FontSize
|
||||
$messageTextBlock.TextWrapping = [Windows.TextWrapping]::Wrap # Enable text wrapping
|
||||
$messageTextBlock.HorizontalAlignment = [Windows.HorizontalAlignment]::Left
|
||||
$messageTextBlock.VerticalAlignment = [Windows.VerticalAlignment]::Top
|
||||
@ -162,7 +207,7 @@ function Show-CustomDialog {
|
||||
$hyperlink.NavigateUri = New-Object System.Uri($match.Groups[1].Value)
|
||||
$hyperlink.Inlines.Add($match.Groups[2].Value)
|
||||
$hyperlink.TextDecorations = [Windows.TextDecorations]::None # Remove underline
|
||||
$hyperlink.Foreground = $sync.Form.Resources.LinkForegroundColor
|
||||
$hyperlink.Foreground = $LinkForegroundColor
|
||||
|
||||
$hyperlink.Add_Click({
|
||||
param($sender, $args)
|
||||
@ -170,11 +215,15 @@ function Show-CustomDialog {
|
||||
})
|
||||
$hyperlink.Add_MouseEnter({
|
||||
param($sender, $args)
|
||||
$sender.Foreground = $sync.Form.Resources.LinkHoverForegroundColor
|
||||
$sender.Foreground = $LinkHoverForegroundColor
|
||||
$sender.FontSize = ($FontSize + ($FontSize / 4))
|
||||
$sender.FontWeight = "SemiBold"
|
||||
})
|
||||
$hyperlink.Add_MouseLeave({
|
||||
param($sender, $args)
|
||||
$sender.Foreground = $sync.Form.Resources.LinkForegroundColor
|
||||
$sender.Foreground = $LinkForegroundColor
|
||||
$sender.FontSize = $FontSize
|
||||
$sender.FontWeight = "Normal"
|
||||
})
|
||||
|
||||
$messageTextBlock.Inlines.Add($hyperlink)
|
||||
@ -218,7 +267,7 @@ function Show-CustomDialog {
|
||||
$okButton.Margin = New-Object Windows.Thickness(0, 0, 0, 10)
|
||||
$okButton.Background = $buttonBackgroundColor
|
||||
$okButton.Foreground = $buttonForegroundColor
|
||||
$okButton.BorderBrush = $borderColor
|
||||
$okButton.BorderBrush = $BorderColor
|
||||
$okButton.Add_Click({
|
||||
$dialog.Close()
|
||||
})
|
||||
|
54
functions/public/Invoke-WPFPopup.ps1
Normal file
54
functions/public/Invoke-WPFPopup.ps1
Normal file
@ -0,0 +1,54 @@
|
||||
function Invoke-WPFPopup {
|
||||
param (
|
||||
[ValidateSet("Show", "Hide", "Toggle")]
|
||||
[string]$Action = "",
|
||||
|
||||
[string[]]$Popups = @(),
|
||||
|
||||
[ValidateScript({
|
||||
$invalid = $_.GetEnumerator() | Where-Object { $_.Value -notin @("Show", "Hide", "Toggle") }
|
||||
if ($invalid) {
|
||||
throw "Found invalid Popup-Action pair(s): " + ($invalid | ForEach-Object { "$($_.Key) = $($_.Value)" } -join "; ")
|
||||
}
|
||||
$true
|
||||
})]
|
||||
[hashtable]$PopupActionTable = @{}
|
||||
)
|
||||
|
||||
if (-not $PopupActionTable.Count -and (-not $Action -or -not $Popups.Count)) {
|
||||
throw "Provide either 'PopupActionTable' or both 'Action' and 'Popups'."
|
||||
}
|
||||
|
||||
if ($PopupActionTable.Count -and ($Action -or $Popups.Count)) {
|
||||
throw "Use 'PopupActionTable' on its own, or 'Action' with 'Popups'."
|
||||
}
|
||||
|
||||
# Collect popups and actions
|
||||
$PopupsToProcess = if ($PopupActionTable.Count) {
|
||||
$PopupActionTable.GetEnumerator() | ForEach-Object { [PSCustomObject]@{ Name = "$($_.Key)Popup"; Action = $_.Value } }
|
||||
} else {
|
||||
$Popups | ForEach-Object { [PSCustomObject]@{ Name = "$_`Popup"; Action = $Action } }
|
||||
}
|
||||
|
||||
$PopupsNotFound = @()
|
||||
|
||||
# Apply actions
|
||||
foreach ($popupEntry in $PopupsToProcess) {
|
||||
$popupName = $popupEntry.Name
|
||||
|
||||
if (-not $sync.$popupName) {
|
||||
$PopupsNotFound += $popupName
|
||||
continue
|
||||
}
|
||||
|
||||
$sync.$popupName.IsOpen = switch ($popupEntry.Action) {
|
||||
"Show" { $true }
|
||||
"Hide" { $false }
|
||||
"Toggle" { -not $sync.$popupName.IsOpen }
|
||||
}
|
||||
}
|
||||
|
||||
if ($PopupsNotFound.Count -gt 0) {
|
||||
throw "Could not find the following popups: $($PopupsNotFound -join ', ')"
|
||||
}
|
||||
}
|
@ -142,7 +142,7 @@ function Invoke-WPFUIElements {
|
||||
|
||||
$label = New-Object Windows.Controls.Label
|
||||
$label.Content = $category -replace ".*__", ""
|
||||
$label.FontSize = $theme.FontSizeHeading
|
||||
$label.FontSize = $theme.HeadingFontSize
|
||||
$label.FontFamily = $theme.HeaderFontFamily
|
||||
$stackPanel.Children.Add($label) | Out-Null
|
||||
|
||||
|
@ -33,19 +33,16 @@ $sync.runspace.Open()
|
||||
|
||||
class WingetFailedInstall : Exception {
|
||||
[string]$additionalData
|
||||
|
||||
WingetFailedInstall($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
class ChocoFailedInstall : Exception {
|
||||
[string]$additionalData
|
||||
|
||||
ChocoFailedInstall($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
class GenericException : Exception {
|
||||
[string]$additionalData
|
||||
|
||||
GenericException($Message) : base($Message) {}
|
||||
}
|
||||
|
||||
@ -254,12 +251,7 @@ $commonKeyEvents = {
|
||||
$sync["Form"].Add_PreViewKeyDown($commonKeyEvents)
|
||||
|
||||
$sync["Form"].Add_MouseLeftButtonDown({
|
||||
# Hide Settings and Theme Popup on click anywhere else
|
||||
if ($sync.SettingsButton.IsOpen -or
|
||||
$sync.ThemePopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme")
|
||||
$sync["Form"].DragMove()
|
||||
})
|
||||
|
||||
@ -277,12 +269,7 @@ $sync["Form"].Add_MouseDoubleClick({
|
||||
|
||||
$sync["Form"].Add_Deactivated({
|
||||
Write-Debug "WinUtil lost focus"
|
||||
# Hide Settings and Theme Popup on Winutil Focus Loss
|
||||
if ($sync.SettingsButton.IsOpen -or
|
||||
$sync.ThemePopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme")
|
||||
})
|
||||
|
||||
$sync["Form"].Add_ContentRendered({
|
||||
@ -521,101 +508,79 @@ Set-WinUtilTaskbaritem -overlay "logo"
|
||||
$sync["Form"].Add_Activated({
|
||||
Set-WinUtilTaskbaritem -overlay "logo"
|
||||
})
|
||||
# Define event handler for ThemeButton click
|
||||
$sync["ThemeButton"].Add_Click({
|
||||
if ($sync.ThemePopup.IsOpen) {
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
}
|
||||
else{
|
||||
$sync.ThemePopup.IsOpen = $true
|
||||
}
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
})
|
||||
|
||||
# Define event handlers for menu items
|
||||
$sync["ThemeButton"].Add_Click({
|
||||
Write-Debug "ThemeButton clicked"
|
||||
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Hide"; "Theme" = "Toggle" }
|
||||
$_.Handled = $false
|
||||
})
|
||||
$sync["AutoThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Write-Debug "About clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Auto"
|
||||
$_.Handled = $false
|
||||
})
|
||||
# Define event handlers for menu items
|
||||
$sync["DarkThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Write-Debug "Dark Theme clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Dark"
|
||||
$_.Handled = $false
|
||||
})
|
||||
# Define event handlers for menu items
|
||||
$sync["LightThemeMenuItem"].Add_Click({
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Write-Debug "Light Theme clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Light"
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
|
||||
# Define event handler for button click
|
||||
$sync["SettingsButton"].Add_Click({
|
||||
Write-Debug "SettingsButton clicked"
|
||||
if ($sync.SettingsPopup.IsOpen) {
|
||||
$sync.SettingsPopup.IsOpen = $false
|
||||
}
|
||||
else{
|
||||
$sync.SettingsPopup.IsOpen = $true
|
||||
}
|
||||
$sync.ThemePopup.IsOpen = $false
|
||||
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Toggle"; "Theme" = "Hide" }
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
# Define event handlers for menu items
|
||||
$sync["ImportMenuItem"].Add_Click({
|
||||
# Handle Import menu item click
|
||||
Write-Debug "Import clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
Invoke-WPFImpex -type "import"
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
$sync["ExportMenuItem"].Add_Click({
|
||||
# Handle Export menu item click
|
||||
Write-Debug "Export clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
Invoke-WPFImpex -type "export"
|
||||
$_.Handled = $false
|
||||
})
|
||||
|
||||
$sync["AboutMenuItem"].Add_Click({
|
||||
# Handle Export menu item click
|
||||
Write-Debug "About clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
|
||||
$authorInfo = @"
|
||||
Author : <a href="https://github.com/ChrisTitusTech">@christitustech</a>
|
||||
Runspace : <a href="https://github.com/DeveloperDurp">@DeveloperDurp</a>
|
||||
MicroWin : <a href="https://github.com/KonTy">@KonTy</a>
|
||||
MicroWin : <a href="https://github.com/KonTy">@KonTy</a>, <a href="https://github.com/CodingWonders">@CodingWonders</a>
|
||||
GitHub : <a href="https://github.com/ChrisTitusTech/winutil">ChrisTitusTech/winutil</a>
|
||||
Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sync.version)">$($sync.version)</a>
|
||||
"@
|
||||
|
||||
Show-CustomDialog -Message $authorInfo -LogoSize $LogoSize
|
||||
Show-CustomDialog -Title "About" -Message $authorInfo
|
||||
})
|
||||
|
||||
$sync["SponsorMenuItem"].Add_Click({
|
||||
# Handle Export menu item click
|
||||
Write-Debug "Sponsors clicked"
|
||||
$sync["SettingsPopup"].IsOpen = $false
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
|
||||
$authorInfo = @"
|
||||
<a href="https://github.com/sponsors/ChrisTitusTech">Current sponsors for ChrisTitusTech:</a>
|
||||
"@
|
||||
$authorInfo += "`n"
|
||||
try {
|
||||
# Call the function to get the sponsors
|
||||
$sponsors = Invoke-WinUtilSponsors
|
||||
|
||||
# Append the sponsors to the authorInfo
|
||||
$sponsors | ForEach-Object { $authorInfo += "$_`n" }
|
||||
foreach ($sponsor in $sponsors) {
|
||||
$authorInfo += "<a href=`"https://github.com/sponsors/ChrisTitusTech`">$sponsor</a>`n"
|
||||
}
|
||||
} catch {
|
||||
$authorInfo += "An error occurred while fetching or processing the sponsors: $_`n"
|
||||
}
|
||||
|
||||
Show-CustomDialog -Message $authorInfo -EnableScroll $true
|
||||
Show-CustomDialog -Title "Sponsors" -Message $authorInfo -EnableScroll $true
|
||||
})
|
||||
|
||||
$sync["Form"].ShowDialog() | out-null
|
||||
|
@ -1004,19 +1004,19 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Row="0" Grid.Column="0" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
|
||||
<Button Name="WPFUpdatesdefault" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Default (Out of Box) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<Button Name="WPFUpdatesdefault" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Default (Out of Box) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is the default settings that come with Windows. <LineBreak/><LineBreak/> No modifications are made and will remove any custom windows update settings.<LineBreak/><LineBreak/>Note: If you still encounter update errors, reset all updates in the config tab. That will restore ALL Microsoft Update Services from their servers and reinstall them to default settings.</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="1" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
|
||||
<Button Name="WPFUpdatessecurity" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Security (Recommended) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<Button Name="WPFUpdatessecurity" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Security (Recommended) Settings" Margin="20,4,20,10" Padding="10"/>
|
||||
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This is my recommended setting I use on all computers.<LineBreak/><LineBreak/> It will delay feature updates by 2 years and will install security updates 4 days after release.<LineBreak/><LineBreak/>Feature Updates: Adds features and often bugs to systems when they are released. You want to delay these as long as possible.<LineBreak/><LineBreak/>Security Updates: Typically these are pressing security flaws that need to be patched quickly. You only want to delay these a couple of days just to see if they are safe and don't break other systems. You don't want to go without these for ANY extended periods of time.</TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="2" Style="{StaticResource BorderStyle}">
|
||||
<StackPanel Background="{DynamicResource MainBackgroundColor}" SnapsToDevicePixels="True">
|
||||
<Button Name="WPFUpdatesdisable" FontSize="{DynamicResource ConfigTabButtonFontSize}" Height="Auto" Width="Auto" Content="Disable ALL Updates (NOT RECOMMENDED!)" Margin="20,4,20,10" Padding="10,10,10,10"/>
|
||||
<Button Name="WPFUpdatesdisable" FontSize="{DynamicResource ConfigUpdateButtonFontSize}" Height="Auto" Width="Auto" Content="Disable ALL Updates (NOT RECOMMENDED!)" Margin="20,4,20,10" Padding="10,10,10,10"/>
|
||||
<TextBlock Foreground="{DynamicResource ComboBoxForegroundColor}" Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300">This completely disables ALL Windows Updates and is NOT RECOMMENDED.<LineBreak/><LineBreak/> However, it can be suitable if you use your system for a select purpose and do not actively browse the internet. <LineBreak/><LineBreak/>Note: Your system will be easier to hack and infect without security updates.</TextBlock>
|
||||
<TextBlock Text=" " Margin="20,0,20,0" Padding="10" TextWrapping="WrapWithOverflow" MaxWidth="300"/>
|
||||
</StackPanel>
|
||||
|
Loading…
Reference in New Issue
Block a user