Using fonts in Silverlight: evaluating the options

Silverlight gives the developer the possibility of completely customizing the developed application in all aspects. Defining fonts used for displaying text is no exception. However there are multiple ways on how to go ahead with specifying fonts to use, this article attempts to summarize the options.

In Silverlight, using fonts can be done in three ways:

  • Built-in fonts
    Silverlight can use a limited number of “built-in” fonts to display text such as Arial, Verdana, Times New Roman and a couple of more. The list is limited and it’s also worth noting that Silverlight can only use these fonts if they are installed on the client machine as the runtime does not ship with any fonts.
  • Embedded custom fonts
    Custom font files can be embedded in Silverlight applications and then shipped within the xap files. This option makes sure that the font will be rendered as wanted regardless of wether the font is installed on the client machine or not.
  • Streamed (dynamically downloaded) custom fonts
    The problem with embedding fonts in Silverlight is that it increases the xap size. If a font is only needed in certain cases the font file can be dynamically loaded from a remote location making the initial download time faster.

For details on how to implement the above use cases and some sample applications with source code check out my blog post on the Scott Logic website: Using built-in, embedded and streamed fonts in Silverlight.

Workspace alternatives: a comprehensive comparison

Teamwork isn’t an easy sport: the bigger the team the harder it gets. If the goals/milestones are set clear, one person will probably complete the project just fine. If it’s a team of two they’ll probably split up the work, track each other progress and finish in time. If its one of three, four or five they’ll probably start calling meetings, send emails, update their progress. If it’s a team of over 20, there’ll probably be people working full time just managing the communication between teams.

As the team grows the overhead of coordinating work just increases. I’m sure everyone has realized at some point that emails and Excel sheets are quite limited at managing things as the project grows and sticky notes work good, but not with distributed teams.

Of course lots of others have realized this problem before and created software to aid this process: these tools are usually referred to as project management tools or (virtual) workspace solutions. The idea of these is to have users store and update documents in the workspace, be able to constantly track their and others’ progress and make collaboration easy in this space. There are lots of promising workspace solutions: when first searching I came across at least two dozen seemingly good products/services.

One of the most efficient and popular way to help manage comlpex projects is by providing workspaces to users – a common shared storage area related to a specific task. Users can upload and share documents related to the project to the workplace, collaborate with other users involved in the project and track what is going on in the workspace.

Back in September 2009 while I took up the task to test the major players in workspace management fields so that the company would have a picture of where their workspace module was on the market. This study never got published however while doing the research I didn’t find any useful comparisons that were not funded by some vendor. I’ve left Sense/Net in October 2009 and decided to publish my research as it might be a good guideline for someone looking for a short list of project management tools.

The products evaluated in this comparison are Central Desktop, Huddle, Office Live WorkspacesO3Spaces, ProjectPlace, ProjectSpaces, Sense/Net 6.0 and Sharepoint 2007. Evaluation criteria is detailed and is grouped into general overview, document management, collaboration and content publishing categories.

General overview
Central Desktop Huddle Office Live
Work
spaces
O3
Spaces
Project
Place
Project
Spaces
Sense
/Net 6.0
Share
point
2007
SaaS solution Yes Yes Yes Yes Yes Yes No No
Self Hosted No No No Yes No Yes Yes Yes
Price estimate for small team (3-10 people,3-10 workspaces) $25-50/month $15-38/month Free with MS Office license €15-65/month (€177-790/year) $80-270
/month
$79-129
/month
Free (open source) $4800+
one-time
fee
Price estimate for mid-large team (50-150 people, 50-150 workspaces) $500-1500/month $200+/month, price provided upon request Free with MS Office license
Workspaces
€250-1000
/month (€2950-11850
/year)
$1100-3500
/month
$399-749
/month
Free (open source) $9500-
19500+
one-time fee
Detailed pricing See details See details See details See details See details See details See details See details
Company response time for e-mail inquiries * Within days Within days Within hours Within hours Never Within hours Within hours Within days

Read More…

My MIX 10K entry – SilverCooler

I’ve entered the MIX 10K competition where the goal is to write an application using no more than 10KBytes of source code in Silverlight. I’ve decided to implement a cocktail selector application – strictly listing alcohol free cocktails only – using the web services I’ve previously built for a popular cocktail site, iCocktail.co.uk.

ICocktail.co.uk was built with Flash using XML services and since Silverlight is indeed as powerful as Flash implementation was quite an ease – my only problem was squishing in the 10K limit (thanks for Colin’s post on some tips on minifying the code). The application I’ve developed is the following:

SilverCooler - Gergely Orosz's entry for MIX 10K

If you like it, please vote for it on its the MIX 10K entry site.

One thing all people noticed when looking at the application at first is the cool “bouncing” effect of the cocktail name. In the flash version this was done by using an EaseOutElastic transition. Not surprisingly Silverlight has similar animation effects as Flash, these are called easing functions. To achieve the bouncing effect I only had to add the following code to the animations changing the width and height of the shape:

DoubleAnimation animation; // The animation changing width or height of the shape popping up
animation.EasingFunction=new ElasticEase(){ Oscillations=3, Springiness=1, EasingMode=EasingMode.EaseOut };

Oh, and if you’re in for some more drinks, check out iCocktail.co.uk as well!

Animated Christmas Card using jQuery

As the holiday season is close I was looking for a way of sending a simple, yet nice animated Christmas card to friends. I wasn’t looking for one of the many popular sites offering e-card sending, instead I wanted something I could somewhat customize, put on my server and send the link to friends and family so they could view it in their browsers.

At first I was thinking of creating a simple application with fading pictures in Silverlight. However I’m intending to send it to some older relatives whom I don’t want to have to mess with installing the Silverlight plugin – they would probably skip from that point. Doing the card in Powerpoint was not an option as not all friends have software to open it. So that left me trying to find a Flash application that does something like that – without any luck. So at that point I almost gave up. And then realized that I’ve forgorren about one of the most simple cross-crowser solution: using javascript to do the job.

So I’ve created a nice greeting card using jQuery that fades in a few images like it was a slideshow and writes out a greeting message in the end. You can take a look at it working here: Christmas Card using jQuery demo, and here’s a screenshot of what it looks like:

jQuery Christmas Card - preview

I’m sharing the complete application for further re-use, you can download the package here: source code for Christmas Card using jQuery. It consists of a html page, a css file, some demo images and a javascript file. If you want to create a similar nice greeting card, you can do it the following way:
Read More…

Behaviour Driven Development for .NET developers

On the Scot ALT.NET meeting held on 4th November Robert Lewis gave a talk on BDD explaining the basics, motivations and demonstrating the .NET tools available to support this methodology. I found the talk to be really interesting, mostly because Robert was focusing on the practical side of BDD – that is how .NET developers can use this methodology and at what projects might this be beneficial.

Based on this talk I’ve written a small article on what BDD is, what tools there are out there to use it in the .NET world and how it can help in software projects. Read the article on my ScottLogic blog: Behaviour Driven Development for .NET developers

Silverlight bug when drawing large paths

I’m working on creating a zoom effect for a Silverlight Path object. This effect is easy to implement: I just have to apply a ScaleTransform and and a TranslateTransform within a TransformGroup for the Path (scale it up and move it on the screen where the user clicked to zoom). However when reaching a certain zoom level I’ve noticed some weird behaviour: the Path was drawn in some random, sometimes inverse way.

I’ve tracked the behaviour down to the point to when it seems that the problem is not with ScaleTransform but with Paths above a certain size. I’ve created a simple example project to reproduce the problem. The source can be downloaded here.

What I’m doing is drawing a simple rectangle with 5 points:
11

The issue

And I start to redraw it in larger sizes and at the same time re-positioning it to stay in the center (so I’m basically doing a centre zoom effect):
21

However when the size of the path is about 65 000px (or 80 times the height of the LayoutRoot – I used 1280*1024 resolution with the LayoutRoot grid being about 770px) the shape is drawn incorrectly:
3

Read More…

File Upload in Silverlight – a Simple Solution

Recently I wanted to implement a very simple file upload component in Silverlight that uploads a single file and if possible shows upload progress. Having done some search I’ve found numerous examples but all of them seemed too complex for the simple task of uploading a file so I implemented a really lightweight solution. The source code can be downloaded from here: SimpleFileUpload_v2.zip

Uploading files in Silverlight

Uploading files is quite an easy one in Silverlight: it’s basically just a request made to another server and the file contents are passed in this request. A possible way of implementing this is by using the WebClient class:

private void UploadFile()
{
FileStream _data; // The file stream to be read
string uploadUri;
 
byte[] fileContent = new byte[_data.Length]; // Read the contents of the stream into a byte array
int bytesRead = _data.Read(fileContent, 0, CHUNK_SIZE);
 
WebClient wc = new WebClient();
wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
Uri u = new Uri(uploadUri);
wc.OpenWriteAsync(u, null, new object[] { fileContent, bytesRead }); // Upload the file to the server
}
 
