Bootstrapper Manifest Generator per Visual Studio 2008


Segnalo il rilascio dell'aggiornamento di questo tool al seguente link:

http://code.msdn.microsoft.com/bmg

author: Paolo Ongari | posted @ martedì 18 novembre 2008 10.27 | Feedback (0)

Notepad++: una sua chicca


Ogni giorno che si usa Notepad++ si scoprono sempre belle cose, piccole cose che sono sempre utili nei lavori di tutti i giorni.
Per quei pochi che non conoscessero questo programmino, trattasi di un editor leggero che può sostituire il blocco note dandoci un po di strumenti come la colorazione della sintassi, macro per aggiustare il testo, split delle finestre, tabs ecc.... da quando l'ho provato non vivo più senza tanto che lo installo fisso anche nelle virtual machines che mi faccio da tanto che mi torna utile.....

Oggi un mio amico ha scoperto come poter utilizzarlo per fare in modo che una finestra si auto-aggiorni: in pratica capita spesso di dover leggere dei file di testo o dei log che vengono scritti periodicamente; che fare per leggerlo? Chiudere e riaprire il file tutte le volte? Bene con Notepad++ se tenete aperto un file di log in un tab, tutte le volte che ritornate a consultarlo questo si autoaggiorna e si posiziona in fondo al file senza dover schiacciare nulla.

Per attivarla andate in "Configurazione/MISC/Autorilevamento dello stato del file" e giocate con le opzioni come ho illustrato nell'immagine sotto.

Non so a voi, ma a me questa "cazzatina" è mooooolto comoda!


15-11-2008 0.19

 

asd

author: Paolo Ongari | posted @ sabato 15 novembre 2008 0.36 | Feedback (1)

Sabato si parte per Los Angeles... ci si vede al PDC!!


Con mia grande soddisfazione e felicità, questo sabato parto con il mio capo per partecipare al PDC2008.

E' la prima volta che ho l'opportunità di partecipare a un grande appuntamento come questo... non vedo l'ora.

Quando torno posterò un po di foto e commenti.

author: Paolo Ongari | posted @ lunedì 20 ottobre 2008 22.50 | Feedback (0)

Utilizzare i WebServices di Virtual Earth


Dopo un po di vicissitudini sono riuscito finalmente a provare un po i webservices di Virtual Earth all'interno di una mia windows form.

04-10-2008 22.56

La documentazione è abbastanza esauriente, ma io un po di casino sono riuscito a farlo ugualmente :).... il problema è attivare un account di test e configurare l'ambiente.

Ecco i passi che ho seguito:

  1. con il mio account live mi sono attivato un "Developer account" a questo indirizzo.
  2. dopo aver attivato l'account (vi verrà inviata una mail di attivazione) bisogna testare se è tutto a posto sulla vs pagina di virtual earth (cliccate su "Verify credentials" e controllate che veniate autorizzati correttamente).
  3. a questo punto aggiungete i references ai web services... ce ne sono 4 (Geocode, Imagery, Route e Search) e 1 Common che convalida le vostre credenziali.

 

A questo punto siamo pronti per scrivere un po di codice... ad esempio io ho creato una form che fa vedere una immagine in una picturebox prendendola dalle coordinate che passo.

Ecco le references che ho fatto (in produzione i link sono diversi, in fase di test si usano i 'staging') :
VETest.TokenStage = https://staging.common.virtualearth.net/find-30/common.asmx
VETest.Imagery = http://staging.dev.virtualearth.net/webservices/v1/imageryservice/imageryservice.svc

 04-10-2008 23.23

 

