internal int Add(DockPane pane)
		{
			if (InnerList.Contains(pane))
				return InnerList.IndexOf(pane);

			return InnerList.Add(pane);
		}
		internal void Add(DockPane pane, DockPane paneBefore)
		{
			if (paneBefore == null)
				Add(pane);
			else
				InnerList.Insert(IndexOf(paneBefore), pane);
		}
示例#3
0
		public void BeginDragPane(DockPane pane)
		{
			if (!InitDrag(pane, DragSource.Pane))
				return;

			Pane_BeginDrag();
		}
		protected internal DockPaneCaptionFromBase(DockPane pane) : base(pane)
		{
			

			SuspendLayout();

			Font = SystemInformation.MenuFont;

			m_buttonClose = new InertButton(ImageCloseEnabled, ImageCloseDisabled);
			m_buttonAutoHide = new InertButton();

			m_buttonClose.ToolTipText = ToolTipClose;
			
			m_buttonClose.Anchor = AnchorStyles.Top | AnchorStyles.Right;
			m_buttonClose.Click += new EventHandler(this.Close_Click);

			m_buttonAutoHide.ToolTipText = ToolTipAutoHide;
			m_buttonAutoHide.Anchor = AnchorStyles.Top | AnchorStyles.Right;
			m_buttonAutoHide.Click += new EventHandler(AutoHide_Click);

			m_buttonWhatIsIt = new InertButton();
			m_buttonWhatIsIt.BackColor = ColorMixer.LightColor;
			m_buttonWhatIsIt.ForeColor = ColorMixer.DarkColor;
			m_buttonWhatIsIt.ToolTipText = "What is this?";
			m_buttonWhatIsIt.Text = "?";
			m_buttonWhatIsIt.Anchor = AnchorStyles.Top | AnchorStyles.Right;
			m_buttonWhatIsIt.Click+=new EventHandler(m_buttonWhatIsIt_Click);


			Controls.AddRange(new Control[]	{	m_buttonWhatIsIt, m_buttonClose, m_buttonAutoHide });

			ResumeLayout();
		}
示例#5
0
		private void InternalConstruct(DockPanel dockPanel, DockPane pane, bool boundsSpecified, Rectangle bounds)
		{
			if (dockPanel == null)
				throw(new ArgumentNullException(ResourceHelper.GetString("FloatWindow.Constructor.NullDockPanel")));

			m_dockList = new DockList(this);

			FormBorderStyle = FormBorderStyle.SizableToolWindow;
			ShowInTaskbar = false;
			
			SuspendLayout();
			if (boundsSpecified)
			{
				Bounds = bounds;
				StartPosition = FormStartPosition.Manual;
			}
			else
				StartPosition = FormStartPosition.WindowsDefaultLocation;

			if (Environment.Version.Major == 1)
			{
				m_dummyControl = new DummyControl();
				m_dummyControl.Bounds = Rectangle.Empty;
				Controls.Add(m_dummyControl);
			}

			m_dockPanel = dockPanel;
			Owner = DockPanel.FindForm();
			DockPanel.AddFloatWindow(this);
			if (pane != null)
				pane.FloatWindow = this;

			ResumeLayout();
		}
		internal void AddAt(DockPane pane, int index)
		{
			if (index < 0 || index > InnerList.Count - 1)
				return;
			
			if (Contains(pane))
				return;

			InnerList.Insert(index, pane);
		}
示例#7
0
		internal void Add(DockPane pane)
		{
			if (pane == null)
				return;

			DockList oldDockList = (pane.DockListContainer == null) ? null : pane.DockListContainer.DockList;
			if (oldDockList != null)
				oldDockList.InternalRemove(pane);
			InnerList.Add(pane);
			if (oldDockList != null)
				oldDockList.CheckFloatWindowDispose();
		}
		public bool ContainsPane(DockPane pane)
		{
			if (pane.IsHidden)
				return false;

			for (int i=0; i<m_states.Length; i++)
			{
				if (m_states[i].DockState == pane.DockState && m_states[i].Selected)
					return true;
			}
			return false;
		}
		/// <include file='CodeDoc/DockPaneStripBase.xml' path='//CodeDoc/Class[@name="DockPaneStripBase"]/Construct[@name="(DockPane)"]/*'/>
		protected internal DockPaneStripBase(DockPane pane)
		{
			m_dockPane = pane;

			#if FRAMEWORK_VER_2x
			SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
			#else
			SetStyle(ControlStyles.DoubleBuffer, true);
			#endif

			SetStyle(ControlStyles.Selectable, false);
		}
示例#10
0
		private void SetActivePane()
		{
			DockPane value = (ActiveContent == null ? null : ActiveContent.DockHandler.Pane);

			if (value == m_activePane)
				return;

			if (m_activePane != null)
				if (m_activePane.IsActivated)
					DockPanel.Focus();

			m_activePane = value;
		}
		/// <include file='CodeDoc/DockPaneCaptionBase.xml' path='//CodeDoc/Class[@name="DockPaneCaptionBase"]/Construct[@name="(DockPane)"]/*'/>
		protected internal DockPaneCaptionBase(DockPane pane)
		{
			m_dockPane = pane;

			#if FRAMEWORK_VER_2x
			SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
			#else
			SetStyle(ControlStyles.DoubleBuffer, true);
			#endif
			SetStyle(ControlStyles.ResizeRedraw, true);
			SetStyle(ControlStyles.UserPaint, true);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			SetStyle(ControlStyles.Selectable, false);
		}
		/// <include file='CodeDoc/DockPaneCaptionVS2003.xml' path='//CodeDoc/Class[@name="DockPaneCaptionVS2003"]/Construct[@name="(DockPane)"]/*'/>
		protected internal DockPaneCaptionVS2003(DockPane pane) : base(pane)
		{
			SuspendLayout();

			Font = SystemInformation.MenuFont;

			m_buttonClose = new InertButton(ImageCloseEnabled, ImageCloseDisabled);
			m_buttonAutoHide = new InertButton();

			m_buttonClose.ToolTipText = ToolTipClose;
			m_buttonClose.Anchor = AnchorStyles.Top | AnchorStyles.Right;
			m_buttonClose.Click += new EventHandler(this.Close_Click);

			m_buttonAutoHide.ToolTipText = ToolTipAutoHide;
			m_buttonAutoHide.Anchor = AnchorStyles.Top | AnchorStyles.Right;
			m_buttonAutoHide.Click += new EventHandler(AutoHide_Click);

			Controls.AddRange(new Control[]	{	m_buttonClose, m_buttonAutoHide });

			ResumeLayout();
		}
示例#13
0
        public void Load()
        {
            Application.MainForm.MainMenuStrip.Visible = true;
            Application.Tabs.Diagram.Show();
            Application.Tabs.Diagram.ChangeToolbarVisibility(DiagramMenuStrip.All, false);
            Application.WebBrowser.Navigate("root/addins/Yttrium/index.htm");
            Application.Tabs.WebBrowser.Show(Application.MainForm.DockPanel, Netron.Neon.WinFormsUI.DockState.DockLeft);
            
            //new Form2().Show(Application.MainForm.DockPanel, DockState.Float);
            //this show the control panel in floating mode
            controlPanel = new ControlPanel();
            //controlPanel.Show(Application.MainForm.DockPanel, Netron.Neon.WinFormsUI.DockState.Float);

            //this shows the control panel in a sub-level of the diagram control
            DockPane pane = new DockPane(Application.Tabs.Diagram, DockState.Document, true); 
            controlPanel.Show(pane, DockAlignment.Bottom, 0.1);

            //add a new channel especially for Yttrium, I must admire your work I guess ;-)
            Application.Output.AddChannel("Yttrium output");
            //change the color of the diagramming background
            Application.Diagram.BackColor = Color.FloralWhite;
        }
		private void ResumeSetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
		{
			ResumeSetDockState();
			SetDockState(isHidden, visibleState, oldPane);
		}
示例#15
0
		/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SetPaneIndex(DockPane, int)"]/*'/>
		public void SetPaneIndex(DockPane pane, int index)
		{
			int oldIndex = Panes.IndexOf(pane);
			if (oldIndex == -1)
				throw(new ArgumentException(ResourceHelper.GetString("DockPanel.SetPaneIndex.InvalidPane")));

			if (index < 0 || index > Panes.Count - 1)
				if (index != -1)
					throw(new ArgumentOutOfRangeException(ResourceHelper.GetString("DockPanel.SetPaneIndex.InvalidIndex")));
				
			if (oldIndex == index)
				return;
			if (oldIndex == Panes.Count - 1 && index == -1)
				return;

			Panes.Remove(pane);
			if (index == -1)
				Panes.Add(pane);
			else if (oldIndex < index)
				Panes.AddAt(pane, index - 1);
			else
				Panes.AddAt(pane, index);
		}
示例#16
0
 private void SetVisibleContentsToPane(DockPane pane)
 {
     SetVisibleContentsToPane(pane, ActiveContent);
 }
示例#17
0
        private void FloatWindow_OnEndDrag(bool abort)
        {
            if (abort)
            {
                return;
            }

            FloatWindow floatWindow = (FloatWindow)DragControl;

            if (!DockOutline.FloatWindowBounds.IsEmpty)
            {
                DragControl.Bounds = DockOutline.FloatWindowBounds;
            }
            else if (DockOutline.DockTo is DockPane)
            {
                DockPane paneTo = DockOutline.DockTo as DockPane;

                if (DockOutline.Dock == DockStyle.Fill)
                {
                    for (int i = floatWindow.DockList.Count - 1; i >= 0; i--)
                    {
                        DockPane pane = floatWindow.DockList[i];
                        for (int j = pane.Contents.Count - 1; j >= 0; j--)
                        {
                            IDockContent c = pane.Contents[j];
                            c.DockHandler.Pane = paneTo;
                            if (DockOutline.ContentIndex != -1)
                            {
                                paneTo.SetContentIndex(c, DockOutline.ContentIndex);
                            }
                            c.DockHandler.Activate();
                        }
                    }
                }
                else
                {
                    DockAlignment alignment = DockAlignment.Left;
                    if (DockOutline.Dock == DockStyle.Left)
                    {
                        alignment = DockAlignment.Left;
                    }
                    else if (DockOutline.Dock == DockStyle.Right)
                    {
                        alignment = DockAlignment.Right;
                    }
                    else if (DockOutline.Dock == DockStyle.Top)
                    {
                        alignment = DockAlignment.Top;
                    }
                    else if (DockOutline.Dock == DockStyle.Bottom)
                    {
                        alignment = DockAlignment.Bottom;
                    }

                    MergeDockList(floatWindow.DisplayingList, paneTo.DockListContainer.DockList, paneTo, alignment, 0.5);
                }
            }
            else if (DockOutline.DockTo is DockPanel)
            {
                SetDockWindow();

                DockList dockListTo = null;

                if (DockOutline.Dock == DockStyle.Top)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockTop].DockList;
                }
                else if (DockOutline.Dock == DockStyle.Bottom)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockBottom].DockList;
                }
                else if (DockOutline.Dock == DockStyle.Left)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockLeft].DockList;
                }
                else if (DockOutline.Dock == DockStyle.Right)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.DockRight].DockList;
                }
                else if (DockOutline.Dock == DockStyle.Fill)
                {
                    dockListTo = floatWindow.DockPanel.DockWindows[DockState.Document].DockList;
                }

                DockPane prevPane = null;
                for (int i = dockListTo.Count - 1; i >= 0; i--)
                {
                    if (dockListTo[i] != floatWindow.DisplayingList[0])
                    {
                        prevPane = dockListTo[i];
                    }
                }
                MergeDockList(floatWindow.DisplayingList, dockListTo, prevPane, DockAlignment.Left, 0.5);
            }
        }
示例#18
0
		/// <include file='CodeDoc\FloatWindow.xml' path='//CodeDoc/Class[@name="FloatWindow"]/Constructor[@name="Overloads"]/*'/>
		/// <include file='CodeDoc\FloatWindow.xml' path='//CodeDoc/Class[@name="FloatWindow"]/Constructor[@name="(DockPanel, DockPane)"]/*'/>
		public FloatWindow(DockPanel dockPanel, DockPane pane)
		{
			InternalConstruct(dockPanel, pane, false, Rectangle.Empty);
		}
		/// <include file='CodeDoc\DockContentHandler.xml' path='//CodeDoc/Class[@name="DockContentHandler"]/Method[@name="Show(DockPane, DockAlignment, double)"]/*'/>
		public void Show(DockPane prevPane, DockAlignment alignment, double proportion)
		{
			if (prevPane == null)
				throw(new ArgumentException(ResourceHelper.GetString("IDockContent.Show.InvalidPrevPane")));

			if (DockHelper.IsDockStateAutoHide(prevPane.DockState))
				throw(new ArgumentException(ResourceHelper.GetString("IDockContent.Show.InvalidPrevPane")));

			DockPanel = prevPane.DockPanel;
			DockPanel.DockPaneFactory.CreateDockPane(Content, prevPane, alignment, proportion, true);
			Show();
		}
		internal void SetPane(DockPane pane)
		{
			if (pane != null && pane.DockState == DockState.Document && DockPanel.DocumentStyle == DocumentStyles.DockingMdi)
			{
				if (Form.Parent is DockPane)
					SetParent(null);
				if (Form.MdiParent != DockPanel.ParentForm)
				{
					FlagClipWindow = true;
					Form.MdiParent = DockPanel.ParentForm;
				}
			}
			else
			{
				FlagClipWindow = true;
				if (Form.MdiParent != null)
					Form.MdiParent = null;
				if (Form.TopLevel)
					Form.TopLevel = false;
				SetParent(pane);
			}
		}
