Sunday, 16 November 2008

Calculator for Silverlight

Wanna do some math? Be my guest:



Nothing to explain here, I guess... Just your average run-of-the-mill calculator. It's implemented as a custom control, so all you have to do in order to use it is declare it in your XAML file:


<Grid x:Name="LayoutRoot" Background="YellowGreen">
<calculator:Calculator Height="200" Width="300"></calculator:Calculator>
</Grid>


If you don't want to push the buttons with your mouse, you can use the keyboard shortcuts. Of course, the Silverlight plug-in must have the focus. The shortcuts for the digits don't need elaboration, I believe. And here are all the rest:

  • A - Add

  • S - Subtract

  • M - Multiply

  • D - Divide

  • E - Equals

  • C - Clear

  • N - Negate

  • F - Floating point


To be able to work with very large numbers, the Calculator uses my Number class - more about it here.

Well, that's all for now... Happy calculating!

The source code for the Calculator is here.

Regards,
Boyan

0 comments: