본문 바로가기

Programing (프로그래밍)/WPF & C# (C Sharp)

Splashimage 스플래시 이미지 사용하기

728x90
반응형

[WPF & C# (C Sharp)] -Splash image 스플래시 이미지 사용하기

 

Splash - 자동으로 사라짐]

 - 나타났다가 사라지는 간단한 스플래쉬

 

[소스코드]

 

SplashScreen Splash_img = new SplashScreen("133147504770905.png");

Splash_img.Show(false);

Splash_img.Close(new TimeSpan(0, 0, 5));


Splash 처럼... - 패스워드 PW 입력 시 사라짐 ]

 - 패스워드 입력 시 사라지는 스플래쉬 처럼...


splash.zip



[소스코드]

 [MainWindow.xaml]

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;


namespace WpfApp4

{

    /// <summary>

    /// MainWindow.xaml에 대한 상호 작용 논리

    /// </summary>

    public partial class MainWindow : Window

    {



        public MainWindow()

        {

            InitializeComponent();

        }


        private void Grid_MouseDown(object sender, MouseButtonEventArgs e)

        {

            DragMove();

        }


        private void Button_Click(object sender, RoutedEventArgs e)

        {

            Close();

        }


        private void Button_Click_1(object sender, RoutedEventArgs e)

        {

            WindowState = WindowState.Minimized;

        }


        private void Button_Click_2(object sender, RoutedEventArgs e)

        {

            if ((UN.Text == "id") && (PW.Password == "PW"))

            {

                Close();


                splashpage splashpage = new splashpage();

                splashpage.Show();

            }

        }

    }

}




 [MainWindow.xaml]


<Window x:Class="WpfApp4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp4"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" Background="{x:Null}" Foreground="{x:Null}" WindowStyle="None" ResizeMode="NoResize" AllowsTransparency="True">
    <Grid MouseDown="Grid_MouseDown" >
        <Grid.Background>
            <ImageBrush ImageSource="media/Splash_bg.png"/>
        </Grid.Background>
        <Button Content="X" HorizontalAlignment="Left" Margin="392,72,0,0" VerticalAlignment="Top" Width="24" Height="19" Click="Button_Click"/>
        <Button Content="_" HorizontalAlignment="Left" Margin="367,72,0,0" VerticalAlignment="Top" Width="20" Height="19" Click="Button_Click_1"/>
        <TextBox x:Name="UN" HorizontalAlignment="Left" Height="23" Margin="203,148,0,0" TextWrapping="Wrap" Text="id" VerticalAlignment="Top" Width="120"/>
        <Button Content="Login in" HorizontalAlignment="Left" Margin="223,239,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_2"/>
        <PasswordBox x:Name="PW" HorizontalAlignment="Left" Margin="203,189,0,0" VerticalAlignment="Top" Width="120"/>

    </Grid>
</Window>




728x90
반응형