ailon's DevBlog: Development related stuff in my life

amCharts for WPF 1.0 released

4/27/2009 10:49:00 AM

Pie chart, Column chart, Line chart, Mixed column and line chart

We have just released the final 1.0 version of our charts for WPF. Hooray!

Please, help me spread the word by kicking, shouting, dzoning, cross-posting and otherwise promoting the release. Thanks a million!

Tags: , , ,

Book Review: Professional ASP.NET 3.5: In C# and VB

4/24/2009 4:29:00 PM

proaspnet About a year ago I bought this book when Scott Guthrie promoted a deal on it at Amazon. This was probably the biggest technology book I’ve ever read and it took me months to read and not only because of the size but because it was boooring.

Most of the book is written by Bill Evjen (as far as I understand) and his chapters are very dry and not very different from just browsing through MSDN documentation. There are almost no personal opinions, recommendations or anything. Just plain reference.

Some chapters are written by Scott Hanselman and you can see it right from the start. These chapters offer opinions, advices and you can see a person behind them. I don’t know, maybe it’s just me, but I prefer seeing a person behind a book or an article rather than reading a book which looks like it’s written by some technical documentation team. Unfortunately only a few chapters are authored by Scott.

I couldn’t identify chapters by Devin Rader so he either writes indistinguishably from Bill or Scott :)

The other point to criticize would be the fact that book has samples in both C# and VB. I understand that it’s easier to publish one book instead of two but the book could’ve been like 20-30% thinner and lighter and I wouldn’t have to decide against bringing it with me on the flight (yes, it’s that heavy). And, you know, 300-400 useless pages for almost every reader (either VB or C# developers) doesn’t help preserve Amazonia forests.

Overall this is not a bad book if you are looking for printed ASP.NET reference but not quite a good read if you want some insight, recommendations and depth.

Verdict: complete but dry and boring.

Other recommended books about ASP.NET: 4 years ago I’ve read Programming Microsoft ASP.NET 2.0 Applications: Advanced Topics by Dino Esposito and it was really good. Unfortunately it doesn’t seem that there’s an updated edition of this book by Dino, but there’s other book called Programming Microsoft ASP.NET 3.5. I’m not sure how this new book is related to the older ones (in terms of topics) but I really like Dino Esposito’s style and depth of his books.

Tags: ,

amCharts for WPF: Line & Area Chart Released

3/13/2009 12:53:44 PM

Just released Line and Area charts for WPF. The announcement is here.

amCharts WPF Line and Area charts

Enjoy. And help us spread the word if you do!

kick it on Shout it

Tags: , ,

Charts for WPF

2/18/2009 4:29:05 PM

I haven’t posted anything significant here for quite some time. That’s not because I’m lazy (that too), but because I’ve been busy working on WPF edition of amCharts. For those who don’t know, amCharts is one of the leading charting controls for web developed with Adobe Flash, and I’ve been working on charts for WPF based on the know-how gathered in 2 years amCharts been out.

WPF charts

Overall working with WPF was quite a pleasant change of scenery. There were some rought edges and you really have to turn your head around if you’ve only been dealing with web and/or Windows Forms before. But after some time you get used to it and it’s really amazing what you can do with it.

So, if you are developing for Windows Presentation Foundation platform or plan too and you need a really flexible and powerful charting solution, take a look at amCharts for WPF. And, btw, you can use it absolutely free even in commercial applications as long as you don’t mind a small link back to amCharts in the corner. Or you can purchase a commercial (link-free) license which are going with 75% discount for now.

Tags: , ,

Html.ActionLink for images in ASP.NET MVC

12/27/2008 1:35:00 PM

As far as I understand there will be some methods in the future versions of ASP.NET MVC to get the same raw URL that is generated by Html.ActionLink helper method so you can wrap an image (or whatever) with a link, but in the current release (Beta) there's no such thing.

A quick google search revealed different ways people deal with this but first results weren't about the simplest workaround I just used and it works for me. So, I thought that someone might find this useful too.

The simple idea is just to place a marker as a link text and then just use simple string.Replace to place an image in place of the marker. Something like this:

<%= Html.ActionLink("__IMAGE_PLACEHOLDER__", "Products").Replace("__IMAGE_PLACEHOLDER__", "<img src=\"" + myImgUrl + "\" />")%>

Sure, this is not a very elegant solution but it works for me and it's simple.

Update: Oops. It appears that I wasn't aware of UrlHelper class and it's Action method which does just that (returns Action url). Thanks to James for pointing this out in the comments.

Tags: ,

SPAW Editor v.2.0.8 and Flash Uploader

8/29/2008 2:29:10 PM

We (Solmetra) have released a new version of SPAW Editor for both PHP and .NET. Download links here. More info here.

In other news we've released a new product aimed at web developers — Flash Uploader.


It’s a highly customizable Flash-based control that replaces stagnant HTML’s <input type="file"> tag. It not only displays neat progress bar — a feature lacking in <input type="file"> tag — but also provides some pretty neat upload security features and client-side restrictions (i.e. file size and type) as well as JavaScript API.

Give it a try and let us know what you think. Oh, and it’s free!

Tags: , , ,

