728x90
반응형
728x170
▶ MainWindow.cs
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 속성 정보 배열
/// </summary>
private PropertyInfo[] propertyInfoArray;
/// <summary>
/// 속성 정보 배열 인덱스
/// </summary>
private int propertyInfoArrayIndex = 0;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
this.propertyInfoArray = typeof(Brushes).GetProperties(BindingFlags.Public | BindingFlags.Static);
Width = 800;
Height = 600;
SetTitleAndBackground();
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Public
#region 프로그램 실행하기 - Main()
/// <summary>
/// 프로그램 실행하기
/// </summary>
[STAThread]
public static void Main()
{
Application application = new Application();
application.Run(new MainWindow());
}
#endregion
////////////////////////////////////////////////////////////////////////////////////////// Instance
//////////////////////////////////////////////////////////////////////////////// Public
#region 키 다운시 처리하기 - OnKeyDown(e)
/// <summary>
/// 키 다운시 처리하기
/// </summary>
/// <param name="e">이벤트 인자</param>
protected override void OnKeyDown(KeyEventArgs e)
{
if(e.Key == Key.Down || e.Key == Key.Up)
{
this.propertyInfoArrayIndex += e.Key == Key.Up ? 1 : this.propertyInfoArray.Length - 1;
this.propertyInfoArrayIndex %= this.propertyInfoArray.Length;
SetTitleAndBackground();
}
base.OnKeyDown(e);
}
#endregion
//////////////////////////////////////////////////////////////////////////////// Private
#region 제목/배경 설정하기 - SetTitleAndBackground()
/// <summary>
/// 제목/배경 설정하기
/// </summary>
private void SetTitleAndBackground()
{
Title = "Type 클래스 : GetProperties 메소드 사용하기 : " + this.propertyInfoArray[this.propertyInfoArrayIndex].Name;
Background = this.propertyInfoArray[this.propertyInfoArrayIndex].GetValue(null, null) as Brush;
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] ToggleButton 클래스 사용하기 (0) | 2018.03.10 |
---|---|
[C#/WPF] CommandBinding 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] FrameworkElement 클래스 : 커스텀 엘리먼트 사용하기 (0) | 2018.03.10 |
[C#/WPF] RadialGradientBrush 클래스 사용하기 (0) | 2018.03.10 |
[C#/WPF] LinearGradientBrush 클래스 : MappingMode 속성 사용하기 (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 |
[C#/WPF] MediaElement 클래스 사용하기 (0) | 2018.02.18 |
[C#/WPF] RotateTransform 엘리먼트 : 마우스 진입시 이미지 회전하기 (0) | 2018.02.18 |
댓글을 달아 주세요