Saturday, September 26, 2009

Antialiasing graphics GDI+ in .NET

Was looking for this.
All you need to do is set the smoothing mode on your graphics object :

g.SmoothingMode = SmoothingMode.AntiAlias;

Thats all folks. Enjoy!

Thursday, September 24, 2009

Passing Large Arrays (Lists) Via WCF

Was getting the error "The underlying connection was closed: The connection was closed unexpectedly" when passing arrays from large datasets to the client.

This is the solution:

http://consultingblogs.emc.com/merrickchaffer/archive/2007/09/19/WCF-System.Net.WebException_3A00_-The-underlying-connection-was-closed_3A00_-The-connection-was-closed-unexpectedly.aspx

Basically requires adding the following to both the server and the client config files (web.config / app.config)

<dataContractSerializer maxItemsInObjectGraph="2147483646"/>


Wednesday, September 23, 2009

Best Feature of C# 4

Optional Parameters. For real ... C++ had it ... python had it...... Excel required it (which meant that when using excel COM via c# you need to lookup the documentation and put in the default values yourself...) and .. VBA (and therefore VB.net) had it. Sure you had function overloading.... but still this is more fun!

Details of how it works here: http://geekswithblogs.net/michelotti/archive/2009/02/05/c-4.0-optional-parameters.aspx

Enjoy!

Sunday, September 20, 2009

Learning videos for expression suite

I simply admire the Expression Teams effort. Like all microsoft products soon after the release you will find tons of useful video tutorials. For Expression suite you can find them here:
http://expression.microsoft.com/en-us/cc197142.aspx

Enjoy!

Thursday, September 17, 2009

VSTO video tutorials

Here are two great videos from microsoft about the VSTO in VS2008.

Taking Office Development to the Next Level

http://www.microsoft.com/resources/msdn/vstudio/media/en/vstudio2008/OFC342.wvx
The second url is from the entire sequence of VS2008 videos :
http://msdn.microsoft.com/en-us/vstudio/bb655906.aspx

Monday, September 14, 2009

Setting up validation with DevExpress XtraEditors combobox

DevExpress gives a lot of features for the amount of money that you are required to spend. Fact. I like the way everything looks so consistent.

So generally for all controls:
  • Drag and drop DxValidationProvider onto your form.
  • Click the provider.
  • Set validation mode to manual.
  • You will also be get a smart tag for "Customize Validation Rules"
  • Select your control and setup the validation rules.
  • When you want to validate (e.g. on OK button) use something like the following code:
dxValidationProvider1.Validate();
if(dxValidationProvider1.GetInvalidControls().Count!=0)
return;
this.DialogResult = DialogResult.OK;
this.Close();

Done :)

Now for setting up a combobox with valid values as no values along with a list do the following:
  • Select your combobox
  • In its properties expand the properties section.
  • set your selectables in its items collection (with a blank newline as the first line for the empty string)
  • Delete its edit value
  • Launch its validation editor (from DxValidationProvider).
  • Set "Contition Validation" along with "Conditional Operator" as "AnyOf". Edit the values and paste the same items as you did in the items collection.
Enjoy!