Per prima cosa è importante prendersi e memorizzasi da parte il proprio token da utilizzare per le richieste che passeremo ai WebServices).

   1:  private string GetToken()
   2:  {
   3:      VETest.Imagery.Credentials c = new Babba.VirtualEarthWStest.VETest.Imagery.Credentials();
   4:   
   5:      // Set Virtual Earth Platform Developer Account credentials to access the Token Service
   6:      VETest.TokenStage.CommonService commonService = new VETest.TokenStage.CommonService();
   7:      commonService.Credentials = new System.Net.NetworkCredential("123456", "miapassword");
   8:   
   9:      // Set the token specification properties
  10:      VETest.TokenStage.TokenSpecification tokenSpec = new VETest.TokenStage.TokenSpecification();
  11:      tokenSpec.ClientIPAddress = "mioip";
  12:      tokenSpec.TokenValidityDurationMinutes = 60;
  13:   
  14:      string token = "";
  15:   
  16:      // Get a token
  17:      try
  18:      {
  19:          token = commonService.GetClientToken(tokenSpec);
  20:      }
  21:      catch (Exception ex)
  22:      {
  23:          throw ex;
  24:      }
  25:   
  26:      return token;
  27:  }

 

Adesso possiamo richiamare il webservices Imagery per farci dare una immagine della mappa da visualizzare in base alle coordinate passate:

   1:  private void RequestImage(double latitude, double longitude)
   2:  {
   3:      try
   4:      {
   5:          // Get a Virtual Earth token before making a request
   6:          string token = GetToken();
   7:   
   8:          VETest.Imagery.MapUriRequest mapUriRequest = new VETest.Imagery.MapUriRequest();
   9:   
  10:          // Set credentials using a valid Virtual Earth Token
  11:          mapUriRequest.Credentials = new VETest.Imagery.Credentials();
  12:          mapUriRequest.Credentials.Token = token;
  13:   
  14:          // Set the location of the requested image
  15:          mapUriRequest.Center = new VETest.Imagery.Location();
  16:          mapUriRequest.Center.Latitude = latitude;
  17:          mapUriRequest.Center.Longitude = longitude;
  18:   
  19:          // Set the map style and zoom level
  20:          VETest.Imagery.MapUriOptions mapUriOptions = new VETest.Imagery.MapUriOptions();
  21:          mapUriOptions.Style = VETest.Imagery.MapStyle.AerialWithLabels;
  22:          mapUriOptions.ZoomLevel = 10;
  23:   
  24:          // Set the size of the requested image to match the size of the image control
  25:          mapUriOptions.ImageSize = new VETest.Imagery.SizeOfint();
  26:          mapUriOptions.ImageSize.Height = picMap.Height;
  27:          mapUriOptions.ImageSize.Width = picMap.Width;
  28:          mapUriRequest.Options = mapUriOptions;
  29:          VETest.Imagery.ImageryServiceClient imageryService = new VETest.Imagery.ImageryServiceClient();
  30:          
  31:          // Make the image request 
  32:          VETest.Imagery.MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest);
  33:   
  34:          // Set the picturebox image property
  35:          picMap.Image = GetImageFromWeb(mapUriResponse.Uri);
  36:      }
  37:      catch (Exception ex)
  38:      {
  39:          lblMessage.Text = "An exception occurred: " + ex.Message;
  40:      }
  41:  }

 

La funzioncina che ritorna una immagine a partire da un url:

   1:  private Image GetImageFromWeb(string imageUrl)
   2:  { 
   3:      Image retVal = null;
   4:      HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(imageUrl);
   5:      WebResponse myResp = myReq.GetResponse();
   6:      Stream stream = myResp.GetResponseStream();
   7:      retVal = Image.FromStream(stream);
   8:      myResp.Close();
   9:      return retVal;
  10:  }

 

Un po di link utili:

 

Spero torni utile a qualcuno per iniziare.... buon lavoro!

author: Paolo Ongari | posted @ sabato 4 ottobre 2008 23.53 | Feedback (0)

Errore nel creare il Bootstrapper con 3.5 sp1


Oggi mi sono imbattuto in un problema "grave" del nuovo sp1 del framework.

L'errore si verifica quando si pubblica una applicazione ClickOnce che ha come prerequisito il framework 3.5 sp1 e come opzione di download dei prerequisti "Download prerequisites from the same location as my application".

Questo l'errore:

