コード例 #1
0
        /// <summary>
        /// Renders control points in a graph that derives from Graph2dPiecewiseLinear
        /// </summary>
        public void Render( IGraphCanvas graphics, GraphTransform transform, IGraph2dSource data, PointF cursorDataPt, bool enabled )
        {
            if ( data.Disabled )
            {
                return;
            }
            GraphX2dSourceFunction1dAdapter pwlGraph = ( GraphX2dSourceFunction1dAdapter )data;
            PiecewiseLinearFunction1d pwlFunc = ( PiecewiseLinearFunction1d )pwlGraph.Function;

            float tolerance = transform.ScreenToDataYScale * GraphX2dControlPointController.ScreenSelectionTolerance;
            int highlightCpIndex = pwlFunc.FindControlPoint( new Point2( cursorDataPt.X, cursorDataPt.Y ), tolerance );

            for ( int cpIndex = 0; cpIndex < pwlFunc.NumControlPoints; ++cpIndex )
            {
                Point2 cp = pwlFunc[ cpIndex ];
                PointF screenPt = transform.DataToScreen( new PointF( cp.X, cp.Y ) );
                graphics.FillCircle( m_CpBrush, screenPt.X, screenPt.Y, 2 );

                if ( cpIndex == highlightCpIndex )
                {
                    graphics.DrawCircle( s_HighlightPen, screenPt.X, screenPt.Y, 4 );
                }
            }
        }
 /// <summary>
 /// Draws a control point
 /// </summary>
 private static void DrawControlPoint( IGraphCanvas graphics, Point screenPt, Brush brush, bool highlight )
 {
     graphics.FillCircle( brush, screenPt.X, screenPt.Y, 2 );
     if ( highlight )
     {
         graphics.DrawCircle( s_HighlightedPen, screenPt.X, screenPt.Y, 4 );
     }
 }