1.Color结构
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace LY.VaryTheBackGround
{
public class VaryTheBackGround : Window
{
SolidColorBrush brush = new SolidColorBrush(Colors.Beige);
[STAThread]
public static void Main()
{
new Application().Run(new VaryTheBackGround());
}
public VaryTheBackGround()
{
Title = "Vary the Background";
Width = 384;
Height = 384;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
WindowStyle = WindowStyle.ToolWindow;
ResizeMode = ResizeMode.CanMinimize;
Background = brush;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
double width = ActualWidth -
2 * SystemParameters.ResizeFrameVerticalBorderWidth;
double height = ActualHeight -
2 * SystemParameters.ResizeFrameHorizontalBorderHeight -
SystemParameters.CaptionHeight;
Point ptMouse = e.GetPosition(this);
Point ptCenter = new Point(Width / 2, Height / 2);
Vector vectMouse = ptMouse - ptCenter;
double angle = Math.Atan2(vectMouse.Y, vectMouse.X);
Color cr = brush.Color;
cr.ScR = cr.ScG = cr.ScB = (float)angle;
brush.Color = cr;
}
}
}
using System;
using System.Wind