Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '
- '''Docks a window to side of Desktop.
- private void Form1_MouseUp(object sender, MouseEventArgs e)
- {
- Screen screen = Screen.FromControl(this);
- if (OnRight(this))
- {
- Left = (screen.Bounds.Width) - Width;
- Top = (screen.Bounds.Height / 2) - (Height / 2);
- }
- else if (OnLeft(this))
- {
- Left = 0;
- Top = (screen.Bounds.Height / 2) - (Height / 2);
- }
- else if (OnBottom(this))
- {
- Left = (screen.Bounds.Width / 2) - (Width / 2);
- Top = (screen.Bounds.Height) - (Height);
- }
- else
- {
- Left = (screen.Bounds.Width / 2) - (Width / 2);
- Top = 0;
- }
- }
- private bool OnRight(Form1 f)
- {
- Screen screen = Screen.FromControl(f);
- if (Right > (screen.Bounds.Width / 1.5))
- {
- return true;
- }
- else
- return false;
- }
- private bool OnLeft(Form1 f)
- {
- Screen screen = Screen.FromControl(f);
- if (Left < (screen.Bounds.Width * .33))
- return true;
- else
- return false;
- }
- private bool OnBottom(Form1 f)
- {
- Screen screen = Screen.FromControl(f);
- if (Bottom > screen.Bounds.Height * .66)
- return true;
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement