Skip to content

Commit 8f37198

Browse files
committed
Added General section of Settings (#670)
1 parent 11c64e5 commit 8f37198

File tree

8 files changed

+296
-3
lines changed

8 files changed

+296
-3
lines changed

InternetTest/InternetTest/Components/Sidebar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250

251251
<RadioButton
252252
Grid.Row="4"
253-
Padding="5"
253+
Padding="5" Command="{Binding SettingsPageCommand}"
254254
HorizontalContentAlignment="Left"
255255
Background="Transparent"
256256
GroupName="Sidebar"

InternetTest/InternetTest/Enums/AppPages.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public enum AppPages
2828
Settings = -1, // Special page
2929
Home,
3030
History, // Legacy feature, leaving for compatibility
31-
Status,
31+
Status, // Legacy feature, leaving for compatibility
3232
DownDetector,
33-
MyIP,
33+
MyIP, // Legacy feature, leaving for compatibility
3434
LocateIP,
3535
Ping,
3636
IPConfig,

InternetTest/InternetTest/InternetTest.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13+
<None Remove="Assets\DarkTheme.png" />
14+
<None Remove="Assets\LightTheme.png" />
15+
<None Remove="Assets\SystemTheme.png" />
1316
<None Remove="Fonts\FluentSystemIcons-Filled.ttf" />
1417
<None Remove="Fonts\FluentSystemIcons-Regular.ttf" />
1518
<None Remove="Fonts\Hauora-ExtraBold.ttf" />
@@ -29,6 +32,15 @@
2932
</ItemGroup>
3033

3134
<ItemGroup>
35+
<Resource Include="Assets\DarkTheme.png">
36+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
37+
</Resource>
38+
<Resource Include="Assets\LightTheme.png">
39+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
40+
</Resource>
41+
<Resource Include="Assets\SystemTheme.png">
42+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
43+
</Resource>
3244
<Resource Include="Fonts\FluentSystemIcons-Filled.ttf">
3345
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3446
</Resource>

InternetTest/InternetTest/MainWindow.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
<DataTemplate DataType="{x:Type vm:HomePageViewModel}">
2929
<views:HomePage />
3030
</DataTemplate>
31+
<DataTemplate DataType="{x:Type vm:SettingsPageViewModel}">
32+
<views:SettingsPage />
33+
</DataTemplate>
3134
</Grid.Resources>
3235
<Grid DataContext="{Binding SidebarViewModel}">
3336
<Grid.Resources>

InternetTest/InternetTest/ViewModels/Components/SidebarViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,23 @@ public class SidebarViewModel : ViewModelBase
3131
private readonly MainViewModel _mainViewModel;
3232

3333
public ICommand HomePageCommand { get; }
34+
public ICommand SettingsPageCommand { get; }
3435

3536
public SidebarViewModel(MainViewModel mainViewModel)
3637
{
3738
_mainViewModel = mainViewModel;
3839

3940
HomePageCommand = new RelayCommand(HomePage);
41+
SettingsPageCommand = new RelayCommand(SettingsPage);
4042
}
4143

4244
private void HomePage(object? obj)
4345
{
4446
_mainViewModel.CurrentViewModel = new HomePageViewModel(_mainViewModel.Settings);
4547
}
48+
49+
private void SettingsPage(object? obj)
50+
{
51+
_mainViewModel.CurrentViewModel = new SettingsPageViewModel(_mainViewModel);
52+
}
4653
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) Léo Corporation
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
using System;
25+
using System.Collections.Generic;
26+
using System.Linq;
27+
using System.Text;
28+
using System.Threading.Tasks;
29+
30+
namespace InternetTest.ViewModels;
31+
public class SettingsPageViewModel : ViewModelBase
32+
{
33+
private readonly MainViewModel _mainViewModel;
34+
35+
public SettingsPageViewModel(MainViewModel mainViewModel)
36+
{
37+
_mainViewModel = mainViewModel;
38+
}
39+
}
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<UserControl
2+
x:Class="InternetTest.Views.SettingsPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:lang="clr-namespace:InternetTest.Properties"
7+
xmlns:local="clr-namespace:InternetTest.Views"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
d:DesignHeight="450"
10+
d:DesignWidth="800"
11+
FontFamily="..\Fonts\#Hauora"
12+
Foreground="{DynamicResource Foreground1}"
13+
mc:Ignorable="d">
14+
<Grid>
15+
<Grid.RowDefinitions>
16+
<RowDefinition Height="Auto" />
17+
<RowDefinition />
18+
</Grid.RowDefinitions>
19+
<Grid.ColumnDefinitions>
20+
<ColumnDefinition />
21+
<ColumnDefinition />
22+
<ColumnDefinition />
23+
<ColumnDefinition />
24+
<ColumnDefinition />
25+
<ColumnDefinition />
26+
</Grid.ColumnDefinitions>
27+
<StackPanel Grid.ColumnSpan="6">
28+
<TextBlock
29+
Margin="10 5"
30+
FontSize="24"
31+
FontWeight="Bold"
32+
Text="{x:Static lang:Resources.Settings}" />
33+
<TextBlock
34+
Margin="10 0"
35+
FontSize="14"
36+
Text="{x:Static lang:Resources.SettingsDesc}"
37+
TextWrapping="Wrap" />
38+
</StackPanel>
39+
<StackPanel
40+
Grid.Row="1"
41+
Grid.Column="1"
42+
Grid.ColumnSpan="4">
43+
<Border
44+
Margin="5"
45+
Padding="10"
46+
Background="{DynamicResource CardBackground}"
47+
BorderBrush="{DynamicResource Border}"
48+
BorderThickness="1"
49+
CornerRadius="10">
50+
<Grid>
51+
<Grid.RowDefinitions>
52+
<RowDefinition Height="Auto" />
53+
<RowDefinition Height="Auto" />
54+
<RowDefinition />
55+
</Grid.RowDefinitions>
56+
<StackPanel Orientation="Horizontal">
57+
<TextBlock
58+
VerticalAlignment="Center"
59+
FontFamily="..\Fonts\#FluentSystemIcons-Regular"
60+
FontSize="16"
61+
Text="&#xF2F6;" />
62+
<TextBlock
63+
Margin="5 0"
64+
VerticalAlignment="Center"
65+
FontSize="16"
66+
FontWeight="Bold"
67+
Text="{x:Static lang:Resources.General}" />
68+
</StackPanel>
69+
<TextBlock
70+
Grid.Row="1"
71+
Foreground="{DynamicResource DarkGray}"
72+
Text="{x:Static lang:Resources.GeneralDesc}" />
73+
<StackPanel Grid.Row="2">
74+
<TextBlock
75+
Margin="0 5"
76+
FontWeight="SemiBold"
77+
Text="{x:Static lang:Resources.Theme}" />
78+
<StackPanel Orientation="Horizontal">
79+
<RadioButton
80+
BorderThickness="2"
81+
GroupName="Theme"
82+
Style="{DynamicResource ThemeButton}">
83+
<Grid>
84+
<Grid.ColumnDefinitions>
85+
<ColumnDefinition Width="Auto" />
86+
<ColumnDefinition />
87+
</Grid.ColumnDefinitions>
88+
<Rectangle
89+
Width="50"
90+
Height="50"
91+
RadiusX="4"
92+
RadiusY="4">
93+
<Rectangle.Fill>
94+
<ImageBrush ImageSource="../Assets/LightTheme.png" />
95+
</Rectangle.Fill>
96+
</Rectangle>
97+
<TextBlock
98+
Grid.Column="1"
99+
Margin="5"
100+
VerticalAlignment="Center"
101+
FontWeight="SemiBold"
102+
Text="{x:Static lang:Resources.Light}" />
103+
104+
</Grid>
105+
</RadioButton>
106+
<RadioButton
107+
Margin="10 0"
108+
BorderThickness="2"
109+
GroupName="Theme"
110+
Style="{DynamicResource ThemeButton}">
111+
<Grid>
112+
<Grid.ColumnDefinitions>
113+
<ColumnDefinition Width="Auto" />
114+
<ColumnDefinition />
115+
</Grid.ColumnDefinitions>
116+
<Rectangle
117+
Width="50"
118+
Height="50"
119+
RadiusX="4"
120+
RadiusY="4">
121+
<Rectangle.Fill>
122+
<ImageBrush ImageSource="../Assets/DarkTheme.png" />
123+
</Rectangle.Fill>
124+
</Rectangle>
125+
<TextBlock
126+
Grid.Column="1"
127+
Margin="5"
128+
VerticalAlignment="Center"
129+
FontWeight="SemiBold"
130+
Text="{x:Static lang:Resources.Dark}" />
131+
132+
</Grid>
133+
</RadioButton>
134+
<RadioButton
135+
BorderThickness="2"
136+
GroupName="Theme"
137+
Style="{DynamicResource ThemeButton}">
138+
<Grid>
139+
<Grid.ColumnDefinitions>
140+
<ColumnDefinition Width="Auto" />
141+
<ColumnDefinition />
142+
</Grid.ColumnDefinitions>
143+
<Rectangle
144+
Width="50"
145+
Height="50"
146+
RadiusX="4"
147+
RadiusY="4">
148+
<Rectangle.Fill>
149+
<ImageBrush ImageSource="../Assets/SystemTheme.png" />
150+
</Rectangle.Fill>
151+
</Rectangle>
152+
<TextBlock
153+
Grid.Column="1"
154+
Margin="5"
155+
VerticalAlignment="Center"
156+
FontWeight="SemiBold"
157+
Text="{x:Static lang:Resources.DefaultTheme}" />
158+
159+
</Grid>
160+
</RadioButton>
161+
</StackPanel>
162+
<TextBlock
163+
Margin="0 5"
164+
FontWeight="SemiBold"
165+
Text="{x:Static lang:Resources.StartupPage}" />
166+
<ComboBox
167+
Width="200"
168+
HorizontalAlignment="Left"
169+
>
170+
<ComboBoxItem Content="{x:Static lang:Resources.Home}" />
171+
<ComboBoxItem Content="{x:Static lang:Resources.DownDetector}" />
172+
<ComboBoxItem Content="{x:Static lang:Resources.DNSTool}" />
173+
<ComboBoxItem Content="{x:Static lang:Resources.WiFiNetworks}" />
174+
<ComboBoxItem Content="{x:Static lang:Resources.LocateIP}" />
175+
<ComboBoxItem Content="{x:Static lang:Resources.IPConfig}" />
176+
<ComboBoxItem Content="{x:Static lang:Resources.Ping}" />
177+
<ComboBoxItem Content="{x:Static lang:Resources.Requests}" />
178+
<ComboBoxItem Content="{x:Static lang:Resources.TraceRoute}" />
179+
</ComboBox>
180+
<TextBlock
181+
Margin="0 5"
182+
FontWeight="SemiBold"
183+
Text="{x:Static lang:Resources.Language}" />
184+
<ComboBox Width="200" HorizontalAlignment="Left">
185+
<ComboBoxItem Content="{x:Static lang:Resources.DefaultLanguage}" />
186+
<ComboBoxItem Content="English (United States)" />
187+
<ComboBoxItem Content="Français (France)" />
188+
<ComboBoxItem Content="中文(简体)" />
189+
<ComboBoxItem Content="Italiano (Italia)" />
190+
</ComboBox>
191+
</StackPanel>
192+
</Grid>
193+
</Border>
194+
</StackPanel>
195+
</Grid>
196+
</UserControl>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) Léo Corporation
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
using System.Windows.Controls;
25+
26+
namespace InternetTest.Views;
27+
/// <summary>
28+
/// Interaction logic for SettingsPage.xaml
29+
/// </summary>
30+
public partial class SettingsPage : UserControl
31+
{
32+
public SettingsPage()
33+
{
34+
InitializeComponent();
35+
}
36+
}

0 commit comments

Comments
 (0)