示例#21
0
        private void Pane_OnEndDrag(bool abort)
        {
            User32.SetCursor(DragControl.Cursor.Handle);

            if (abort)
            {
                return;
            }

            DockPane pane = (DockPane)DragControl;

            if (!DockOutline.FloatWindowBounds.IsEmpty)
            {
                if (pane.FloatWindow == null || pane.FloatWindow.DockList.Count != 1)
                {
                    pane.FloatWindow = pane.DockPanel.FloatWindowFactory.CreateFloatWindow(pane.DockPanel, pane, DockOutline.FloatWindowBounds);
                }
                else
                {
                    pane.FloatWindow.Bounds = DockOutline.FloatWindowBounds;
                }

                pane.DockState = DockState.Float;
                pane.Activate();
            }
            else if (DockOutline.DockTo is DockPane)
            {
                DockPane paneTo = DockOutline.DockTo as DockPane;

                if (DockOutline.Dock == DockStyle.Fill)
                {
                    for (int i = pane.Contents.Count - 1; i >= 0; i--)
                    {
                        IDockContent c = pane.Contents[i];
                        c.DockHandler.Pane = paneTo;
                        if (DockOutline.ContentIndex != -1)
                        {
                            paneTo.SetContentIndex(c, DockOutline.ContentIndex);
                        }
                        c.DockHandler.Activate();
                    }
                }
                else
                {
                    if (DockOutline.Dock == DockStyle.Left)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Left, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Right)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Right, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Top)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Top, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Bottom)
                    {
                        pane.AddToDockList(paneTo.DockListContainer, paneTo, DockAlignment.Bottom, 0.5);
                    }

                    pane.DockState = paneTo.DockState;
                    pane.Activate();
                }
            }
            else if (DockOutline.DockTo is DockPanel)
            {
                SetDockWindow();
                if (DockOutline.Dock == DockStyle.Top)
                {
                    pane.DockState = DockState.DockTop;
                }
                else if (DockOutline.Dock == DockStyle.Bottom)
                {
                    pane.DockState = DockState.DockBottom;
                }
                else if (DockOutline.Dock == DockStyle.Left)
                {
                    pane.DockState = DockState.DockLeft;
                }
                else if (DockOutline.Dock == DockStyle.Right)
                {
                    pane.DockState = DockState.DockRight;
                }
                else if (DockOutline.Dock == DockStyle.Fill)
                {
                    pane.DockState = DockState.Document;
                }

                pane.Activate();
            }
        }
		internal DockPaneTabCollection(DockPane pane)
		{
			m_dockPane = pane;
		}
示例#23
0
        private void MergeDockList(DisplayingDockList dockListFrom, DockList dockListTo, DockPane prevPane, DockAlignment alignment, double proportion)
        {
            if (dockListFrom.Count == 0)
            {
                return;
            }

            int count = dockListFrom.Count;

            DockPane[]      panes       = new DockPane[count];
            DockPane[]      prevPanes   = new DockPane[count];
            DockAlignment[] alignments  = new DockAlignment[count];
            double[]        proportions = new double[count];

            for (int i = 0; i < count; i++)
            {
                panes[i]       = dockListFrom[i];
                prevPanes[i]   = dockListFrom[i].NestedDockingStatus.PrevPane;
                alignments[i]  = dockListFrom[i].NestedDockingStatus.Alignment;
                proportions[i] = dockListFrom[i].NestedDockingStatus.Proportion;
            }

            DockPane pane = panes[0].AddToDockList(dockListTo.Container, prevPane, alignment, proportion);

            panes[0].DockState = dockListTo.DockState;
            panes[0].Activate();

            for (int i = 1; i < count; i++)
            {
                for (int j = i; j < count; j++)
                {
                    if (prevPanes[j] == panes[i - 1])
                    {
                        prevPanes[j] = pane;
                    }
                }
                pane = panes[i].AddToDockList(dockListTo.Container, prevPanes[i], alignments[i], proportions[i]);
                panes[i].DockState = dockListTo.DockState;
                panes[i].Activate();
            }
        }
示例#24
0
 /// <include file='CodeDoc\DockContent.xml' path='//CodeDoc/Class[@name="DockContent"]/Method[@name="Show(DockPane, DockHandler)"]/*'/>
 public void Show(DockPane pane, IDockContent beforeContent)
 {
     DockHandler.Show(pane, beforeContent);
 }
示例#25
0
 /// <include file='CodeDoc\DockContent.xml' path='//CodeDoc/Class[@name="DockContent"]/Method[@name="Show(DockPane, DockAlignment, double)"]/*'/>
 public void Show(DockPane prevPane, DockAlignment alignment, double proportion)
 {
     DockHandler.Show(prevPane, alignment, proportion);
 }
示例#26
0
        public static void LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream)
        {
            if (dockPanel.Contents.Count != 0)
            {
                throw new InvalidOperationException(ResourceHelper.GetString("DockPanel.LoadFromXml.AlreadyInitialized"));
            }

            EnumConverter      dockStateConverter     = new EnumConverter(typeof(DockState));
            EnumConverter      dockAlignmentConverter = new EnumConverter(typeof(DockAlignment));
            RectangleConverter rectConverter          = new RectangleConverter();

            XmlTextReader xmlIn = new XmlTextReader(stream);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            while (!xmlIn.Name.Equals("DockPanel"))
            {
                if (!MoveToNextElement(xmlIn))
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
            }

            string formatVersion = xmlIn.GetAttribute("FormatVersion");

            if (!IsFormatVersionValid(formatVersion))
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidFormatVersion"));
            }

            DockPanelStruct dockPanelStruct = new DockPanelStruct();

            dockPanelStruct.DockLeftPortion         = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockRightPortion        = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockTopPortion          = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.DockBottomPortion       = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture);
            dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"));
            dockPanelStruct.IndexActivePane         = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"));

            // Load Contents
            MoveToNextElement(xmlIn);
            if (xmlIn.Name != "Contents")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            ContentStruct[] contents = new ContentStruct[countOfContents];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfContents; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Content" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                contents[i].PersistString   = xmlIn.GetAttribute("PersistString");
                contents[i].AutoHidePortion = Convert.ToDouble(xmlIn.GetAttribute("AutoHidePortion"), CultureInfo.InvariantCulture);
                contents[i].IsHidden        = Convert.ToBoolean(xmlIn.GetAttribute("IsHidden"));
                contents[i].IsFloat         = Convert.ToBoolean(xmlIn.GetAttribute("IsFloat"));
                MoveToNextElement(xmlIn);
            }

            // Load Panes
            if (xmlIn.Name != "Panes")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfPanes = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            PaneStruct[] panes = new PaneStruct[countOfPanes];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfPanes; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "Pane" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                panes[i].DockState          = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                panes[i].IndexActiveContent = Convert.ToInt32(xmlIn.GetAttribute("ActiveContent"));
                panes[i].ZOrderIndex        = -1;

                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "Contents")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfPaneContents = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                panes[i].IndexContents = new int[countOfPaneContents];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfPaneContents; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Content" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }

                    panes[i].IndexContents[j] = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    MoveToNextElement(xmlIn);
                }
            }

            // Load DockWindows
            if (xmlIn.Name != "DockWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfDockWindows = dockPanel.DockWindows.Count;

            DockWindowStruct[] dockWindows = new DockWindowStruct[countOfDockWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfDockWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "DockWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                dockWindows[i].DockState   = (DockState)dockStateConverter.ConvertFrom(xmlIn.GetAttribute("DockState"));
                dockWindows[i].ZOrderIndex = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                dockWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    dockWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    dockWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    dockWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    dockWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }

            // Load FloatWindows
            if (xmlIn.Name != "FloatWindows")
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
            }
            int countOfFloatWindows = Convert.ToInt32(xmlIn.GetAttribute("Count"));

            FloatWindowStruct[] floatWindows = new FloatWindowStruct[countOfFloatWindows];
            MoveToNextElement(xmlIn);
            for (int i = 0; i < countOfFloatWindows; i++)
            {
                int id = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                if (xmlIn.Name != "FloatWindow" || id != i)
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }

                floatWindows[i].Bounds         = (Rectangle)rectConverter.ConvertFromInvariantString(xmlIn.GetAttribute("Bounds"));
                floatWindows[i].AllowRedocking = Convert.ToBoolean(xmlIn.GetAttribute("AllowRedocking"));
                floatWindows[i].ZOrderIndex    = Convert.ToInt32(xmlIn.GetAttribute("ZOrderIndex"));
                MoveToNextElement(xmlIn);
                if (xmlIn.Name != "DockList")
                {
                    throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                }
                int countOfDockList = Convert.ToInt32(xmlIn.GetAttribute("Count"));
                floatWindows[i].DockList = new DockListItem[countOfDockList];
                MoveToNextElement(xmlIn);
                for (int j = 0; j < countOfDockList; j++)
                {
                    int id2 = Convert.ToInt32(xmlIn.GetAttribute("ID"));
                    if (xmlIn.Name != "Pane" || id2 != j)
                    {
                        throw new ArgumentException(ResourceHelper.GetString("DockPanel.LoadFromXml.InvalidXmlFormat"));
                    }
                    floatWindows[i].DockList[j].IndexPane     = Convert.ToInt32(xmlIn.GetAttribute("RefID"));
                    floatWindows[i].DockList[j].IndexPrevPane = Convert.ToInt32(xmlIn.GetAttribute("PrevPane"));
                    floatWindows[i].DockList[j].Alignment     = (DockAlignment)dockAlignmentConverter.ConvertFrom(xmlIn.GetAttribute("Alignment"));
                    floatWindows[i].DockList[j].Proportion    = Convert.ToDouble(xmlIn.GetAttribute("Proportion"), CultureInfo.InvariantCulture);
                    MoveToNextElement(xmlIn);
                }
            }

            if (closeStream)
            {
                xmlIn.Close();
            }

            dockPanel.DockLeftPortion   = dockPanelStruct.DockLeftPortion;
            dockPanel.DockRightPortion  = dockPanelStruct.DockRightPortion;
            dockPanel.DockTopPortion    = dockPanelStruct.DockTopPortion;
            dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion;

            // Set DockWindow ZOrders
            int prevMaxDockWindowZOrder = int.MaxValue;

            for (int i = 0; i < dockWindows.Length; i++)
            {
                int maxDockWindowZOrder = -1;
                int index = -1;
                for (int j = 0; j < dockWindows.Length; j++)
                {
                    if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder)
                    {
                        maxDockWindowZOrder = dockWindows[j].ZOrderIndex;
                        index = j;
                    }
                }

                dockPanel.DockWindows[dockWindows[index].DockState].BringToFront();
                prevMaxDockWindowZOrder = maxDockWindowZOrder;
            }

            // Create Contents
            for (int i = 0; i < contents.Length; i++)
            {
                IDockContent content = deserializeContent(contents[i].PersistString);
                if (content == null)
                {
                    content = new DummyContent();
                }
                content.DockHandler.DockPanel       = dockPanel;
                content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion;
                content.DockHandler.IsHidden        = true;
                content.DockHandler.IsFloat         = contents[i].IsFloat;
            }

            // Create panes
            for (int i = 0; i < panes.Length; i++)
            {
                DockPane pane = null;
                for (int j = 0; j < panes[i].IndexContents.Length; j++)
                {
                    IDockContent content = dockPanel.Contents[panes[i].IndexContents[j]];
                    if (j == 0)
                    {
                        pane = dockPanel.DockPaneFactory.CreateDockPane(content, panes[i].DockState, false);
                    }
                    else if (panes[i].DockState == DockState.Float)
                    {
                        content.DockHandler.FloatPane = pane;
                    }
                    else
                    {
                        content.DockHandler.PanelPane = pane;
                    }
                }
            }

            // Assign Panes to DockWindows
            for (int i = 0; i < dockWindows.Length; i++)
            {
                for (int j = 0; j < dockWindows[i].DockList.Length; j++)
                {
                    DockWindow    dw            = dockPanel.DockWindows[dockWindows[i].DockState];
                    int           indexPane     = dockWindows[i].DockList[j].IndexPane;
                    DockPane      pane          = dockPanel.Panes[indexPane];
                    int           indexPrevPane = dockWindows[i].DockList[j].IndexPrevPane;
                    DockPane      prevPane      = (indexPrevPane == -1) ? dw.DockList.GetDefaultPrevPane(pane) : dockPanel.Panes[indexPrevPane];
                    DockAlignment alignment     = dockWindows[i].DockList[j].Alignment;
                    double        proportion    = dockWindows[i].DockList[j].Proportion;
                    pane.AddToDockList(dw, prevPane, alignment, proportion);
                    if (panes[indexPane].DockState == dw.DockState)
                    {
                        panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex;
                    }
                }
            }

            // Create float windows
            for (int i = 0; i < floatWindows.Length; i++)
            {
                FloatWindow fw = null;
                for (int j = 0; j < floatWindows[i].DockList.Length; j++)
                {
                    int      indexPane = floatWindows[i].DockList[j].IndexPane;
                    DockPane pane      = dockPanel.Panes[indexPane];
                    if (j == 0)
                    {
                        fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds);
                    }
                    else
                    {
                        int           indexPrevPane = floatWindows[i].DockList[j].IndexPrevPane;
                        DockPane      prevPane      = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane];
                        DockAlignment alignment     = floatWindows[i].DockList[j].Alignment;
                        double        proportion    = floatWindows[i].DockList[j].Proportion;
                        pane.AddToDockList(fw, prevPane, alignment, proportion);
                        if (panes[indexPane].DockState == fw.DockState)
                        {
                            panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex;
                        }
                    }
                }
            }

            // sort IDockContent by its Pane's ZOrder
            int[] sortedContents = null;
            if (contents.Length > 0)
            {
                sortedContents = new int[contents.Length];
                for (int i = 0; i < contents.Length; i++)
                {
                    sortedContents[i] = i;
                }

                int lastDocument = contents.Length;
                for (int i = 0; i < contents.Length - 1; i++)
                {
                    for (int j = i + 1; j < contents.Length; j++)
                    {
                        DockPane pane1        = dockPanel.Contents[sortedContents[i]].DockHandler.Pane;
                        int      ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex;
                        DockPane pane2        = dockPanel.Contents[sortedContents[j]].DockHandler.Pane;
                        int      ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex;
                        if (ZOrderIndex1 > ZOrderIndex2)
                        {
                            int temp = sortedContents[i];
                            sortedContents[i] = sortedContents[j];
                            sortedContents[j] = temp;
                        }
                    }
                }
            }

            // show non-document IDockContent first to avoid screen flickers
            for (int i = 0; i < contents.Length; i++)
            {
                IDockContent content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document)
                {
                    content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            // after all non-document IDockContent, show document IDockContent
            for (int i = 0; i < contents.Length; i++)
            {
                IDockContent content = dockPanel.Contents[sortedContents[i]];
                if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document)
                {
                    content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden;
                }
            }

            for (int i = 0; i < panes.Length; i++)
            {
                dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 ? null : dockPanel.Contents[panes[i].IndexActiveContent];
            }

            if (dockPanelStruct.IndexActiveDocumentPane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate();
            }

            if (dockPanelStruct.IndexActivePane != -1)
            {
                dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate();
            }

            for (int i = dockPanel.Contents.Count - 1; i >= 0; i--)
            {
                if (dockPanel.Contents[i] is DummyContent)
                {
                    dockPanel.Contents[i].DockHandler.Form.Close();
                }
            }
        }
		internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
		{
			if (IsSuspendSetDockState)
				return;

			if (DockPanel == null && visibleState != DockState.Unknown)
				throw new InvalidOperationException(ResourceHelper.GetString("IDockContent.SetDockState.NullPanel"));

			if (visibleState == DockState.Hidden || (visibleState != DockState.Unknown && !IsDockStateValid(visibleState)))
				throw new InvalidOperationException(ResourceHelper.GetString("IDockContent.SetDockState.InvalidState"));

			SuspendSetDockState();

			DockState oldDockState = DockState;

			if (m_isHidden != isHidden || oldDockState == DockState.Unknown)
			{
				m_isHidden = isHidden;
			}
			m_visibleState = visibleState;
			m_dockState = isHidden ? DockState.Hidden : visibleState;

			if (visibleState == DockState.Unknown)
				Pane = null;
			else
			{
				m_isFloat = (m_visibleState == DockState.Float);

				if (Pane == null)
					Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true);
				else if (Pane.DockState != visibleState)
				{
					if (Pane.Contents.Count == 1)
						Pane.SetDockState(visibleState);
					else
						Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true);
				}
			}

			SetPane(Pane);
			SetVisible();

			if (oldPane != null && !oldPane.IsDisposed && oldDockState == oldPane.DockState)
				RefreshDockPane(oldPane);

			if (Pane != null && DockState == Pane.DockState)
			{
				if ((Pane != oldPane) ||
					(Pane == oldPane && oldDockState != oldPane.DockState))
					RefreshDockPane(Pane);
			}

			if (oldDockState != DockState)
				OnDockStateChanged(EventArgs.Empty);

			ResumeSetDockState();
		}
		private void RefreshDockPane(DockPane pane)
		{
			pane.RefreshChanges();
			pane.ValidateActiveContent();
		}
示例#29
0
			public DockPaneStripBase CreateDockPaneStrip(DockPane pane)
			{
				return new DockPaneStripFromBase(pane);
			}
		/// <include file='CodeDoc\DockContentHandler.xml' path='//CodeDoc/Class[@name="DockContentHandler"]/Method[@name="Show(DockPane, IDockContent)"]/*'/>
		public void Show(DockPane pane, IDockContent beforeContent)
		{
			if (pane == null)
				throw(new ArgumentNullException(ResourceHelper.GetString("IDockContent.Show.NullPane")));

			if (beforeContent != null && pane.Contents.IndexOf(beforeContent) == -1)
				throw(new ArgumentException(ResourceHelper.GetString("IDockContent.Show.InvalidBeforeContent")));

			DockPanel = pane.DockPanel;
			Pane = pane;
			pane.SetContentIndex(Content, pane.Contents.IndexOf(beforeContent));
			Show();
		}
示例#31
0
		private void SetActivePane()
		{
			DockPane value = GetPaneFromHandle(User32.GetFocus());
			if (m_activePane == value)
				return;

			if (m_activePane != null)
				m_activePane.SetIsActivated(false);

			m_activePane = value;

			if (m_activePane != null)
				m_activePane.SetIsActivated(true);
		}
示例#32
0
		private void SetActiveDocumentPane()
		{
			DockPane value = null;

			if (ActivePane != null && ActivePane.DockState == DockState.Document)
				value = ActivePane;

			if (value == null)
			{
				if (ActiveDocumentPane == null)
					value = DockWindows[DockState.Document].DefaultPane;
				else if (ActiveDocumentPane.DockPanel != this || ActiveDocumentPane.DockState != DockState.Document)
					value = DockWindows[DockState.Document].DefaultPane;
				else
					value = m_activeDocumentPane;
			}

			if (m_activeDocumentPane == value)
				return;

			if (m_activeDocumentPane != null)
				m_activeDocumentPane.SetIsActiveDocumentPane(false);

			m_activeDocumentPane = value;

			if (m_activeDocumentPane != null)
				m_activeDocumentPane.SetIsActiveDocumentPane(true);
		}