Add Interactive Flash Charts to Your ASP.NET Web Application. Part 4: Column Chart from Code-behind

8/8/2008 10:29:36 AM

This is the fourth part in the series of tutorials showing how to add dynamic, interactive, data-driven charts to your ASP.NET web applications. These tutorials use amCharts Flash charting components and "ASP.NET Controls for amCharts" for ASP.NET integration.

This part is long overdue. Sorry for that. A tutorial on adding amCharts to ASP.NET page from code-behind was the most requested on amCharts ASP.NET controls forum. So, here we go.

Make sure you have your environment setup, ASP.NET controls for amCharts DLL added and amCharts Column chart added to your project. Details on doing that were provided in Part 1 of the series so I wont repeat it here.

Now let's add a new ASP.NET web form to our project and let's call it CodeBehindBar.aspx. We will only add a single PlaceHolder object to the markup side of our script so it looks like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CodeBehindBar.aspx.cs" Inherits="CodeBehindBar" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    <asp:PlaceHolder ID="ChartPlaceHolder" runat="server" />

Now let's switch to the code-behind file.

We will be creating a column chart with two graphs and we'll use Northwind database as data source. The first graph will represent sales totals for 1997 grouped by category and divided by 1000 (just for the sake of being in the same range as our second graph). The second graph will show quantities of products in each group we have in stock.

Make sure that you have access to some SQL Server instance with Northwind database installed, connection string setup, and let's start by pulling our data from SQL Server and placing it into DataSet:

// Get data from Northwind
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);

SqlCommand myCommand = new SqlCommand("select CategoryName, CategorySales/1000 as CategorySales from [Category Sales for 1997]", conn);
SqlDataAdapter da = new SqlDataAdapter(myCommand);
DataSet ds = new DataSet();
da.Fill(ds, "Category Sales for 1997");

myCommand.CommandText = "select CategoryName, sum(UnitsInStock) as UnitsInStock from [Products by Category] group by CategoryName";
da.Fill(ds, "Products by Category");


Now it's time to create our chart. We create a ColumnChart object and setup it's DataSource. This is what will be used for the chart series (X axis).

// create column chart
ColumnChart chart = new ColumnChart();
chart.DataSource = ds.Tables["Category Sales for 1997"].DefaultView;
chart.DataSeriesIDField = "CategoryName";
chart.DataSeriesValueField = "CategoryName"; // here it's the same as ID and could've been ommited

Notice that we've specified "CategoryName" as both SeriesIDField and SeriesValueField. This isn't necessary in case like this were we have the same field for both ID and Value. It would suffice to just specify the ID, but I've added Value line so you know you can use different data fields for that.

What we've done so far is created a grid where to add actual data graphs. Now let's create 2 graphs:

// crete sales graph
ColumnChartGraph graph1 = new ColumnChartGraph();
graph1.DataSource = ds.Tables["Category Sales for 1997"].DefaultView;
graph1.DataSeriesItemIDField = "CategoryName";
graph1.DataValueField = "CategorySales";
graph1.Title = "Sales (in thousands)";

// crete stock graph
ColumnChartGraph graph2 = new ColumnChartGraph();
graph2.DataSource = ds.Tables["Products by Category"].DefaultView;
graph2.DataSeriesItemIDField = "CategoryName";
graph2.DataValueField = "UnitsInStock";
graph2.Title = "Units in stock";

and add these graphs to our chart:


What's left is just data-binding the chart and adding it to our place holder control on the page


And that' basically it. This is what you should see if you run this:


You can customize the look and feel by changing various properties according to your taste.

Download the source code here: (1kb)

kick it on

Tags: , , ,

Essential Silverlight 2 (Up-to-Date) by Christian Wenz

6/18/2008 4:04:03 PM

Finished reading Essential Silverlight 2 (Up-to-Date) by Christian Wenz. I've posted about the look and feel of the "Up-to-Date" concept when I got the book. To that aspect I can only add that it was actually more comfortable to read than I've anticipated. The binder doesn't stand in the way and probably is sturdier than paperback or even hardcover.

Now let's move on to the reason why I bought this book - content. The book succeeds at getting you excited about the technology and that's basically it. It shows you how to do basic XAML and how to access the objects from C# and JavaScript very briefly (currently it's only about 200 pages long). I really missed a part dealing with creation of objects and drawing directly from C#. I don't think that's something outside of the scope of "essential" book. It also seems that some chapters are being rewritten from JavaScript to C# but the text still says "JavaScript" while the code in the example is in C#.

I was mostly interested in Part 3: Programming Silverlight with .NET. But to my surprise it dealt with embedding Silverlight into ASP.NET pages rather than actual programming of Silverlight apps.

Anyway I got my share of excitement about the technology and feel pretty comfortable to start actually doing some stuff with it after reading this book.

Verdict: succeeds at getting reader excited about Silverlight 2 and stops right there

P.S.: This review refers to the book with "Update 1" (Beta 1) applied.

Tags: , ,

Accelerated C# 2008 by Trey Nash

6/13/2008 3:56:01 PM

