阅读背景:

《WPF程序设计指南》读书笔记——第2章 基本画刷

来源:互联网 

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



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: