sábado, 30 de agosto de 2014

El Libro del Día: Pro HTML5 and CSS3 Design Patterns

El Libro del Día: 2014-08-30

Titulo: Pro HTML5 and CSS3 Design Patterns
Autor: Michael Bowers, Dionysios Synodinos, Victor Sumner
Editorial: Apress
Nro Paginas: 514

Capítulos:
Chapter 1: Design Patterns: Making CSS Easy
Chapter 2: HTML Design Patterns
Chapter 3: CSS Selectors and Inheritance
Chapter 4: Box Models
Chapter 5: Box Model Extents
Chapter 6: Box Model Properties
Chapter 7: Positioning Models
Chapter 8: Positioning: Indented, Offset, and Aligned
Chapter 9: Positioning: Advanced
Chapter 10: Styling Text
Chapter 11: Spacing Content
Chapter 12: Aligning Content
Chapter 13: Blocks
Chapter 14: Images
Chapter 15: Tables
Chapter 16: Table Column Layout
Chapter 17: Layouts
Chapter 18: Drop Caps
Chapter 19: Callouts and Quotes
Chapter 20: Alerts

Descarga:
Pro_HTML5_CSS3_DesignPatterns

viernes, 29 de agosto de 2014

El Libro del Día: Pro CSS3 Animation

El Libro del Día: 2014-08-29

Titulo: Pro CSS3 Animation
Autor: Dudley Storey
Editorial: Apress
Nro Paginas: 168

Capítulos:
Chapter 1: CSS3 Fundamentals
Chapter 2: CSS3 Transforms and Transitions
Chapter 3: CSS3 Transitions for Images
Chapter 4: CSS3 Transitions for UI Elements
Chapter 5: CSS3 Keyframe Animations
Chapter 6: CSS3 Keyframe Animations for Web Content
Chapter 7: Integrating CSS3 Animations with SVG and Filters
Chapter 8: Integrating CSS3 Animation with Responsive Web Design and JavaScript
Chapter 9: CSS3 3D Transforms, Transitions, and Animations
Chapter 10: Tools, Technologies, and the Future of CSS Animation

Descarga:
Pro_CSS3_Animation

jueves, 28 de agosto de 2014

El Libro del Día: Beginning CSS3

El Libro del Día: 2014-08-28

Titulo: Beginning CSS3
Autor: David Powers
Editorial: Apress
Nro Paginas: 547

Capítulos:
Part I: CSS Basics
Chapter 1: Introducing CSS The Language of Web Design
Chapter 2: Using Basic Selectors
Chapter 3: Specifying Sizes, Colors, and Files
Part II: Working with Text
Chapter 4: Styling Text
Chapter 5: Embedding Web Fonts
Part III: CSS Page Layout
Chapter 6: Understanding the CSS Box Model
Chapter 7: Floating Elements for Layout
Chapter 8: Adding Backgrounds
Chapter 9: Adding Borders and Drop Shadows
Chapter 10: Styling Lists and Navigation Menus
Chapter 11: Positioning Elements Precisely
Chapter 12: Cross-Browser Layout Techniques
Part IV: Advanced CSS Techniques
Chapter 13: Using Advanced Selectors
Chapter 14: Styling Tables
Chapter 15: Generated Content
Chapter 16: Creating a Print Style Sheet
Chapter 17: Targeting Styles with Media Queries
Chapter 18: Using CSS3 Multi-Column Layout
Chapter 19: Creating Gradients Without Images
Chapter 20: 2D Transforms and Transitions
Chapter 21: Animating with CSS Keyframes
Chapter 22: What Next?

Descarga:
Beginning_CSS3

miércoles, 27 de agosto de 2014

El Demo del Día: Descargar Archivos Asincronamente con WebClient

Descargar Archivos Asincronamente con WebClient

Requerimiento

Muchas veces los Administradores de Red bloquean las descargas de Archivos en los Navegadores y a veces necesitamos con urgencia bajar uno o mas archivos (de cualquier tipo). Si conocemos las direcciones de descarga podemos crear una aplicación que baje dichos archivos.

Características de la Aplicación Windows

1. Debe permitir bajar varios archivos desde URLs conocidas.
2. La descarga debe ser asíncrona sin bloquear el trabajo de la pantalla.
3. Se debe mostrar el progreso de la descarga en % y en forma gráfica con una barra de progreso.

Solución

Crearemos una aplicación Windows Forms en C# que use la clase WebClient del espacio de nombres "System.Net" que tiene un método asíncrono llamado "DownloadFileAsync". Además mostraremos el progreso en el evento: "DownloadProgressChanged" y actualizaremos el estado a Finalizado en el evento "DownloadFileCompleted".

Crear la Aplicación Windows Forms en C#

Crear un proyecto llamado "DescargarArchivos" en C# como una "Aplicación de Windows Forms".
Cambiar de nombre al formulario por: "frmDescarga", configurar su tamaño a 650 de ancho por 400 de alto, centrarlo y arrastrar 3 controles:
- Un TextBox llamado "txtURL"
- Un Button llamado "btnDescargar"
- Un ListView llamado "lvwProgreso"

El diseño del formulario debe quedar como se muestra a continuación:


Nota: El botón debe estar deshabilitado y solo se debe habilitar al ingresar una URL sobre el TextBox.

Escribir el siguiente código en el formulario "frmDescarga":

using System;
using System.Net;
using System.Net.Mime; //ContentDisposition
using System.IO;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;

namespace DescargarArchivos
{
    public partial class frmDescarga : Form
    {
        private string archivoFin="";

        public frmDescarga()
        {
            InitializeComponent();
        }

        private void configurarListView(object sender, EventArgs e)
        {
            lvwProgreso.FullRowSelect = true;
            lvwProgreso.GridLines = true;
            lvwProgreso.HotTracking = true;
            lvwProgreso.Columns.Add("Nombre Archivo", 200);
            lvwProgreso.Columns.Add("MB", 70, HorizontalAlignment.Center);
            lvwProgreso.Columns.Add("%", 40, HorizontalAlignment.Center);
            lvwProgreso.Columns.Add("Progreso", 200);
            lvwProgreso.Columns.Add("Estado", 80, HorizontalAlignment.Center);
            lvwProgreso.View = View.Details;
        }

        private void habilitarBotonDescargar(object sender, EventArgs e)
        {
            btnDescargar.Enabled = (!txtURL.Text.Equals(""));
        }

        private void iniciarDescarga(object sender, EventArgs e)
        {
            WebClient oCliente = new WebClient();
            Uri url = new Uri(txtURL.Text);
            string archivo = Path.GetFileName(url.AbsolutePath);
            ServicePointManager.DefaultConnectionLimit = 10;
            ListViewItem fila = lvwProgreso.Items.Add(archivo);
            fila.Name = archivo;
            fila.SubItems.Add("0");
            fila.SubItems.Add("0");
            fila.SubItems.Add("");
            fila.SubItems.Add("Iniciado");
            Rectangle rec = fila.SubItems[3].Bounds;
            ProgressBar pbr =new ProgressBar();
            pbr.Name = archivo;
            pbr.Parent = lvwProgreso;
            pbr.SetBounds(rec.X, rec.Y, rec.Width, rec.Height);
            pbr.Visible = true;
            txtURL.Clear();
            oCliente.DownloadProgressChanged +=
            new DownloadProgressChangedEventHandler(mostrarProgreso);
            oCliente.DownloadFileCompleted +=
            new AsyncCompletedEventHandler(finalizarDescarga);
            oCliente.DownloadFileAsync(url, archivo, archivo);
        }

        private void mostrarProgreso(object sender, DownloadProgressChangedEventArgs e)
        {
            int bytesRecibidos = (int)(e.BytesReceived / (1024 * 1024));
            int bytesTotales = (int)(e.TotalBytesToReceive / (1024 * 1024));
            string archivo = e.UserState.ToString();
            Control[] rpta = lvwProgreso.Controls.Find(archivo, false);
            if(rpta!=null&&rpta.Length > 0){
                ProgressBar pbr = (ProgressBar)rpta[0];
                lvwProgreso.Items[archivo].SubItems[1].Text = String.Format("{0} - {1}",
                bytesRecibidos, bytesTotales);
                lvwProgreso.Items[archivo].SubItems[2].Text = e.ProgressPercentage.ToString();
                pbr.Value = e.ProgressPercentage;
                lvwProgreso.Items[archivo].SubItems[4].Text = "Descargando";
            }
        }

        private void finalizarDescarga(object sender, AsyncCompletedEventArgs e)
        {
            archivoFin = e.UserState.ToString();
            MethodInvoker mi = new MethodInvoker(mostrarResultado);
            this.Invoke(mi);
        }

        private void mostrarResultado()
        {
            lvwProgreso.Items[archivoFin].SubItems[4].Text = "Finalizado";
        }
    }
}

Nota: Una de las dificultades de la aplicación fue como actualizar la Fila del ListView adecuada, ya que son varios archivos los que se descargan, para eso a cada barra y a cada ListViewItem se le dio como nombre el archivo que se descargaba y se uso como identificador para obtenerlos.

Otra dificultad que encontré fue que la clase WebClient no podía descargar varios a la vez, para lo cual se uso la propiedad "DefaultConnectionLimit" de la clase "ServicePointManager", en este caso configurada para bajar 10 archivos.

Probar la Aplicación de Descarga de Archivos

Grabar la aplicación, compilarla y ejecutarla con F5. Se mostrará una ventana como la siguiente:


Ingresar una dirección URL conteniendo un archivo y clic en el botón "Descargar", copiar varias direcciones e iniciar sus descarga, se irá mostrando el progreso de cada descarga y su estado, tal como se ve en la siguiente figura:


