C#/Basics

W014. WindowsCalc

페프 2021. 4. 25. 22:49

GUI

<Window x:Class="W014.WindowsCalc.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:W014.WindowsCalc"
        mc:Ignorable="d"
        Title="윈도우 표준계산기" 
        Height="550" Width="400"
        MinHeight="580" MinWidth="400"
        >
    <DockPanel LastChildFill="True">
        <!-- 메뉴 -->
        <Menu Padding="5" DockPanel.Dock="Top" Background="WhiteSmoke">
            <MenuItem Header="선택">
                <MenuItem Header="표준"/>
                <MenuItem Header="공학용"/>
                <MenuItem Header="프로그래머용"/>
            </MenuItem>
            <MenuItem Header="끝내기"/>
        </Menu>
        <!-- 결과창 -->
        <Grid Height="100" DockPanel.Dock="Top" Background="WhiteSmoke">
            <TextBox x:Name="txtExp" FontSize="16"
                     HorizontalAlignment="Right" Margin="15" Text="1234"
                     BorderThickness="0" Background="WhiteSmoke">
            </TextBox>
            <TextBox x:Name="txtResult"
                     FontWeight="Bold" FontSize="36"
                     VerticalAlignment="Bottom"
                     HorizontalContentAlignment="Right"
                     Margin="15" Text="0"
                     Background="WhiteSmoke">
            </TextBox>
        </Grid>
        <Grid Height="50" Background="LightGray"
              DockPanel.Dock="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button x:Name="btnMC" Grid.Column="0"
                    FontSize="14" BorderThickness="0"
                    FontWeight="Bold" Background="WhiteSmoke"
                    IsEnabled="False">
                MC
            </Button>
            <Button x:Name="btnMR" Grid.Column="1"
                    FontSize="14" BorderThickness="0"
                    FontWeight="Bold" Background="WhiteSmoke"
                    IsEnabled="False">
                MR
            </Button>
            <Button x:Name="btnMPlus" Grid.Column="2"
                    FontSize="14" BorderThickness="0"
                    FontWeight="Bold" Background="WhiteSmoke"
                    IsEnabled="False">
                M+
            </Button>
            <Button x:Name="btnMMinus" Grid.Column="3"
                    FontSize="14" BorderThickness="0"
                    FontWeight="Bold" Background="WhiteSmoke"
                    IsEnabled="False">
                M-
            </Button>
            <Button x:Name="btnMS" Grid.Column="4"
                    FontSize="14" BorderThickness="0"
                    FontWeight="Bold" Background="WhiteSmoke"
                    IsEnabled="False">
                MS
            </Button>
        </Grid>
        
        <!-- 버튼들 -->
        <Grid MinHeight="360" Background="LightGray">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            
            <Button Grid.Row="0" Grid.Column="0" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                %
            </Button>
            <Button Grid.Row="0" Grid.Column="1" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                √
            </Button>
            <Button Grid.Row="0" Grid.Column="2" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                x²
            </Button>
            <Button Grid.Row="0" Grid.Column="3" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                x
            </Button>

            <!-- 첫 번쨰 줄-->
            <Button Grid.Row="1" Grid.Column="0" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                CE
            </Button>
            <Button Grid.Row="1" Grid.Column="1" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                C
            </Button>
            <Button Grid.Row="1" Grid.Column="2" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                ⌫
            </Button>
            <Button Grid.Row="1" Grid.Column="3" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                ÷
            </Button>

            <!-- 두 번쨰 줄-->
            <Button Grid.Row="2" Grid.Column="0" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                7
            </Button>
            <Button Grid.Row="2" Grid.Column="1" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                8
            </Button>
            <Button Grid.Row="2" Grid.Column="2" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                9
            </Button>
            <Button Grid.Row="2" Grid.Column="3" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                ×
            </Button>


            <!-- 세 번쨰 줄-->
            <Button Grid.Row="3" Grid.Column="0" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                4
            </Button>
            <Button Grid.Row="3" Grid.Column="1" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                5
            </Button>
            <Button Grid.Row="3" Grid.Column="2" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                6
            </Button>
            <Button Grid.Row="3" Grid.Column="3" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                -
            </Button>

            <!-- 네 번쨰 줄-->
            <Button Grid.Row="4" Grid.Column="0" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                1
            </Button>
            <Button Grid.Row="4" Grid.Column="1" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                2
            </Button>
            <Button Grid.Row="4" Grid.Column="2" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                3
            </Button>
            <Button Grid.Row="4" Grid.Column="3" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                +
            </Button>

            <!-- 다섯 번쨰 줄-->
            <Button Grid.Row="5" Grid.Column="0" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1"
                    >
                ±
            </Button>
            <Button Grid.Row="5" Grid.Column="1" BorderThickness="0"
                    FontSize="22" Margin="2,1,1,1"
                    Background="WhiteSmoke" FontWeight="Bold">
                0
            </Button>
            <Button Grid.Row="5" Grid.Column="2" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1"
                    >
                .
            </Button>
            <Button Grid.Row="5" Grid.Column="3" BorderThickness="0"
                    FontSize="25" Margin="2,1,1,1">
                =
            </Button>
        </Grid>
    </DockPanel>
</Window>