Hang on to your pants… this is going to be a long one :) Or maybe I’ll do all my topics as 2 posts. First thing is my adventures in GDI+. With WPF coming out I realize many may not care about GDI anymore, but for some poor souls ( me ) we still have to deal with GDI. I recently got the idea to create a Ghant chart to map some stuff out. How did I do this?

Warning: Winform app ahead

1. Create a DataGridView.
2. Add 2 columns.
* 1. A new textbox column, to hold the text.
* 2. A new image column that we will be filling with an image we will draw.

So now what? Well we have to draw the image. For a Ghant chart we have to calculate an offset, the start date of the event vs the start date of the chart. Then we have to calculate the length of the event. These two measurements will let us know how to draw our rectangle.

So how do we figure this out? Create a start date tick mark, which can be a label. This tick mark will have a pixel X Position. You will also create an end date tick mark. That will have an X Position value too. Subtract the end X value from the start and BAM you have your pixel representation of your date range. To figure out what 1 day would be for example divide the value you just got by the number of days between the start and end date.

So now for the GDI part::

Dim g As System.Drawing.Graphics
Dim rect As Rectangle
Dim style As DataGridViewCellStyle
Dim oimgtemp As Bitmap

‘– IMAGE ———-
oimgtemp = New Bitmap(Me.dgTimeline.Columns(1).Width, 25)

g = Graphics.FromImage(oimgtemp)

iOffset = dtStart.Subtract(Me.StartDate).Days * GetPixelDateRange()
iRange = dtEnd.Subtract(dtStart).Days * GetPixelDateRange()

‘– DRAW RECTANGLE —————-
rect = New Rectangle(iOffset , 1, iRange , 22)
g.DrawRectangle(Pens.Black, rect)
g.FillRectangle(Brushes.CornflowerBlue, rect)

‘– DRAW THE IMAGE ———————–
g.DrawImage(oimgtemp, rect, rect, GraphicsUnit.Pixel)

‘– SET IMAGE IN GRID ——————-
Me.dgTimeline.Item(1, iRow).Value = oimgtemp

Now, that is not all the code I wrote, but it should give you a good idea of how to do that. You have to loop through your rows or do that on bind, either works. I imagine the same thing could be done on the web.

Onto the next thing, I had an issue on my new Mac Book Pro where I kept seeing a process called ATSServer going completely nuts and taking up 50 – 60 % of one of the cores. So I searched and searched and found a ton of stuff that pointed me to fixing my broken font cache to fix ATSServer.

I nuked my font cache a few times, rebooted, and then BAM it came back and it was back up to 50 – 60 % CPU usage…Crap….Well I also noticed that there was some Metadata process running. So I put 2 and 2 together and figured that it was Spotlight indexing the 12gb I had just copied to the hard drive. So since I don’t actually use Spotlight ever, I disabled it. Soon as I did that and rebooted the process was at 0.0% . If you don’t know how to disable spotlight just google it, there are tons of people that have done it.