Skip to content
This repository was archived by the owner on Nov 25, 2023. It is now read-only.

Commit b459da4

Browse files
authored
Merge pull request #88 from Invvard/feature/add-reddit-link
Feature/add reddit link
2 parents 6f32205 + c90dd1d commit b459da4

File tree

5 files changed

+74
-22
lines changed

5 files changed

+74
-22
lines changed

src/InvvardDev.EZLayoutDisplay.Desktop/InvvardDev.EZLayoutDisplay.Desktop.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@
279279
<Resource Include="Skins\Images\pin.png" />
280280
<Resource Include="Skins\Images\pin.remove.png" />
281281
</ItemGroup>
282+
<ItemGroup>
283+
<Resource Include="Skins\Images\reddit-logo.png" />
284+
</ItemGroup>
282285
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
283286
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
284287
Other similar extension points exist, see Microsoft.Common.targets.
784 Bytes
Loading

src/InvvardDev.EZLayoutDisplay.Desktop/View/AboutWindow.xaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
mc:Ignorable="d"
7-
Title="{Binding WindowTitle}" Height="300" Width="500"
7+
Title="{Binding WindowTitle}" Height="330" Width="500"
88
ResizeMode="NoResize" Background="{StaticResource WindowBackgroundBrush}"
99
WindowStartupLocation="CenterScreen" Icon="{StaticResource WindowIcon}"
1010
DataContext="{Binding About, Source={StaticResource Locator}}">
@@ -21,6 +21,7 @@
2121
<RowDefinition/>
2222
<RowDefinition/>
2323
<RowDefinition/>
24+
<RowDefinition/>
2425
<RowDefinition Height="10"/>
2526
<RowDefinition/>
2627
</Grid.RowDefinitions>
@@ -29,7 +30,7 @@
2930
<ColumnDefinition Width="100"/>
3031
<ColumnDefinition Width="19*"/>
3132
</Grid.ColumnDefinitions>
32-
<Image Source="{StaticResource EzLogo}" Grid.RowSpan="8"/>
33+
<Image Source="{StaticResource EzLogo}" Grid.RowSpan="9"/>
3334

3435
<StackPanel Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2">
3536
<Label Content="{Binding AppTitleLabel}" Style="{StaticResource AppTitleStyle}"/>
@@ -56,11 +57,17 @@
5657

5758
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="2">
5859
<Image Source="/InvvardDev.EZLayoutDisplay.Desktop;component/Skins/Images/twitter-logo.png" Style="{StaticResource LogoInfoStyle}"/>
59-
<Button Style="{StaticResource HyperlinkStyledButton}" Content="{Binding ContactInfoLabel}"
60-
Command="{Binding NavigateContactUrlCommand}" />
60+
<Button Style="{StaticResource HyperlinkStyledButton}" Content="{Binding TwitterInfoLabel}"
61+
Command="{Binding NavigateTwitterUrlCommand}" />
62+
</StackPanel>
63+
64+
<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="2">
65+
<Image Source="/InvvardDev.EZLayoutDisplay.Desktop;component/Skins/Images/reddit-logo.png" Style="{StaticResource LogoInfoStyle}"/>
66+
<Button Style="{StaticResource HyperlinkStyledButton}" Content="{Binding RedditInfoLabel}"
67+
Command="{Binding NavigateRedditUrlCommand}" />
6168
</StackPanel>
6269

63-
<Button Grid.Row="7" Grid.Column="2" Content="{Binding CloseButtonLabel}"
70+
<Button Grid.Row="8" Grid.Column="2" Content="{Binding CloseButtonLabel}"
6471
Command="{Binding CloseAboutCommand}"
6572
Width="100" Margin="0,5,5,5" HorizontalAlignment="Right"/>
6673
</Grid>

src/InvvardDev.EZLayoutDisplay.Desktop/ViewModel/AboutViewModel.cs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ public class AboutViewModel : ViewModelBase
3030
private string _creatorInfoLabel;
3131
private string _basedOnInfoLabel;
3232
private string _projectHomeInfoLabel;
33-
private string _contactInfoLabel;
33+
private string _twitterInfoLabel;
34+
private string _redditInfoLabel;
3435
private string _closeButtonLabel;
3536

3637
private readonly string _basedOnUrl;
3738
private readonly string _projectHomeUrl;
38-
private readonly string _contactUrl;
39+
private readonly string _twitterUrl;
40+
private readonly string _redditUrl;
3941

4042
private ICommand _navigateBasedOnUrlCommand;
4143
private ICommand _navigateProjectHomeUrlCommand;
42-
private ICommand _navigateContactUrlCommand;
44+
private ICommand _navigateTwitterUrlCommand;
45+
private ICommand _navigateRedditUrlCommand;
4346
private ICommand _closeAboutCommand;
4447

4548
#endregion
@@ -109,10 +112,16 @@ public string ProjectHomeInfoLabel
109112
set => Set(ref _projectHomeInfoLabel, value);
110113
}
111114

112-
public string ContactInfoLabel
115+
public string TwitterInfoLabel
113116
{
114-
get => _contactInfoLabel;
115-
set => Set(ref _contactInfoLabel, value);
117+
get => _twitterInfoLabel;
118+
set => Set(ref _twitterInfoLabel, value);
119+
}
120+
121+
public string RedditInfoLabel
122+
{
123+
get => _redditInfoLabel;
124+
set => Set(ref _redditInfoLabel, value);
116125
}
117126

