Skip to content

Commit

Permalink
Add recipient item
Browse files Browse the repository at this point in the history
  • Loading branch information
woin2ee committed Oct 14, 2024
1 parent aca77d6 commit cddad7f
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 31 deletions.
41 changes: 27 additions & 14 deletions MemoGenerator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,36 @@
</StackPanel>

<StackPanel VerticalAlignment="Top" Orientation="Horizontal" Spacing="26">
<StackPanel Margin="0,-10,0,0" Orientation="Vertical">
<TextBlock Margin="10,11,0,10" VerticalAlignment="Center" FontWeight="Bold" Text="거래 식별" />
<StackPanel Width="220" Padding="10" VerticalAlignment="Top" Background="#F6F6F6" BorderBrush="DarkGray"
BorderThickness="1" CornerRadius="10" Orientation="Vertical">
<TextBox x:Name="dateTextBox" Width="100" Margin="4" HorizontalAlignment="Left" Header="날짜"
PlaceholderForeground="LightGray" PlaceholderText="240619" TextChanged="updateIdentifyingComponent" />
<TextBlock x:Name="dateErrorTextBox" Margin="4" FontSize="11" Foreground="Red" Text="날짜 오류" />
<TextBox x:Name="amountTextBox" Width="180" Margin="4" HorizontalAlignment="Left" Header="금액"
PlaceholderForeground="LightGray" PlaceholderText="금액을 입력하세요." TextChanged="updateIdentifyingComponent" />
<StackPanel Margin="0,-10,0,0" Orientation="Vertical" Spacing="20">
<StackPanel Orientation="Vertical">
<TextBlock Margin="10,11,0,10" VerticalAlignment="Center" FontWeight="Bold" Text="거래 식별" />
<StackPanel Width="220" Padding="10" VerticalAlignment="Top" Background="#F6F6F6" BorderBrush="DarkGray"
BorderThickness="1" CornerRadius="10" Orientation="Vertical">
<TextBox x:Name="dateTextBox" Width="100" Margin="4" HorizontalAlignment="Left" Header="날짜"
PlaceholderForeground="LightGray" PlaceholderText="240619" TextChanged="updateIdentifyingComponent" />
<TextBlock x:Name="dateErrorTextBox" Margin="4" FontSize="11" Foreground="Red" Text="날짜 오류" />
<TextBox x:Name="amountTextBox" Width="180" Margin="4" HorizontalAlignment="Left" Header="금액"
PlaceholderForeground="LightGray" PlaceholderText="금액을 입력하세요." TextChanged="updateIdentifyingComponent" />
</StackPanel>
</StackPanel>
<StackPanel x:Name="recipientStackPanel" Orientation="Vertical">
<TextBlock Margin="10,11,0,10" VerticalAlignment="Center" FontWeight="Bold" Text="수신인" />
<StackPanel Width="220" Padding="10" VerticalAlignment="Top" Background="#F6F6F6" BorderBrush="DarkGray"
BorderThickness="1" CornerRadius="10" Orientation="Vertical">

<TextBox x:Name="nameTextBox" Width="180" Margin="4" HorizontalAlignment="Left" Header="이름"
IsEnabled="True" PlaceholderForeground="LightGray" PlaceholderText="이름"
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextChanged="updateMemoTextBlock" />
<TextBox x:Name="emailTextBox" Width="180" Margin="4" HorizontalAlignment="Left" Header="메일"
IsEnabled="True" PlaceholderForeground="LightGray" PlaceholderText="example@email.com"
Text="{Binding EmailAddress, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextChanged="updateMemoTextBlock" />
</StackPanel>
</StackPanel>
</StackPanel>


<StackPanel x:Name="paymentProofStackPanel" Margin="0,-10,0,0" Orientation="Vertical">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<TextBlock Margin="10,0,0,0" VerticalAlignment="Center" FontWeight="Bold" Text="결제 증빙" />
Expand Down Expand Up @@ -122,11 +140,6 @@
<TextBlock Margin="4" FontWeight="Normal" Text="발송 경로" />
<CheckBox x:Name="sendingEmailCheckBox" Click="updateDocumentsDeliveryRouteComponent" Content="메일"
IsChecked="{Binding DeliversByEmail, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<TextBox x:Name="emailTextBox" Width="200" Margin="4" HorizontalAlignment="Left"
IsEnabled="{Binding DeliversByEmail}"
PlaceholderForeground="LightGray" PlaceholderText="example@email.com"
Text="{Binding EmailAddress, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
TextChanged="updateDocumentsDeliveryRouteComponent" />
<CheckBox x:Name="sendingRegisteredCheckBox" Click="updateDocumentsDeliveryRouteComponent" Content="등기"
IsChecked="{Binding DeliversByRegisteredMail, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<TextBox x:Name="documentListTextBox" Width="200" Margin="4,14,4,4" Header="상세 목록" PlaceholderForeground="LightGray"
Expand Down
17 changes: 13 additions & 4 deletions MemoGenerator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public sealed partial class MainWindow : Window
private TaxCalculatingModel taxCalculatingModel = new TaxCalculatingModel();
private PaymentProofModel paymentProofModel = new PaymentProofModel();
private ProofDocumentModel proofDocumentModel = new ProofDocumentModel();
private RecipientModel recipientModel = new RecipientModel();

