Brightness of chartplotter (Dynamic Data Display) C#

痞子三分冷 提交于 2019-12-12 02:55:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!