Skip to main content

Posts

Showing posts from January, 2013

Loading large html pages using Awesomium.NET

While there is no limitation in the page size per se, you may experience some weird behavior (errors) when trying to load large html files using the Awesomium WebView LoadHTML method. I been using this framework for a week now and I’m more than satisfied, it’s a great piece of software, but the error message you get when a large page fails to load, it is a bit confusing “the uri is too long” …. I was working with two files, one of them was large, the other was small, but URL length was the same for both, let say foo.html and bar.html . When I load foo.html things work great, but when I try to load bar.html, boom, I got an error saying that something is wrong with URI’s length? here is where I went “WTF, both URIs have the same length!” ;) The thing is that the framework internally is using the .NET Uri class which have a limitation of 65K something characters, if the html that you are trying to load exceeds that limitation (not the url, the html) you will get that excep

How to get windows.external to work when using Awesomium.NET

Note: There is an updated version of this post right here  (with source code and all stuff) I been doing some experiments with the Awesomium  web browser framework, and after a lot of failing attempts, I finally got windows.external calls working. Awesomium  is a windowless port of Chromium/WebKit. For WinForm developers, an alternative way to embed web pages in your winforms or WPF apps without having to use the WebBrowser control. For a long time, I been using the IE embedded browser to show reports (webpages) in winform apps, with let say…, acceptable results ;), but the thruth is there is a lot of goodness out there into the wild with better support for css, html 5, etc. So I decided to install Awesomium.NET and give it a try. While the API is pretty intuitive, I had some trouble trying to call C# methods from Javascript, a fairly easy thing to do with the classic webbrowser control. This is how things work when using embedded IE Browser C# code htm

WinForms, How to enable sorting for a datagridview that uses linq queries as data source

How to enable sorting for a datagridview that uses linq queries as data source it is a frequently asked question on the web. The short answer is you cannot, but let dig a little deeper. Why the sorting functionality works as expected when you use it on a grid binded to a DataTable and miserably fails when you bind it to an IEnumerable<DataRow>?  A bit of research later… Easy, the DataTable class provides its own implementation for sorting rows whereas IEnumrable<T> does not. I faced this problem building the power grid control, because (to make paging records easy) internally I was using linq queries. As soon as I realized that the datagrid sorting was broken, I started to look on the web an easy way to solve this problem (other than implement my own sorting mechanisms, of course). I found a couple of alternatives but this one  convinced me. This class has a neat way to solve generic sorting with a minimal impact on performance. I’ve tested it sorting pages

WinForms, how to implement conditional format for DataGridViews (part 2)

In the previous post I showed you how to implement conditional format functionality for datagridviews using C#, working on conditions that we already know at compile time, which means that those conditions will be written by programmers, not end users. In this post I’ll show you how to deal with user defined conditional formats, which is a more useful thing to do if what you want to provide this kind of functionality. With this new feature the users are going to be able to write conditions in an Excel fashion (formula like, if you will) To implement this feature I’ve upgraded the project that we been using for this series to .NET Framework 4.5 in order to use the latest version of the Roslyn compiler. The Roslyn compiler is the backbone of this feature. If you are interested in Roslyn, I made a series on How to build a DSL on top of Roslyn  that covers some basic stuff of this great piece of software. As in the Roslyn DSL series I'll rely on source to source translati

WinForms, how to implement conditional format for DataGridViews

Being able to apply conditional formats to datagridviews is a must nowadays, users of our app probably make heavy use of this feature on Excel spreadsheets, and they want it to be present on any "grid alike" screen. I’ll show you two ways to implement this feature the first one is using pre-built formats, or formats specified in C# at compile time (better performance) and  the second one that allows users to add their own conditional formats with formulas written in an excel fashion . In the last case the performance is not good enough for prod., but I’ll be sanding rough edges and hopefully make it work in a near future. To work on this feature, I'm going to use the same datagrid I used in the previous post, which you can download from here . The whole functionality is already implemented, so I'll just show you how to use it. The only thing you have to do is register the conditional format and the component will take care of the rest.  To register a