mercoledì 23 settembre 2009

Implementazione Deep Zoom Silverlight




http://77.43.34.207/SILVERLIGHTDEMO/ZoomTestPage.html

In questo esempio abbiamo impostato una mappa con Deep Zoom per testare le potenzialità offerte dallo strumento.
Con immagini a più alta risoluzione il risultato sarebbe ancora più efficace
consentendo di ingrandire qualsiasi parte dell'immagine senza perdita di dettaglio.
Attraverso l'intercettazione delle posizioni del mouse e degli eventi (indicati nel
pannello in alto a destra) possiamo poi gestire a nostro piacimento l'interattività
dell'utente.
Nella nostra implementazione inoltre utilizziamo la libreria nativa DeepZoomTools.dll (grazie a: http://blogs.sqlxml.org/bryantlikes/archive/2008/11/27/deep-zoom-image-generation-with-deepzoomtools-dll.aspx)per la creazione a run-time delle immagini navigabili.
Lo strumento si pone come base ideale per la realizzazione di applicazioni multimediali per la presentazione via web o presso totem informativi in fiere, esposizioni o luoghi pubblici volti all'illustrazione dettagliata di prodotti
e servizi.
In particolare si presta alla presentazione di immobili per agenzie immobiliari, edili o studi di progettazione con una delle tecnologie più avanzate presenti sul mercato.
Per qualsiasi valutazione di personalizzazione o realizzazione specifica potete inviare una mail a: info@progressive.it



http://77.43.34.207/SILVERLIGHTDEMO/ZoomTestPage.html

In this example we set up a map with Deep Zoom to test the potential of the tool.
With images at higher resolution, the result would be even more effective
allows you to magnify any part of the image without loss of detail.
Through the interception of the mouse position and the events (listed in
panel at top right) then we can handle at best the user interaction.
In our implementation also we use the native library DeepZoomTools.dll(thanks to: http://blogs.sqlxml.org/bryantlikes/archive/2008/11/27/deep-zoom-image-generation-with-deepzoomtools-dll.aspx) to create navigable image a run-time.
The instrument itself is the ideal base for the realization of multimedia applications for submission via the web or at notice boards in fairs, exhibitions or public places intended to illustrate detailed product
and services.
In particular, lends itself to presentation of real estate for real estate agencies, construction or design studies with one of the most advanced technologies on the market.
For any evaluation of the specific implementation or customization, please mail to: info@progressive.it

Aggiungere elementi animati di silverlight a run-time


In questo esempio, vediamo come aggiungere semplicemente degli elementi di layout Silverlight di diverso tipo a run-time e gestirne delle semplici animazioni, nell'esempio è presente anche un controllo mediaelement per la riproduzione di un file audio mp3 con la possibilità di mettere in mute la riproduzione.
Il codice e fornito così com'è, senza commenti, indentazioni etc..
Per me è stato molto utile, spero lo sia anche per voi.

In this example, we add layout elements in grid control at run-time.
We add simple animations too and a media element for .mp3 playback with option to mute/unmute audio.

This is tested with Microsoft Silverlight 3.0:

XAML (page.xaml):

(see image)

C# (page.xaml.cs):


using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Resources;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SimpleImageAnimation
{
public partial class Page : UserControl
{

public Page()
{
InitializeComponent();
}

private void img2_MouseLeftButtonDown(Object sender, MouseEventArgs e)
{
//TransTimeline.Begin();
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
MainControl.Width = 690;
MainControl.Height = 100;

LayoutRoot.Width = 690;
LayoutRoot.Height = 100;
Canvas newCanvas = new Canvas();
newCanvas.Name = "TextMessages";

Canvas icoCanvas = new Canvas();
icoCanvas.Name = "Icons";
icoCanvas.VerticalAlignment = VerticalAlignment.Top;
icoCanvas.HorizontalAlignment = HorizontalAlignment.Right;
icoCanvas.Width = 22;
icoCanvas.Height = 22;

LayoutRoot.Children.Add(newCanvas);
Image newimage1 = new Image();
newimage1.Name = "img1";
newimage1.Source = new BitmapImage(new Uri("Images/sound_off.jpg", UriKind.RelativeOrAbsolute));
newimage1.MouseLeftButtonDown += new MouseButtonEventHandler(newimage1_MouseLeftButtonDown);

newimage1.Width = 22;
newimage1.Height = 22;

icoCanvas.Children.Add(newimage1);
LayoutRoot.Children.Add(icoCanvas);

TextBlock newText1 = new TextBlock();
newText1.Name = "Message1";
newText1.Text = "Text1";
newText1.FontSize = 48;
newText1.Foreground = new SolidColorBrush(Colors.LightGray);
Canvas.SetLeft(newText1, 250);

TextBlock newText2 = new TextBlock();
newText2.Name = "Message2";
newText2.Text = "Text2";
newText2.FontSize = 36;
newText2.Foreground = new SolidColorBrush(Colors.Black);
Canvas.SetLeft(newText2, 200);
Canvas.SetTop(newText2, 50);

TextBlock newText3 = new TextBlock();
newText3.Name = "Message3";
newText3.Text = "Text3";
newText3.FontSize = 36;
newText3.Foreground = new SolidColorBrush(Colors.DarkGray);
Canvas.SetTop(newText3, 30);
Canvas.SetLeft(newText3, 10);

TextBlock newText4 = new TextBlock();
newText4.Name = "Message4";
newText4.Text = "Text4";
newText4.FontSize = 36;
newText4.Foreground = new SolidColorBrush(Colors.Gray);
Canvas.SetTop(newText4, 0);

newCanvas.Children.Add(newText1);
newCanvas.Children.Add(newText2);
newCanvas.Children.Add(newText3);
newCanvas.Children.Add(newText4);

Duration duration = new Duration(TimeSpan.FromSeconds(15));
Duration duration1 = new Duration(TimeSpan.FromSeconds(3));
Duration duration2 = new Duration(TimeSpan.FromSeconds(10));

DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();
DoubleAnimation myDoubleAnimation3 = new DoubleAnimation();
DoubleAnimation TextAnimation1 = new DoubleAnimation();
DoubleAnimation TextAnimation2 = new DoubleAnimation();
DoubleAnimation TextAnimation3 = new DoubleAnimation();
DoubleAnimation TextAnimation4 = new DoubleAnimation();

myDoubleAnimation1.Duration = duration1;
myDoubleAnimation2.Duration = duration1;

TextAnimation1.Duration = duration2;
TextAnimation2.Duration = duration2;
TextAnimation3.Duration = duration2;
TextAnimation4.Duration = duration2;

Storyboard sb = new Storyboard();
sb.Duration = duration;
sb.RepeatBehavior = RepeatBehavior.Forever;

sb.Children.Add(TextAnimation1);
sb.Children.Add(TextAnimation2);
sb.Children.Add(TextAnimation3);
sb.Children.Add(TextAnimation4);

//sb.Children.Add(myDoubleAnimation1);
//sb.Children.Add(myDoubleAnimation2);
//Storyboard.SetTarget(myDoubleAnimation1, newimage1);
//Storyboard.SetTarget(myDoubleAnimation2, newimage2);

Storyboard.SetTarget(TextAnimation1, newText1);
Storyboard.SetTarget(TextAnimation2, newText2);
Storyboard.SetTarget(TextAnimation3, newText3);
Storyboard.SetTarget(TextAnimation4, newText4);

//Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Opacity)"));
//Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Opacity)"));

Storyboard.SetTargetProperty(TextAnimation1, new PropertyPath("(Canvas.Left)"));
Storyboard.SetTargetProperty(TextAnimation2, new PropertyPath("(Opacity)"));
Storyboard.SetTargetProperty(TextAnimation3, new PropertyPath("(Canvas.Left)"));
Storyboard.SetTargetProperty(TextAnimation4, new PropertyPath("(Opacity)"));

//myDoubleAnimation1.From = 0.0;
//myDoubleAnimation1.To= 1.0;
//myDoubleAnimation1.BeginTime = TimeSpan.FromSeconds(3);
//myDoubleAnimation2.From = 0.5;
//myDoubleAnimation2.To = 0.0;
//myDoubleAnimation2.BeginTime = TimeSpan.FromSeconds(0);

TextAnimation1.From = 310;
TextAnimation1.To = 210;
TextAnimation1.BeginTime = TimeSpan.FromSeconds(0);
TextAnimation2.From = 0.0;
TextAnimation2.To = 1.0;
TextAnimation2.BeginTime = TimeSpan.FromSeconds(1);
TextAnimation3.From = 10;
TextAnimation3.To = 90;
TextAnimation3.BeginTime = TimeSpan.FromSeconds(2);
TextAnimation4.From = 0.0;
TextAnimation4.To = 1.0;
TextAnimation4.BeginTime = TimeSpan.FromSeconds(3);


LayoutRoot.Resources.Add("unique_id", sb);

sb.Begin();

Uri af = new Uri("http://www.yoururl.eu/audio.mp3", UriKind.Absolute);

me.Source = af;
me.Volume = 0.5;

}

void newimage1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (me.IsMuted)
me.IsMuted = false;
else
me.IsMuted = true;
}
}
}

Code is provided as is! Sorry for not indenting,not comment etc...
We found it very useful, let us know if solved something to you...

progressive.it Blog

Benvenuti,
In questo blog troverete aggiornamenti sui prodotti Progressive, appunti di sviluppo e problemi risolti di varia natura incontranti nelle varie fasi di implementazione.
Contiamo di utilizzare questo spazio per contribuire alla condivisione di informazioni inerenti
un argomento complesso e in continua evoluzione come la programmazione.
E' gradito il contributo di chiunque condivida la passione per questa materia o sia semplicemente spinto dall curiosità.

Roberto Zanardo
http://www.progressive.it