The install location for prerequisites has not been set to 'component vendor's web site' and the file 'DotNetFX35SP1\dotNetFX20 aspnet.msp ' in item '.NET Framework 3.5 SP1' can not be located on disk. See Help for more information.

Inutile dire il mio sconcerto... Tutti sti frameworks iniziano un po troppo ad incasinarsi...

Il problema sta nel package che si trova in "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFX35SP1" che non è corretto. Seguendo le istruzioni riportate qui e che riporto anche sotto sarete in grado di fare il deploy correttamente:

 

Update the Package Data

  1. Open the [Program Files]\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder or %ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems
  2. Edit the Product.xml file in Notepad.
  3. Paste the following into the < PackageFiles > element:
    < PackageFile Name="TOOLS\clwireg.exe" />
    < PackageFile Name="TOOLS\clwireg_x64.exe" />
    < PackageFile Name="TOOLS\clwireg_ia64.exe" />
  4. Find the element for < PackageFile Name="dotNetFX30\XPSEPSC-x86-en-US.exe" and change the PublicKey value to: 3082010A0282010100A2DB0A8DCFC2C1499BCDAA3A34AD23596BDB6CBE2122B794C8EAAEBFC6D526C232118BBCDA5D2CFB36561E152BAE8F0DDD14A36E284C7F163F41AC8D40B146880DD98194AD9706D05744765CEAF1FC0EE27F74A333CB74E5EFE361A17E03B745FFD53E12D5B0CA5E0DD07BF2B7130DFC606A2885758CB7ADBC85E817B490BEF516B6625DED11DF3AEE215B8BAF8073C345E3958977609BE7AD77C1378D33142F13DB62C9AE1AA94F9867ADD420393071E08D6746E2C61CF40D5074412FE805246A216B49B092C4B239C742A56D5C184AAB8FD78E833E780A47D8A4B28423C3E2F27B66B14A74BD26414B9C6114604E30C882F3D00B707CEE554D77D2085576810203010001
  5. Find the element for < PackageFile Name="dotNetFX30\XPSEPSC-amd64-en-US.exe" and change the PublicKey value to the same as in step 4 above
  6. Save the product.xml file 

Download and Extract the Core Installation Files

  1. Navigate to the following URL: http://go.microsoft.com/fwlink?LinkID=118080
  2. Download the dotNetFx35.exe file to your local disk.
  3. Open a Command Prompt window and change to the directory to which you downloaded dotNetFx35.exe.
  4. At the command prompt, type:
    dotNetFx35.exe /x:.
    This will extract the Framework files to a folder named “WCU” in the current directory.
  5. Copy the contents of the WCU\dotNetFramework folder and paste them in the %Program Files%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 folder (%ProgramFiles(x86)%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFx35SP1 on x64 operating systems). Note: Do not copy the WCU\dotNetFramework folder itself. There should be 5 folders under the WCU folder, and each of these should now appear in the DotNetFx35SP1 folder. The folder structure should resemble the following:
    o DotNetFx35SP1 (folder)
    • dotNetFX20 (folder
    • dotNetFX30 (folder)
    • dotNetFX35 (folder)
    • dotNetMSP (folder)
    • TOOLS folder)
    • en (or some other localized folder)
    • dotNetFx35setup.exe (file)
      You may now delete the files and folders you downloaded and extracted in steps 2 and 4.  
      Package35sp1

 

 

Download the Language Pack Support Files

  1. Refer to the Table below for the download locations.
  2. Navigate to the URL provided, and when prompted, download to the subdirectory of the dotNetFx35SP1 folder that is indicated in the table. Note: You must do this once for the x86, and also the x64 files, even if you do not have to support x64 with your package.

Italian x86 http://go.microsoft.com/fwlink?LinkID=118097

da mettere nella sottodirectory it\DotNetFX35\x86

Italian x64 http://go.microsoft.com/fwlink?LinkID=118115

da mettere nella sottodirectory it\DotNetFX35\x64

 

(le altre lingue le potete prendere dalla tabella allegata a questo link)

