๐๋ชฉํ
- TextBlock, TextBox, ComboBox control ์ฌ์ฉ
- ๋
ธ๋ ์ ๋ณด๋ฅผ ์
๋ ฅํ๊ณ ์ถ๊ฐ ๋ฒํผ์ ๋๋ฅด๋ฉด ๋
ธ๋ ์ ๋ณด๊ฐ ํ
์คํธ ํํ๋ก ์ถ๋ ฅ
โญํ๋ก์ ํธ ์์ฑ
- WPF ์ ํ๋ฆฌ์ผ์ด์
- G24W1301WPFControls
<Window x:Class="G24W1301WPFControls.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:G24W1301WPFControls"
mc:Ignorable="d"
Title="๋
ธ๋ ์ ๋ณด" Height="450" Width="400">
<Border Padding="10">
<DockPanel>
<StackPanel DockPanel.Dock="Top">
<TextBlock Text="๋
ธ๋ ์
๋ ฅ"
FontWeight="Bold"
Margin="0, 10"/>
<TextBlock Text="์ ๋ชฉ"/>
<TextBox x:Name="Title" Padding="2"/>
<TextBlock Text="๊ฐ์" Margin="0, 10, 0, 0"/>
<TextBox x:Name="Singer" Padding="2"/>
<TextBlock Text="์ฅ๋ฅด" Margin="0, 10, 0, 0"/>
<ComboBox x:Name="Genre" Padding="2">
<ComboBoxItem>๋ฐ๋ผ๋</ComboBoxItem>
<ComboBoxItem>ํํฉ</ComboBoxItem>
<ComboBoxItem>ํธ๋กํธ</ComboBoxItem>
<ComboBoxItem>๋์ค</ComboBoxItem>
<ComboBoxItem>ํ</ComboBoxItem>
<ComboBoxItem>๊ธฐํ</ComboBoxItem>
</ComboBox>
<Button Content="์ถ๊ฐ" Margin="0, 20, 0, 0" Click="OnAdd"/>
</StackPanel>
<TextBox x:Name="Result" Margin="0, 20, 0, 0"
IsReadOnly="True" Background="LightGray"
AcceptsReturn="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
DockPanel.Dock="Bottom"/>
</DockPanel>
</Border>
</Window>
โญ์ข
์ฑ ์ฒดํฌ
- ์/๋, ์ด/๊ฐ, ์/๋ฅผ ์ฌ์ฉ ํ๋ณ
- ์์ด๋ ์๋จ
using System.Windows;
namespace G24W1301WPFControls {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void OnAdd(object sender, RoutedEventArgs e) {
string str = $"{Singer.Text}{(HasJongsung(Singer.Text) ? "์ด" : "๊ฐ")} ๋ถ๋ฅธ "
+ $"{Genre.Text} ์ฅ๋ฅด์ "
+ $"{Title.Text}{(HasJongsung(Title.Text) ? "์ด" : "๊ฐ")} ์ถ๊ฐ๋จ\\n";
//Result.Text += str;
Result.Text = str + Result.Text;
}
public bool HasJongsung(string str) {
if (str.Length < 1)
return true;
char last = str[str.Length - 1];
// return (last - 44032) % 28 != 0 ? true : false;
return (last - 44032) % 28 != 0;
}
}
}
GitHub
๐ ์ข
์ฑ ์ฒดํฌ