29.wpf程序设计指南[第二章]渐变画刷

来源:互联网 发布:淘宝店转让风险大吗 编辑:程序博客网 时间:2024/05/23 23:08

using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
//渐变画刷最简单的形式是LinearGradientBrush,2,2种颜色的渐变,需要2个点,2种颜色
namespace SayHello
{
    //3当前对象继承自Window
 public  class GradiateTheBrush:Window
    {
     //1.任何 一个WCF程序里面必须有STAThread,否则编译会失败,STAThread 特性为了申明该应用程序的初始模型是“Single threaded apartment”
     //它是为了兼容com模型。理解为:我们的应用程序不会使用“源自运行环境”的多线程。
       [STAThread]
     //2.static去掉的话会编译错误
     public static void Main()
     {
         //4.Application一个程序只能有一个,但是Window一个程序可以创建N个
         Application app=new Application();
         //5.运行当前Window
         app.Run(new GradiateTheBrush());
     }
     public GradiateTheBrush()
     {
         Title = "Gradiate the Brush";
         //6.用一个刷子上面涂上要画画的颜色
         LinearGradientBrush brush = new LinearGradientBrush(Colors.Red, Colors.Blue, new Point(0, 0), new Point(1, 1));
        //7.用刷子把颜色刷上,是一个动作
         Background = brush;
     }
    }
}

原创粉丝点击