- <Rectangle Width="154"
- Height="77"
- MouseLeftButtonDown="RectangleMouseLeftButtonDown">
- <Rectangle.Fill>
- <LinearGradientBrush x:Name="GradientFill" StartPoint="0,0" EndPoint="1,1">
- <GradientStop Offset="0" Color="Red" />
- <GradientStop Offset="0.1667" Color="Orange" />
- <GradientStop Offset="0.334" Color="Yellow" />
- <GradientStop Offset="0.5001" Color="Green" />
- <GradientStop Offset="0.6668" Color="Blue" />
- <GradientStop Offset="0.8335" Color="Indigo" />
- <GradientStop Offset="1" Color="Violet" />
- </LinearGradientBrush>
- </Rectangle.Fill>
- </Rectangle>
- <TextBlock x:Name="ClickCountTextBlock"
- Foreground="White"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"
- FontSize="40"
- Opacity="0.4"
- Text="" />
- private void RectangleMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- this.ClickCountTextBlock.Text = e.ClickCount.ToString();
- var topLeft = new Point(0, 0);
- var topRight = new Point(1, 0);
- var bottomLeft = new Point(0, 1);
- var bottomRight = new Point(1, 1);
- switch (e.ClickCount)
- {
- case 2:
- this.GradientFill.StartPoint = topRight;
- this.GradientFill.EndPoint = bottomLeft;
- break;
- case 3:
- this.GradientFill.StartPoint = bottomRight;
- this.GradientFill.EndPoint = topLeft;
- break;
- case 4:
- this.GradientFill.StartPoint = bottomLeft;
- this.GradientFill.EndPoint = topRight;
- break;
- default:
- this.GradientFill.StartPoint = topLeft;
- this.GradientFill.EndPoint = bottomRight;
- break;
- }
- }