Tuesday, November 27, 2007

Copy an ArrayList in VB.NET

Say you have the following two arraylists, A, B

You can't just do A = B to copy A to B. It will just create a
reference to B (so when you modify B, A will be modified as well).

In order to copy it, you need to do the following

A = new ArrayList(B)

Thursday, November 15, 2007

How to creating a larger arrowhead when drawing lines in VB.NET

To attach an arrow to the end of a line in VB.NET, you just need to do
the following:

Dim aPen as Pen = New Pen(Color.Red)
aPen.EndCap = LineCap.ArrowAnchor

Then when you draw the line, you specify the pen created above as the
pen for the line. The problem with this approach is that the size of
the arrow depends on the size of the line, in this case, our line is
of pixel width = 1, if we create a larger line we will have a larger
arrow, but what if you don't want a larger line, but do want a larger
arrowhead (the arrowhead with a line of 1 pixel is so small that its
hard to even see it).

Here we create a Custom Cap. Below is the code:
Dim aPen as Pen = New Pen(Color.Red)
Dim mycap As CustomLineCap = New AdjustableArrowCap(5, 5)
aPen.EndCap = LineCap.ArrowAnchor
aPen.CustomEndCap = mycap

Now the arrowhead will be 5 pixel by 5 pixels, which is a decent enough size.

Wednesday, November 14, 2007

What's New and Different in VB .NET

A good (and short) overview of changes from VB to VB.NET
http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnetnut_appa/index.html?page=1

Find the angle between two line segments - VB6 and VB.NET

This website gives you the code to get the angle between two line
segments. The code is in VB6, but to convert it to VB.NET all you
have to do is change "Abs" to System.Math.Abs and "atn" to
System.Math.ATAN

http://www.vb-helper.com/howto_find_angles.html

Testing out the blog

This is a test of emailing blogs.

Adjust the position of the question container

Today I had a problem where I wanted to adjust the position of the question container (it was going off the screen), but I couldn't do it. I tried calling GetQuestionContainerPosition, but that didn't work. What ended up working was calling SetQuestionPositionAndAskQuestion. I called this after setting up the position, and it positioned it correctly.