| 0: | // DockableControl.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: | using System.Xml; | |
| 22: | ||
| 23: | using SharpDevelop.Tool.Data; | |
| 24: | ||
| 25: | using TimeSprint.Alexandria.UI.Tab; | |
| 26: | ||
| 27: | namespace SharpDevelop.Gui.Docking { | |
| 28: | ||
| 29: | public enum DockedIn { | |
| 30: | LeftContainer, | |
| 31: | RightContainer, | |
| 32: | TopContainer, | |
| 33: | BottomContainer | |
| 34: | } | |
| 35: | ||
| 36: | public class DockState : IXmlConvertable | |
| 37: | { | |
| 38: | public bool Visible = true; | |
| 39: | public bool Float = true; | |
| 40: | ||
| 41: | public Rectangle Bounds = new Rectangle(0, 0, -1, -1); | |
| 42: | public DockedIn DockedIn = DockedIn.LeftContainer; | |
| 43: | ||
| 44: | public DockState() | |
| 45: | { | |
| 46: | ||
| 47: | } | |
| 48: | ||
| 49: | public DockState(XmlElement element) | |
| 50: | { | |
| 51: | string[] boundstr = element.InnerText.Split(new char [] {'|'}); | |
| 52: | ||
| 53: | Bounds = new Rectangle (Int32.Parse(boundstr[0]), | |
| 54: | Int32.Parse(boundstr[1]), | |
| 55: | Int32.Parse(boundstr[2]), | |
| 56: | Int32.Parse(boundstr[3])); | |
| 57: | ||
| 58: | Visible = Boolean.Parse(element.Attributes["Visible"].InnerText); | |
| 59: | Float = Boolean.Parse(element.Attributes["Floating"].InnerText); | |
| 60: | ||
| 61: | DockedIn = (DockedIn)Enum.Parse(typeof(DockedIn), element.Attributes["DockedIn"].InnerText); | |
| 62: | } | |
| 63: | ||
| 64: | public object FromXmlElement(XmlElement element) | |
| 65: | { | |
| 66: | return new DockState(element); | |
| 67: | } | |
| 68: | ||
| 69: | public XmlElement ToXmlElement(XmlDocument doc) | |
| 70: | { | |
| 71: | XmlElement element = doc.CreateElement("DockState"); | |
| 72: | ||
| 73: | element.InnerText = Bounds.X + "|" + | |
| 74: | Bounds.Y + "|" + | |
| 75: | Bounds.Width + "|" + | |
| 76: | Bounds.Height; | |
| 77: | ||
| 78: | XmlAttribute attr1 = doc.CreateAttribute("Floating"); | |
| 79: | attr1.InnerText = Float.ToString(); | |
| 80: | element.Attributes.Append(attr1); | |
| 81: | ||
| 82: | XmlAttribute attr2 = doc.CreateAttribute("Visible"); | |
| 83: | attr2.InnerText = Visible.ToString(); | |
| 84: | element.Attributes.Append(attr2); | |
| 85: | ||
| 86: | XmlAttribute attr3 = doc.CreateAttribute("DockedIn"); | |
| 87: | attr3.InnerText = DockedIn.ToString(); | |
| 88: | element.Attributes.Append(attr3); | |
| 89: | ||
| 90: | return element; | |
| 91: | } | |
| 92: | } | |
| 93: | ||
| 94: | public class DockableControl : Panel | |
| 95: | { | |
| 96: | public string WindowName = ""; | |
| 97: | public string TabName = ""; | |
| 98: | public Form FormContainer = null; | |
| 99: | public AxTabControl TabControl = null; | |
| 100: | public AxTabPage TabPage = null; | |
| 101: | public Bitmap Icon = null; | |
| 102: | int tabnumber = 0; | |
| 103: | ||
| 104: | DockState dockstate = new DockState(); | |
| 105: | ||
| 106: | public event EventHandler DockedVisibleChanged; | |
| 107: | ||
| 108: | public void ShowDockedControl() | |
| 109: | { | |
| 110: | dockstate.Visible = true; | |
| 111: | Show(); | |
| 112: | if (FormContainer != null) | |
| 113: | FormContainer.Show(); | |
| 114: | if (TabControl != null) { | |
| 115: | TabPage.TabFlap.Visible = true; | |
| 116: | } | |
| 117: | ||
| 118: | if (DockedVisibleChanged != null) | |
| 119: | DockedVisibleChanged(this, null); | |
| 120: | } | |
| 121: | ||
| 122: | public void HideDockedControl() | |
| 123: | { | |
| 124: | dockstate.Visible = false; | |
| 125: | Hide(); | |
| 126: | if (FormContainer != null) | |
| 127: | FormContainer.Hide(); | |
| 128: | if (TabPage != null) { | |
| 129: | tabnumber = TabControl.TabPages.IndexOf(TabPage); | |
| 130: | TabPage.TabFlap.Visible = false; | |
| 131: | } | |
| 132: | if (DockedVisibleChanged != null) | |
| 133: | DockedVisibleChanged(this, null); | |
| 134: | } | |
| 135: | ||
| 136: | public DockState DockState { | |
| 137: | get { | |
| 138: | if (FormContainer != null) | |
| 139: | dockstate.Bounds = FormContainer.Bounds; | |
| 140: | return dockstate; | |
| 141: | } | |
| 142: | set { | |
| 143: | dockstate = value; | |
| 144: | if (dockstate == null) | |
| 145: | dockstate =new DockState(); | |
| 146: | } | |
| 147: | ||
| 148: | } | |
| 149: | public ContextMenu formatmenu = null; | |
| 150: | MouseEventArgs meventargs; | |
| 151: | ||
| 152: | protected void OnMouseDown(object sender, MouseEventArgs e) | |
| 153: | { | |
| 154: | meventargs = e; | |
| 155: | base.OnMouseDown(e); | |
| 156: | } | |
| 157: | ||
| 158: | protected void OnClick(object sender, EventArgs e) | |
| 159: | { | |
| 160: | base.OnClick(e); | |
| 161: | ||
| 162: | if (meventargs.Button == MouseButtons.Middle && formatmenu != null) { | |
| 163: | formatmenu.Show(this, new Point(meventargs.X, meventargs.Y)); | |
| 164: | } | |
| 165: | } | |
| 166: | ||
| 167: | public DockableControl() | |
| 168: | { | |
| 169: | Dock = DockStyle.Fill; | |
| 170: | } | |
| 171: | } | |
| 172: | } |
This page was automatically generated by SharpDevelop.