My Portfolio and (not) so personal blog Hi, welcome to the portfolio and blog of programmer, Ricardo Figueira. Co-author of the book C# 3.5, released by the publisher FCA in Jan/2009. Please take a look around.


Wordpress + Twitter = Tumblr

To exit the routine I dedicated my free time to the world of arts. Make oil and digital paintings. For many years that I am involved in the creation of beautiful musics, guitar stuff and digital sounds.

I have create one place to share and talk about my art, music and some art news … In this space I will try, not avoid, talking about programming ;D

Please check my tumblr page:
tumblr.rbfigueira.net

Pixelinked Project

I have upload one of my last project. If you know me, to exit the routine I dedicated my free time to the world of arts. Pixelinked is a beautiful and flexible digital project gallery, used to linked only the best pixel images on the web, in one place. My idea is to join all the best images of the web and make the artists recognized and known!! This will give you the started point for your inspiration, and be your digital bookmark. You can find here images of great illustrators and digital painting renown gurus. Each day, will be added one or more startling images.

Pixelinked Project

The site always give the credits to the artist; The artist is the owner of that image and all credits belong to him! ;D
Take a look around. Believe me, the site is very inspiring. You will not regret it.

DataBinder (increase performance)

DataBinder.Eval method saves you from writing complex expressions, but using this method does impose a performance penalty on your code, because all the work it does is late-bound. If we want the fastest possible code, you can replace calls to DataBinder.Eval with explicit casts.

For example:

< %# DataBinder.Eval(Container.DataItem, “myField”,“{0:c}”) %>

An equivalent expression using casts would be this:

< %# String.Format(“{0:c}”,(CType(Container.DataItem,DataRowView)(“myField”))) %>

Looking Ahead to C# 4.0: Optional and Named Parameters

Bill Wagner has explored two related upcoming features in the C# language: named and optional parameters. These features were added to the language to support COM interoperability, specifically COM interoperability with Microsoft Office.

For a variety of historical reasons, Office COM APIs have large numbers of parameters, several of which have reasonable defaults. In addition, while you may want to use many of the defaults, you may need to specify a value for some of the parameters later in the list. It would be great to call those Office methods having 15 or more parameters by only specifying those parameters where you want something other than the default. Optional and named parameters enable that for you in C# 4.0.

Named and Optional Parameters Explained
Named parameters allow you to call a method by specifying which argument in a method call refers to which formal parameter. Suppose someone had written this trivial Subtract method:

public static int Subtract(int left, int right)
{
return left - right;
}

All three of these calls are equivalent:

result = Subtract(7, 5);
result = Subtract(left: 7, right: 5);
result = Subtract(right: 5, left: 7);

If you don’t specify a name for any of the parameters, the normal order is used. Notice that you can rearrange the order of the parameters by specifying them by name.

Optional parameters enable you to specify a default value for any parameter to a method. Any parameters that have default values must be at the end of the argument list. Optional parameters must be compile-time constants.

One of the things I like the most about named parameters is that you can improve the readability of code.

Please read the complete article here:
Visual Studio Magazine : Looking Ahead to C# 4.0: Optional and Named Parameters

Programming the .NET Compact Framework (Free ebook)

Paul Yao and David Durant have simultaneously write two Compact Framework books: one with all C# samples, the other with all VB samples. (The samples are going to be made available for download to registered users.)

Note that this book is not updated to the latest version (.NET Compact Framework 3.5) but it is an excellent start. ;D

Check his link:
http://www.paulyao.com/cfbook/index.asp

————————————————–
PART 1: FOUNDATIONS

1 Compact Framework Architecture
2 What is a Compact Framework Program?
3 Fundamental .NET Data Types
4 Platform Invoke

PART 2: USER-INTERFACE PROGRAMMING

5 Creating Forms
6 Mouse and Keyboard Input
7 Inside Controls
8 Data Binding
9 Inside More Controls
10 Custom Controls

PART 3: MANAGING DEVICE DATA

11 Storage
12 ADO.NET Programming
13 Synchronizing Mobile Data
14 Remote API (RAPI )

PART 4: CREATING GRAPHICAL OUTPUT

15 Compact Framework Graphics
16 Text and Fonts
17 Printing

A Appendix A: Hungarian Naming for .NET
————————————————–

If you want the updated book, you must to buy it:
Programming .NET Compact Framework 3.5 (2nd Ed) Autographed Copy

Completely revised and updated for .NET Compact Framework 2.0 and 3.5, Visual Studio 2008, and Windows Mobile Smart Phones, Programming .NET Compact Framework 3.5, 2nd Edition, teaches you how to write highly effective applications for handheld wireless devices with small screens, limited memory, and finite battery life.

Programming .NET Compact Framework 3.5 Second Edition

The C# source code from the book is available here

GridView : HeaderStyle-HorizontalAlign=”Left” - BUG

I have made several tests and in the end … again … one more bug related with IE8. This time in the GridView control ! The GridView is not outputting the correct HTML in IE8 !! Example:

<asp :GridView runat="server" Width="100%" .... HeaderStyle-HorizontalAlign="Left" />

Resulting output:

<tr align="left" valign="top"> <th scope="col">Your Column Name</th><th scope="col">Your Column Name 2</th><th scope="col">Your Column Name3</th><th scope="col"></th></tr>

