/// <summary>
 /// Adds a graph component to the control
 /// </summary>
 public void AddGraphComponent( GraphComponent component )
 {
     m_GraphComponents.Add( component );
     GraphComponentControl componentControl = new GraphComponentControl( component );
     componentControl.AssociatedGraphControl = m_GraphControl;
     componentControl.Anchor |= AnchorStyles.Right;
     tableLayoutPanel1.Controls.Add( componentControl );
 }
        public GraphComponentControl( GraphComponent graphComponent )
        {
            InitializeComponent( );

            m_GraphComponent = graphComponent;

            graphComponent.Source.GraphChanged += OnGraphChanged;

            enableCheckbox.Checked = !GraphComponent.Source.Disabled;
            graphNameLabel.Text = GraphComponent.Name;

            Color dark = GraphUtils.ScaleColour( Color.LightSteelBlue, 0.9f );
            Color light = Color.White;

            m_Blends = GraphUtils.CreateColourBlend( light, 0, light, 0.75f, dark, 1 );
            m_SelectedBlends = GraphUtils.CreateColourBlend( dark, 0, dark, 0.75f, light, 1 );
        }
Ejemplo n.º 3
0
        public TestForm()
        {
            InitializeComponent();

            IGraph2dSource data = new Graph2dSourceUniformValue( Graph2dSourceUniformValue.Axis.X, 0.5f );
            GraphComponent component = new GraphComponent( "test0", data, data.CreateRenderer( ), new Graph2dUniformValueController( ) );
            component.Renderer.Colour = m_Colours.NextColour( );
            graphControl1.AddGraphComponent( component );

            data = new GraphX2dSourceFunction( 0, 100, -1, 1, delegate( float x ) { return ( float )Math.Sin( x ); } );
            component = new GraphComponent( "test1", data, data.CreateRenderer( ), null );
            component.Renderer.Colour = m_Colours.NextColour( );
            graphControl1.AddGraphComponent( component );

            if ( m_EnableDynamicSource )
            {
                data = m_DynamicSource;
                m_DynamicSource.MaximumNumberOfSamples = 100;
                component = new GraphComponent( "dynamic source", data, data.CreateRenderer( ), null );
                component.Renderer.Colour = m_Colours.NextColour( );
                graphControl1.AddGraphComponent( component );
            }

            GraphX2dSourceLineSegments segData = new GraphX2dSourceLineSegments( );
            segData.AddControlPoint( new Graph2dSourcePiecewiseLinear.ControlPoint( 0, 1 ) );
            segData.AddControlPoint( new Graph2dSourcePiecewiseLinear.ControlPoint( 0.2f, 0.3f ) );
            segData.AddControlPoint( new Graph2dSourcePiecewiseLinear.ControlPoint( 0.6f, 0.8f ) );
            IGraph2dRenderer renderer = segData.CreateRenderer( );
            renderer.Colour = m_Colours.NextColour( );
            graphControl1.AddGraphComponent( new GraphComponent( "very long graph name that will overrun bounds", segData, renderer, new GraphX2dControlPointController( ) ) );

            foreach ( GraphComponent graphComponent in graphControl1.GraphComponents )
            {
                graphComponentsControl1.AddGraphComponent( graphComponent );
            }

            graphComponentsControl1.AssociatedGraphControl = graphControl1;
        }
        /// <summary>
        /// Removes a graph component from the control
        /// </summary>
        public bool RemoveGraphComponent( GraphComponent component )
        {
            if ( !m_GraphComponents.Remove( component ) )
            {
                return false;
            }

            foreach ( Control control in tableLayoutPanel1.Controls )
            {
                GraphComponentControl graphControl = control as GraphComponentControl;
                if ( graphControl == null )
                {
                    continue;
                }
                if ( graphControl.GraphComponent == component )
                {
                    tableLayoutPanel1.Controls.Remove( control );
                    return true;
                }
            }

            return false;
        }
 /// <summary>
 /// Removes a graph component frmo the control
 /// </summary>
 /// <param name="component"></param>
 public void RemoveGraphComponent( GraphComponent component )
 {
     if ( component != null )
     {
         m_GraphComponents.Remove( component );
         Invalidate( );
     }
 }
 /// <summary>
 /// Adds a graph component to the control
 /// </summary>
 public GraphComponent AddGraphComponent( GraphComponent component )
 {
     if ( component == null )
     {
         throw new ArgumentNullException( "component" );
     }
     m_GraphComponents.Add( component );
     component.Source.GraphChanged += delegate { Invalidate( ); };
     Invalidate( );
     return component;
 }
        /// <summary>
        /// Sets up this control
        /// </summary>
        /// <param name="altitudeGraph">Altitude distribution graph</param>
        /// <param name="slopeGraph">Slope distribution graph</param>
        public void Initialise( GraphControl altitudeGraph, GraphControl slopeGraph )
        {
            Arguments.CheckNotNull( altitudeGraph, "altitudeGraph" );
            Arguments.CheckNotNull( slopeGraph, "slopeGraph" );
            m_SlopeGraphComponent = new GraphComponent( "", new GraphX2dSourceFunction1dAdapter( TerrainType.SlopeDistribution ) );
            m_AltitudeGraphComponent = new GraphComponent( "", new GraphX2dSourceFunction1dAdapter( TerrainType.AltitudeDistribution ) );

            m_SlopeGraphComponent.Source.GraphChanged += OnGraphChanged;
            m_AltitudeGraphComponent.Source.GraphChanged += OnGraphChanged;

            m_AltitudeGraph = altitudeGraph;
            m_SlopeGraph = slopeGraph;

            m_SlopeGraph.AddGraphComponent( m_SlopeGraphComponent );
            m_AltitudeGraph.AddGraphComponent( m_AltitudeGraphComponent );

            selectedCheckBox.Checked = true;
        }