๐Ÿ’Ž๋ชฉํ‘œ

image.png

โญํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

<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;
        }
    }
}

image.png

GitHub

๐Ÿš€ ์ข…์„ฑ ์ฒดํฌ