i have this code which allows you to draw polygon but i don't know how to implement the formula to calculate the area of the polygon (the formula is in the end of the code).

I think the 'C' function to calculate area is flawed. You should go back to the site you obtained it from and make sure you have copied it correctly. Pay particular attention to the signs of the terms.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com