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

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Viewing an image from within Powershell

Closed Thread
 
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?
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?

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

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
Closed Thread

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 5 2 Weeks Ago 05:26 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








Vistax64.com 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 2005-2008

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