In questo post mostro un semplice snippet per estrarre un archivio Tar in una directory temporanea.
$phar = new PharData('nome-archivio.tar'); //Estraggo tutti i files posizionandoli in /tmp/ $phar->extractTo('/tmp/', null, true);
$phar = new PharData('nome-archivio.tar'); //Estraggo tutti i files posizionandoli in /tmp/ $phar->extractTo('/tmp/', null, true);
$_DIR = '/var/www/html/images/'; $images_array = glob($_DIR . '*.jpg'); foreach ($images_array as $image) { echo $image; }
private Size currSize;2. Aggiungere nel costruttore, dopo InitializeComponent()
this.AutoScaleMode = AutoScaleMode.None; currSize = this.Size;3. Aggiungere la seguente funzione
private void autoscale() { Font tempFont; SizeF ratio = SizeF.Empty; //calculate resizing ratio ratio = new SizeF((float)this.Width / currSize.Width, (float)this.Height / currSize.Height); //loop through all controls and scale them foreach (Control c in this.Controls) {//Get current font size, Scale object and scale font tempFont = new Font(c.Font.Name, c.Font.SizeInPoints * ratio.Width * ratio.Height); c.Scale(ratio); c.Font = tempFont; } //update current size currSize = this.Size; }4. Utilizzare la funzione precedente nell'evento SizeChanged della windows form
private void Form1_SizeChanged(object sender, EventArgs e) { autoscale(); }
In principio fu l'include (o il require) di tanti file php che contenevano funzioni.Ed ora? Adesso il Php è un linguaggio molto più maturo, dotato di namespace, che permettono a classi con lo stesso nome di coesistere (con namespace diversi) all'interno dello stesso progetto. In questo modo, includere una libreria di terze parti progettata a namespace non comporta più problemi di omonimia di classi.
Poi vennero le classi, incluse a mano una per una.
//Autoloading classes spl_autoload_register(function($className) { //Obtain the pure class name $pureClassName = getRealClassName($className); //Build the path $namespace = getNameSpace($className); if(file_exists($namespace.'/'.$pureClassName.'.php')) { include_once($namespace.'/'.$pureClassName.'.php'); } }); function getRealClassName($fullClassName) { //Explode class name $classNameArray = explode('\\',$fullClassName); //Obtain the pure class name return end($classNameArray); } function getNameSpace($fullClassName) { //Explode class name $classNameArray = explode('\\',$fullClassName); //Remove the pure class name array_pop($classNameArray); //Remove the main namespace (first) array_shift($classNameArray); //Build the path $namespace = implode('/', $classNameArray); return $namespace; }Breve spiegazione: nel caso il Php non trovi una classe, tenta una inclusione automatica, cercando il file posizionato nel percorso indicato dal namespace (stessa struttura delle cartelle quindi) e chiamato come il nome della classe, con estensione php. Le due funzioni getRealClassName() e getNameSpace() sono semplici funzioni che interpretano il nome della classe separando namespace dal nome "proprio" della classe stessa. Unica cosa degna di nota, viene eliminato il primo ramo del namespace, che solitamente è il nome del progetto.
new \ProjectName\Core\Othernamespace\Classname()Causerà una include automatica del percorso
Core/Othernamespace/Classname.php
$('body').append($('<div></div>').load('file_esterno.html', function() { //Qui operazioni opzionali sull'html appena caricato });:-)
RawPrinterHelper.SendStringToPrinter("Zebra GX420T", "^XA^FDESEMPIO^FS^XZ");Di seguito posto anche il codice originale della classe, che si può trovare comunque a questo indirizzo: http://support.microsoft.com/kb/322091/it
using System; using System.Drawing; using System.Drawing.Printing; using System.Windows.Forms; using System.Runtime.InteropServices; using System.IO; namespace TintoLavaApp { public class RawPrinterHelper { // Structure and API declarions: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public class DOCINFOA { [MarshalAs(UnmanagedType.LPStr)] public string pDocName; [MarshalAs(UnmanagedType.LPStr)] public string pOutputFile; [MarshalAs(UnmanagedType.LPStr)] public string pDataType; } [DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd); [DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern bool ClosePrinter(IntPtr hPrinter); [DllImport("winspool.Drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern bool StartDocPrinter(IntPtr hPrinter, Int32 level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di); [DllImport("winspool.Drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern bool EndDocPrinter(IntPtr hPrinter); [DllImport("winspool.Drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern bool StartPagePrinter(IntPtr hPrinter); [DllImport("winspool.Drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern bool EndPagePrinter(IntPtr hPrinter); [DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten); // SendBytesToPrinter() // When the function is given a printer name and an unmanaged array // of bytes, the function sends those bytes to the print queue. // Returns true on success, false on failure. public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount) { Int32 dwError = 0, dwWritten = 0; IntPtr hPrinter = new IntPtr(0); DOCINFOA di = new DOCINFOA(); bool bSuccess = false; // Assume failure unless you specifically succeed. di.pDocName = "My C#.NET RAW Document"; di.pDataType = "RAW"; // Open the printer. if (OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero)) { // Start a document. if (StartDocPrinter(hPrinter, 1, di)) { // Start a page. if (StartPagePrinter(hPrinter)) { // Write your bytes. bSuccess = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten); EndPagePrinter(hPrinter); } EndDocPrinter(hPrinter); } ClosePrinter(hPrinter); } // If you did not succeed, GetLastError may give more information // about why not. if (bSuccess == false) { dwError = Marshal.GetLastWin32Error(); } return bSuccess; } public static bool SendFileToPrinter(string szPrinterName, string szFileName) { // Open the file. FileStream fs = new FileStream(szFileName, FileMode.Open); // Create a BinaryReader on the file. BinaryReader br = new BinaryReader(fs); // Dim an array of bytes big enough to hold the file's contents. Byte[] bytes = new Byte[fs.Length]; bool bSuccess = false; // Your unmanaged pointer. IntPtr pUnmanagedBytes = new IntPtr(0); int nLength; nLength = Convert.ToInt32(fs.Length); // Read the contents of the file into the array. bytes = br.ReadBytes(nLength); // Allocate some unmanaged memory for those bytes. pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength); // Copy the managed byte array into the unmanaged array. Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength); // Send the unmanaged bytes to the printer. bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, nLength); // Free the unmanaged memory that you allocated earlier. Marshal.FreeCoTaskMem(pUnmanagedBytes); return bSuccess; } public static bool SendStringToPrinter(string szPrinterName, string szString) { IntPtr pBytes; Int32 dwCount; // How many characters are in the string? dwCount = szString.Length; // Assume that the printer is expecting ANSI text, and then convert // the string to ANSI text. pBytes = Marshal.StringToCoTaskMemAnsi(szString); // Send the converted ANSI string to the printer. SendBytesToPrinter(szPrinterName, pBytes, dwCount); Marshal.FreeCoTaskMem(pBytes); return true; } } }
try { txt_esempio.Invoke((MethodInvoker)delegate() { txt_esempio.Text = "Testo modificato da backgroundWorker"; }); } catch (InvalidOperationException ioe) { }
$config['image_library'] = 'gd2'; $config['source_image'] = '/percorso/mypic.jpg'; $config['maintain_ratio'] = TRUE; $config['width'] = 75; $config['height'] = 50; //Carico la libreria con la configurazione $this->load->library('image_lib', $config); //Ridimensiono l'immagine /percorso/mypic.jpg $this->image_lib->resize();
$config['new_image'] = '/percorso/nuovaimmaginediversa.jpg';
$config['image_library'] = 'gd2'; $config['source_image'] = '/percorso/mypic.jpg'; $config['rotation_angle'] = 'hor'; //Carico la libreria con la configurazione $this->load->library('image_lib', $config); $this->image_lib->rotate();
$config['image_library'] = 'gd2'; $config['source_image'] = '/percorso/mypic.jpg'; $config['x_axis'] = '100'; $config['y_axis'] = '60'; //Carico la libreria con la configurazione $this->load->library('image_lib', $config); //Eseguo il cropping $this->image_lib->crop();
$config['image_library'] = 'gd2'; $config['source_image'] = '/percorso/mypic.jpg'; $config['wm_vrt_alignment'] = 'bottom'; $config['wm_hor_alignment'] = 'right'; $config['wm_padding'] = '5'; $config['wm_overlay_path'] = '/percorso/watermark.png'; //Carico la libreria con la configurazione $this->load->library('image_lib', $config); //Eseguo l'aggiunta del watermark $this->image_lib->watermark();
//Impostazioni cropping $config['image_library'] = 'gd2'; $config['source_image'] = '/percorso/mypic.jpg'; $config['x_axis'] = '100'; $config['y_axis'] = '60'; //Carico la libreria con la configurazione $this->load->library('image_lib', $config); //Eseguo il cropping $this->image_lib->crop(); //Cancello le impostazioni della libreria $this->image_lib->clear(); //Impostazioni per rotazione orizzontale $config['image_library'] = 'gd2'; $config['source_image'] = '/percorso/mypic.jpg'; $config['rotation_angle'] = 'hor'; //Carico la libreria con la configurazione $this->image_lib->initialize($config); //Eseguo la rotazione $this->image_lib->rotate();
application/libraries/Format.php application/libraries/REST_Controller.php application/config/rest.phpnella propria directory application, e ricordarsi di caricare automaticamente la classe REST_Controller come libreria nel fi le di con gurazione
application/config/autoload.phpPer personalizzare le opzioni di restserver, basta modi care l'apposito fi le precedentemente copiato:
application/config/rest.php
class News extends REST_Controller { public function index_get() { // Lettura delle news } public function index_post() { // Crea una news } public function index_put() { // Modifica una news } public function index_delete() { // Elimina una news } }Una richiesta del tipo
GET http://www.example.com/newscomporterà l'esecuzione della funzione index_get, index perché l'url è senza una funzione specificata (news è direttamente il controller) e get perché il metodo HTTP utilizzato è, appunto, GET.
$this->get('id'); //mappatura di $this->input->get() $this->post('id'); //mappatura di $this->input->post() $this->put('id');Per i parametri del metodo DELETE, poiché lo standard non li prevede, è sufficiente gestirli direttamente dalla funzione richiamata dal controllore:
public function index_delete($id) { $this->response(array( 'returned from delete:' => $id, )); }
public function index_post() { // ...crea una news $this->response($news, 201); // Manda la risposta HTTP 201 }Queste sono i tips principali per lo sviluppo di un sistema API con codeigniter-restserver. Non ho parlato per motivi di tempo delle altre caratteristiche della libreria, quali la gestione di API Keys, la gestione dell'autenticazione ecc. per le quali rimando direttamente al sito ufficiale.
application |- controllers |- api |- news.php
http://www.example.com/api/news/getAll http://www.example.com/api/news/getSingle/12richiedendo l'esecuzione del controller news.php che compare nell'albero di esempio, con i metodi getAll senza parametri e getSingle con un parametro GET valorizzato a "12".
class News extends CI_Controller { public function getAll() { $query = $this->db->get('news'); $elenco_news = array(); foreach ($query->result() as $row) { $news = new stdClass(); $news->id = $row->id; $news->titolo = $row->titolo; $news->contenuto = $row->contenuto; array_push($elenco_news, $news); } echo json_encode($elenco_news); } public function getSingle(id) { $this->db->from('news')->where('id',$id); $query = $this->db->get(); $row = $query->row(); $news = new stdClass(); $news->id = $row->id; $news->titolo = $row->titolo; $news->contenuto = $row->contenuto; echo json_encode($news); } }Sarà sufficiente quindi creare un controller per ogni tipo di risorsa (ad esempio news, eventi, banner) ed i relativi metodi, ricordandosi di strutturare le risposte in formato JSON come da esempio.
package net.stefanobianchini.util; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; import net.stefanobianchini.ricette.R; import android.app.Activity; import android.content.res.Resources; import android.os.Environment; import android.util.Log; import android.widget.Toast; public class backupdb { public static void backupDatabase(String dbPath, String nomeFileBackup, Activity act, Resources res) { try { File currentDB = new File(dbPath);// path del db su telefono File backupDB = new File(sd, nomeFileBackup);// file di destinazione @SuppressWarnings("resource") FileChannel src = new FileInputStream(currentDB) .getChannel();// apriamo un filechannel sul db e sul // file di destinazione @SuppressWarnings("resource") FileChannel dst = new FileOutputStream(backupDB) .getChannel(); dst.transferFrom(src, 0, src.size());// trasferiamo il contenuto src.close(); dst.close(); Toast.makeText( act.getBaseContext(), res.getString(R.string.msg_db_location) + "\n " + backupDB.getAbsolutePath(), Toast.LENGTH_LONG).show(); } catch (IOException e) { Toast.makeText(act.getBaseContext(), e.toString(), Toast.LENGTH_LONG).show(); } } @SuppressWarnings("resource") private static void copyFile(File src, File dst) throws IOException { FileChannel inChannel = new FileInputStream(src).getChannel(); FileChannel outChannel = new FileOutputStream(dst).getChannel(); try { inChannel.transferTo(0, inChannel.size(), outChannel); } finally { if (inChannel != null) inChannel.close(); if (outChannel != null) outChannel.close(); } } public static void restoreDatabase(String dbPath, String percorsoFileBackup, Activity act, Resources res) { try { File currentDB = new File(dbPath);// path del db su telefono File backupDB = new File(percorsoFileBackup);// file di backup sorgente copyFile(backupDB, currentDB); Toast.makeText( act.getBaseContext(), String.format(res.getString(R.string.restore_done), backupDB.toString()), Toast.LENGTH_LONG).show(); } catch (IOException e) { Toast.makeText(act.getBaseContext(), e.toString(), Toast.LENGTH_LONG).show(); } } }Ora siamo pronti per eseguire il backup. Da notare che prima di eseguire il backup viene chiuso per sicurezza il db mediante il SQLiteOpenHelper (nel mio caso chiamato db_help);
//Backup del DB sqlite db_help.close(); backupdb.backupDatabase(db_help.getReadableDatabase().getPath(), "backup_mie_ricette.db", HomeActivity.this, res);
using System; using System.Collections.Generic; using System.Text; using System.IO.Ports; using System.Windows.Forms; namespace Sweda { public static class RegistratoreFiscale { public static SerialPort serialPort = null; public static void inizializza(string opzioni_di_inizializzazione) {} public static void aggiungiVoceAcquisto(double prezzo, string reparto, string descrizione, double prezzo_originale) {} public static void scegliOperatore(string operatore) {} public static void chiusuraScontrino(double totale) {} } }A questo punto la libreria Ditron sarà esattamente identica (o altre librerie in futuro che gestiranno altri registratori), quello che cambia è ovviamente l'implementazione dei metodi pubblici sopracitati.
using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace CosmeticSeller.oggetti { class RegistratoreFiscale { private Type oggettoRegistratoreRuntime; public RegistratoreFiscale(string tipo_registratore) { Assembly SampleAssembly; SampleAssembly = Assembly.LoadFrom(tipo_registratore + ".dll"); AppDomain.CurrentDomain.Load(SampleAssembly.GetName()); foreach (Type t in SampleAssembly.GetTypes()) { if (t.Name.Equals("RegistratoreFiscale")) { oggettoRegistratoreRuntime = t; } } } public void aggiungiVoceAcquisto(double prezzo, string reparto, string descrizione, double prezzo_originale) { MethodInfo Method = oggettoRegistratoreRuntime.GetMethod("aggiungiVoceAcquisto"); List>object< listaParametri = new List>object<(); listaParametri.Add(prezzo); listaParametri.Add(reparto); listaParametri.Add(descrizione); listaParametri.Add(prezzo_originale); Method.Invoke(this, listaParametri.ToArray()); } public void inizializza(string opzioni_di_inizializzazione) { MethodInfo Method = oggettoRegistratoreRuntime.GetMethod("inizializza"); List<object> listaParametri = new List<object>(); listaParametri.Add(opzioni_di_inizializzazione); Method.Invoke(this, listaParametri.ToArray()); } public void chiusuraScontrino(double totale) { MethodInfo Method = oggettoRegistratoreRuntime.GetMethod("chiusuraScontrino"); List<object> listaParametri = new List<object>(); listaParametri.Add(totale); Method.Invoke(this, listaParametri.ToArray()); } public void scegliOperatore(string operatore) { MethodInfo Method = oggettoRegistratoreRuntime.GetMethod("scegliOperatore"); List<object> listaParametri = new List<object>(); listaParametri.Add(operatore); Method.Invoke(this, listaParametri.ToArray()); } } }Volendo descrivere questa classe in due parole, il suo compito è essere un wrapper tra il programma di vendita e la libreria da utilizzare. Il cuore del funzionamento è nel costruttore, dove viene caricata dinamicamente la dll a partire dal nome passato come parametro. Nella libreria dll viene quindi cercato l'oggetto RegistratoreFiscale (implementato in tutte le librerie) e caricato in memoria come oggetto Type (oggettoRegistratoreRuntime).
... RegistratoreFiscale reg = new RegistratoreFiscale("Sweda"); reg.inizializza("COM1"); for( ... ) { //Ciclo tutti gli acquisti reg.aggiungiVoceAcquisto(prezzoComplessivo, reparto, descrizione, totaleriga); } reg.chiusuraScontrino(importo_totale); ...
<?php final class MySQL { private $connection; public function __construct($hostname, $username, $password, $database) { if (!$this->connection = mysql_connect($hostname, $username, $password)) { exit('Error: Could not make a database connection using ' . $username . '@' . $hostname); } if (!mysql_select_db($database, $this->connection)) { exit('Error: Could not connect to database ' . $database); } mysql_query("SET NAMES 'utf8'", $this->connection); mysql_query("SET CHARACTER SET utf8", $this->connection); mysql_query("SET CHARACTER_SET_CONNECTION=utf8", $this->connection); mysql_query("SET SQL_MODE = ''", $this->connection); } public function query($sql) { $resource = mysql_query($sql, $this->connection); if ($resource) { if (is_resource($resource)) { $i = 0; $data = array(); while ($result = mysql_fetch_assoc($resource)) { $data[$i] = $result; $i++; } mysql_free_result($resource); $query = new stdClass(); $query->row = isset($data[0]) ? $data[0] : array(); $query->rows = $data; $query->num_rows = $i; unset($data); return $query; } else { return TRUE; } } else { exit('Error: ' . mysql_error($this->connection) . '<br />Error No: ' . mysql_errno($this->connection) . '<br />' . $sql); } } public function escape($value) { return mysql_real_escape_string($value, $this->connection); } public function countAffected() { return mysql_affected_rows($this->connection); } public function getLastId() { return mysql_insert_id($this->connection); } public function __destruct() { mysql_close($this->connection); } } ?>Notate il costruttore (che si occupa di creare la connessione) ma soprattutto il distruttore (__destruct) che avrà il compito di chiudere la connessione (cosa che, diciamolo, viene spesso dimenticata).
//creo l'oggetto con i parametri desiderati $db = new MySql("localhost","user","password","test_db"); //ottengo il risultato della query $result = $db->query("SELECT * FROM users"); //se il numero di righe è maggiore di zero if($result->num_rows) { //Ciclo nelle righe del risultato stampando il campo "name" foreach ($result->rows as $user_row) { echo $user_row['name']; } }
#!/bin/sh while : do clear dialog --backtitle "Gestione Macchine Virtuali" \ --menu "Seleziona dall'elenco l'azione che vuoi eseguire" \ 15 60 5 \ 1 "Visualizzare lista VM accese" \ 2 "Visualizzare lista VM disponibili" \ 3 "Accendere una VM" \ 4 "Spegnere una VM" \ 5 "Esci" \ 2>/tmp/menuitem.$$ OPZIONE=`cat /tmp/menuitem.$$` case $OPZIONE in 1) RESULT=`vmrun -T server -h https://localhost:8333/sdk -u administrator -p password list` dialog --title "Lista Macchine accese" --backtitle "Creato da Stefano Bianchini" --msgbox "$RESULT" 12 50 ;; 2) RESULT=`vmrun -T server -h https://localhost:8333/sdk -u administrator -p password listRegisteredVM` dialog --title "Lista Macchine disponibili" --backtitle "Creato da Stefano Bianchini" --msgbox "$RESULT" 12 50 ;; 3) vmrun -T server -h https://localhost:8333/sdk -u administrator -p password listRegisteredVM | grep ".vmx" > /tmp/regVM.$$ righe=$(wc -l /tmp/regVM.$$ | awk '{print $1}') riga=0 TOTALE="" while [ $riga -lt $righe ]; do #let riga+=1 riga=`expr $riga + 1` #riga=$riga+1 current=$(head -$riga /tmp/regVM.$$ | tail -1) TOTALE="$TOTALE \"$current\" ==" done TOTALE="dialog --backtitle \"Creato da Stefano Bianchini\" --menu \"Seleziona la macchina virtuale\" 0 0 0 $TOTALE 2>/tmp/menuitem.$$" echo $TOTALE > /tmp/menu.$$ chmod +x /tmp/menu.$$ /tmp/menu.$$ CHOICE=`cat /tmp/menuitem.$$` if [ "$CHOICE" != "" ] ; then vmrun -T server -h https://localhost:8333/sdk -u administrator -p password start "$CHOICE" fi ;; 4) vmrun -T server -h https://localhost:8333/sdk -u administrator -p password list | grep ".vmx" > /tmp/regVM.$$ righe=$(wc -l /tmp/regVM.$$ | awk '{print $1}') riga=0 TOTALE="" while [ $riga -lt $righe ]; do riga=`expr $riga + 1` current=$(head -$riga /tmp/regVM.$$ | tail -1) TOTALE="$TOTALE \"$current\" ==" done TOTALE="dialog --backtitle \"Creato da Stefano Bianchini\" --menu \"Seleziona la macchina virtuale\" 0 0 0 $TOTALE 2>/tmp/menuitem.$$" echo $TOTALE > /tmp/menu.$$ chmod +x /tmp/menu.$$ /tmp/menu.$$ CHOICE=`cat /tmp/menuitem.$$` if [ "$CHOICE" != "" ] ; then vmrun -T server -h https://localhost:8333/sdk -u administrator -p password stop "$CHOICE" soft fi ;; 5) exit 0 ;; *) exit 1 ;; esac done
public static string ToByteString(long bytes) { long kilobyte = 1024; long megabyte = 1024 * kilobyte; long gigabyte = 1024 * megabyte; long terabyte = 1024 * gigabyte; if (bytes > terabyte) return (bytes / terabyte).ToString("0.00 TB"); else if (bytes > gigabyte) return (bytes / gigabyte).ToString("0.00 GB"); else if (bytes > megabyte) return (bytes / megabyte).ToString("0.00 MB"); else if (bytes > kilobyte) return (bytes / kilobyte).ToString("0.00 KB"); else return bytes + " Bytes"; }
FileInfo fi = new FileInfo(filename); Console.Write("Dimensione file: " + ToByteString(fi.Length));
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Prova Slideshow</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>Proseguiamo con il cuore del codice:
<script> $(function(){ $('.slideshow img:gt(0)').hide(); setInterval(function(){$('.slideshow :first-child').fadeOut(1500).next('img').fadeIn(1500).end().appendTo('.slideshow');}, 2400); }); </script>Io ho aggiunto la tempistica del fadeOut e del fadeIn (1 secondo e mezzo).
<style type="text/css"> body { margin:0; padding:0; text-align:center; } .slideshow { margin:0 auto; padding:0; width:618px; height:246px; border:1px solid #eeeeee; } .slideshow img { display:block; position:absolute; } </style>E finiamo in bellezza con il codice html dello slideshow (e del resto della pagina)
</head> <body> <div class="slideshow"> <img src="1.jpg"/> <img src="2.jpg"/> <img src="3.jpg"/> </div> </body> </html>
private void FormCassa_KeyDown(object sender, KeyEventArgs e) { //Intercetto il tasto F2 if (e.KeyCode == Keys.F2) MessageBox.Show("F2 Premuto"); }Chiaramente se voglio intercettare F5, basta confrontare il tasto premuto con Keys.F5 . Tutto qua :-)