Note that the align style is applied to the tr and not the td. IE8 by default is setting the alignment for th (header) elements to center, while td defaults to left. Solution: Instead of using the HeaderStyle-HorizontalAlign property, set a CssClass instead and apply the alignment directly on the th element:

<asp :GridView HeaderStyle-CssClass="HeaderStyle"... />

then add one css class rule:

<style type="text/css"> .HeaderStyle th{text-align:left} </style>

Performance Comparison of Web Browsers

There are many different web browser companies competing for the attention of consumers all around the world. At present the most popular are Firefox, Chrome, Explorer, Safari and Opera and with more services like communication, banking and in particular entertainment (i.e. videos, music and online casino) shifting online, these web browsers have had to continually update and improve their product. So, who has had the most success in doing that?

Jacob Gube is the Founder and Chief Editor of Six Revisions. He have made one excellent Performance Comparison of different Web Browsers. The end results were very interesting as we can see below:

The latest versions of the five major most web browsers (Mozilla Firefox 3.5, Google Chrome 3.0, Microsoft Internet Explorer 8.0, Opera 10.0, and Apple Safari 4.0) went head to head under six performance indicators: JavaScript speed, average CPU usage under stress, DOM selection, CSS rendering speed, page load time, and browser cache performance. Each web browser was tested three times under an unprimed cache (except for the browser cache performance), and their average value reported in the results.

Browser Performance

See the Original Source: Performance Comparison of Web Browsers

ASP.NET menu control BUG

I have lost 4 hours, trying to fix it. I have made several tests and in the end … I suspected it was a bug! I searched in the web and … voilá:

Internet Explorer 8 is a unique release in the history of Internet Explorer in more than one way, but the decision to make standards mode the default means that authors of existing sites are impacted by it, if only to set the compatibility mode to IE7. (…)

Most ASP.NET built-in controls have been doing just fine in IE8, or the faulty behavior was actually due to an IE bug that we reported and that got fixed.

All except asp:menu. It so happens that the menu control is making a bad assumption on what the default value for z-index should be.

asp:menu fix for IE8 problem available
http://weblogs.asp.net/bleroy/archive/2009/03/23/asp-menu-fix-for-ie8-problem-available.aspx

Description of the hotfix rollup package for ASP.NET 2.0: April 2009
http://support.microsoft.com/kb/969612/

Direct FIX: ASP.NET 2.0 rollup package (April 2009)
Applies to ASP.NET 2.0 running on Windows 2000, Windows XP, or Windows Server 2003.
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=18157

Detecting IE8 Browser

If you want to know the type of the client browser, you will probably check the Request.Browser.Type property.

However, you will notice that using the IE8, several times, is reported as IE7.

[test.aspx]

< %
response.write(Request.ServerVariables("HTTP_USER_AGENT"))
%>

Using the IE8 browser, in both cases, I get these two different results:

Local Machine (Localhost):

"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM 8; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"

Production Server:

"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; MS-RTC LM 8; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"

If you notice, one says MSIE 8.0 and other MSIE 7.0.

Since IE8 include 3 rendering engines (IE8 Standards, IE7 Compatibility, IE6 Quirks), IE8 will set the Version Token dynamically, based on the user compatibility settings for each site.

This two links, will show you the best practices to detect IE8 on real world scenarios:

  • Detecting IE8 (Server side)
  • How to detect IE8 using JavaScript (Client side)
  • Sony PRS-505

    After quite a bit of research on which one I was going to get, I decided on the Sony Reader PRS 505. There are a lot of reasons for this…

    Sony Reader PRS 505

    First, because uses the same basic technology as the Kindle, supports more formats and is more ìopenî allowing you to get more ebooks on the device. The Sony PRS can deal with the following formats: BBeB (LRF), PDF, TXT, RTF, ePub, LRX, MP3, AAC, JPEG, GIF, PNG, BMP, RSS (you are able to point to “any” RSS feed and then pull that content onto your device).

    This device uses one E Ink screen technology, which it is not like any display device you have ever seen. This is something quite revolutionary. It appears as if you are reading a real book.

    Second, the ability to work easily with PDFs was one of the features that I was looking for. With the Sony PRS, you are able to pull up a PDF and it will first be viewed as you would expect, by viewing the entire page. Though, you can also use the zoom button and the Sony PRS will then reformat your PDF document and you will be able to see the text larger. The other option is to change the view entirely by rotating the view.

    Furthermore (unlike the Kindle), this device does not include any kind of search functionality. It does include bookmarks for marking arbitrary pages for random access later on.

    To manage all the books, the package comes with ebook library software (Windows OS only). Yeap, nothing for mac, but since the device presents itself to the host operating system as a flash disk drive, actually copying content to the device is as simple as dragging and dropping the files to the correct folder. If you want one great tool to manage ebooks, you can download calibre, the best tool I have found out there. It is free, open source and cross-platform in design and works well on Linux, OS X and Windows.

    Also comes with a nice leather cover that is a little larger than the device and therefore protects it quite a bit. It also has some magnets built into the corners and stays conveniently closed when put away or thrown into your backpack or briefcase.
    Iíve been very happy with this device and I think its one great way to read technical PDF books.

    One thing is certain; I will save much money on books.