// Selection changed in the hostogram
        private void histogram_SelectionChanged( object sender, IPLab.HistogramEventArgs e )
        {
            int min = e.Min;
            int max = e.Max;
            int count = 0;

            levelLabel.Text = min.ToString( ) + "..." + max.ToString( );

            // count pixels
            for ( int i = min; i <= max; i++ )
            {
                count += activeHistogram.Values[i];
            }
            countLabel.Text = count.ToString( );
            percentileLabel.Text = ( (float) count * 100 / stat.PixelsCount ).ToString( "F2" );
        }
 // Value changed in grid
 private void grid_ValueChanged( object sender, IPLab.GridEventArgs e )
 {
     UpdateFilter( );
 }
        // Cursor position changed over the hostogram
        private void histogram_PositionChanged( object sender, IPLab.HistogramEventArgs e )
        {
            int pos = e.Position;

            if ( pos != -1 )
            {
                levelLabel.Text = pos.ToString( );
                countLabel.Text = activeHistogram.Values[pos].ToString( );
                percentileLabel.Text = ( (float) activeHistogram.Values[pos] * 100 / stat.PixelsCount ).ToString( "F2" );
            }
            else
            {
                levelLabel.Text = "";
                countLabel.Text = "";
                percentileLabel.Text = "";
            }
        }