Category ‘C#’ – View all
Monte Carlo Pi
Today we’re gonna calculate pi. You might say, it doesn’t seem too interesting; it’s an old hat. You may be true, but we’re going to calculate pi using a method, other than approximating a circle with a polygon. So here’s what we do:
- We draw the unit circle on our cartesian coordinate system.
- We randomly drop points on the square, which contains our unit circle.
The probability of the point dropping on the circle is
Animating in C# without WPF
One of the fundamental Metro Interface principles is motion. The use of animation is to let the user know where your application is going. It helps the user understand the hierarchy of your application and foreshadow what’s coming.
In Homework, instead of showing another dialogue to let the user edit tasks as in previous versions, I’ve decided to slide in the edit form and slide it out when the user is finished.
Animations with WPF is super easy, but as Homework is not a WPF application, I have to animate controls manually. With a
Timer. So I wrote a class which will make animating nearly as easy as under WPF.
See more after the jump.
Check for updates class
If you write apps for the public you should always keep in mind that you will always improve your apps and publish newer updates by the time. And you have to inform your users about these updates. Especially when you’ve published a very critical bug fix and the user’s life depends on it. Also you can’t expect the user to read your blog regularly and follow everything.
So what now? Well you have to implement a “check for updates” feature in your app. Nothing’s easier than that. And yes, I’m being ironic.
Let’s put us ourselves in the user’s place and reflect on what we, not as developers, but as users, expect a really good updater to be able to do:
- We should be able to turn it off, so it won’t nag us with warnings
- It should automatically check for updates and warn the user if there are any
- It should automatically download, extract, and replace current, old version with the newest version.