示例#33
0
		internal void AddPane(DockPane pane)
		{
			if (Panes.Contains(pane))
				return;

			Panes.Add(pane);
		}
示例#34
0
		/// <include file='CodeDoc\FloatWindow.xml' path='//CodeDoc/Class[@name="FloatWindow"]/Constructor[@name="(DockPanel, DockPane, Rectangle)"]/*'/>
		public FloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds)
		{
			InternalConstruct(dockPanel, pane, true, bounds);
		}
示例#35
0
		internal void RemovePane(DockPane pane)
		{
			if (!Panes.Contains(pane))
				return;

			Panes.Remove(pane);
		}
示例#36
0
			public DockPaneCaptionBase CreateDockPaneCaption(DockPane pane)
			{
				return new DockPaneCaptionFromBase(pane);
			}
示例#37
0
        private void InternalConstruct(IDockContent content, DockState dockState, bool flagBounds, Rectangle floatWindowBounds, DockPane prevPane, DockAlignment alignment, double proportion, bool show)
        {
            if (dockState == DockState.Hidden || dockState == DockState.Unknown)
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPane.DockState.InvalidState"));
            }

            if (content == null)
            {
                throw new ArgumentNullException(ResourceHelper.GetString("DockPane.Constructor.NullContent"));
            }

            if (content.DockHandler.DockPanel == null)
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPane.Constructor.NullDockPanel"));
            }


            SuspendLayout();
            SetStyle(ControlStyles.Selectable, false);

            m_isFloat = (dockState == DockState.Float);

            m_contents           = new DockContentCollection();
            m_displayingContents = new DockContentCollection(this);
            m_tabs      = new DockPaneTabCollection(this);
            m_dockPanel = content.DockHandler.DockPanel;
            m_dockPanel.AddPane(this);

            m_splitter = new DockPaneSplitter(this);

            m_nestedDockingStatus = new NestedDockingStatus(this);

            m_autoHidePane    = DockPanel.AutoHidePaneFactory.CreateAutoHidePane(this);
            m_captionControl  = DockPanel.DockPaneCaptionFactory.CreateDockPaneCaption(this);
            m_tabStripControl = DockPanel.DockPaneStripFactory.CreateDockPaneStrip(this);
            Controls.AddRange(new Control[] { m_captionControl, m_tabStripControl });

            DockPanel.SuspendLayout(true);
            if (flagBounds)
            {
                FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this, floatWindowBounds);
            }
            else if (prevPane != null)
            {
                AddToDockList(prevPane.DockListContainer, prevPane, alignment, proportion);
            }

            SetDockState(dockState);
            if (show)
            {
                content.DockHandler.Pane = this;
            }
            else if (this.IsFloat)
            {
                content.DockHandler.FloatPane = this;
            }
            else
            {
                content.DockHandler.PanelPane = this;
            }

            ResumeLayout();
            DockPanel.ResumeLayout(true, true);
        }
		internal AutoHideTabCollection(DockPane pane)
		{
			m_dockPane = pane;
			m_dockPanel = pane.DockPanel;
		}
示例#39
0
        private void Content_OnEndDrag(bool abort)
        {
            User32.SetCursor(DragControl.Cursor.Handle);

            if (abort)
            {
                return;
            }

            IDockContent content = DragControl as IDockContent;

            if (!DockOutline.FloatWindowBounds.IsEmpty)
            {
                DockPane pane = content.DockHandler.DockPanel.DockPaneFactory.CreateDockPane(content, DockOutline.FloatWindowBounds, true);
                pane.Activate();
            }
            else if (DockOutline.DockTo is DockPane)
            {
                DockPane paneTo = DockOutline.DockTo as DockPane;

                if (DockOutline.Dock == DockStyle.Fill)
                {
                    bool samePane = (content.DockHandler.Pane == paneTo);
                    if (!samePane)
                    {
                        content.DockHandler.Pane = paneTo;
                    }

                    if (DockOutline.ContentIndex == -1 || !samePane)
                    {
                        paneTo.SetContentIndex(content, DockOutline.ContentIndex);
                    }
                    else
                    {
                        DockContentCollection contents = paneTo.Contents;
                        int oldIndex = contents.IndexOf(content);
                        int newIndex = DockOutline.ContentIndex;
                        if (oldIndex < newIndex)
                        {
                            newIndex += 1;
                            if (newIndex > contents.Count - 1)
                            {
                                newIndex = -1;
                            }
                        }
                        paneTo.SetContentIndex(content, newIndex);
                    }

                    content.DockHandler.Activate();
                }
                else
                {
                    DockPane           pane      = content.DockHandler.DockPanel.DockPaneFactory.CreateDockPane(content, paneTo.DockState, true);
                    IDockListContainer container = paneTo.DockListContainer;
                    if (DockOutline.Dock == DockStyle.Left)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Left, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Right)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Right, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Top)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Top, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Bottom)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Bottom, 0.5);
                    }

                    pane.DockState = paneTo.DockState;
                    pane.Activate();
                }
            }
            else if (DockOutline.DockTo is DockPanel)
            {
                DockPane  pane;
                DockPanel dockPanel = content.DockHandler.DockPanel;

                SetDockWindow();
                if (DockOutline.Dock == DockStyle.Top)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockTop, true);
                }
                else if (DockOutline.Dock == DockStyle.Bottom)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockBottom, true);
                }
                else if (DockOutline.Dock == DockStyle.Left)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockLeft, true);
                }
                else if (DockOutline.Dock == DockStyle.Right)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockRight, true);
                }
                else if (DockOutline.Dock == DockStyle.Fill)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.Document, true);
                }
                else
                {
                    return;
                }

                pane.Activate();
            }
        }