Custom Membership Provider
Custom Membership Provider is easy to do. Firstly, please extends MembershipProvider
Code
public class AdvCMSMembershipProvider : MembershipProvider |
Secondly, Right Click MembershipProvider, and then implements all abstract methods.
The only method you need to change:
Code
public override bool ValidateUser(string username, string password) | |
{ | |
IAdvUser user = userRepository.GetByUserName(username); | |
| |
return user.Password == password; | |
} |
Lastly, chaging web.config
Code
<membership defaultProvider="AdvCMSMembershipProvider"> | |
<providers> | |
<clear/> | |
<add name="AdvCMSMembershipProvider" | |
type="AdvCMS.Security.AdvCMSMembershipProvider, AdvCMS.Security" /> | |
</providers> | |
</membership> |
Please download our opensource project, AdvGenCMS, as the example.
Timer in WPF
In Windows Form time, there is a component for Timer. But in WPF, there is not such things. So, what thing we can do, when we need to execute a piece of code periodically. We can use the timers under System.Timers. But please do not use System.Timers.Timer, because it triggered, it will execute the code in a new thread. If you try to access any controls in WPF Windows, the system will throw an exception. I like to use System.Windows.Threading.DispatcherTimer in WPF, because that is very similar with the Timer in Windows Timer.
There are the example code:
Code
DispatcherTimer sysTimer = new DispatcherTimer(); | |
sysTimer.IsEnabled = true; | |
sysTimer.Interval = new TimeSpan(0, 0, 1); | |
sysTimer.Tick += new EventHandler(sysTimer_Tick); |
To find more about this, please download the example project, AdvGenStopWatch.
WPF Example Code - AdvGenStopWatch
I created an opensource project, AdvGenStopWatch. This is a simple stop watch program and aimed to show how to use WPF. Including the following features:
- How to use Grid Layout and ViewPoint, this make all elements will be autosize.
- How to use Timer in WPF
- How to use ListView
I believe this is a good starting point to learn WPF.
FireBug in Server Side for .Net
Yesterday, I went to the QLD MSDN User Group Meeting. One of presenters shows his opensource project, Glimpse. That is very very cool! This project is a Server Side version of FireBug in .Net. It will add a collapsible div at the bottom of page. In the div, all about the current request, including the server variable and session id, even MVC route. That is so cool! In addition, inside your code, you can add the track and the div will show them as well. Lastly, there is a remote tab inside this div. In the remote tab, you get the request information about the other clients which are on the same application. That is very helpful to mobile development. You can go into a page in the desktop and access the request information which is from the other mobile clients, rather than directly accessing them from a mobile device. I highly recommend to spend some time on learning this project!
Windows 8 Boot Camp
I went to Windows 8 Boot Camp today. I got a lot of new information about Windows 8. First of all, Windows 8 is not just for desktop. It is for touch devices too and supports ARM CPU as well as Intel. I think Microsoft wants Windows to works in Tablet too!
Secondly, for making Windows works in touch devices, Metro UI is introduced in Windows. In old UI, that was trying to use abstract graphics as representation for physical object. Metro is completely different. This UI thinks in a digital way. It changes the way to operate Windows. There are not Windows in Metro. Instead of Tiles, Snap, App Bar, they are Context Oriented UI and is easier to operate in touch devices. At the start screen, there are a lot of square blocks which are Tiles. They will shows some information from apps to you. Snap is a lot of side bar which contains a stream of Information, such as Tweets. Also, Metro contains some new gestures to operate the system. For example, dragging the current screen to the bottom is to close the current apps. Well, those gestures are not just for the touch version, for mouse version as well. For example, using the mouse to click the top left corner means switching the apps. That is a bit hard to understand that.
Lastly, Windows 8 will integrate with MicrosoftID which is your live account. You need to login with MicrosoftID to enter Windows 8. In this way, you can bring your preference to different machines via logging with a same MicrosoftID. Also, if you wants to use Metro apps, you need to use MicrosoftID. All metro apps will get from Windows Store which is the Microsoft version apps store. This is very similar with getting mobile phone apps. You login to Windows Store with your MicrosoftID. Then you pick the app in the store. It will download the software package and install for you! This MicrosoftID concept makes Windows 8 works in a similar way as the current smart phone OS such as iOS and Android.
That is very exciting! That sounds we have an OS works in Desktop and mobile devices!
P.S. Windows 8 is still keeping the old desktop windows UI. In Start screen, that is a Tile calls Desktop. Clicking this tile, you can see a UI similar with Windows 7, but that is without "Start" button.