lunes, 29 de septiembre de 2014

El Libro del Día: Extending jQuery

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

Titulo: Extending jQuery
Autor: Keith Wood
Editorial: Manning
Nro Paginas: 311

Capítulos:
PART 1 SIMPLE EXTENSIONS
1. jQuery extensions
2. A first plugin
3. Selectors and filters
PART 2 PLUGINS AND FUNCTIONS
4. Plugin principles
5. Collection plugins
6. Function plugins
7. Test, package, and document your plugin
PART 3 EXTENDING JQUERY UI
8. jQuery UI widgets
9. jQuery UI mouse interactions
10. jQuery UI effects
PART 4 OTHER EXTENSIONS
11. Animating properties
12. Extending Ajax
13. Extending events
14. Creating validation rules

Descarga:
Extending_jQuery

domingo, 28 de septiembre de 2014

El Libro del Día: Learning jQuery (Fourth Edition)

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

Titulo: Learning jQuery (Fourth Edition)
Autor: Jonathan Chaffer, Karl Swedberg
Editorial: Packt
Nro Paginas: 444

Capítulos:
Chapter 1: Getting Started
Chapter 2: Selecting Elements
Chapter 3: Handling Events
Chapter 4: Styling and Animating
Chapter 5: Manipulating the DOM
Chapter 6: Sending Data with Ajax
Chapter 7: Using Plugins
Chapter 8: Developing Plugins
Chapter 9: Advanced Selectors and Traversing
Chapter 10: Advanced Events
Chapter 11: Advanced Effects
Chapter 12: Advanced DOM Manipulation
Chapter 13: Advanced Ajax
Appendix A: JavaScript Closures
Appendix B: Testing JavaScript with QUnit
Appendix C: Quick Reference

Descarga:
Learning_jQuery

sábado, 27 de septiembre de 2014

El Libro del Día: Learning from jQuery

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

Titulo: Learning from jQuery
Autor: Callum Macrae
Editorial: O'Reilly
Nro Paginas: 116

Capítulos:
1. Event Handling
2. Constructors and Prototypes
3. DOM Traversal and Manipulation
4. AJAX
5. JavaScript Conventions
A. JavaScript Basics
B. JavaScript Resources

Descarga:
Learning_From_jQuery

viernes, 26 de septiembre de 2014

El Demo del Día: Visor de Imágenes con Zoom en WinForms

Visor de Imágenes con Zoom en WinForms

Este post es a pedido de un alumno que quiere una aplicación en Windows Forms que muestre una secuencia de Imágenes y pueda realizar el Zoom.

Crear la Aplicación Windows Forms

Primero crearemos una aplicación en Windows Forms en C# llamada: "VisorImagenesZoom".
Cambiar de nombre al formulario por el de "frmVisor", luego diseñar la pantalla como se muestra en la siguiente figura:


Nota: También hay que incluir un Timer llamado "tmrPreview" que cada 3 segundos muestre las imágenes del directorio seleccionado.

Escribir el siguiente código en el formulario:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace VisorImagenesZoom
{
    public partial class frmVisor : Form
    {
        private int c;
        private int n;
        private Point punto1;

        public frmVisor()
        {
            InitializeComponent();
        }

        private void abrirDirectorio(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog().Equals(DialogResult.OK))
            {
                txtDirectorio.Text = fbd.SelectedPath;
                IEnumerable<string> archivos = Directory.EnumerateFiles(fbd.SelectedPath, "*.jpg");
                lstArchivo.Items.Clear();
                lstArchivo.BeginUpdate();
                foreach (string archivo in archivos)
                {
                    lstArchivo.Items.Add(Path.GetFileNameWithoutExtension(archivo));
                }
                lstArchivo.EndUpdate();
                txtTotalArchivos.Text = lstArchivo.Items.Count.ToString();
                tmrPreview.Enabled = true;
                tmrPreview.Start();
            }
        }

        private void mostrarImagenes(object sender, EventArgs e)
        {
            lstArchivo.SelectedIndex = c;
            string archivo = Path.Combine(txtDirectorio.Text, lstArchivo.Items[c].ToString() + ".jpg");
            picPreview.LoadAsync(archivo);
            c++;
            if (c == lstArchivo.Items.Count) c = 0;
        }

        private void configurarZoom(object sender, MouseEventArgs e)
        {
            if (e.Button.Equals(MouseButtons.Left))
            {
                if (n == 0)
                {
                    punto1 = e.Location;
                    tmrPreview.Stop();
                    tmrPreview.Enabled = false;
                }
                else
                {
                    if (n == 1)
                    {
                        Point punto2 = e.Location;
                        string archivo = Path.Combine(txtDirectorio.Text,
                                                   lstArchivo.Items[c].ToString() + ".jpg");
                        Bitmap bmp = new Bitmap(picPreview.Image);
                        Bitmap bmpZoom = new Bitmap(bmp.Width, bmp.Height);
                        Graphics g = Graphics.FromImage(bmpZoom);
                        float ratioX = (bmp.Width/picPreview.Width);
                        float ratioY = (bmp.Height / picPreview.Height);
                        int posX = (int)(ratioX * punto1.X);
                        int posY = (int)(ratioY * punto1.Y);
                        int ancho = (int)(ratioX*(punto2.X-punto1.X));
                        int alto = (int)(ratioY * (punto2.Y - punto1.Y));
                        Rectangle srcRect = new Rectangle(posX, posY, ancho, alto);
                        Rectangle dstRect = new Rectangle(0, 0, bmpZoom.Width, bmpZoom.Height);
                        g.DrawImage(bmp, dstRect, srcRect, GraphicsUnit.Pixel);
                        picPreview.Image = bmpZoom;
                        tmrPreview.Enabled = true;
                        tmrPreview.Start();
                    }
                }
                n++;
                if (n == 2) n = 0;
            }
        }
    }
}

