[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 입력 시 사라짐 ]
- 패스워드 입력 시 사라지는 스플래쉬 처럼...
[소스코드]
[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>
- 패스워드 입력 시 사라지는 스플래쉬 처럼...
[소스코드] [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> |
'Programing (프로그래밍) > WPF & C# (C Sharp)' 카테고리의 다른 글
WPF & C# (C Sharp) - 메세지박스 종류 및 비동기식 띄우기 ( MessageBox.Show / 메시지 / 띄우기 / 나타내기 ) (0) | 2017.10.23 |
---|---|
[ WPF & C# (C Sharp)] - REG ( regstry / 레지스트리 / 레지 ) (0) | 2017.10.23 |
WPF & C# (C Sharp) - 마우스 드래그로 윈도우 창 이동하기 ( window / drag move 드래그 무브 ) (0) | 2017.10.23 |
컨트롤 접두사 명명 규칙 (0) | 2017.10.23 |
WPF & C# (C Sharp) - Environment 로 부터 추출되는 data 각종 정보 (0) | 2017.10.19 |
WPF & C# (C Sharp) - XML 파일 저장하기 ( 쓰기 ) / 읽어오기 ( 읽기 ) / LINQ (0) | 2017.10.19 |
WPF & C# - 새창열기 ( 새 창 띄우기 / 창팝업 ) (0) | 2017.10.17 |
DoubleAnimation을 이용한 ToastMessage 토스트메세지 toast Message (3) | 2017.10.17 |