Skip to content

Commit

Permalink
Merge pull request #19 from FlexConfirmMail/improve-confirm-new-domai…
Browse files Browse the repository at this point in the history
…n-dialog

Improve design of dialog to confirm new domain
  • Loading branch information
HashidaTKS authored Mar 28, 2024
2 parents 77a3e0c + a5f090e commit 2887a2b
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 36 deletions.
7 changes: 2 additions & 5 deletions Dialog/MainDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ private bool CheckNewDomains()
{
return true;
}
var message = string.Format(
Properties.Resources.ConfirmNewDomains,
string.Join("\n", newDomainAddresses));
MessageBoxResult result = MessageBox.Show(message, Properties.Resources.Warning, MessageBoxButton.YesNo);
return result == MessageBoxResult.Yes;
NewDomainDialog mainDialog = new NewDomainDialog(newDomainAddresses);
return mainDialog.ShowDialog() ?? false;
}

private bool IsEmbeddedImage(Outlook.Attachment item)
Expand Down
16 changes: 16 additions & 0 deletions Dialog/NewDomainDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Window x:Class="FlexConfirmMail.Dialog.NewDomainDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FlexConfirmMail"
xmlns:resx="clr-namespace:FlexConfirmMail.Properties"
Title="{x:Static resx:Resources.NewDomainDialogTitle}"
mc:Ignorable="d" Width="600" Height="400">
<Grid Background="Red">
<TextBlock x:Name="textBlockTitle" HorizontalAlignment="Center" TextWrapping="Wrap" Text="{x:Static resx:Resources.Warning}" VerticalAlignment="Top" TextAlignment="Center" Margin="-8,0,0,0" Width="450" Height="47" FontSize="36" Foreground="White"/>
<TextBlock x:Name="textBlockBody" TextWrapping="Wrap" Text="" Margin="50,62,50,40" Background="White" FontSize="24"/>
<Button x:Name="buttonSend" Content="{x:Static resx:Resources.Send}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="75" Margin="200,0,0,7" Height="25" Click="buttonSend_Click"/>
<Button Content="{x:Static resx:Resources.Cancel}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Margin="0,0,200,7" Height="25" IsCancel="True"/>
</Grid>
</Window>
44 changes: 44 additions & 0 deletions Dialog/NewDomainDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Threading;

namespace FlexConfirmMail.Dialog
{
public partial class NewDomainDialog : Window
{
public NewDomainDialog()
{
QueueLogger.Log($"===== Open {nameof(NewDomainDialog)} =====");
InitializeComponent();
}

public NewDomainDialog(HashSet<string> addresses) : this()
{
CultureInfo.CurrentCulture = new CultureInfo("en-US", false);

if (addresses.Count > 2)
{
double margin = 10;
this.Height += (addresses.Count - 2) * (textBlockBody.FontSize + margin);
}
textBlockBody.Inlines.Add(Properties.Resources.ConfirmNewDomainsBody1);
textBlockBody.Inlines.Add("\n\n");
textBlockBody.Inlines.Add(new Run()
{
Text = string.Join("\n", addresses),
FontWeight = FontWeights.Bold
});
textBlockBody.Inlines.Add("\n\n");
textBlockBody.Inlines.Add(Properties.Resources.ConfirmNewDomainsBody2);
}

private void buttonSend_Click(object sender, RoutedEventArgs e)
{
QueueLogger.Log($"* Send button clicked. closing...");
DialogResult = true;
}
}
}
7 changes: 7 additions & 0 deletions FlexConfirmMail.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
<Compile Include="Dialog\ConfigDialog.xaml.cs">
<DependentUpon>ConfigDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Dialog\NewDomainDialog.xaml.cs">
<DependentUpon>NewDomainDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Dialog\Helper.cs" />
<Compile Include="Config\Config.cs" />
<Compile Include="Config\File.cs" />
Expand Down Expand Up @@ -222,6 +225,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Dialog\NewDomainDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialog\MainDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
30 changes: 22 additions & 8 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,16 @@ so please use Bcc when sending an message to unrelated parties.</value>
<data name="ConfigSafeNewDomainsEnabled" xml:space="preserve">
<value>Confirm when any recipients with domains different from any existing recipients are added</value>
</data>
<data name="ConfirmNewDomains" xml:space="preserve">
<value>There are recipients with domains not included in the recipients of the original message.

{0}

Do you really want to send this message?</value>
<data name="ConfirmNewDomainsBody1" xml:space="preserve">
<value>There are recipients with domains not included in the recipients of the original message.</value>
</data>
<data name="NewDomainDialogTitle" xml:space="preserve">
<value>Warning - FlexConfirmMail</value>
</data>
<data name="ConfirmNewDomainsBody2" xml:space="preserve">
<value>Do you really want to send this message?</value>
</data>
<data name="Warning" xml:space="preserve">
<value>Warning</value>
<data name="Warrning" xml:space="preserve">
<value>Warning!</value>
</data>
</root>
16 changes: 9 additions & 7 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,16 @@ ToおよびCcに含まれるメールアドレスはすべての受取人が確
<data name="ConfigSafeNewDomainsEnabled" xml:space="preserve">
<value>返信の宛先に今まで含まれていなかったドメインのアドレスが追加された場合に警告する</value>
</data>
<data name="ConfirmNewDomains" xml:space="preserve">
<value>返信元のメールの宛先に含まれていなかったドメインの以下の宛先が追加されています。

{0}

送信してよろしいですか?</value>
<data name="ConfirmNewDomainsBody1" xml:space="preserve">
<value>返信元のメールの宛先に含まれていなかったドメインの以下の宛先が追加されています。</value>
</data>
<data name="NewDomainDialogTitle" xml:space="preserve">
<value>警告 - FlexConfirmMail</value>
</data>
<data name="ConfirmNewDomainsBody2" xml:space="preserve">
<value>送信してよろしいですか?</value>
</data>
<data name="Warning" xml:space="preserve">
<value>警告</value>
<value>警告</value>
</data>
</root>
16 changes: 9 additions & 7 deletions Properties/Resources.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,16 @@ example.org</value>
<data name="ConfigSafeNewDomainsEnabled" xml:space="preserve">
<value>Confirm when any recipients with domains different from any existing recipients are added</value>
</data>
<data name="ConfirmNewDomains" xml:space="preserve">
<value>There are recipients with domains not included in the recipients of the original message.

{0}

Do you really want to send this message?</value>
<data name="ConfirmNewDomainsBody1" xml:space="preserve">
<value>There are recipients with domains not included in the recipients of the original message.</value>
</data>
<data name="NewDomainDialogTitle" xml:space="preserve">
<value>警告 - FlexConfirmMail</value>
</data>
<data name="ConfirmNewDomainsBody2" xml:space="preserve">
<value>Do you really want to send this message?</value>
</data>
<data name="Warning" xml:space="preserve">
<value>警告</value>
<value>警告</value>
</data>
</root>
2 changes: 1 addition & 1 deletion ThisAddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class ThisAddIn
private Dictionary<string, List<RecipientInfo>> EntryIdToOriginalRecipientsDictionary { get; set; } = new Dictionary<string, List<RecipientInfo>>();

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
{
Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(ThisAddIn_ItemSend);
Explorers = Application.Explorers;
foreach (Outlook.Explorer explorer in Explorers)
Expand Down

0 comments on commit 2887a2b

Please sign in to comment.