Skip to content

Commit afaddf0

Browse files
author
Fujimoto Seiji
committed
Tweak the placeholder behavior on ConfigDialog()
- Make the explanation more concise. - Use the placeholder only when configuration does not exist. Signed-off-by: Fujimoto Seiji <[email protected]>
1 parent dea11d4 commit afaddf0

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

Config/FileLoader.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,18 @@ public bool TryOptionFile(string basedir, string file)
5050
return false;
5151
}
5252
}
53-
public string TryRawFile(string basedir, string file)
53+
public bool TryRawFile(string basedir, string file, out string ret)
5454
{
5555
try
5656
{
57-
return File.ReadAllText(Path.Combine(basedir, file));
57+
ret = File.ReadAllText(Path.Combine(basedir, file));
58+
return true;
5859
}
5960
catch (IOException e)
6061
{
6162
QueueLogger.Log($"* Skip {file} ({e.GetType().Name})");
62-
return "";
63+
ret = "";
64+
return false;
6365
}
6466
}
6567

Dialog/ConfigDialog.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<TabItem Header="注意が必要なファイル名">
6363
<Grid>
6464

65-
<GroupBox Header="注意が必要なドメイン設定" Margin="5,5,5,5">
65+
<GroupBox Header="注意が必要なファイル名設定" Margin="5,5,5,5">
6666
<TextBox x:Name="UnsafeFiles" AcceptsReturn="True" Padding="1,3,1,3" Margin="3,3,3,3"></TextBox>
6767
</GroupBox>
6868
</Grid>

Dialog/ConfigDialog.xaml.cs

+28-21
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,34 @@ namespace FlexConfirmMail.Dialog
1111
public partial class ConfigDialog : Window
1212
{
1313
private string _templateTrutedDomains = @"
14-
# 社内の宛先として扱うドメイン ###
14+
# 社内ドメイン設定 ###
1515
#
16-
# ドメインとはメールアドレスのうち「@」の後の部分を指し、
17-
# 以下の例のように一行に一件ずつ記載します。
16+
# (1) 送信時に社内の宛先として扱うドメインを指定します。
17+
# (2) 以下の例のように一行に一件ずつ記載します。
18+
# (3) 冒頭が「#」から始まる行は無視されます。
1819
#
19-
# また、冒頭が「#」から始まる行は無視されますので、
20-
# 更新管理にご利用下さい。
2120
##################################
2221
2322
example.com
2423
example.org";
2524
private string _templateUnsafeDomains = @"
26-
# 送信時に警告するドメイン ###
25+
# 注意が必要なドメイン設定 ###
2726
#
28-
# ドメインとはメールアドレスのうち「@」の後の部分を指し、
29-
# 以下の例のように一行に一件ずつ記載します。
27+
# (1) 送信時に警告対象とする注意ドメインを指定します。
28+
# (2) 以下の例のように一行に一件ずつ記載します。
29+
# (3) 冒頭が「#」から始まる行は無視されます。
3030
#
31-
# また、冒頭が「#」から始まる行は無視されますので、
32-
# 更新管理にご利用下さい。
3331
##################################
3432
3533
example.com
3634
example.org";
3735
private string _templateUnsafeFiles = @"
38-
# 警告対象となるファイル名 ###
36+
# 注意が必要なファイル名設定 ###
3937
#
40-
# 添付ファイルに含まれている場合に警告対象とする単語を
41-
# 以下の例のように一行に一件ずつ記載します。
38+
# (1) 添付ファイルに含まれる場合に警告する注意ワードを指定します。
39+
# (2) 以下の例のように一行に一件ずつ記載します。
40+
# (3) 冒頭が「#」から始まる行は無視されます。
4241
#
43-
# また、冒頭が「#」から始まる行は無視されますので、
44-
# 更新管理にご利用下さい。
4542
##################################
4643
4744
社外秘
@@ -65,22 +62,32 @@ public ConfigDialog()
6562
SafeBccThreshold.Text = config.GetInt(ConfigOption.SafeBccThreshold).ToString();
6663

6764
// TrustedDomains
68-
TrustedDomains.Text = loader.TryRawFile(StandardPath.GetUserDir(), ConfigFile.TrustedDomains);
69-
if (String.IsNullOrWhiteSpace(TrustedDomains.Text))
65+
string text;
66+
if (loader.TryRawFile(StandardPath.GetUserDir(), ConfigFile.TrustedDomains, out text))
67+
{
68+
TrustedDomains.Text = text;
69+
}
70+
else
7071
{
7172
TrustedDomains.Text = _templateTrutedDomains.Trim();
7273
}
7374

7475
// UnsafeDomains
75-
UnsafeDomains.Text = loader.TryRawFile(StandardPath.GetUserDir(), ConfigFile.UnsafeDomains);
76-
if (String.IsNullOrWhiteSpace(UnsafeDomains.Text))
76+
if (loader.TryRawFile(StandardPath.GetUserDir(), ConfigFile.UnsafeDomains, out text))
77+
{
78+
UnsafeDomains.Text = text;
79+
}
80+
else
7781
{
7882
UnsafeDomains.Text = _templateUnsafeDomains.Trim();
7983
}
8084

8185
// UnsafeFiles
82-
UnsafeFiles.Text = loader.TryRawFile(StandardPath.GetUserDir(), ConfigFile.UnsafeFiles);
83-
if (String.IsNullOrWhiteSpace(UnsafeFiles.Text))
86+
if (loader.TryRawFile(StandardPath.GetUserDir(), ConfigFile.UnsafeFiles, out text))
87+
{
88+
UnsafeFiles.Text = text;
89+
}
90+
else
8491
{
8592
UnsafeFiles.Text = _templateUnsafeFiles.Trim();
8693
}

0 commit comments

Comments
 (0)