public MainWindow()
{
Expand Down Expand Up @@ -69,6 +70,7 @@ public MainWindow()
taxCalculatorPanel.DataContext = taxCalculatingModel;
paymentProofStackPanel.DataContext = paymentProofModel;
proofDocumentStackPanel.DataContext = proofDocumentModel;
recipientStackPanel.DataContext = recipientModel;

disableDeductionGroup();
}
Expand All @@ -86,7 +88,7 @@ private void changePanel(object sender, RoutedEventArgs e)
panels[tag].Visibility = Visibility.Visible;
}

private void updateMemoTextBlock()
private void updateMemoTextBlock(object sender, RoutedEventArgs e)
{
const char componentPrefix = '[';
const char componentSuffix = ']';
Expand All @@ -107,6 +109,11 @@ private void updateMemoTextBlock()

string text = String.Join("-", components);

if (!String.IsNullOrEmpty(recipientModel.memoComponent))
{
text += $" {recipientModel.memoComponent}";
}

memoTextBox.Text = text;
}

Expand Down Expand Up @@ -142,7 +149,7 @@ private void updateIdentifyingComponent(object sender, TextChangedEventArgs e)
}

identifyingComponent = String.Join(" ", elements);
updateMemoTextBlock();
updateMemoTextBlock(null, null);
}

private void updatePaymentProofMethodComponent(object sender, RoutedEventArgs e)
Expand All @@ -151,13 +158,13 @@ private void updatePaymentProofMethodComponent(object sender, RoutedEventArgs e)
// 분할 발행 기능

paymentProofMethodComponent = paymentProofModel.memoComponent;
updateMemoTextBlock();
updateMemoTextBlock(null, null);
}

private void updateDocumentsDeliveryRouteComponent(object sender, RoutedEventArgs e)
{
documentsDeliveryRouteComponent = proofDocumentModel.memoComponent;
updateMemoTextBlock();
updateMemoTextBlock(null, null);
}

private void resetButton_Click(object sender, RoutedEventArgs e)
Expand All @@ -175,6 +182,8 @@ private void memoResetButton_Click(object sender, RoutedEventArgs e)
paymentProofModel.propertyChanged(null);
proofDocumentModel.initializeProofDocumentModel();
proofDocumentModel.propertyChanged(null);
recipientModel.initializeRecipientModel();
recipientModel.propertyChanged(null);
updatePaymentProofMethodComponent(null, null);
updateDocumentsDeliveryRouteComponent(null, null);
}
Expand Down
13 changes: 0 additions & 13 deletions MemoGenerator/Model/MemoGenerating/ProofDocumentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ internal static string name(this PreDefinedDocument document)
sealed class ProofDocumentModel : BaseINotifyPropertyChanged
{
private Dictionary<DeliveryRoute, bool> deliveryRouteSelections;
private string? emailAddress;
private string? detailedDocumentList;
private Dictionary<PreDefinedDocument, bool> preDefinedDocumentSelections;
internal string memoComponent
Expand Down Expand Up @@ -89,7 +88,6 @@ internal string memoComponent
if (deliversDocument)
{
elements.Add("발송");
if (emailAddress is string) elements.Add(emailAddress);
}

return String.Join(" ", elements);
Expand All @@ -108,7 +106,6 @@ internal void initializeProofDocumentModel()
this.deliveryRouteSelections = new Dictionary<DeliveryRoute, bool>();
deliveryRouteSelections.Add(DeliveryRoute.email, false);
deliveryRouteSelections.Add(DeliveryRoute.registeredMail, false);
this.emailAddress = null;
this.detailedDocumentList = null;
this.preDefinedDocumentSelections = new Dictionary<PreDefinedDocument, bool>();
disableAllPreDefinedDocumentSelections();
Expand All @@ -135,16 +132,6 @@ public bool DeliversByRegisteredMail
}
}

public string EmailAddress
{
get => emailAddress ?? "";
set
{
if (String.IsNullOrEmpty(value)) emailAddress = null;
else emailAddress = value;
}
}

public string DetailedDocumentList
{
get => detailedDocumentList ?? "";
Expand Down
68 changes: 68 additions & 0 deletions MemoGenerator/Model/MemoGenerating/RecipientModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

#nullable enable

namespace MemoGenerator.Model.MemoGenerating
{
sealed class RecipientModel : BaseINotifyPropertyChanged
{
private string? name;
private string? emailAddress;

internal string memoComponent
{
get
{
List<String> elements = new List<string>();
if (name != null)
{
elements.Add(name);
}
if (emailAddress != null)
{
elements.Add(emailAddress);
}
return String.Join(" ", elements);
}
}

internal RecipientModel()
{
initializeRecipientModel();
}

internal void initializeRecipientModel()
{
this.name = null;
this.emailAddress = null;
}

// Bindings

public string Name
{
get => name ?? "";
set
{
if (String.IsNullOrEmpty(value)) name = null;
else name = value;
}
}

public string EmailAddress
{
get => emailAddress ?? "";
set
{
if (String.IsNullOrEmpty(value)) emailAddress = null;
else emailAddress = value;
}
}
}
}

#nullable disable

0 comments on commit cddad7f

Please sign in to comment.