展开全部
<Canvas Name="LayoutRoot" Background="LightGray" >
<!-- Create an Ellipse -->
<Ellipse Name="mcCircle" Width="200" Height="200"
Canvas.Left="60" Canvas.Top="20"
Fill="Gray" Stroke="Black" StrokeThickness="2">
</Ellipse>
<!-- Create Slider controls -->
<Slider Name="RedSlider" Width="300" Height="20"
Background="Red" Maximum="255" Minimum="0"
Canvas.Left="30" Canvas.Top="240"
ValueChanged="RedSlider_ValueChanged"/>
<Slider Name="GreenSlider" Width="300" Height="20"
Background="Green" Maximum="255" Minimum="0"
Canvas.Left="30" Canvas.Top="270"
ValueChanged="GreenSlider_ValueChanged"/>
<Slider Name="BlueSlider" Width="300" Height="20"
Background="Blue" Maximum="255" Minimum="0"
Canvas.Left="30" Canvas.Top="300"
ValueChanged="BlueSlider_ValueChanged"/>
</Canvas>
private void RedSlider_ValueChanged(object sender,RoutedPropertyChangedEventArgs<double> e)
{
UpdateCircleWithColors();
}
private void GreenSlider_ValueChanged(object sender,RoutedPropertyChangedEventArgs<double> e)
{
UpdateCircleWithColors();
}
private void BlueSlider_ValueChanged(object sender,RoutedPropertyChangedEventArgs<double> e)
{
UpdateCircleWithColors();
}
private void UpdateCircleWithColors()
{
Color clr = Color.FromArgb(255, Convert.ToByte(RedSlider.Value),
Convert.ToByte(GreenSlider.Value), Convert.ToByte(BlueSlider.Value));
mcCircle.Fill = new SolidColorBrush(clr);
}
<!-- Create an Ellipse -->
<Ellipse Name="mcCircle" Width="200" Height="200"
Canvas.Left="60" Canvas.Top="20"
Fill="Gray" Stroke="Black" StrokeThickness="2">
</Ellipse>
<!-- Create Slider controls -->
<Slider Name="RedSlider" Width="300" Height="20"
Background="Red" Maximum="255" Minimum="0"
Canvas.Left="30" Canvas.Top="240"
ValueChanged="RedSlider_ValueChanged"/>
<Slider Name="GreenSlider" Width="300" Height="20"
Background="Green" Maximum="255" Minimum="0"
Canvas.Left="30" Canvas.Top="270"
ValueChanged="GreenSlider_ValueChanged"/>
<Slider Name="BlueSlider" Width="300" Height="20"
Background="Blue" Maximum="255" Minimum="0"
Canvas.Left="30" Canvas.Top="300"
ValueChanged="BlueSlider_ValueChanged"/>
</Canvas>
private void RedSlider_ValueChanged(object sender,RoutedPropertyChangedEventArgs<double> e)
{
UpdateCircleWithColors();
}
private void GreenSlider_ValueChanged(object sender,RoutedPropertyChangedEventArgs<double> e)
{
UpdateCircleWithColors();
}
private void BlueSlider_ValueChanged(object sender,RoutedPropertyChangedEventArgs<double> e)
{
UpdateCircleWithColors();
}
private void UpdateCircleWithColors()
{
Color clr = Color.FromArgb(255, Convert.ToByte(RedSlider.Value),
Convert.ToByte(GreenSlider.Value), Convert.ToByte(BlueSlider.Value));
mcCircle.Fill = new SolidColorBrush(clr);
}
追问
能注释下代码 么 感谢
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询