To slide down, you need to change
Location
and/or
Size
of your wallpaper-showing window. Start near the top, then gradually set your window to move lower and lower.
That for you will need some events to trigger the Location change. Typically you would use a
System.Windows.Forms.Timer
set to
Interval = 40
ms.
I personally would also run a
System.Diagnostics.Stopwatch
to control the window motion. Timer to create the event, Stopwatch to process exact location. This is because
Stopwatch.ElapsedMilliseconds
's precision is a lot better than that of a
Forms.Timer
.
So you would have something like
double panningTimeMs = 500D;
private void PanningTimer_Tick( object sender, EventArgs e)
{
int elapsedMilliseconds = _panningStopwatch.ElapsedMilliseconds;
if( elapsedMilliseconds > panningTimeMs)
{
_panningTimer.Stop();
elapsedMilliseconds = panningTimeMs;
}
int windowTop = -this.Height + ( this.Height * elapsedMilliseconds / panningTimeMs);
this.Location = new System.Drawing.Point( this.Location.X, windowTop);
}
For detecting the upwards slide, override
OnMouseDown
. Check mouse position and decide whether it qualifies as movement starting point. Set a member field if it does.
Override
OnMouseMove
and check whether you're in sliding mode (that's what the member field was for). If so, check mouse position. If it is far enough up the screen, remove the lock.
Finally, override
OnMouseUp
as well and check for sliding mode. Reset the mentioned member field if mouse position is still to near the bottom to release lock.
For the extra double-lock button, you could use a
System.Windows.Forms.CheckBox
with
Appearance = Appearance.Button
. If checked, the button will remain pressed, until you uncheck it. You could then check the
Checked
property to determine if you do all the other sliding stuff.