author: Paolo Ongari | posted @ mercoledì 17 settembre 2008 16.56 | Feedback (1)

"Physics Helper" per Silverlight


Avevo visto tempo fa su Codeplex questa spettacolare libreria per la gestione della fisica.

Oggi leggo di  un UserControl (per adesso in alpha) che consente di gestire mooolto più semplicemente la fisica all'interno dei propri progetti silverlight, direttamente all'interno di Blend.

Vi consiglio vivamente di dare un occhio ai due filmati di esempio Video1, Video2.. o leggervi il post.

author: Paolo Ongari | posted @ martedì 16 settembre 2008 20.54 | Feedback (0)

Da Flash a Silverlight


Bellissimo articolo dove viene illustrato in nove lezioni come affrontare lo stesso argomento in flash e come in silverlight.

author: Paolo Ongari | posted @ domenica 7 settembre 2008 9.48 | Feedback (2)

.NET Client Profile


Segnalo questo ottimo post su una delle novità dell'SP1 del 3.5

author: Paolo Ongari | posted @ mercoledì 27 agosto 2008 10.25 | Feedback (0)

.NET Reflector sempre a portata di mano


Ho appena scaricato l'ultima versione di .NET Reflector che come già saprete è stato acquistato da Redgate (tranquilli è sempre free cmq).

Una cosa che non sapevo è che ha dei parametri di avvio che consentono anche di integrarlo nel menu contestuale di windows.
Basta lanciare un cmd e poi scrivendo "C:\....\Reflector.exe /register":

ReflectorContext

 

Ecco i parametri:

Usage:
Reflector.exe [options] [assemblies]

Options:
/register - Register file extensions
/unregister - Unregister file extensions
/select:<identifier> - Select item in browser
/fontname:<name> - Use specified font name
/fontsize:<size> - Use specified font size
/configuration:<file> - Use configuration file name
/help - Show this help message

author: Paolo Ongari | posted @ venerdì 22 agosto 2008 18.00 | Feedback (0)

Silverlight tip #4: una classe sprite


Ho appena letto e provato un ottimo esempio e spunto di partenza per creare sprite in silverlight. Ecco il codice che fa uso di caricamento dinamico di codice xaml:

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Markup;
 
namespace SilverlightApplication11
{
    public class Sprite : Control
    {
        private Image _spriteImage;
        private RotateTransform _rotateTransform;
        private int _width;
        private int _height;
        private double _posX = 0;
        private double _posY = 0;
        private double _xInc = 0;
        private double _yInc = 0;
        private int _opacityDir = 1;
 
        private string _spriteTemplate =
          "<ControlTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" +
          "                  xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" +
          "<Image x:Name=\"SpriteImage\">" +
          "   <Image.RenderTransform>" +
          "      <RotateTransform x:Name=\"ImageTransform\">" +
          "      </RotateTransform>" +
          "   </Image.RenderTransform>" +
          "</Image>" +
          "</ControlTemplate>";
 
        public Sprite(int width, int height)
        {
            _width = width;
            _height = height;
 
            Template = (ControlTemplate)XamlReader.Load(_spriteTemplate);
            ApplyTemplate();
        }
 
        public override void OnApplyTemplate()
        {
            _spriteImage = (Image)GetTemplateChild("SpriteImage");
            _rotateTransform = (RotateTransform)GetTemplateChild("ImageTransform");
 
            _rotateTransform.CenterX = _width / 2;
            _rotateTransform.CenterY = _height / 2;
        }
 
        public void SetImage(string resource)
        {
            Uri uri = new Uri(resource, UriKind.Relative);
            ImageSource imgSrc = new System.Windows.Media.Imaging.BitmapImage(uri);
            _spriteImage.Source = imgSrc;
        }
 
 
        public double YInc
        {
            set { _yInc = value; }
        }
        public double XInc
        {
            set { _xInc = value; }
        }
 
        public double PosX
        {
            get { return _posX; }
            set
            {
                _posX = value;
                this.SetValue(Canvas.LeftProperty, _posX);
            }
        }
 
