첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ SplashScreenWindow.xaml

<Window x:Name="_pSplashWindow"
    x:Class="HowToShowSplashScreenViaDXSplashScreenService.SplashScreenWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    ShowInTaskbar="False"
    Topmost="True"
    WindowStyle="None"
    ResizeMode="NoResize"
    Width="800"
    Height="600"
    AllowsTransparency="True"
    Background="Transparent">
    <Window.Triggers>
        <EventTrigger RoutedEvent="Window.Unloaded">
            <BeginStoryboard>
                <Storyboard x:Name="storyboard">
                    <DoubleAnimation
                        Storyboard.TargetName="splashWindow"
                        Storyboard.TargetProperty="Opacity"
                        From="1.0"
                        To="0"
                        Duration="0:0:0.5" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Window.Triggers>
    <Grid x:Name="layoutGrid">
        <Grid x:Name="splashGrid"
            HorizontalAlignment="Center"
            VerticalAlignment="Top"
            Width="450"
            Margin="0 100 0 0">
            <Grid x:Name="shadowGrid"
                Margin="-10 -10 -10 -11">
                <Grid.Background>
                    <ImageBrush ImageSource="Images/shadow.png" />
                </Grid.Background>
            </Grid>
            <Grid x:Name="backgroundGrid">
                <Border
                    Background="Black"
                    CornerRadius="3"
                    Opacity="0.15" />
                <Border
                    Margin="1"
                    CornerRadius="2"
                    Background="White" />
            </Grid>
            <Grid x:Name="contentGrid"
                Margin="12">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*"    />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Image x:Name="mainImage"
                    Source="Images/main.png"
                    Stretch="None" />
                <TextBlock x:Name="messageTextBlock"
                    Grid.Row="1"
                    Margin="0 12 0 0"
                    Foreground="#ff2d2d2d"
                    TextWrapping="Wrap"
                    Text="DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools,
Business Application Frameworks, and Reporting Systems for Visual Studio. Whether using WPF, Silverlight,
ASP.NET or WinForms, DevExpress tools help you build and deliver your best in the shortest time possible." />
                <ProgressBar x:Name="progressBar"
                    Grid.Row="2"
                    Margin="32 12"
                    Height="12" />
                <DockPanel x:Name="footerDockPanel"
                    Grid.Row="3"
                    Margin="0 12 0 0">
                    <TextBlock x:Name="footerTextBlock"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Bottom"
                        Opacity="0.5"
                        Foreground="#ff2d2d2d"
                        TextWrapping="Wrap"
                        Text="Copyright © 1998-2013 Developer Express Inc." />
                    <Image x:Name="logoImage"
                        DockPanel.Dock="Right"
                        HorizontalAlignment="Right"
                        Stretch="None"
                        Source="Images/logo.png" />
                </DockPanel>
            </Grid>
        </Grid>
    </Grid>
</Window>

 

728x90

 

▶ SplashScreenWindow.xaml.cs

using System;
using System.Windows;

using DevExpress.Xpf.Core;

namespace HowToShowSplashScreenViaDXSplashScreenService
{
    /// <summary>
    /// 스플래시
    /// </summary>
    public partial class SplashScreenWindow : Window, ISplashScreen
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - SplashScreenWindow()

        /// <summary>
        /// 생성자
        /// </summary>
        public SplashScreenWindow()
        {
            InitializeComponent();

            this.storyboard.Completed += storyboard_Completed;
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        // ISplashScreen
        #region 진행하기 - Progress(value)

        /// <summary>
        /// 진행하기
        /// </summary>
        /// <param name="value">값</param>
        public void Progress(double value)
        {
            this.progressBar.Value = value;
        }

        #endregion

        // ISplashScreen
        #region 스플래시 화면 닫기 - CloseSplashScreen()

        /// <summary>
        /// 스플래시 화면 닫기
        /// </summary>
        public void CloseSplashScreen()
        {
            this.storyboard.Begin(this);
        }

        #endregion

        // ISplashScreen
        #region 진행 상태 설정하기 - SetProgressState(isIndeterminate)

        /// <summary>
        /// 진행 상태 설정하기
        /// </summary>
        /// <param name="isIndeterminate">미결정 여부</param>
        public void SetProgressState(bool isIndeterminate)
        {
            this.progressBar.IsIndeterminate = isIndeterminate;
        }

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 스토리 보드 완료시 처리하기 - storyboard_Completed(sender, e)

        /// <summary>
        /// 스토리 보드 완료시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private void storyboard_Completed(object sender, EventArgs e)
        {
            this.storyboard.Completed -= storyboard_Completed;

            Close();
        }

        #endregion
    }
}

 

300x250

 

▶ MainViewModel.cs

using System;
using System.Threading;
using System.Windows.Input;

using DevExpress.Xpf.Mvvm;

namespace HowToShowSplashScreenViaDXSplashScreenService
{
    /// <summary>
    /// 메인 뷰 모델
    /// </summary>
    public class MainViewModel : ViewModelBase
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Property
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region Show Splash Screen 명령 - ShowSplashScreenCommand

        /// <summary>
        /// Show Splash Screen 명령
        /// </summary>
        public ICommand ShowSplashScreenCommand { get; private set; }

        #endregion


        #region 스플래시 화면 서비스 - SplashScreenService

        /// <summary>
        /// 스플래시 화면 서비스
        /// </summary>
        ISplashScreenService SplashScreenService
        {
            get
            {
                return GetService<ISplashScreenService>();
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainViewModel()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainViewModel()
        {
            ShowSplashScreenCommand = new DelegateCommand(OnShowSplashScreenCommandExecute);
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region Show Splash Screen 명령 실행시 처리하기 - OnShowSplashScreenCommandExecute()

        /// <summary>
        /// Show Splash Screen 명령 실행시 처리하기
        /// </summary>
        private void OnShowSplashScreenCommandExecute()
        {
            if(!SplashScreenService.IsSplashScreenActive)
            {
                SplashScreenService.ShowSplashScreen();

                Thread.Sleep(TimeSpan.FromSeconds(3));

                SplashScreenService.HideSplashScreen();
            }
        }

        #endregion
    }
}

 

▶ MainWindow.xaml

<Window
    x:Class="HowToShowSplashScreenViaDXSplashScreenService.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:local="clr-namespace:HowToShowSplashScreenViaDXSplashScreenService"
    Title="DXSplashScreenService"
    Width="600"
    Height="450">
    <Window.DataContext>
        <local:MainViewModel />
    </Window.DataContext>
    <dxm:Interaction.Behaviors>
        <dx:DXSplashScreenService SplashScreenType="{x:Type local:SplashScreenWindow}" />
    </dxm:Interaction.Behaviors>
    <Grid>
        <Button
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Padding="5"
            FontSize="16"
            Content="Show Splash Screen"
            Command="{Binding ShowSplashScreenCommand}" />
    </Grid>
</Window>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요