Around and About .NET World

Il blog di Marco Minerva
posts - 1671, comments - 2232, trackbacks - 2135

My Links

News

Contattami su Live Messenger:


MCTS: Windows, Web, Distributed Applications & SQL Server

MCPD: Enterprise Applications

Tag Cloud

Archives

Post Categories

Links

sabato 20 gennaio 2007

Windows SideShow .NET Framework Components 1.0 (Beta)

Windows SideShow is a new technology that lets Windows Vista drive auxiliary, small displays of various form-factors where ready-access to bite-size bits of information could be imagined. These include displays embedded on the outside of a laptop lid or on a detachable device, enabling access to information and media even when the main system is in a standby mode. Data can also be displayed on cell phones and other network-connected devices via Bluetooth and other connectivity options. [da Wikipedia]

Da qualche giorno è stato reso disponibile il Windows SideShow .NET Framework Components 1.0 (Beta), che consente di creare ed eseguire gadget per Windows SideShow utilizzando il .NET Framework 2.0. In questa pagina, inoltre, è possibile trovare un video introduttivo a Windows SideShow, oltre ad una serie di link di approfondimento.

posted @ lunedì 1 gennaio 0001 00:00 | Feedback (1) | Filed Under [ C# VB .NET Windows Related .NET 3.0 Updates & Service Pack ]

Tutorial su SQL Server 2005 Compact Edition

Recentemente su MSDN è stata pubblicata una serie di tutorial sull'utilizzo di SQL Server 2005 Compact Edition:

I primi tre link contengono esempi di codice in C#, per avere accesso alle versioni Visual Basic .NET fare riferimento a questa pagina.

posted @ lunedì 1 gennaio 0001 00:00 | Feedback (15) | Filed Under [ C# VB .NET ADO .NET & SQL ]

Visualizzare l'output di una compilazione con Visual Studio

Ogni volta che reinstallo Visual Studio me ne dimentico... Se si vuole visualizzare automaticamente la finestra Output quando si avvia la compilazione di un progetto, bisogna spuntare l'opzione evidenzata:

Nota: lo screenshot è stato preso utilizzando lo Snipping Tool di Windows Vista smile_wink

posted @ lunedì 1 gennaio 0001 00:00 | Feedback (0) | Filed Under [ C# VB .NET .NET Compact Framework ADO .NET & SQL ASP .NET .NET 3.0 ]

Comprimere e decomprimere un array di byte

Se si devono inviare array di byte da un client ad un server e viceversa, attraverso una connessione TCP, comprimendo i dati prima dell'invio si può ridurre il traffico di rete. A questo scopo, è possibile utilizzare una delle classi che fa parte della libreria SharpZipLib:

public byte[] Compress(byte[] buffer) { using (MemoryStream ms = new MemoryStream()) { int size = buffer.Length; using (BinaryWriter bw = new BinaryWriter(ms)) { //Scrive la lunghezza originale dell'array. bw.Write(size); using (BZip2OutputStream zip = new BZip2OutputStream(ms)) zip.Write(buffer, 0, size); } return ms.ToArray(); } } public byte[] Decompress(byte[] buffer) { using (MemoryStream ms = new MemoryStream(buffer)) { using (BinaryReader br = new BinaryReader(ms)) { //Legge la lunghezza dell'array di byte decompresso. int size = br.ReadInt32(); using (BZip2InputStream unzip = new BZip2InputStream(ms)) { byte[] result = new byte[size]; unzip.Read(result, 0, size); return result; } } } }

Tutto il codice ruota intorno agli oggetti BZip2OutputStream e BZip2InputStream, utilizzati rispettivamente per comprimere e decomprimere gli array. Questo esempio, inoltre, funziona anche se il client oppure il server sono realizzati con il .NET Compact Framework, che è pienamente supportato dalla libreria SharpZipLib.

posted @ lunedì 1 gennaio 0001 00:00 | Feedback (3) | Filed Under [ C# ]

ShieldLink in C#

Dopo aver mostrato come utilizzare le nuove API di Windows Vista per creare ShieldButton e TextBox con Cue Banner, è la volta dello ShieldLink:

Per creare un controllo di questo tipo è sufficiente inviare il messaggio BS_COMMANDLINK ad un oggetto Button:

public class ShieldLink : Button { private const int BS_COMMANDLINK = 0x0000000E; private const uint BCM_SETNOTE = 0x00001609; private const uint BCM_SETSHIELD = 0x0000160C; [DllImport("user32.dll", CharSet = CharSet.Unicode)] private static extern IntPtr SendMessage(HandleRef hWnd, UInt32 Msg, IntPtr wParam, string lParam); [DllImport("user32.dll", CharSet = CharSet.Unicode)] private static extern IntPtr SendMessage(HandleRef hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam); public ShieldLink() { this.FlatStyle = FlatStyle.System; } protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.Style |= BS_COMMANDLINK; return cp; } } private string _textNote; public string TextNote { get { return _textNote; } set { _textNote = value; SendMessage(new HandleRef(this, this.Handle), BCM_SETNOTE, IntPtr.Zero, value); } } private bool _showShield; public bool ShowShield { get { return _showShield; } set { _showShield = value; SendMessage(new HandleRef(this, this.Handle), BCM_SETSHIELD, IntPtr.Zero, new IntPtr(value ? 1 : 0)); } } }
Come nota personale, trovo molto carino l'effetto di fade out quando si sposta il mouse fouri dal controllo smile_tongue.

posted @ lunedì 1 gennaio 0001 00:00 | Feedback (3) | Filed Under [ C# ]

TextBox con Cue Banner

Alcune caselle di testo di Internet Explorer 7 e Windows Vista sono dotate di una caratteristica chiamata Cue Banner: quando non contengono testo e non hanno il focus, esse visualizzano un breve messaggio che funge da suggerimento (un effetto di questo tipo è utilizzato, ad esempio, nella casella di ricerca di IE7 e nella TextBox per la password della schermata di login di Vista).

Su CodeProject è disponibile uno UserControl che consente di aggiungere questo effetto all'interno delle proprie applicazioni:

Il codice sorgente, disponibile qui, è scritto in C#, ma all'interno del file scaricato è possibile trovare anche la DLL compilata del controllo, che quindi può essere direttamente utilizzata pure all'interno di progetti VB .NET.

Il controllo di questione utilizza solo codice managed. L'API di Windows fornisce anche una modo per impostare questo stile utilizzando la funzione SendMessage:

private const uint ECM_FIRST = 0x1500; private const uint EM_SETCUEBANNER = ECM_FIRST + 1; [DllImport("user32", CharSet = CharSet.Unicode)] private static extern bool SendMessage(IntPtr hWnd, UInt32 message, IntPtr wParam, string lParam); //Esempio... SendMessage(textBox1.Handle, EM_SETCUEBANNER, IntPtr.Zero, "Password");

Il messaggio EM_SETCUEBANNER è supportato anche da Windows XP.

posted @ lunedì 1 gennaio 0001 00:00 | Feedback (2) | Filed Under [ C# VB .NET ]

Design guidelines for Windows Vista

A partire da questa pagina è possibile trovare tutte le linee guida ufficiali di Microsoft per la progettazione di interfacce grafiche secondo i nuovi standard introdotti da Windows Vista.

posted @ lunedì 1 gennaio 0001 00:00 | Feedback (1) | Filed Under [ C# VB .NET Windows Related .NET 3.0 ]

Powered by:
Powered By Subtext Powered By ASP.NET