        public double PosY
        {
            get { return _posY; }
            set
            {
                _posY = value;
                this.SetValue(Canvas.TopProperty, _posY);
            }
        }
     
        public bool Step(int speed)
        {
            if (_xInc * speed + _posX > 800 || _xInc * speed + _posX < 0)
                return false;
            if (_yInc * speed + PosY > 600 || _yInc * speed + PosY < 0)
                return false;
 
            PosX += _xInc * speed;
            PosY += _yInc * speed;
 
            if (_opacityDir == 1)
                _spriteImage.Opacity += 0.01;
            else
                _spriteImage.Opacity -= 0.01;
            if (_spriteImage.Opacity >= 1)
                _opacityDir = 0;
            else if (_spriteImage.Opacity <= 0)
                _opacityDir = 1;
 
            return true;
        }
 
        public void Rotate()
        {
            _rotateTransform.Angle += 1;
            _rotateTransform.Transform(new Point(32, 24));
        }
 
    }
}

 

Per animare ad esempio un mio sprite (un pokemon per mio nipotino ad esempio :))

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Markup;
 
namespace SilverlightApplication11
{
    public partial class Page : UserControl
    {
        Sprite _sprite;
 
        public Page()
        {
            InitializeComponent();
 
            this.Loaded += new RoutedEventHandler(Page_Loaded);
            this.KeyDown += new KeyEventHandler(Page_KeyDown);
        }
 
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            _sprite = new Sprite(50, 50);
            _sprite.SetImage("GOKU.png");
            _sprite.PosX = 350;
            _sprite.PosY = 400;
            MyCanvas.Children.Add(_sprite);
        }
 
        void Page_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.Up:
                    _sprite.PosY -= 10;
                    break;
                case Key.Down:
                    _sprite.PosY += 10;
                    break;
                case Key.Left:
                    _sprite.PosX -= 10;
                    break;
                case Key.Right:
                    _sprite.PosX += 10;
                    break;
                default:
                    break;
            }
        }
    }
}

 

 

L' esempio completo a questo indirizzo.

author: Paolo Ongari | posted @ giovedì 21 agosto 2008 14.13 | Feedback (0)

Silverlight tip #3: Password textbox


Per rendere la textbox di tipo "password" (nascondendo i caratteri digitati) un semplice modo è quello indicato su questo post utilizzarando un font particolare.

Ecco come fare:

  • scaricare il font allegato e inserirlo nella ClientBin (al pari dello XAP)
  • dichiarare l'utilizzo del font sul controllo in questo modo:
    <TextBox x:Name="txtPwd" FontFamily="password.ttf#Password" />

 

image

 

Lo Xaml:

<UserControl x:Class="SilverlightApplication8.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Canvas x:Name="LayoutRoot" Background="White">
        <TextBox x:Name="txtPwd" FontFamily="password.ttf#Password" Width="100" Canvas.Top="10" Canvas.Left="10"/>
        <Button x:Name="btnPwd" Width="100" Canvas.Top="40" Canvas.Left="10" Content="Cosa ho scritto?" Click="btnPwd_Click"/>
        <TextBlock x:Name="lblPwd" Width="100" Canvas.Top="70" Canvas.Left="10"/>
    </Canvas>
</UserControl>

 

Il codice c#

using System.Windows.Controls;
using System.Windows;
 
namespace SilverlightApplication8
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }
        private void btnPwd_Click(object sender, RoutedEventArgs e)
        {
            lblPwd.Text = txtPwd.Text;
        }
    }
}

author: Paolo Ongari | posted @ sabato 16 agosto 2008 0.54 | Feedback (0)

Silverlight tip #2: Loading images


Ci sono diversi modi per caricare una immagine.... eccone alcuni:

1) includere l'immagine nel progetto, settare nelle proprietà dell'immagine "Build Action" su "Resource" e "Do not copy":

<Image x:Name="imgPic" Source="images/Babba.jpg" />

In questo caso l'immagine sarà embeddata nel nostro assembly.

 