118127
public string CloseButtonLabel
@@ -140,11 +149,18 @@ public string CloseButtonLabel
140149
?? (_navigateProjectHomeUrlCommand = new RelayCommand(NavigateProjectHomeUrl));
141150

142151
/// <summary>
143-
/// Navigate to contact URL command.
152+
/// Navigate to Twitter URL command.
153+
/// </summary>
154+
public ICommand NavigateTwitterUrlCommand =>
155+
_navigateTwitterUrlCommand
156+
?? (_navigateTwitterUrlCommand = new RelayCommand(NavigateTwitterUrl));
157+
158+
/// <summary>
159+
/// Navigate to Reddit URL command.
144160
/// </summary>
145-
public ICommand NavigateContactUrlCommand =>
146-
_navigateContactUrlCommand
147-
?? (_navigateContactUrlCommand = new RelayCommand(NavigateContactUrl));
161+
public ICommand NavigateRedditUrlCommand =>
162+
_navigateRedditUrlCommand
163+
?? (_navigateRedditUrlCommand = new RelayCommand(NavigateRedditUrl));
148164

149165
/// <summary>
150166
/// Close about window command.
@@ -166,7 +182,8 @@ public AboutViewModel(IWindowService windowService, IProcessService processServi
166182

167183
_basedOnUrl = "https://configure.ergodox-ez.com/layouts/default/latest/0";
168184
_projectHomeUrl = "https://github.com/Invvard/EZLayoutDisplay";
169-
_contactUrl = "https://twitter.com/invvard";
185+
_twitterUrl = "https://twitter.com/invvard";
186+
_redditUrl = "https://www.reddit.com/r/EZLayoutDisplay/";
170187

171188
SetLabelUi();
172189
}
@@ -189,7 +206,8 @@ private void SetLabelUi()
189206
CreatorInfoLabel = "Pierre CAVAROC";
190207
BasedOnInfoLabel = "ErgoDox EZ Configurator";
191208
ProjectHomeInfoLabel = appTitle;
192-
ContactInfoLabel = "@Invvard";
209+
TwitterInfoLabel = "@Invvard";
210+
RedditInfoLabel = "r/EZLayoutDisplay";
193211
CloseButtonLabel = "OK";
194212
}
195213

@@ -229,10 +247,16 @@ private void NavigateProjectHomeUrl()
229247
_processService.StartWebUrl(_projectHomeUrl);
230248
}
231249

232-
private void NavigateContactUrl()
250+
private void NavigateTwitterUrl()
251+
{
252+
Logger.TraceRelayCommand();
253+
_processService.StartWebUrl(_twitterUrl);
254+
}
255+
256+
private void NavigateRedditUrl()
233257
{
234258
Logger.TraceRelayCommand();
235-
_processService.StartWebUrl(_contactUrl);
259+
_processService.StartWebUrl(_redditUrl);
236260
}
237261

238262
private void CloseAboutWindow()

src/InvvardDev.EZLayoutDisplay.Tests/ViewModel/AboutViewModelTest.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public void AboutViewModelConstructor()
2929
Assert.Equal("Pierre CAVAROC", aboutViewModel.CreatorInfoLabel);
3030
Assert.Equal("ErgoDox EZ Configurator", aboutViewModel.BasedOnInfoLabel);
3131
Assert.Equal("EZ Layout Display", aboutViewModel.ProjectHomeInfoLabel);
32-
Assert.Equal("@Invvard", aboutViewModel.ContactInfoLabel);
32+
Assert.Equal("@Invvard", aboutViewModel.TwitterInfoLabel);
33+
Assert.Equal("r/EZLayoutDisplay", aboutViewModel.RedditInfoLabel);
3334
Assert.Equal("OK", aboutViewModel.CloseButtonLabel);
3435
}
3536

@@ -84,7 +85,7 @@ public void NavigateProjectHomeUrl_Execute()
8485
}
8586

8687
[ Fact ]
87-
public void NavigateContactUrl_Execute()
88+
public void NavigateTwitterUrl_Execute()
8889
{
8990
// Arrange
9091
var expectedUrl = "https://twitter.com/invvard";
@@ -94,7 +95,24 @@ public void NavigateContactUrl_Execute()
9495

9596
// Act
9697
var aboutViewModel = new AboutViewModel(mockWindowService.Object, mockProcessService.Object);
97-
aboutViewModel.NavigateContactUrlCommand.Execute(null);
98+
aboutViewModel.NavigateTwitterUrlCommand.Execute(null);
99+
100+
// Assert
101+
mockProcessService.Verify(p => p.StartWebUrl(expectedUrl));
102+
}
103+
104+
[ Fact ]
105+
public void NavigateRedditUrl_Execute()
106+
{
107+
// Arrange
108+
var expectedUrl = "https://www.reddit.com/r/EZLayoutDisplay/";
109+
var mockWindowService = new Mock<IWindowService>();
110+
var mockProcessService = new Mock<IProcessService>();
111+
mockProcessService.Setup(p => p.StartWebUrl(expectedUrl)).Verifiable();
112+
113+
// Act
114+
var aboutViewModel = new AboutViewModel(mockWindowService.Object, mockProcessService.Object);
115+
aboutViewModel.NavigateRedditUrlCommand.Execute(null);
98116

99117
// Assert
100118
mockProcessService.Verify(p => p.StartWebUrl(expectedUrl));

0 commit comments

Comments
 (0)