Skip to content

Commit e792950

Browse files
committed
Added Error message dialog
1 parent df4c8bf commit e792950

File tree

6 files changed

+102
-3
lines changed

6 files changed

+102
-3
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<UserControl x:Class="LiveWriterPluginManager.Controls.Messages.ErrorControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:wpf="http://materialdesigninxaml.net/winfx/xaml/themes"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300"
9+
d:DesignWidth="300"
10+
MaxWidth="300">
11+
<Border Padding="10">
12+
<Grid>
13+
<Grid.RowDefinitions>
14+
<RowDefinition Height="3*" />
15+
<RowDefinition Height="Auto" />
16+
</Grid.RowDefinitions>
17+
<Grid.ColumnDefinitions>
18+
<ColumnDefinition Width="*" />
19+
<ColumnDefinition Width="3*" />
20+
</Grid.ColumnDefinitions>
21+
22+
<Border Background="OrangeRed"
23+
Grid.Row="0"
24+
VerticalAlignment="Top"
25+
Height="50"
26+
Width="50"
27+
CornerRadius="60">
28+
<Viewbox>
29+
<TextBlock Text="!"
30+
Foreground="White"
31+
HorizontalAlignment="Center"
32+
VerticalAlignment="Center"
33+
FontSize="53.333" />
34+
</Viewbox>
35+
</Border>
36+
37+
<TextBlock Grid.Row="0"
38+
Grid.Column="1"
39+
VerticalAlignment="Top"
40+
TextWrapping="Wrap"
41+
Text="{Binding ErrorMessage}"
42+
Margin="10,0,0,0"/>
43+
44+
<Button Grid.Row="1"
45+
Grid.Column="0"
46+
Grid.ColumnSpan="2"
47+
HorizontalAlignment="Center"
48+
Command="{x:Static wpf:DialogHost.CloseDialogCommand}"
49+
Content="Ok"
50+
IsDefault="True"
51+
Style="{DynamicResource MaterialDesignFlatButton}"
52+
Margin="0,10,0,0"/>
53+
</Grid>
54+
</Border>
55+
</UserControl>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Windows;
2+
3+
namespace LiveWriterPluginManager.Controls.Messages
4+
{
5+
/// <summary>
6+
/// Interaction logic for ErrorControl.xaml
7+
/// </summary>
8+
public partial class ErrorControl
9+
{
10+
public ErrorControl()
11+
{
12+
InitializeComponent();
13+
14+
DataContext = this;
15+
}
16+
17+
public static readonly DependencyProperty ErrorMessageProperty = DependencyProperty.Register(
18+
"ErrorMessage", typeof (string), typeof (ErrorControl), new PropertyMetadata(default(string)));
19+
20+
public string ErrorMessage
21+
{
22+
get { return (string) GetValue(ErrorMessageProperty); }
23+
set { SetValue(ErrorMessageProperty, value); }
24+
}
25+
}
26+
}

LiveWriterPluginManager/Controls/Messages/QuestionControl.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using System.Windows;
2-
using System.Windows.Controls;
32

43
namespace LiveWriterPluginManager.Controls.Messages
54
{
65
/// <summary>
76
/// Interaction logic for QuestionControl.xaml
87
/// </summary>
9-
public partial class QuestionControl : UserControl
8+
public partial class QuestionControl
109
{
1110
public QuestionControl()
1211
{

LiveWriterPluginManager/LiveWriterPluginManager.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
<Compile Include="Controls\AddPluginControl.xaml.cs">
118118
<DependentUpon>AddPluginControl.xaml</DependentUpon>
119119
</Compile>
120+
<Compile Include="Controls\Messages\ErrorControl.xaml.cs">
121+
<DependentUpon>ErrorControl.xaml</DependentUpon>
122+
</Compile>
120123
<Compile Include="Controls\Messages\QuestionControl.xaml.cs">
121124
<DependentUpon>QuestionControl.xaml</DependentUpon>
122125
</Compile>
@@ -143,6 +146,10 @@
143146
<SubType>Designer</SubType>
144147
<Generator>MSBuild:Compile</Generator>
145148
</Page>
149+
<Page Include="Controls\Messages\ErrorControl.xaml">
150+
<SubType>Designer</SubType>
151+
<Generator>MSBuild:Compile</Generator>
152+
</Page>
146153
<Page Include="Controls\Messages\QuestionControl.xaml">
147154
<SubType>Designer</SubType>
148155
<Generator>MSBuild:Compile</Generator>

LiveWriterPluginManager/Services/MessageService.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace LiveWriterPluginManager.Services
77
public interface IMessageService
88
{
99
Task<bool> ShowQuestionAsync(string question, string positive, string negative);
10+
Task ShowErrorAsync(string errorMessage);
1011
}
1112

1213
public class MessageService : IMessageService
@@ -22,5 +23,15 @@ public async Task<bool> ShowQuestionAsync(string question, string positive, stri
2223
var result = await DialogHost.Show(questionControl);
2324
return (bool)result;
2425
}
26+
27+
public Task ShowErrorAsync(string errorMessage)
28+
{
29+
var errorControl = new ErrorControl
30+
{
31+
ErrorMessage = errorMessage
32+
};
33+
34+
return DialogHost.Show(errorControl);
35+
}
2536
}
2637
}

LiveWriterPluginManager/ViewModel/PluginViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ public RelayCommand DeletePluginCommand
2828
{
2929
if (AppHelper.IsLiveWriterRunning())
3030
{
31-
// TODO: Display an error message
31+
await _messageService.ShowErrorAsync("Live Writer is currently running, please close it before trying to remove any plugins");
3232
return;
3333
}
34+
3435
var removePlugin = await _messageService.ShowQuestionAsync("Are you sure you wish to remove this plugin?", "Yes", "No, ignore me");
3536
if (removePlugin)
3637
{

0 commit comments

Comments
 (0)