2) stesso esempio ma fatto da codice:

private void OnLoad(object sender, RoutedEventArgs e)
{
    BitmapImage bitmapImage = new BitmapImage();
    Uri uri = new Uri("images/Babba.jpg", UriKind.Relative);
    bitmapImage.UriSource = uri;
    imgPic.Source = bitmapImage;
}

 

3) settare "Build Action" su "Content" e "Do not copy", in questo modo l'immagine sarà embeddata nello XAP:

private void OnLoad(object sender, RoutedEventArgs e)
{
    BitmapImage bitmapImage = new BitmapImage();
    Uri uri = new Uri("/images/Babba.jpg", UriKind.Relative);
    bitmapImage.UriSource = uri;
    imgPic.Source = bitmapImage;
}

 

4) settare "Build Action" su "None" e "Copy always" (o anche "Copy if newer"); in questo caso l'immagine non sarà embeddata ma sarà esterna. Nell'esempio sotto basta copiare l'immagine allo stesso livello dello XAP (nella ClientBin):

private void OnLoad(object sender, RoutedEventArgs e)
{
    BitmapImage bitmapImage = new BitmapImage();
    Uri uri = new Uri("/Babba.jpg", UriKind.Relative);
    bitmapImage.UriSource = uri;
    imgPic.Source = bitmapImage;
}

 

 

5) caricare una immagine dal web specificando il tipo di Uri Assoluto:

private void OnLoad(object sender, RoutedEventArgs e)
{
    BitmapImage bitmapImage = new BitmapImage();
    Uri uri = new Uri("http://www.ongari.it/Images/BabbaOnLine.jpg", UriKind.Absolute);
    bitmapImage.UriSource = uri;
    imgPic.Source = bitmapImage;
}

 

 

6) caricamento tramite WebClient in modo asincrono per file di grosse dimensioni; nell'esempio sotto riportato, posizionare l'immagine nella ClientBin dove si trova lo XAP:

private void OnLoad(object sender, RoutedEventArgs e)
{
    WebClient wc = new WebClient();
    wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
    wc.OpenReadAsync(new Uri("Babba.jpg", UriKind.Relative));
}
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    if (e.Error == null)
    {
        StreamResourceInfo streamResourceInfo = new StreamResourceInfo(e.Result as Stream, null);
        BitmapImage bitmapImage = new BitmapImage();
        bitmapImage.SetSource(streamResourceInfo.Stream);
        imgPic.Source = bitmapImage;
    }
}

 

7) caricamento da un file ZIP scaricato tramite WebClient; nell'esempio sotto riportato, posizionare lo ZIP nella ClientBin dove si trova lo XAP:

private void OnLoad(object sender, RoutedEventArgs e)
{
    WebClient wc = new WebClient();
    wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
    wc.OpenReadAsync(new Uri("MioZippone.zip", UriKind.Relative), "Babba.jpg");
}
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    if (e.Error == null)
    {
        StreamResourceInfo stream1 = new StreamResourceInfo(e.Result as Stream, null);
        String uri = e.UserState as String;
        StreamResourceInfo stream2 = Application.GetResourceStream(stream1, new Uri(uri, UriKind.Relative));
        BitmapImage bitmapImage = new BitmapImage();
        bitmapImage.SetSource(stream2.Stream);
        imgPic.Source = bitmapImage;
    }
}

 

8) caricamento da percorso locale:

private void OnLoad(object sender, RoutedEventArgs e)
{
    OpenFileDialog d = new OpenFileDialog();
    d.Filter = "Immagini (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|Tutti i files (*.*)|*.*";
    if (d.ShowDialog() == true)
    {
        Stream stream = d.SelectedFile.OpenRead();
        BitmapImage bitmapImage = new BitmapImage();
        bitmapImage.SetSource(stream);
        imgPic.Source = bitmapImage;
        stream.Close();
    }
}

author: Paolo Ongari | posted @ venerdì 15 agosto 2008 14.20 | Feedback (0)