I\'ve decided to teach myself C# by writing a music player in Visual Studio 2010. I went with WPF because from what I hear it sounds like it will be a good base to skin from
Well there are a few areas you need to address. First to get notifications that the edge is coming close to the screen:
Then, there is a list of TODOs to work out if the window edge is close to the screen edge.
Whether or not there are multiple monitors and if the window is solely contained within on monitor. This answer will help you get the monitor information.
Handle the action of snapping the edge. Will need a bit of rect arithmetic acrobatics for this one. Then you either set Window.Top, Window.Left, Window.Height or Window.Width.
You will need conditional code for each edge but it will look something like this:
void SnapWindow(Window window, Size monitorSize) {
if (window.Left < c_SnapThreshold && window.Left > 0)
window.Left = 0;
if (window.Left + window.Width > (monitorSize.Width - SnapThreshold) && window.Left + window.Width < monitorSize.Width)
window.Width = monitorSize.Width - window.Left; //docks the right edge
//..etc
}
}