Then use this line:
AppDomain.CurrentDomain.BaseDirectory
Xml Serialisation (Serialization) in C# -
One thing I absolutely hate doing is reading xml, it bores me to bits. So to make this dreadful task a little more easier I use a nice little extension function that I found (and improved; then put up on stackoverflow). If you mark a class with the XmlSerialization attributes (XmlRoot/XmlElement) you can quickly take an xml string and turn it in to an object.
I built this quite a while ago - some one might find it useful.
The other day I had to create an image element that contained a png with transparent sections and have it display a hand cursor when the mouse was over the opaque sections.
The first thing I tried (and failed) was to have an image element with the cursor property set to “Hand” like so:
<Image Source=”{Binding SomeImage}” Cursor=”Hand” />
That obviously never worked so I was forced to look at each individual pixel and see if it was transparent. What I ended up with was a function that generated a bunch of coordinates.
This is that function:
private static Dictionary<Point, object> FindTransparentPixelCoordinates(BitmapSource source)
{
var points = new Dictionary<Point, object>();
// Convert the source if the pixel format is not what we expect
if (source.Format != PixelFormats.Bgra32)
{
source = new FormatConvertedBitmap(source, PixelFormats.Bgra32, null, 0);
}
int width = source.PixelWidth;
int height = source.PixelHeight;
var bytes = new byte[width * height * 4];
source.CopyPixels(bytes, width * 4, 0);
var position = 0;
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var byteOffset = position;
// The pixel format is stored as 32-bits (4 bytes) with the last byte being the alpha
if (bytes[byteOffset + 3] == 0)
{
points.Add(new Point(x, y), null);
}
position += 4;
}
}
return points;
}
Fantastic site that keeps me updated on all the goings on around .Net / Development.
Chimp TV -
The chimps chose a good score to accompany their film ;)
Invaluable resource for getting start with touch and WPF 4. Helped out greatly when developing the touch features of the graphic.ly WPF app.
[video]
Until I can think of something to write for this I’ll start off by telling you all little about my self. In bullet form of course ;)
That’s it for now…
Cheerio
P.S.
I’m also online else where: