728x90
728x170
■ DropShadowEffect 엘리먼트를 사용해 네온싸인 효과를 만드는 방법을 보여준다.
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="TestProject"
Background="#2a2a2a"
FontFamily="나눔고딕코딩"
FontSize="16">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Canvas Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="300"
Height="50">
<Path
StrokeThickness="10"
StrokeStartLineCap="Flat"
StrokeEndLineCap="Flat"
StrokeLineJoin="Round"
Stroke="#fef200">
<Path.Data>
<LineGeometry x:Name="lineGeometry"
StartPoint="0 25"
EndPoint="0 25" />
</Path.Data>
<Path.Effect>
<DropShadowEffect
BlurRadius="50"
ShadowDepth="2"
Direction="-90"
Color="#fef200" />
</Path.Effect>
</Path>
</Canvas>
<Button Name="runButton" Grid.Row="2"
Margin="0 50 0 0"
Width="100"
Height="30"
Content="실행" />
</Grid>
</Window>
▶ MainWindow.xaml.cs
using System;
using System.Windows;
using System.Windows.Threading;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 타이머
/// </summary>
private DispatcherTimer timer;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
this.timer = new DispatcherTimer();
this.timer.Interval = TimeSpan.FromMilliseconds(10);
this.runButton.Click += runButton_Click;
this.timer.Tick += timer_Tick;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 실행 버튼 클릭시 처리하기 - runButton_Click(sender, e)
/// <summary>
/// 실행 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void runButton_Click(object sender, RoutedEventArgs e)
{
this.runButton.IsEnabled = false;
this.lineGeometry.EndPoint = new Point(0, 25);
this.timer.Start();
}
#endregion
#region 타이머 틱 처리하기 - timer_Tick(sender, e)
/// <summary>
/// 타이머 틱 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void timer_Tick(object sender, EventArgs e)
{
double width = this.lineGeometry.EndPoint.X;
width = width + 1;
if(width > 300)
{
this.timer.Stop();
this.runButton.IsEnabled = true;
}
this.lineGeometry.EndPoint = new Point(width, this.lineGeometry.EndPoint.Y);
}
#endregion
}
}
728x90
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Canvas 클래스 : 캔버스 확장 사용하기 (0) | 2022.08.25 |
---|---|
[C#/WPF/.NET6] BitmapImage 클래스 : WINFORM Bitmap 객체에서 비트맵 이미지 구하기 (0) | 2022.08.20 |
[C#/WPF/.NET6] Image 클래스 : 움직이는 GIF 이미지 만들기 (0) | 2022.08.20 |
[C#/WPF] BlurEffect 엘리먼트 : 네온싸인 효과 만들기 (0) | 2022.07.23 |
[C#/WPF] DropShadowEffect 엘리먼트 : 네온싸인 효과 만들기 (0) | 2022.07.23 |
[C#/WPF] ControlTemplate 엘리먼트 : ToggleButton 엘리먼트를 정의해 전원 버튼 만들기 (0) | 2022.07.23 |
[C#/WPF] ControlTemplate 엘리먼트 : ToggleButton 엘리먼트를 정의해 재생 버튼 만들기 (0) | 2022.07.23 |
[C#/WPF] ListBox 엘리먼트 : IsSynchronizedWithCurrentItem 속성을 사용해 현재 항목 동기화 설정하기 (0) | 2022.05.28 |
[C#/WPF] DateTemplate 클래스 : FindName 메소드를 사용해 자식 객체 구하기 (0) | 2022.05.28 |
[C#/WPF] ControlTemplate 엘리먼트 : Button 엘리먼트 정의하기 (0) | 2022.05.25 |