Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Windows 7 Forum Vista Tutorials Tags

Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Viewing an image from within Powershell

Reply
 
LinkBack Thread Tools Display Modes
Old 08-09-2007   #1 (permalink)
Luke
Guest


 
 

Viewing an image from within Powershell

I want to create a separate window (with the system.windows.forms class) and
view images from a URL through the new window. As my .NET skills are lacking,
this is what I've managed to whip up so far:

[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = new-object System.Windows.Forms.form
$form.MaximizeBox = $false;
$form.MinimizeBox = $false;
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.ShowDialog()

I'm still uncertain how I would go about pulling images from the web and
viewing it from this window (System.Windows.Media.Imaging maybe?). Also how
do I set the autosize property correctly so that the window resizes itself
according to the image size?

My System SpecsSystem Spec
Old 08-09-2007   #2 (permalink)
Luke
Guest


 
 

RE: Viewing an image from within Powershell

I've found a way to draw the image. Does anyone know how to get the image to
update at an interval?

"Luke" wrote:

> I want to create a separate window (with the system.windows.forms class) and
> view images from a URL through the new window. As my .NET skills are lacking,
> this is what I've managed to whip up so far:
>
> [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
> $form = new-object System.Windows.Forms.form
> $form.MaximizeBox = $false;
> $form.MinimizeBox = $false;
> $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
> $form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
> $form.ShowDialog()
>
> I'm still uncertain how I would go about pulling images from the web and
> viewing it from this window (System.Windows.Media.Imaging maybe?). Also how
> do I set the autosize property correctly so that the window resizes itself
> according to the image size?

My System SpecsSystem Spec
Old 08-09-2007   #3 (permalink)
Jeff
Guest


 
 

Re: Viewing an image from within Powershell

On Aug 10, 10:08 am, Luke <L...@discussions.microsoft.com> wrote:
> I've found a way to draw the image. Does anyone know how to get the image to
> update at an interval?
>
> "Luke" wrote:
> > I want to create a separate window (with the system.windows.forms class) and
> > view images from a URL through the new window. As my .NET skills are lacking,
> > this is what I've managed to whip up so far:

>
> > [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
> > $form = new-object System.Windows.Forms.form
> > $form.MaximizeBox = $false;
> > $form.MinimizeBox = $false;
> > $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen
> > $form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
> > $form.ShowDialog()

>
> > I'm still uncertain how I would go about pulling images from the web and
> > viewing it from this window (System.Windows.Media.Imaging maybe?). Also how
> > do I set the autosize property correctly so that the window resizes itself
> > according to the image size?


[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = new-object System.Windows.Forms.form
$form.MaximizeBox = $false;
$form.MinimizeBox = $false;
$form.StartPosition =
[System.Windows.Forms.FormStartPosition]::CenterScreen
$form.FormBorderStyle =
[System.Windows.Forms.FormBorderStyle]::FixedDialog

$urls = "http://www.google.com/intl/en_ALL/images/logo.gif", `
"http://groups.google.com/groups/img/3nb/groups_medium.gif", `
"http://www.google.com/ig/images/igoogle_logo_sm.gif", `
"http://docs.google.com/images/doclist/logo_docs.gif"
$script:urlIndex = 0

function NextImage
{
if ( $script:urlIndex -gt $urls.Length - 1 )
{
$script:urlIndex = 0
}

$webRequest =
[System.Net.WebRequest]::Create( $urls[ $script:urlIndex ] )
$webResponse = $webRequest.GetResponse()
$image = New-Object System.Drawing.Bitmap
$webResponse.GetResponseStream()
$webResponse.Close()

$imageLabel.Image = $image
$imageLabel.Size = $image.Size
$form.ClientSize = $image.Size

$script:urlIndex++
}

$imageLabel = New-Object System.Windows.Forms.Label
$imageLabel.add_Click( [System.EventHandler] { NextImage } )

$form.Controls.Add( $imageLabel )

NextImage

$imageTimer = New-Object System.Windows.Forms.Timer
$imageTimer.Interval = 2000
$imageTimer.add_Tick( [System.EventHandler] { NextImage } )
$imageTimer.Start()

$form.ShowDialog()

This will move to the next image when you click on the label, or every
two seconds on a timer.

Good luck.

Jeff

My System SpecsSystem Spec
Old 08-10-2007   #4 (permalink)
Marco Shaw
Guest


 
 

Re: Viewing an image from within Powershell


> This will move to the next image when you click on the label, or every
> two seconds on a timer.
>
> Good luck.
>
> Jeff
>


Super cool! Thanks for sharing.

Marco

--
----------------
PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Reply

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
can powershell be included in a Win PE boot image? James PowerShell 7 10-13-2008 04:34 PM
Acronis True Image recovery of Vista Image mrh981 Vista General 1 07-01-2008 09:57 PM
"Copy/paste functionality has been disabled while viewing the3 image." Paul J. Perillo Vista General 0 02-18-2008 09:44 PM
Windows programming and image manipulation in Powershell question hasten PowerShell 0 02-16-2008 03:22 PM
Reduce Image viewing size in Windows Mail Program Josh Vista mail 2 09-04-2007 07:10 AM


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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