accelerated_csharp_2008I've been developing in C# (on and off) since version 1.0 was in beta. I've read a book about it when version 1 came out and then I relied on online articles, blogs and docs to stay updated. Now (2 versions later) I decided that it's about time to read something systematic on the language to get a complete overview of the things I could've missed over the years and to familiarize myself with new features in C# 3.0 (btw, book title is probably a work of some crazy marketing mind since there's no such thing as C# 2008 AFAIK) .

And the book delivers just what I needed: concise overview of most of the language features complete with samples, usage patterns and best practices. Accelerated C# 2008 (Accelerated) is targeted at developers with some prior experience. It's stated in several places that it's for C++, Java and Visual Basic developers though it's perfectly clear that Trey Nash has lots of things to say to C/C++ and C# guys and not so much to the Java and Visual Basic crowd. Almost all comparisons are done with C++ world so if you are Java/VB developer I suggest you look elsewhere or at least be warned that you wont find many references to these languages.

Verdict: highly recommended for C++ and C# developers, not so much for beginners and Java and VB developers

P.S.: actually in this case I've read a Russian translation of this book titled "C# 2008 ускоренный курс для профессионалов" so I can't talk about publishing related qualities of the book.

Tags: , ,

What's Wrong with this?

5/29/2008 9:55:30 AM

Every time I read a C# book or an article or just a code sample in MSDN I can't stop wondering why don't people (and by people I don't mean just average Joe's but respected authors, MSDN documenters, etc.) use this qualifier unless it's absolutely required to distinguish between identically named local variables and object fields?

I use this all the time and I think it's way easier to understand your own code. And don't get me started on someone else's code. Let me show you an example.

Yesterday I was implementing a SiteMapProvider for a project I'm working on. I looked  at the sample in MSDN. The main "meat" is in BuildSiteMap method. I'll paste it here in full. It's a little long but that's exactly the point.

// Build an in-memory representation from persistent // storage, and return the root node of the site map. public override SiteMapNode BuildSiteMap() { // Since the SiteMap class is static, make sure that it is // not modified while the site map is built. lock (this) { // If there is no initialization, this method is being // called out of order. if (!IsInitialized) { throw new Exception("BuildSiteMap called incorrectly."); } // If there is no root node, then there is no site map. if (null == rootNode) { // Start with a clean slate Clear(); // Select the root node of the site map from Microsoft Access. int rootNodeId = -1; if (accessConnection.State == ConnectionState.Closed) accessConnection.Open(); OleDbCommand rootNodeCommand = new OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid IS NULL", accessConnection); OleDbDataReader rootNodeReader = rootNodeCommand.ExecuteReader(); if (rootNodeReader.HasRows) { rootNodeReader.Read(); rootNodeId = rootNodeReader.GetInt32(0); // Create a SiteMapNode that references the current StaticSiteMapProvider. rootNode = new SiteMapNode(this, rootNodeId.ToString(), rootNodeReader.GetString(1), rootNodeReader.GetString(2)); } else return null; rootNodeReader.Close(); // Select the child nodes of the root node. OleDbCommand childNodesCommand = new OleDbCommand("SELECT nodeid, url, name FROM SiteMap WHERE parentnodeid = ?", accessConnection); OleDbParameter rootParam = new OleDbParameter("parentid", OleDbType.Integer);
rootParam.Value = rootNodeId;
childNodesCommand.Parameters.Add(rootParam); OleDbDataReader childNodesReader = childNodesCommand.ExecuteReader(); if (childNodesReader.HasRows) { SiteMapNode childNode = null; while (childNodesReader.Read()) { childNode = new SiteMapNode(this, childNodesReader.GetInt32(0).ToString(), childNodesReader.GetString(1), childNodesReader.GetString(2)); // Use the SiteMapNode AddNode method to add // the SiteMapNode to the ChildNodes collection.

AddNode(childNode, rootNode);

} } childNodesReader.Close(); accessConnection.Close(); } return rootNode; } }

I've highlighted one line in the method:

AddNode(childNode, rootNode);

By glancing at that line could you tell me right away is rootNode a local variable or a field of the object? Wouldn't it be much more obvious if it was

AddNode(childNode, this.rootNode);

We loose readability by omitting this so we must gain something in return, right? What are we gaining? Do I miss something other than saving 5-10 bytes in source file and 5 extra keystrokes? And the keystroke argument isn't always true.

Suppose you have a class defined like this:

class test
    public XmlNode XmlNodeHolder;
    public test()
        XmlNodeHolder = null;

To type that XmlNodeHolder in the constructor with the help of IntelliSense I had to press 8 keys (x-m-l-n-o-d-e-h) before I got the right line in IntelliSense. Now I would use this

class test
    public XmlNode XmlNodeHolder;
    public test()
        this.XmlNodeHolder = null;

I could type this.XmlNodeHolder in 4 key presses (t-h-.-x). So the only argument that I see and can't argue with is saving bytes in the file. But who cares about 10 bytes in the source file these days? 100 bytes? 1kb anyone?

So either I miss something important in functionality, performance or something else or I just can't understand the trend.

kick it on

Tags: ,

Copyright © 2003 - 2018 Alan Mendelevich
Powered by BlogEngine.NET