展开全部
<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);
}
追问
能注释下代码 么 感谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询