Coding Archive

Rhino error – This object cannot be modified because it is controlled by a document

So it’s been a bit busy recently at work writing up literature review notes, preparing for a visit to Trondheim, Norway, and continuing my research into operational modelling and planning for NHS hospitals. One of the key concepts of the development work I am currently undertaking to solve a research aim is the use of

A research update

It’s been a while since my last post here, mainly because I haven’t been working on anything overly complicated. Since June, I’ve been working mostly on a dashboard and paper writing/editing (including the European Healthcare Design Conference), so there hasn’t been much interesting to write. Today though I’ve had a little switch back into some

Excel C# interop – obtaining values from cells

Working with C# and Excel has been discussed on this site before with tips on preventing Excel.exe from hanging and converting integers into Excel column headings. Today’s post is a very brief example on how we can extract data from specific cells of an Excel worksheet. Obtaining a value from a specific cell Assuming we

C# – Getting a list of every ‘color’ from System.Drawing or System.Windows.Media

In C# there are two colour structures in existence for making easy reference to a number of colours without the need to use RGB or Hex codes. However, they tend to be accessible only by typing their name – there isn’t an easy way to simply obtain a random colour from these structures. But if

C# WPF – Convert colour to brush for UI styling

Something that may be occasionally frustrating is trying to quickly colour a UI element on a WPF window programmatically when you know the colour code, or maybe even have a ‘color’ variable storing the colour for you. There can be various ways to do this depending on how you have your colour stored, so this

C# – how to iterate through an enum

Frequently I find I wish to iterate through an enum type to add items to a list or do something with each item. Doing so is simple, but remembering how causes a good few minutes of Google searching, so this post is here as an aid to my memory the next time I wish to

C# adding reference error – Checking a C++ DLL is valid for a C# project

DLLs compatible with C# projects can either be managed or unmanaged. However, if they’re unmanaged, they cannot be included in the project using the standard References->Add Reference->Browse->OK method, as only managed DLLs can be added in .net applications in this method. To add unmanaged DLLs you need to use a form of DLLImport, which I

How to install OpenCV – Windows machines

Since 2012 when I first conducted an OpenCV project as part of my Bachelor’s dissertation at Keele, I have ended up having to install OpenCV about 4 times on various computers. Today is yet another occasion where the need for an installation of OpenCV has been necessitated but, because of the length of time between

Experience, exposure, or just plain exploitation?

If you’re a programmer, you might be used to people asking you how easy it is to develop a game, or code up a website. Sometimes they might ask for advice, or ask if you could help them out with an idea they’ve got. I’ve experienced it and seen it a fair few times in

Preventing Excel.exe from hanging when using the Microsoft Excel Interop DLL with C#

So it’s been a bit quiet around here recently because I’ve been mostly working on a client project at the office which hasn’t included anything onerous that I felt a quick post would be useful to aid future development. Until now. Part of the work I’ve been completing has included working with Microsoft Excel through