첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

■ DropShadowEffect 엘리먼트를 사용해 네온싸인 효과를 만드는 방법을 보여준다.

TestProject.zip
0.01MB

▶ 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
그리드형(광고전용)
Posted by icodebroker
,