DougFinke

Clock

Jul 31st, 2011
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function HippyDippy-Clock {
  2.     param (
  3.         [string]$Name,
  4.         [Int]$Row,
  5.         [Int]$Column,
  6.         [Int]$RowSpan,
  7.         [Int]$ColumnSpan,
  8.         [Int]$Width,
  9.         [Int]$Height,
  10.         [Double]$Top,
  11.         [Double]$Left,
  12.         [Windows.Controls.Dock]$Dock,
  13.         [Switch]$Show,
  14.         [Switch]$AsJob
  15.     )            
  16.  
  17.     begin {ipmo showui}
  18.     process {
  19.         if (-not $psBoundParameters.Background) {
  20.             $psBoundParameters.Background = 'Transparent'
  21.         }                        
  22.  
  23.         $uiParameters = @{} + $psBoundParameters            
  24.  
  25.         Border @uiParameters -On_Loaded {
  26.             $this.Child = Grid -Columns 150, 300* {
  27.                 Image -Source "http://weaselzippers.us/wp-content/uploads/2011/05/hippie.jpg" -Column 0
  28.                 Label -Name Target -FontSize 90 -Column 1 `
  29.                     -FontFamily "Impact, Arial" -FontWeight 800 -Foreground (
  30.                     LinearGradientBrush $(
  31.                         GradientStop -Color Red    -Offset 1
  32.                         GradientStop -Color Orange -Offset 0.85
  33.                         GradientStop -Color Yellow -Offset 0.7
  34.                         GradientStop -Color Green  -Offset 0.55
  35.                         GradientStop -Color Blue   -Offset 0.4
  36.                         GradientStop -Color Indigo -Offset 0.2
  37.                         GradientStop -Color Violet -Offset 0
  38.                     )
  39.                 )
  40.             }            
  41.  
  42.             $this.DataContext = Get-PowerShellDataSource -On_OutputChanged {
  43.                 $output = Get-PowerShellOutput -Last -OutputOnly
  44.                 $Target.Content = $output
  45.             } -Script {
  46.                 while ($true) {
  47.                     (Get-Date).ToString('T'); Start-Sleep -Seconds 1
  48.     }
  49.             }                
  50.  
  51.         } -On_Initialized {
  52.             $window.SizeToContent         = 'WidthAndHeight'
  53.             $window.WindowStyle           = 'None'
  54.             $window.Background            = 'Transparent'
  55.             $window.AllowsTransparency    = $true
  56.             $window.WindowStartupLocation = 'CenterScreen'            
  57.  
  58.             Add-EventHandler -EventName "On_Closing" -Handler {
  59.                 if ($this.Content.DataContext.Command.Stop) {
  60.                         $this.Content.DataContext.Command.Stop()
  61.                     }
  62.                 } -Object $window                                    
  63.  
  64.                 # When the right mouse button is down, close the control            
  65.                 Add-EventHandler -EventName "On_PreviewMouseRightButtonDown" -Handler {
  66.                     $_.Handled = $true
  67.                     Close-Control
  68.                 } -Object $window            
  69.  
  70.                 Add-EventHandler -EventName "On_PreviewMouseLeftButtonDown" -Handler {
  71.                     $_.Handled = $true
  72.                     $this.DragMove()
  73.                 } -Object $window
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment