當前位置: 首頁>>代碼示例>>C#>>正文


C# PaneBase.CalcClientRect方法代碼示例

本文整理匯總了C#中ZedGraph.PaneBase.CalcClientRect方法的典型用法代碼示例。如果您正苦於以下問題:C# PaneBase.CalcClientRect方法的具體用法?C# PaneBase.CalcClientRect怎麽用?C# PaneBase.CalcClientRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ZedGraph.PaneBase的用法示例。


在下文中一共展示了PaneBase.CalcClientRect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CalcRect

		/// <summary>
		/// Calculate the <see cref="Legend"/> rectangle (<see cref="Rect"/>),
		/// taking into account the number of required legend
		/// entries, and the legend drawing preferences.
		/// </summary>
		/// <remarks>Adjust the size of the
		/// <see cref="Chart.Rect"/> for the parent <see cref="GraphPane"/> to accomodate the
		/// space required by the legend.
		/// </remarks>
		/// <param name="g">
		/// A graphic device object to be drawn into.  This is normally e.Graphics from the
		/// PaintEventArgs argument to the Paint() method.
		/// </param>
		/// <param name="pane">
		/// A reference to the <see cref="PaneBase"/> object that is the parent or
		/// owner of this object.
		/// </param>
		/// <param name="scaleFactor">
		/// The scaling factor to be used for rendering objects.  This is calculated and
		/// passed down by the parent <see cref="GraphPane"/> object using the
		/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
		/// font sizes, etc. according to the actual size of the graph.
		/// </param>
		/// <param name="tChartRect">
		/// The rectangle that contains the area bounded by the axes, in pixel units.
		/// <seealso cref="Chart.Rect" />
		/// </param>
		public void CalcRect( Graphics g, PaneBase pane, float scaleFactor,
			ref RectangleF tChartRect )
		{
			// Start with an empty rectangle
			_rect = Rectangle.Empty;
			_hStack = 1;
			_legendItemWidth = 1;
			_legendItemHeight = 0;

			RectangleF clientRect = pane.CalcClientRect( g, scaleFactor );

			// If the legend is invisible, don't do anything
			if ( !_isVisible )
				return;

			int nCurve = 0;

			PaneList paneList = GetPaneList( pane );
			_tmpSize = GetMaxHeight( paneList, g, scaleFactor );

			float halfGap = _tmpSize / 2.0F,
					maxWidth = 0,
					tmpWidth,
					gapPix = _gap * _tmpSize;

			foreach ( GraphPane tmpPane in paneList )
			{
				// Loop through each curve in the curve list
				// Find the maximum width of the legend labels
				//foreach ( CurveItem curve in tmpPane.CurveList )
				//foreach ( CurveItem curve in GetIterator( tmpPane.CurveList, _isReverse ) )
				int count = tmpPane.CurveList.Count;
				for ( int i = 0; i < count; i++ )
				{
					CurveItem curve = tmpPane.CurveList[_isReverse ? count - i - 1 : i];
					if ( curve._label._text != string.Empty && curve._label._isVisible )
					{
						// Calculate the width of the label save the max width
						FontSpec tmpFont = ( curve._label._fontSpec != null ) ?
										curve._label._fontSpec : this.FontSpec;

						tmpWidth = tmpFont.GetWidth( g, curve._label._text, scaleFactor ) / 2;

						if ( tmpWidth > maxWidth )
							maxWidth = tmpWidth;

						// Save the maximum symbol height for line-type curves
						if ( curve is LineItem && ( (LineItem)curve ).Symbol.Size > _legendItemHeight )
							_legendItemHeight = ( (LineItem)curve ).Symbol.Size;

						nCurve++;
					}
				}

				if ( pane is MasterPane && ( (MasterPane)pane ).IsUniformLegendEntries )
					break;
			}

			float widthAvail;

			// Is this legend horizontally stacked?

			if ( _isHStack )
			{
				// Determine the available space for horizontal stacking
				switch ( _position )
				{
					// Never stack if the legend is to the right or left
					case LegendPos.Right:
					case LegendPos.Left:
						widthAvail = 0;
						break;

//.........這裏部分代碼省略.........
開發者ID:jackmaynard,項目名稱:MissionPlanner,代碼行數:101,代碼來源:Legend.cs


注:本文中的ZedGraph.PaneBase.CalcClientRect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。