void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e) // The upload completed
{
if (e.Error == null)
{
  // Upload completed without error
}

Upload Progress Indicator

The above solution does the job of uploading the file well. However it does not indicate file upload progress at all: when uploading large files or when having slow internet connection this behaviour would be desirable.

Silverlight has no built-in way to monitor the number of bytes sent which means that the only way to indicate upload progress is sending the file to the server in multiple, smaller chunks. Of course this behaviour needs support from the server side as well.

The idea is that multiple calls are made to the server, every call submitting the next chunk of the file. On the server these chunks are appended to the file.

Read More…

Open Source ECM implements AD synchronization

Sense/Net 6.0, the .NET Open Source Enterprise Content Management System has released its latest, Beta 4.3 version with Active Directory synchronization implemented. This is a small feature addon to the Beta4 version of the software, which among others implemented workspace support probably first in the open source .NET ECM world.

You can see the original announcement on the Sense/Net development blog and you can download and play with the newest release from the Sense/Net project on Codeplex.

Nhibernate vs Entity Framework – a revised performance comparison

Note: before reading this article please see my views on comparing ORM tools. In short: this comparison is not suitable for comparing NHibernate and Entity Framework, due to the complexity of the tools vs the simplicity of this test; treat this post accordingly.

The reason I’m revising previous results is because some members of the NHibernate community looked into the code and discovered that the comparison wasn’t totally fair. While the test cases with Entity Framework used batch operations, the NHibernate implementation had this feature turned off. Tuna Toksoz was kind enough to re-write the critical parts of the code and apply settings enabling batching, you can download the revised source code here.

Note that I’ve made the source open for two reasons. First, I’d like the tests to be reproducible. And more importantly: I have experience with the two frameworks however I’m not an expert at any of them: therefore treat the results with caution. Anyone is free to analyze the source and if there are some issues in the code resulting in major performance drops, please let me know.

After Tuna modified the code NHibernate storage speed rocketed up compared to the previous version:

Framework/ No. of operations 1K 3K 8K 14 K 23K 33K 40K
NHibernate 1,22 3,25 8,98 13,11 28 38 46
Entity Framework 2,11 6,18 18,4 31,3 51,7 77 98

store2

However improving performance does not stop here. Fabio Maulo posted a great article on why the original code was far from optimal and improved runtime results even more.

Conclusion

As I’ve stated before I don’t beleive there is a good way in comparing ORM frameworks and even if there were, this little test certanly is not it.

As the contribution of the NHibernate community members showed the more complex and configurable the tool, the more experience you’ll need to make the best of this. If you’re working on a performance critical product, you’d better know you’re tool well and use it accordingly.

But which one should I use?

From the current results it seems that there is no major performance difference between two tools and even if there is it might be due to misuse. So my advice is to use which ever tool suits you more based on its features.

At first glance Entity Framework seems to have a shorter learning curve as well as some nice integrated VS tools to make development easier. On the other hand there is a constantly active and helping NHibernate community always ready to answer questions and NHibernate seems to be much more customizable at a higher level. Also see this thread on EF vs NH features and learning as well to help decide.

The decision is up to you which one you find more suitable for your needs. However since both are proven and mature solutions you won’t be making a big mistake going with which either.

Thoughts on ranking ORM tools

Posting of the previous performance comparison results (see here) has caused a much greater response I ever expected as well as some confusion about the goal of this test that I would like to respond to.

How real (world) is this?

Most importantly a performance test is useful if it can be used for predicting performance of a real world application. Now the performance test in I did was a really primitive, batch based CRUD test. Unless you are developing an application that does batch actions such as in this test, the results can’t really be used for predicting performance of real world applications. We’re talking about two mature frameworks with lots of additional services – e.g. caching and transaction handling – that are not evaluated in this test even though they can have a huge impact on performance.

Be a little sceptic

I would suggest treating results with caution and checking on the source. There are a lot of people expert on a single ORM framework, some are experts on two but it mostly stops there. Unless stated that the author(s) is/are experts on the topic I would approach these results in a sceptic way.

As for my own case: I do have experience with the tested frameworks however am far from being an expert with any of them – so treat my results with caution. I’ve published the so anyone can analyze it and if there are some issues in the code resulting in major performance drop, hopefully someone will let me know – just as some members of the NHibernate community did after publisihing the first results.

There is no “best”

I believe there is no valid way to decide which framework is ultimately better. There is an ongoing debate about ranking ORM tools and how well a test like this is good for deciding on which framework is better. I think it is not. Just to mention a few reasons:

  • Most real world applications have a far more complex working than this test simulates. What’s more, commonly used additional framework features – e.g. caching, transaction handling – are not tested at all even though these features can have a great impact on real world performance
  • Performance may not be everything. Even if these performance tests would reflect performance in a real world environment (as they don’t), ORM is not used based on performance. When using an ORM tool you make a compromise to have worse performance than using native SQL and gain additional features. It’s usually a tradeoff: the more features you get, the bigger the overhead will be.

There is one case when this kind of test can be useful though. If you find a great performance difference between two frameworks (e.g 50-1000 times), it’s a good indicator that there’s either some issue with the test itself or the framework. If you’re sure that the test is written correctly this comparison could lead to the analysis of why the framework is unacceptably better than the other. If you can find the valid answer, then good. If you can’t, now that’s when things get interesting and the test was worth doing.

The best valid way of comparing an ORM tool in my opinion is based on the project you need it for. Write together your needs, weigh them and evaluate the frameworks accordingly. ORM tools are comparable just as cars are. You can’t decide which one’s better unless you know what to use it for. An F1 car may be great for a speed race but would utterly fail in a desert challenge.

1 3 4 5 6 7 8  Scroll to top