当前位置: 首页>>代码示例>>C#>>正文


C# GraphPane.ScaledGap方法代码示例

本文整理汇总了C#中ZedGraph.GraphPane.ScaledGap方法的典型用法代码示例。如果您正苦于以下问题:C# GraphPane.ScaledGap方法的具体用法?C# GraphPane.ScaledGap怎么用?C# GraphPane.ScaledGap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZedGraph.GraphPane的用法示例。


在下文中一共展示了GraphPane.ScaledGap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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="GraphPane.AxisRect"/> 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="GraphPane"/> 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="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="tAxisRect">
        /// The rectangle that contains the area bounded by the axes, in pixel units.
        /// <seealso cref="GraphPane.AxisRect">AxisRect</seealso>
        /// </param>
        /// <param name="hStack">The number of columns (horizontal stacking) to be used
        /// for drawing the legend</param>
        /// <param name="legendWidth">The width of each column in the legend (pixels)</param>
        /// <param name="legendHeight">The height of each row in the legend (pixels)</param>
        public void CalcRect(Graphics g, GraphPane pane, double scaleFactor,
                                        ref RectangleF tAxisRect, out int hStack,
								        out float legendWidth, out float legendHeight )
        {
            // Start with an empty rectangle
            this.rect = Rectangle.Empty;
            hStack = 1;
            legendWidth = 1;
            legendHeight = 0;

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

            int		nCurve = 0;
            float	charHeight = this.FontSpec.GetHeight( scaleFactor ),
                    halfCharHeight = charHeight / 2.0F,
                    charWidth = this.FontSpec.GetWidth( g, scaleFactor ),
                    gap = pane.ScaledGap( scaleFactor ),
                    maxWidth = 0,
                    tmpWidth;

            // Loop through each curve in the curve list
            // Find the maximum width of the legend labels
            foreach( CurveItem curve in pane.CurveList )
            {
                if ( curve.IsLegendLabelVisible && curve.Label != "" )
                {
                    // Calculate the width of the label save the max width

                    tmpWidth = this.FontSpec.GetWidth( g, curve.Label, scaleFactor );

                    if ( tmpWidth > maxWidth )
                        maxWidth = tmpWidth;

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

                    nCurve++;
                }
            }

            float widthAvail;

            // Is this legend horizontally stacked?
            if ( this.isHStack )
            {
                // Determine the available space for horizontal stacking
                switch( this.position )
                {
                    // Never stack if the legend is to the right or left
                    case LegendPos.Right:
                    case LegendPos.Left:
                        widthAvail = 0;
                        break;

                    // for the top & bottom, the axis border width is available
                    case LegendPos.Top:
                    case LegendPos.Bottom:
                        widthAvail = tAxisRect.Width;
                        break;

                    // for inside the axis area or Float, use 1/2 of the axis border width
                    case LegendPos.InsideTopRight:
                    case LegendPos.InsideTopLeft:
                    case LegendPos.InsideBotRight:
                    case LegendPos.InsideBotLeft:
                    case LegendPos.Float:
//.........这里部分代码省略.........
开发者ID:InsungChoi,项目名称:dddd,代码行数:101,代码来源:Legend.cs

示例2: CalcSpace

        /// <summary>
        /// Calculate the space required for this <see cref="Axis"/>
        /// object.  This is the space between the paneRect and the axisRect for
        /// this particular axis.
        /// </summary>
        /// <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="GraphPane"/> 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="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <returns>Returns the space, in pixels, required for this axis (between the
        /// paneRect and axisRect)</returns>
        public float CalcSpace( Graphics g, GraphPane pane, double scaleFactor )
        {
            float charHeight = this.ScaleFontSpec.GetHeight( scaleFactor );
            float gap = pane.ScaledGap( scaleFactor );
            float ticSize = this.ScaledTic( scaleFactor );

            // axisRect is the actual area of the plot as bounded by the axes

            // Always leave 1xgap space, even if no axis is displayed
            float space = gap;

            // Account for the Axis
            if ( this.isVisible )
            {
                // tic takes up 1x tic
                // space between tic and scale label is 0.5 tic
                // scale label is GetScaleMaxSpace()
                // space between scale label and axis label is 0.5 tic
                space += this.GetScaleMaxSpace( g, pane, scaleFactor ).Height +
                            ticSize * 2.0F;

                // Only add space for the label if there is one
                // Axis Title gets actual height plus 1x gap
                if ( this.title.Length > 0 && this.isShowTitle )
                {
                    space += this.TitleFontSpec.BoundingBox( g, this.title, scaleFactor ).Height;
                }
            }

            // for the Y axes, make sure that enough space is left to fit the first
            // and last X axis scale label
            if ( ( ( this is YAxis ) || ( this is Y2Axis ) ) && pane.XAxis.IsVisible )
            {
                float tmpSpace =
                    pane.XAxis.GetScaleMaxSpace( g, pane, scaleFactor ).Width / 2.0F +
                        charHeight;
                if ( tmpSpace > space )
                    space = tmpSpace;
            }

            // Verify that the minSpace property was satisfied
            space = Math.Max( space, this.minSpace * (float) scaleFactor );

            return space;
        }
开发者ID:InsungChoi,项目名称:dddd,代码行数:66,代码来源:Axis.cs


注:本文中的ZedGraph.GraphPane.ScaledGap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。