Nota: Para programar el Zoom se ha asociado al evento MouseClick del PictureBox llamado "picPreview" donde en el primer clic se captura la ubicación del punto y se guarda en una variable "punto1" y en el segundo clic se captura el punto2 y se crea un rectangulo con la imagen para el Zoom. Solo hay que tener en cuenta que el Rectangulo debe ser en base a la imagen (Bitmap) del PictureBox y No al tamaño del control (con propiedad SizeMode en StrechImage), por lo cual se crea las variables ratios.

Probar la Aplicación Creada

Grabar el proyecto y ejecutarlo con F5. Seleccionar un directorio donde se encuentren archivos jpg y se mostraran en la lista tal como aparece en la siguiente figura:


Cada 3 segundos cambiara la imagen y se seleccionara en la lista el archivo que se esta mostrando, dar el primer clic sobre la imagen y luego el segundo clic mostrará el preview de la imagen, tal como sigue:


Comentario Final

En este post hemos visto como mostrar una secuencia de imágenes usando un Timer y también como realizar el Zoom de una Imagen usando el método DrawImage de la clase Graphics para dibujar un rectángulo con la imagen especificada al dar dos clics, uno para marcar el punto de inicio y otro para marcar el punto final.

Descarga:
Demo19_VisorImagenesZoom



El Libro del Día: jQuery Mobile Cookbook

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

Titulo: jQuery Mobile Cookbook
Autor: Chetan K Jain
Editorial: Packt
Nro Paginas: 320

Capítulos:
Chapter 1: Get Rolling
Chapter 2: Pages and Dialogs
Chapter 3: Toolbars
Chapter 4: Buttons and Content Formatting
Chapter 5: Forms
Chapter 6: List Views
Chapter 7: Configurations
Chapter 8: Events
Chapter 9: Methods and Utilities
Chapter 10: The Theme Framework
Chapter 11: HTML5 and jQuery Mobile

Descarga:
jQuery_Mobile_Cookbook

jueves, 25 de septiembre de 2014

El Libro del Día: Pro jQuery Mobile

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

Titulo: Pro jQuery Mobile
Autor: Brad Broulik
Editorial: Apress
Nro Paginas: 262

Capítulos:
Chapter 1: Why jQuery Mobile?
Chapter 2: Getting Started with jQuery Mobile
Chapter 3: Navigating with Headers, Toolbars, and Tab Bars
Chapter 4: Form Elements and Buttons
Chapter 5: List Views
Chapter 6: Formatting Content with Grids and CSS Gradients
Chapter 7: Creating Themable Designs
Chapter 8: jQuery Mobile API
Chapter 9: Service Integration Strategies
Chapter 10: Easy Deployment with PhoneGap

Descarga:
Pro_jQuery_Mobile

miércoles, 24 de septiembre de 2014

El Libro del Día: Pro ASP.NET Web API Security

El Libro del Día: 2014-09-24

Titulo: Pro ASP.NET Web API Security
Autor: Badrinarayanan Lakshmiraghavan
Editorial: Apress
Nro Paginas: 403

Capítulos:
Chapter 1: Welcome to ASP.NET Web API
Chapter 2: Building RESTful Services
Chapter 3: Extensibility Points
Chapter 4: HTTP Anatomy and Security
Chapter 5: Identity Management
Chapter 6: Encryption and Signing
Chapter 7: Custom STS through WIF
Chapter 8: Knowledge Factors
Chapter 9: Ownership Factors
Chapter 10: Web Tokens
Chapter 11: OAuth 2.0 Using Live Connect API
Chapter 12: OAuth 2.0 from the Ground Up
Chapter 13: OAuth 2.0 Using DotNetOpenAuth
Chapter 14: Two-Factor Authentication
Chapter 15: Security Vulnerabilities
Appendix: ASP.NET Web API Security Distilled

Descarga:
Pro_ASPNET_WebAPI_Security