Cuando la descarga finaliza se completa la barra, se cambia el estado a finalizado y el archivo estará disponible para ejecutarse, por defecto en la carpeta donde se encuentra la aplicación (bin\debug).

Comentario Final

En este post vimos como bajar varios archivos simultáneamente usando WebClient sin bloquear la pantalla, es decir en forma asíncrona, mostrando el progreso. Espero les guste y se animen a hacer sus propios utilitarios y no bajarlos de otros.

Descarga:
Demo17_DescargarArchivos_WebClient

El Libro del Día: Expert C# 5.0

El Libro del Día: 2014-08-27

Titulo: Expert C# 5.0
Autor: Mohammad Rahman
Editorial: Apress
Nro Paginas: 609

Capítulos:
Chapter 1: Reintroducing C#:-A Detailed Look at the Language We All Know
Chapter 2: C# Objects in Memory
Chapter 3: Parameters
Chapter 4: Methods
Chapter 5: Automatic Property Declaration
Chapter 6: Enum
Chapter 7: Delegate
Chapter 8: Event
Chapter 9: Foreach and Iterator
Chapter 10: The String Data Type
Chapter 11: Collections Explained
Chapter 12: Linq in C#
Chapter 13: Exception Management
Chapter 14: Asynchrony
Chapter 15: Diagnostic Tools in .NET

Descarga:
Expert_C#_5.0

martes, 26 de agosto de 2014

El Libro del Día: Beginning C# 5.0 Databases

El Libro del Día: 2014-08-26

Titulo: Beginning C# 5.0 Databases (2nd Edition)
Autor: Vidya Vrat Agarwal
Editorial: Apress
Nro Paginas: 427

Capítulos:
Part I: Understanding Tools and Fundamentals Databases
Chapter 1: Getting and Understanding Your Tools
Chapter 2: Understanding Relational Databases
Chapter 3: Creating Database and Tables
Part II: Working with Database and XML
Chapter 4: Manipulating Database Data
Chapter 5: Querying Databases
Chapter 6: Using Stored Procedures
Chapter 7: Using XML
Chapter 8: Understanding Transactions
Part III: Working with Data Using ADO.NET
Chapter 9: Building Windows Forms Applications
Chapter 10: Introduction to ADO.NET
Chapter 11: Handling Exceptions
Chapter 12: Making Connections
Chapter 13: Executing ADO.NET Commands to Retrieve Data
Chapter 14: Using Data Readers
Part IV: Working with Advanced ADO.NET Related Features
Chapter 15: Using Data Sets and Data Adapters
Chapter 16: Using Data Controls with ASP.NET Applications
Chapter 17: Working with Text and Binary Data
Chapter 18: Using LINQ
Chapter 19: Using the ADO.NET Entity Framework
Chapter 20: Using the CLR in SQL Server

Descarga:
Beginning_C#_5.0_Databases

lunes, 25 de agosto de 2014

El Libro del Día: A Programmer's Guide to C# 5.0

El Libro del Día: 2014-08-25

Titulo: A Programmer's Guide to C# 5.0 (4th Edition)
Autor: Eric Gunnerson, Nick Wienholt
Editorial: Apress
Nro Paginas: 443

Capítulos:
Chapter 1: C# and the .NET Runtime and Libraries
Chapter 2: C# QuickStart and Developing in C#
Chapter 3: Classes 101
Chapter 4: Base Classes and Inheritance
Chapter 5: Exception Handling
Chapter 6: Member Accessibility and Overloading
Chapter 7: Other Class Details
Chapter 8: Structs (Value Types)
Chapter 9: Interfaces
Chapter 10: Versioning and Aliases
Chapter 11: Statements and Flow of Execution
Chapter 12: Variable Scoping and Definite Assignment
Chapter 13: Operators and Expressions
Chapter 14: Conversions
Chapter 15: Arrays
Chapter 16: Properties
Chapter 17: Generic Types
Chapter 18: Indexers, Enumerators, and Iterators
Chapter 19: Strings
Chapter 20: Enumerations
Chapter 21: Attributes
Chapter 22: Delegates, Anonymous Methods, and Lambdas
Chapter 23: Events
Chapter 24: Dynamic Typing
Chapter 25: User-Defined Conversions
Chapter 26: Operator Overloading
Chapter 27: Nullable Types
Chapter 28: Linq to Objects
Chapter 29: Linq to XML
Chapter 30: Linq to SQL
Chapter 31: Other Language Details
Chapter 32: Making Friends with the .NET Framework
Chapter 33: System.Array and the Collection Classes
Chapter 34: Threading
Chapter 35: Asynchronous and Parallel Programming
Chapter 36: Execution-Time Code Generation
Chapter 37: Interop
Chapter 38: .NET Base Class Library Overview
Chapter 39: Deeper into C#
Chapter 40: Logging and Debugging Techniques
Chapter 41: IDEs and Utilities

Descarga:
A_Programmers_Guide_C#_5.0