728x90
반응형
728x170
▶ MainWindow.cs
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 브러시
/// </summary>
private RadialGradientBrush brush;
/// <summary>
/// 각도
/// </summary>
private double angle;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
Title = "RadialGradientBrush 클래스 사용하기";
WindowStartupLocation = WindowStartupLocation.CenterScreen;
Width = 800;
Height = 600;
this.brush = new RadialGradientBrush(Colors.White, Colors.Blue);
this.brush.Center = this.brush.GradientOrigin = new Point(0.5, 0.5);
this.brush.RadiusX = this.brush.RadiusY = 0.10;
this.brush.SpreadMethod = GradientSpreadMethod.Repeat;
Background = this.brush;
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(100);
dispatcherTimer.Tick += dispatcherTimer_Tick;
dispatcherTimer.Start();
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Public
#region 프로그램 시작하기 - Main()
/// <summary>
/// 프로그램 시작하기
/// </summary>
[STAThread]
public static void Main()
{
Application application = new Application();
application.Run(new MainWindow());
}
#endregion
////////////////////////////////////////////////////////////////////////////////////////// Instance
//////////////////////////////////////////////////////////////////////////////// Private
#region 디스패처 타이머 틱 발생시 처리하기 - dispatcherTimer_Tick(sender, e)
/// <summary>
/// 디스패처 타이머 틱 발생시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
Point gradientOriginPoint = new Point(0.5d + 0.05d * Math.Cos(this.angle), 0.5d + 0.05d * Math.Sin(this.angle));
this.brush.GradientOrigin = gradientOriginPoint;
this.angle += Math.PI / 6;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] 디렉토리 탐색하기 (0) | 2018.03.18 |
---|---|
[C#/WPF] RichTextBox 클래스 사용하기 (0) | 2018.03.18 |
[C#/WPF] ToggleButton 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] CommandBinding 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] FrameworkElement 클래스 : 커스텀 엘리먼트 사용하기 (0) | 2018.03.10 |
[C#/WPF] LinearGradientBrush 클래스 : MappingMode 속성 사용하기 (0) | 2018.03.10 |
[C#/WPF] Type 클래스 : GetProperties 메소드 사용하기 (0) | 2018.03.10 |
[C#/WPF] Window 클래스 : Background 속성을 사용해 배경색 변경하기 (0) | 2018.03.10 |
[C#/WPF] Application, Window 클래스 상속하기 (0) | 2018.03.10 |
[C#/WPF] XAML에서 특수 문자 사용하기 (0) | 2018.03.04 |
댓글을 달아 주세요