티스토리 뷰
그냥 갑자기 복습 겸 만들어 보고 싶어서 만들어봤습니다.
data bindiing, 네트워크 연결 등을 구글링하여 추가했습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | MainWindow.xaml <Window x:Class="Chatting.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:Chatting" xmlns:system="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" Icon ="Images/Logo/logo-small.png" Title="One-day chatting" Height="350" Width="400" Background="#FFB9BEC0" ResizeMode="NoResize"> <StackPanel VerticalAlignment="Center" Margin="20" CanVerticallyScroll="True"> <Label Content="_ID : " Target="{Binding ElementName=txtID}" FontSize="20" Padding="0,10,0,5" Foreground="White"/> <TextBox Name="txtID" Height="50" Foreground="#FFB9BEC0" VerticalContentAlignment="Center" FontSize="30"> </TextBox> <Label Content="_Password : " Target="{Binding ElementName=txtPW}" FontSize="20" Padding="0,20,0,5" Foreground="White"></Label> <PasswordBox Name="txtPW" Height="50" Foreground="#FFB9BEC0" VerticalContentAlignment="Center" FontSize="30"> </PasswordBox> <Grid> <Grid.RowDefinitions> <RowDefinition Height="20"></RowDefinition> <RowDefinition Height="40"></RowDefinition> <RowDefinition Height="30"></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="50*"></ColumnDefinition> <ColumnDefinition Width="50*"></ColumnDefinition> </Grid.ColumnDefinitions> <Border Name="ButtonBorder" CornerRadius="5" BorderBrush="white" BorderThickness="3" Grid.Row="1" Grid.Column="1" Background="Transparent" Width="100" HorizontalAlignment="Right"> <Button Name="Login_Button" Content="Log_in" Width="{Binding ButtonBorder.Width}" Height="{Binding ButtonBorder.Height}" FontSize="20" VerticalContentAlignment="Center" Background="White" Foreground="#FFB9BEC0" BorderBrush="Transparent"/> </Border> <Label Name="createAccount" Grid.Row="3" Grid.ColumnSpan="2" FontSize="15" VerticalAlignment="Bottom"> <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="this.Create_account.xaml" Foreground="White"> You can create your account for free </Hyperlink> </Label> </Grid> </StackPanel> </Window> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | MainWindow.xaml.cs using System; using System.Collections.Generic; using System.Linq; using System.Net; 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 Chatting { /// <summary> /// MainWindow.xaml에 대한 상호 작용 논리 /// </summary> public partial class MainWindow : Window { private string LoginID { get; set; } private string LoginPasswd { get; set; } public MainWindow() { InitializeComponent(); this.Loaded += OnLoaded; this.Login_Button.Click += LoginButtonClick; } private void LoginButtonClick(object sender, RoutedEventArgs e) { LoginID = this.txtID.Text; LoginPasswd = this.txtPW.Password; if (string.IsNullOrEmpty(LoginID)) { MessageBox.Show("Please input ID."); Keyboard.Focus(this.txtID); return; } if (string.IsNullOrEmpty(LoginPasswd)) { MessageBox.Show("Please input PassWord."); Keyboard.Focus(this.txtPW); return; } doLogin(); } private void doLogin() { MessageBox.Show(string.Format("ID = {0}, PassWord = {1}", LoginID, LoginPasswd)); return; } private void OnLoaded(object sender, RoutedEventArgs e) { Keyboard.Focus(this.txtID); } private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) { Create_account ca = new Create_account(); ca.Show(); } } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | Create_account.xaml <Window x:Class="Chatting.Create_account" 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:Chatting" xmlns:system="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" Title="Create_account" Height="400" Width="300" ResizeMode="NoResize" Topmost="True"> <Grid Background="#FFB9BEC0"> <Grid.RowDefinitions> <RowDefinition Height="8*"></RowDefinition> <RowDefinition Height="2*"></RowDefinition> </Grid.RowDefinitions> <StackPanel Grid.Row="0" VerticalAlignment="Top" Margin="20,0,20,0" CanVerticallyScroll="True" Height="274.8"> <Label Content="_Create_id : " FontSize="20" Padding="0,10,0,5" Foreground="White" Target="{Binding ElementName=txtCID}" RenderTransformOrigin="0.494,-0.304"></Label> <TextBox Name="txtCID" Height="50" Foreground="#FFB9BEC0" TextAlignment="Center" VerticalContentAlignment="Center" FontSize="30"></TextBox> <Label Content="_Create_password : " FontSize="20" Padding="0,10,0,5" Foreground="White" Target="{Binding ElementName=txtCPW}"></Label> <TextBox Name="txtCPW" Height="50" Foreground="#FFB9BEC0" TextAlignment="Center" VerticalContentAlignment="Center" FontSize="30"></TextBox> <Label Content="_Create_nickname : " FontSize="20" Padding="0,10,0,5" Foreground="White" Target="{Binding ElementName=txtNN}"></Label> <TextBox Name="txtNN" Height="50" Foreground="#FFB9BEC0" TextAlignment="Center" VerticalContentAlignment="Center" FontSize="30"></TextBox> </StackPanel> <Button Name ="Create_Button" Grid.Row="1" Content="Create" FontSize="30" Foreground="Black" Background="white"></Button> </Grid> </Window> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | Create_account.xaml.cs using System; using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Linq; using System.Net; using System.Net.Http; 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.Shapes; namespace Chatting { /// <summary> /// Create_account.xaml에 대한 상호 작용 논리 /// </summary> public partial class Create_account : Window { public string InputID { get; set; } public string InputPW { get; set; } public string InputNN { get; set; } public Create_account() { InitializeComponent(); this.Loaded += OnLoaded; this.Create_Button.Click += CreateButtonClick; } private void CreateButtonClick(object sender, RoutedEventArgs e) { InputID = this.txtCID.Text; InputPW = this.txtCPW.Text; InputNN = this.txtNN.Text; if (string.IsNullOrEmpty(InputID)) { MessageBox.Show("Please input ID."); Keyboard.Focus(this.txtCID); return; } if (string.IsNullOrEmpty(InputPW)) { MessageBox.Show("Please input PassWord."); Keyboard.Focus(this.txtCPW); return; } if (string.IsNullOrEmpty(InputNN)) { MessageBox.Show("Please input NickName."); Keyboard.Focus(this.txtNN); return; } doCreate(); } private void doCreate() { MessageBox.Show(string.Format("ID = {0}, PassWord = {1}, NickName = {2}", InputID, InputPW, InputNN)); //참고용 사이트 : http://jsonobject.tistory.com/154 string sURL = string.Format("...?id={0}&pw={1}&nick={2}",InputID,InputPW,InputNN); WebClient webClient = new WebClient(); Stream stream = webClient.OpenRead(sURL); string responseJSON = new StreamReader(stream).ReadToEnd(); if (responseJSON.Contains("1")) { MessageBox.Show("Success account creation"); } else { MessageBox.Show("Creating account is failed"); } } private void OnLoaded(object sender, RoutedEventArgs e) { Keyboard.Focus(this.txtCID); } } } | cs |
'C# > WPF' 카테고리의 다른 글
WPF tutorial - The RadioButton control (0) | 2017.06.22 |
---|---|
WPF tutorial - The CheckBox control (0) | 2017.06.22 |
WPF tutorial - The TextBox control (0) | 2017.06.20 |
WPF tutorial - The Label control (0) | 2017.06.20 |
WPF tutorial - The TextBlock control (0) | 2017.06.20 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 스택
- Custom Cell
- dfs
- Grid
- WPF
- 코딩야학
- 객체
- DP
- 타일링
- 데이터 바인딩
- 백준온라인
- 그래프
- XAML
- CustomCollectionViewCell
- 백준
- UIView Animation
- Add TapGesture
- 생활코딩
- 문자열
- Fakebook
- MVVM
- listview
- FEED
- C++
- BFS
- CollectionView
- BOJ
- Cell Animation
- command
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함