using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
namespace SayHello
{
public class RotateTheGradientOrigin:Window
{
private RadialGradientBrush brush;
private double angle;
[STAThread]
public static void Main()
{
Application app=new Application();
app.Run(new RotateTheGradientOrigin());
}
public RotateTheGradientOrigin()
{
Title = "Click The Gradient Origin";
WindowStartupLocation = WindowStartupLocation.CenterScreen;
Width=384;
Height = 384;
brush=new RadialGradientBrush(Colors.White,Colors.Blue);
brush.Center = brush.GradientOrigin = new Point(0.5, 0.5);
brush.RadiusX = brush.RadiusY = 0.10;
brush.SpreadMethod=GradientSpreadMethod.Repeat;
Background = brush;
DispatcherTimer tmr=new DispatcherTimer();
tmr.Interval = TimeSpan.FromMilliseconds(100);
tmr.Tick += tmr_Tick;
tmr.Start();
}
void tmr_Tick(object sender,EventArgs args)
{
Point pt=new Point(0.5+0.05*Math.Cos(angle),0.5+0.05*Math.Sin(angle));
brush.GradientOrigin = pt;
angle += Math.PI/6;
}
}
}