| 0: | // FloatingWindow.cs | |
| 1: | // Copyright (C) 2001 Mike Krueger | |
| 2: | // | |
| 3: | // This program is free software; you can redistribute it and/or modify | |
| 4: | // it under the terms of the GNU General Public License as published by | |
| 5: | // the Free Software Foundation; either version 2 of the License, or | |
| 6: | // (at your option) any later version. | |
| 7: | // | |
| 8: | // This program is distributed in the hope that it will be useful, | |
| 9: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 11: | // GNU General Public License for more details. | |
| 12: | // | |
| 13: | // You should have received a copy of the GNU General Public License | |
| 14: | // along with this program; if not, write to the Free Software | |
| 15: | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 16: | ||
| 17: | using System; | |
| 18: | using System.Drawing; | |
| 19: | using System.Collections; | |
| 20: | using System.Windows.Forms; | |
| 21: | ||
| 22: | namespace SharpDevelop.Gui.Docking { | |
| 23: | ||
| 24: | public class FloatingWindow : Form | |
| 25: | { | |
| 26: | DockManager manager; | |
| 27: | DockableControl control; | |
| 28: | bool startup = true; | |
| 29: | ||
| 30: | protected override void OnLocationChanged(EventArgs e) | |
| 31: | { | |
| 32: | if (startup) { | |
| 33: | startup = false; | |
| 34: | return; | |
| 35: | } | |
| 36: | Point rellocation = manager.parent.PointToClient(Location); | |
| 37: | if (manager.parent.ClientRectangle.Contains(rellocation)) { | |
| 38: | if (rellocation.X < 50) | |
| 39: | DockLeft(null, null); | |
| 40: | else | |
| 41: | if (manager.parent.ClientRectangle.Width - rellocation.X < 50 || manager.parent.ClientRectangle.Width - rellocation.X + Width < 50) | |
| 42: | DockRight(null, null); | |
| 43: | else | |
| 44: | if (rellocation.Y < 50) | |
| 45: | DockTop(null, null); | |
| 46: | else | |
| 47: | if (manager.parent.ClientRectangle.Height - rellocation.Y < 50 || manager.parent.ClientRectangle.Width - rellocation.Y + Height < 50) | |
| 48: | DockBottom(null, null); | |
| 49: | } | |
| 50: | ||
| 51: | } | |
| 52: | ||
| 53: | protected override void OnMouseDown(MouseEventArgs e) | |
| 54: | { | |
| 55: | Console.WriteLine("MouseDown"); | |
| 56: | base.OnMouseDown(e); | |
| 57: | } | |
| 58: | ||
| 59: | protected override void OnMove(EventArgs e) | |
| 60: | { | |
| 61: | Point rellocation = manager.parent.PointToClient(Location); | |
| 62: | Console.WriteLine("Move " + rellocation); | |
| 63: | } | |
| 64: | ||
| 65: | public FloatingWindow(DockManager manager, DockableControl control) | |
| 66: | { | |
| 67: | this.manager = manager; | |
| 68: | this.control = control; | |
| 69: | ||
| 70: | control.DockState.Float = true; | |
| 71: | control.FormContainer = this; | |
| 72: | control.formatmenu = new ContextMenu( new MenuItem[] { | |
| 73: | new MenuItem("DockLeft", new EventHandler(DockLeft)), | |
| 74: | new MenuItem("DockRight", new EventHandler(DockRight)), | |
| 75: | new MenuItem("DockBottom", new EventHandler(DockBottom)), | |
| 76: | new MenuItem("DockTop", new EventHandler(DockTop)) | |
| 77: | }); | |
| 78: | ||
| 79: | ShowInTaskbar = false; | |
| 80: | Text = control.WindowName; | |
| 81: | TopMost = true; | |
| 82: | Owner = manager.parent; | |
| 83: | FormBorderStyle = FormBorderStyle.SizableToolWindow; | |
| 84: | Controls.Add(control); | |
| 85: | } | |
| 86: | ||
| 87: | ||
| 88: | void DockLeft(object sender, EventArgs e) | |
| 89: | { | |
| 90: | control.DockState.DockedIn = DockedIn.LeftContainer; | |
| 91: | manager.left.AddDockableControl(control); | |
| 92: | Close(); | |
| 93: | } | |
| 94: | ||
| 95: | void DockRight(object sender, EventArgs e) | |
| 96: | { | |
| 97: | control.DockState.DockedIn = DockedIn.RightContainer; | |
| 98: | manager.right.AddDockableControl(control); | |
| 99: | Close(); | |
| 100: | } | |
| 101: | void DockTop(object sender, EventArgs e) | |
| 102: | { | |
| 103: | control.DockState.DockedIn = DockedIn.TopContainer; | |
| 104: | manager.top.AddDockableControl(control); | |
| 105: | Close(); | |
| 106: | } | |
| 107: | void DockBottom(object sender, EventArgs e) | |
| 108: | { | |
| 109: | control.DockState.DockedIn = DockedIn.BottomContainer; | |
| 110: | manager.bottom.AddDockableControl(control); | |
| 111: | Close(); | |
| 112: | } | |
| 113: | ||
| 114: | } | |
| 115: | } |
This page was automatically generated by SharpDevelop.