コード例 #1
0
		/// <summary>
		/// Occurs when height is being set on child document.
		/// </summary>
		/// <param name="doc">Reference document being changed</param>
		/// <param name="height">Height in pixels</param>
		/// <returns>True if width was applied by parent otherwise false</returns>
		protected internal override bool OnSetHeight(DocumentBaseContainer doc, int height)
		{
			bool ret=false;
			if(m_Orientation!=eOrientation.Vertical || height<doc.MinimumSize.Height && doc.MinimumSize.Height>0)
				return ret;

			DocumentBaseContainer pairDoc=null;
			DocumentBaseContainer previousDoc=null;

			int refIndex=m_Documents.IndexOf(doc);

			// Lock in the display size if it is set
			for(int i=0;i<m_Documents.Count;i++)
			{
				DocumentBaseContainer dc=m_Documents[i];
                if (!dc.Visible) continue;
				if(dc.DisplayBounds.Height>0)
					dc.SetLayoutBounds(dc.DisplayBounds);
				if(i>refIndex && dc.Visible && pairDoc==null)
					pairDoc=dc;
				else if(i<refIndex && dc.Visible)
					previousDoc=dc;
			}

			if(pairDoc==null) pairDoc=previousDoc;

			int diff=doc.LayoutBounds.Height-height;
			if(pairDoc!=null && pairDoc.LayoutBounds.Height>0 && pairDoc.LayoutBounds.Height+diff>0 && 
				(pairDoc.LayoutBounds.Height+diff>=pairDoc.MinimumSize.Height || pairDoc.MinimumSize.Height==0))
			{
				pairDoc.SetLayoutBounds(new Rectangle(pairDoc.LayoutBounds.X,pairDoc.LayoutBounds.Y,pairDoc.LayoutBounds.Width,pairDoc.LayoutBounds.Height+diff));
				ret=true;
			}
            else if (pairDoc == null && previousDoc != null && previousDoc.LayoutBounds.Height > 0 && previousDoc.LayoutBounds.Height + diff > 0 &&
                (previousDoc.LayoutBounds.Height + diff >= previousDoc.MinimumSize.Height || previousDoc.MinimumSize.Height == 0))
            {
                doc.SetLayoutBounds(new Rectangle(doc.LayoutBounds.X, doc.LayoutBounds.Y, doc.LayoutBounds.Width, height));
                previousDoc.SetLayoutBounds(new Rectangle(previousDoc.LayoutBounds.X, previousDoc.LayoutBounds.Y, previousDoc.LayoutBounds.Width, 0));
                ret = true;
            }
			return ret;
		}
コード例 #2
0
		/// <summary>
		/// Occurs when width is being set on child document.
		/// </summary>
		/// <param name="doc">Reference document being changed</param>
		/// <param name="width">Width in pixels</param>
		/// <returns>True if width was applied by parent otherwise false</returns>
		protected internal override bool OnSetWidth(DocumentBaseContainer doc, int width)
		{
			bool ret=false;
			if(m_Orientation!=eOrientation.Horizontal || width<doc.MinimumSize.Width && doc.MinimumSize.Width>0)
				return ret;

			DocumentBaseContainer pairDoc=null;
			DocumentBaseContainer previousDoc=null;

			int refIndex=m_Documents.IndexOf(doc);

			// Lock in the display size if it is set
			for(int i=0;i<m_Documents.Count;i++)
			{
				DocumentBaseContainer dc=m_Documents[i];
                if (!dc.Visible) continue;
				if(dc.DisplayBounds.Width>0)
					dc.SetLayoutBounds(dc.DisplayBounds);
				if(i>refIndex && dc.Visible && pairDoc==null)
					pairDoc=dc;
				else if(i<refIndex && dc.Visible)
					previousDoc=dc;
			}

			int diff=doc.LayoutBounds.Width-width;
			if(pairDoc!=null && pairDoc.LayoutBounds.Width>0 && pairDoc.LayoutBounds.Width+diff>0 && 
				(pairDoc.LayoutBounds.Width+diff>=pairDoc.MinimumSize.Width || pairDoc.MinimumSize.Width==0))
			{
				pairDoc.SetLayoutBounds(new Rectangle(pairDoc.LayoutBounds.X,pairDoc.LayoutBounds.Y,pairDoc.LayoutBounds.Width+diff,pairDoc.LayoutBounds.Height));
				ret=true;
			}
            else if (pairDoc == null && previousDoc != null && previousDoc.LayoutBounds.Width > 0 && previousDoc.LayoutBounds.Width + diff > 0 &&
                (previousDoc.LayoutBounds.Width + diff >= previousDoc.MinimumSize.Width || previousDoc.MinimumSize.Width == 0))
            {
                doc.SetLayoutBounds(new Rectangle(doc.LayoutBounds.X, doc.LayoutBounds.Y, width, doc.LayoutBounds.Height));
                // Resetting previous document width caused problem with ever growing bar when Width of single bar is set
                // Reason is that resetting width here will cause the new space in container to be proportionally allocated thus setting single bar width which is intent of this function never works
                //previousDoc.SetLayoutBounds(new Rectangle(previousDoc.LayoutBounds.X, previousDoc.LayoutBounds.Y, 0, previousDoc.LayoutBounds.Height));
                ret = true;
            }

			return ret;
		}