Brush as its name indicates can be used to paint
the texture and chrome of a specified ContentElement or UIElement, Avalon
comes with tons of different Brushes, one of which called
RadialGradientBrush is what I want to demonstrate in the following code:
With some lines of simple code, you can get the intoxicating look and feel of the window chrome:
Move your mouse around to see the coolness in action:-)
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MoveTheGradientCenter
{
public class MainWindow : Window
{
private RadialGradientBrush brush;
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new MainWindow());
}
public MainWindow()
{
Title = "Move The Gradient Center";
brush = new RadialGradientBrush(Colors.White, Colors.Black);
brush.RadiusX = brush.RadiusY = 0.1d;
brush.SpreadMethod = GradientSpreadMethod.Reflect;
this.Background = brush;
}
protected override void OnMouseMove(MouseEventArgs e)
{
Point mousePosition = e.GetPosition(this);
mousePosition.X /= ActualWidth;
mousePosition.Y /= ActualHeight;
brush.Center = mousePosition;
}
}
}
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MoveTheGradientCenter
{
public class MainWindow : Window
{
private RadialGradientBrush brush;
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new MainWindow());
}
public MainWindow()
{
Title = "Move The Gradient Center";
brush = new RadialGradientBrush(Colors.White, Colors.Black);
brush.RadiusX = brush.RadiusY = 0.1d;
brush.SpreadMethod = GradientSpreadMethod.Reflect;
this.Background = brush;
}
protected override void OnMouseMove(MouseEventArgs e)
{
Point mousePosition = e.GetPosition(this);
mousePosition.X /= ActualWidth;
mousePosition.Y /= ActualHeight;
brush.Center = mousePosition;
}
}
}
With some lines of simple code, you can get the intoxicating look and feel of the window chrome:
Move your mouse around to see the coolness in action:-)