Using LINQ to list all duplicates

posted on 11 March 2011 in programming

There’s plenty of examples on how to find duplicates using LINQ’s GroupBy method, but usually they use a projection to return a new object, like this:

_filteredSubmissions = (from s in _filteredSubmissions
                        group s by s.Email
                        into g
                        where g.Count() > 1
                        select new { Emails = g.Key, DuplicateCount = g.Count() }
Read Article

Unindent in Expression Blend

posted on 14 February 2011 in programming

Unindenting in Expression Blend drove me mad, I just couldn’t get it to work. Today I figured out why.

The code I am copying from Visual Studio uses spaces for indentation, in Blend I was using tabs, this means when I paste code from VS, Blend doesn’t see any tabs to ‘unindent’.

Simple solution - make sure your Visual Studio indentation settings match your Blend settings.

Read Article

WPF RadioButton Binding to IsChecked Property

posted on 08 July 2010 in programming

I wasted a few development hours discovering this strange behaviour when binding to the IsChecked property of a RadioButton in WPF when using MVVM. You can read about the issue on the MSDN forum, but from my experience if you have a two way binding on the is IsChecked property of a RadioButton which is part of a group, then after you set the bound property in code a couple of times, the RadioButton loses it’s binding all together.

Read Article

Logging Messages in Dot Net

posted on 17 June 2010 in programming

The .Net Framework provides an easy way to log messages using the System.Diagnostics.Trace class. By using Trace the user can configure where and what to log in the config file.

Below are two simple ways to log a message to a text file.

Read Article

phreplace Goes Open Source

posted on 14 June 2010 in general

I’ve decided to release phreplace as open source software in order to continue it’s development, I no longer have the time to give it the attention it requires.

The VB6 source code will be released under the GNU Lesser General Public License (LGPL), in my understanding this means that anyone can use phreplace and even include the library in a greater works (e.g. PSPad), however if they modify the code it must be released under a similar open source library, in order that everyone will benefit from the changes.

The source code is available at Assembla, feel free to send any code changes to me to be included in the project.

Read Article

IE Autocomplete Doesn't Fire onchange Event Handler

posted on 17 April 2010 in programming

While testing an ASP validation control in Internet Explorer I found that the validation wasn’t triggered if I selected an item from the autocomplete list for a text box, this was the same in Safari for Windows, but worked fine in Mozilla Firefox. What?!

IE form autocomplete feature

Read Article

Registering phreplace DLL in Windows Vista

posted on 17 March 2010 in programming

phreplace is a VB6 DLL which is called from a vbscript plugin for PSPad. The script tests to see if the correct version of the DLL is registered on this computer, if not it registers it using regsvr32. This works fine in XP but not Vista where the script will error.

A while ago a user pointed out to me this article on Experts Exchange explaining why administrative rights are required to register a DLL in Windows Vista, in the hopes that we could automate the registration of phreplace in Vista.

Read Article

No Validation Messages when Disabling & Enabling ASP.Net Validator in Javascript

posted on 04 March 2010 in programming

Need to validate a form field based on the value of another field in ASP.Net? The .Net Framework provides a javascript function to do just that:

ValidatorEnable(val, enable)

This function takes the validator control (val) and a boolean to determine whether it should be enabled or disabled. The problem with this function is that it triggers the validator to validate itself immediately, showing any validation error messages before the user has submitted the form, which may not always be want you want.  The alternative is to set the validator’s enabled property to trigger this validator to validate itself when the user submits the form, and by using the Page_IsValid variable you can test whether the user has triggered a validation or not, then use ValidatorEnable function only after the validation has occurred when the user expects to see validation messages.

Read Article

Converting Topfield PVR Recordings

posted on 14 February 2010 in general

This weekend I’ve been having fun moving some recording off the full hard drive of my Topfield Masterpiece and trying to convert them into the formats I want. Below is what I’ve learnt in the process, this is only going to be useful to those using Windows.

Read Article

Create a PDF using the .Net ReportViewer control

posted on 25 November 2009 in programming

Need to generate a pdf programmatically in dot net? You could purchase an HTML to PDF converter and worry about getting the page to format nicely for paper, or you could use the freely available ReportViewer control from Microsoft.

Microsoft offers SQL Server Reporting Services (SSRS) with SQL Server 2005 and later editions to generate and publish reports using the Report Definition Language (RDL), as an alternative to Crystal Reports. SSRS requires a Report Server to publish reports to so they can be useful, however they also offer a ASP.Net or Windows Forms component called the ReportViewer which we can use in our code without the need for any SQL database to generate reports, and these reports can be saved as Excel files, PDF’s or images.

Read Article