Center aligning the buttons in a Windows Form
I was trying to align some buttons in the center of a windows form. I was tried to find any properties in a button can set it to be center aligned. But there is no such property! I tried to use layout controls. The table layout control can be very similar stuff. That is still not what I want. Of course, I can do it in the windows resizing, changing the button positions by codes. But that is too complex! Finally, I found a simple way. I just drop a panel at the center position and set no achor. I think that makes it flow at the center.
And then, you can drop buttons in the panel and set their achor property to "Top, Bottom, Left, Right"
Then it will move to the center position when the windows is resized.
Sqlite is good for a standalone system
I have been asked to build a library management system for my church. That is very very simple system. The system only needs to track the borrow records. I don't think that even needs a database. Orginally, I planned to use serialization for storing the records. But if in future, they want the records to be viewable on our church website as well. Then I need to port the records to the database and change the application to use a database. OK, maybe, that is good to install mySQL in the computer. Well, that is too over-kill the resources. So, I found Sqlite. It can relpace the flat system to store the record. Moreover, it has an ADO.Net driver and is fully supported by NHibernate. In the future, I can port the codes to another database technology by changing database driver in NHibernate. Finally, I chose Sqlite as the data storage.
Visual Studio 2010
Now is 2010. So, I think Visual Studio 2010 will be released not far away. That is in Beta 2 now.
Then I think that is a good idea to watch an overivew video of Visual Studio 2010 from MSDN
There are some new key features in Visual Studio 2010. It got the support for parallel programming(that is good for Multi-cores CPU), MVC 2 and a new Managed Extensibility Framework(That is a component technology, it makes the developers can be easier to develop visual studio plug-ins). And for IDE, that is completely built on WPF and the startup page is a xaml file. So, the user can customize the startup page.
That sounds a lot of improvements.
Write a wav file player in C#
That is a bit hard to write a mp3 player in C#. I think you may need to find third party mp3 decoder dll. But if you only want to play to a wav file, that is very easy. .Net libraries already have a control class for you.
Code
System.Media.SoundPlayer |
All you need to put the file name into the constructor
Code
SoundPlayer player = new SoundPlayer(FileName); |
Then you can play and stop the file by these methods:
Code
player.Play(); | |
player.Stop(); |
This afternoon, I wrote an example project for this. Moreover, this project is implemented in WPF rather than normal Windows Forms, because I wish to practice my WPF skills.
Download the example project, please click here.
C# to Skype
I found Skype has API for developers. I can using Skype4COM to allow my C# code to access Skype, so that I can make a call or send a SMS via Skype from my C# application.
There are a lot of detialed tutorials in this URL:
https://developer.skype.com/Docs/Skype4COM/Example?action=show