Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Feb 23, 2022
1 parent 9a76dd0 commit 09b4a49
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 11 deletions.
10 changes: 10 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog for PSClock

## v1.1.0

+ Changed form title to "PSClock".
+ Updated `Start-PSClock` to allow user to delete the flag file if detected.
+ Updated module manifest.
+ Updated `Color` parameter auto completer for `Set-PSClock` to display values using the named color. Use `Ctrl+Space` to display the formatted list.
+ Updated `README.md`.
+ Added private functions `Convert-RGBtoAnsi` and `Get-RGB`.
+ Updated help documentation.

## v1.0.0

+ Fixed bad formatting in markdown help files.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 JDH Information Technology Solutions, Inc.
Copyright (c) 2021-2022 JDH Information Technology Solutions, Inc.


Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
4 changes: 2 additions & 2 deletions PSClock.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
@{

RootModule = 'PSClock.psm1'
ModuleVersion = '1.0.0'
ModuleVersion = '1.1.0'
CompatiblePSEditions = @('Desktop', 'Core')
GUID = '668afa48-5176-4fd0-bd0f-e414155c6da3'
Author = 'Jeff Hicks'
CompanyName = 'JDH Information Technology Solutions, Inc.'
Copyright = '2021 JDH Information Technology Solutions, Inc.'
Copyright = '2021-2022 JDH Information Technology Solutions, Inc.'
Description = 'A set of PowerShell commands for creating and managing a WPF-based clock that runs on your Windows desktop.'
PowerShellVersion = '5.1'
RequiredModules = @('ThreadJob')
Expand Down
6 changes: 5 additions & 1 deletion PSClock.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ForEach-Object {

#the path for Save-PSClock
$SavePath = Join-Path -Path $home -ChildPath PSClockSettings.xml

Write-Verbose "Using save path $SavePath"

#this module should never even run on a non-Windows platform.
Expand All @@ -40,8 +41,11 @@ if ($IsWindows -OR ($PSEdition -eq 'desktop')) {
[System.Drawing.Brushes].GetProperties().name | Select-Object -Skip 1 |
Where-Object { $_ -match "^$($WordToComplete)" } |
ForEach-Object {
#show the color name using the color
$ansi = Get-RGB $_ | Convert-RGBtoAnsi
[string]$show = "$ansi$($_)$([char]27)[0m"
# completion text,listitem text,result type,Tooltip
[System.Management.Automation.CompletionResult]::new("'$($_)'", $_, 'ParameterValue', $_)
[System.Management.Automation.CompletionResult]::new("'$($_)'", $show, 'ParameterValue', $_)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ Set-PS Clock -size 30 -color white -FontFamily 'Baskerville Old Face'

You can also increase the size by selecting the clock and use the <kbd>+</kbd> key. Decrease using the <kbd>-</kbd> key. Each change takes a second to be applied. You might need to "grab" the clock and move it slightly to ensure you have it selected.

If you only want to change the color, you can use PSReadline to display a formatted list of color options. After the `-Color` parameter, press <kbd>Ctrl+Space</kbd> and anser `Y`.

![psreadline completion](images/set-psclock-color.png)

Move the cursor to your selected choice and press <kbd>Enter</kbd>.

## [Stop-PSClock](docs/Stop-PSClock.md)

Use this command to stop a running PSClock from the PowerShell prompt.
Expand Down
2 changes: 1 addition & 1 deletion docs/Set-PSClock.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PS C:\> Set-PSClock -size 28 -FontStyle Oblique -FontFamily 'Tahoma'

### -Color

Specify a font color like Green or an HTML code like '#FF1257EA'. You can also use any [System.Drawing.Brushes] color like Coral or SkyBlue.
Specify a font color like Green or an HTML code like '#FF1257EA'. You can also use any [System.Drawing.Brushes] color like Coral or SkyBlue. If you press Ctrl+Space after the paramter, you can use PSReadline to display options formatted in color.

```yaml
Type: String
Expand Down
8 changes: 6 additions & 2 deletions en-US/PSClock-help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ RunspaceID : 62</dev:code>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none">
<maml:name>Color</maml:name>
<maml:description>
<maml:para>Specify a font color like Green or an HTML code like '#FF1257EA'. You can also use any [System.Drawing.Brushes] color like Coral or SkyBlue.</maml:para>
<maml:para>Specify a font color like Green or an HTML code like '#FF1257EA'. You can also use any [System.Drawing.Brushes] color like Coral or SkyBlue. If you press Ctrl+Space after the paramter, you can use PSReadline to display options formatted in color.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -362,7 +362,7 @@ RunspaceID : 62</dev:code>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="True (ByPropertyName)" position="named" aliases="none">
<maml:name>Color</maml:name>
<maml:description>
<maml:para>Specify a font color like Green or an HTML code like '#FF1257EA'. You can also use any [System.Drawing.Brushes] color like Coral or SkyBlue.</maml:para>
<maml:para>Specify a font color like Green or an HTML code like '#FF1257EA'. You can also use any [System.Drawing.Brushes] color like Coral or SkyBlue. If you press Ctrl+Space after the paramter, you can use PSReadline to display options formatted in color.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
Expand Down Expand Up @@ -878,6 +878,10 @@ RunspaceID : 62</dev:code>
<maml:linkText>Save-PSClock</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Date</maml:linkText>
<maml:uri></maml:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
Expand Down
16 changes: 12 additions & 4 deletions functions/Start-PSClock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Function Start-PSClock {

Begin {
Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)"

} #begin
Process {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Validating"
Expand All @@ -72,7 +71,14 @@ If this is incorrect, delete $env:temp\psclock-flag.txt and try again.
"@
Write-Warning $msg
Return
$r = Read-Host "Do you want to remove the flag file? Y/N"
if ($r -eq 'Y') {
Remove-Item $env:temp\psclock-flag.txt
}
else {
#bail out
Return
}
}

#verify the datetime format
Expand All @@ -85,6 +91,8 @@ If this is incorrect, delete $env:temp\psclock-flag.txt and try again.
}

#Test if there is a saved settings file and no other parameters have been called
# $SavePath is a module-scoped variable set in the psm1 file
# $SavePath = Join-Path -Path $home -ChildPath PSClockSettings.xml
if ((Test-Path $SavePath)-AND (-not $Force)) {
Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Using saved settings"
$import = Import-Clixml -Path $SavePath
Expand Down Expand Up @@ -154,7 +162,7 @@ If this is incorrect, delete $env:temp\psclock-flag.txt and try again.
to debug or troubleshoot
#>

$form.Title = "PSTimer"
$form.Title = "PSClock"
$form.Height = 200
$form.Width = 400
$form.SizeToContent = "WidthAndHeight"
Expand Down Expand Up @@ -260,7 +268,7 @@ If this is incorrect, delete $env:temp\psclock-flag.txt and try again.

Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Creating the flag file $env:temp\psclock-flag.txt"
"[{0}] PSClock started by {1} under PowerShell process id $pid" -f (Get-Date), $env:USERNAME |
Out-File $env:temp\psclock-flag.txt
Out-File -filepath $env:temp\psclock-flag.txt

if ($Passthru) {
Start-Sleep -Seconds 1
Expand Down
40 changes: 40 additions & 0 deletions functions/private.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#these are private functions

function Get-RGB {
[cmdletbinding()]
[OutputType("RGB")]
Param(
[Parameter(Mandatory, HelpMessage = "Enter the name of a system color like Tomato")]
[ValidateNotNullOrEmpty()]
[string]$Name
)
Try {
$Color = [System.Drawing.Color]::FromName($Name)
[PSCustomObject]@{
PSTypeName = "RGB"
Name = $Name
Red = $color.R
Green = $color.G
Blue = $color.B
}
}
Catch {
Throw $_
}
}
function Convert-RGBtoAnsi {
#This will write an opening ANSI escape sequence to the pipeline
[cmdletbinding()]
[OutputType("String")]
Param(
[parameter(Position = 0, ValueFromPipelineByPropertyName)]
[int]$Red,
[parameter(Position = 1, ValueFromPipelineByPropertyName)]
[int]$Green,
[parameter(Position = 2, ValueFromPipelineByPropertyName)]
[int]$Blue
)
Process {
"$([char]27)[38;2;{0};{1};{2}m" -f $red,$green,$blue
}
}
Binary file added images/set-psclock-color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 09b4a49

Please sign in to comment.