问题
I'm using Microsoft Visual Studio 2010, including reference Dynamic Data Display. I'm want to make an scroll bar that control of the brightness of the map . I'm tried to find a property like brightness or something like it but without a success. Thank for help friends. :)
回答1:
You can control the brightness of the plotter by setting its Background
to different RGB values. Each value has a range from 0 (Darkest) to 255 (Brightest). First set a brightest color, for example
Byte R = 255;
Byte G = 255;
Byte B = 255;
And define a factor (range from 0.5
to 1.0) that is controlled by the slider.(0.0 is total blackness, so I set the lower range as 0.5
which is gray).
double minFactor = 0.5;
double maxFactor = 1.0;
double factor = maxFactor; //initially, brightest
Then the Background
of the plotter
Color color = Color.FromRgb((Byte)(factor*R), (Byte)(factor*G), (Byte)(factor*B));
plotter.Background = new SolidColorBrush(color);
And this is how the slider controls the brightness.
Slider slider = new Slider();
slider.Value = factor;
slider.Maximum = maxFactor;
slider.Minimum = minFactor;
slider.ValueChanged += (s, e) =>
{
var newFactor = e.NewValue;
Color newColor = Color.FromRgb((Byte)(newFactor * R), (Byte)(newFactor * G), (Byte)(newFactor * B));
plotter.Background = new SolidColorBrush(newColor);
};
Brightness of Map
a. Set a dark background for plotter
plotter.Background = new SolidColorBrush(Colors.Black);
b. Hide the grid
plotter.AxisGrid.Visibility = System.Windows.Visibility.Collapsed;
c. Adjust map's Opacity by slider
slider.ValueChanged += (s, e) =>
{
var newFactor = e.NewValue;
map.Opacity = newFactor;
//Color newColor = Color.FromRgb((Byte)(newFactor * R), (Byte)(newFactor * G), (Byte)(newFactor * B));
//plotter.Background = new SolidColorBrush(newColor);
}
来源:https://stackoverflow.com/questions/26442491/brightness-of-chartplotter-dynamic-data-display-c-sharp