Skip to content

Commit 2fc332e

Browse files
committed
🧹 Code cleanup.
1 parent 1cba25f commit 2fc332e

20 files changed

+102
-73
lines changed

‎AboutDialog.xaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<UserControl x:Class="youtube_dl_wpf.AboutDialog"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800">
9+
<Grid Margin="16">
10+
<Grid.RowDefinitions>
11+
<RowDefinition Height="auto"/>
12+
<RowDefinition Height="auto"/>
13+
<RowDefinition Height="auto"/>
14+
<RowDefinition Height="auto"/>
15+
</Grid.RowDefinitions>
16+
<TextBlock Grid.Row="0" Margin="8 8 8 8" Style="{StaticResource MaterialDesignHeadline5TextBlock}" TextWrapping="Wrap">About - v0.5 Build 20200424</TextBlock>
17+
<TextBlock Grid.Row="1" Margin="8 8 8 8" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" TextWrapping="Wrap">Cube YouTube Downloader is a simple GUI wrapper for <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="https://github.com/ytdl-org/youtube-dl">https://github.com/ytdl-org/youtube-dl</Hyperlink></TextBlock>
18+
<TextBlock Grid.Row="2" Margin="8 8 8 8" Style="{StaticResource MaterialDesignSubtitle1TextBlock}" TextWrapping="Wrap">For more information please visit <Hyperlink RequestNavigate="Hyperlink_RequestNavigate" NavigateUri="https://github.com/database64128/youtube-dl-wpf">https://github.com/database64128/youtube-dl-wpf</Hyperlink></TextBlock>
19+
<Button Grid.Row="3"
20+
IsDefault="True" Style="{DynamicResource MaterialDesignFlatButton}"
21+
HorizontalAlignment="Right"
22+
Margin="16 16 16 0"
23+
Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}">
24+
_OK
25+
</Button>
26+
</Grid>
27+
</UserControl>

‎AboutDialog.xaml.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Windows.Controls;
2+
using System.Windows.Navigation;
3+
4+
namespace youtube_dl_wpf
5+
{
6+
/// <summary>
7+
/// Interaction logic for AboutDialog.xaml
8+
/// </summary>
9+
public partial class AboutDialog : UserControl
10+
{
11+
public AboutDialog()
12+
{
13+
InitializeComponent();
14+
}
15+
16+
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
17+
{
18+
Link.OpenInBrowser(e.Uri.AbsoluteUri);
19+
}
20+
}
21+
}

‎App.xaml.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Configuration;
4-
using System.Data;
5-
using System.Linq;
6-
using System.Threading.Tasks;
7-
using System.Windows;
1+
using System.Windows;
82

93
namespace youtube_dl_wpf
104
{

‎CubeYouTubeDownloader.ico

106 KB
Binary file not shown.

‎CubeYouTubeDownloader.png

14.1 KB
Loading
File renamed without changes.

‎DrawerItem.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace youtube_dl_wpf
1+
namespace youtube_dl_wpf
62
{
73
public class DrawerItem : ViewModelBase
84
{

‎Home.xaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="clr-namespace:youtube_dl_wpf"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
76
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
87
mc:Ignorable="d"
98
d:DesignHeight="680" d:DesignWidth="960">

‎Home.xaml.cs

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Windows;
5-
using System.Windows.Controls;
6-
using System.Windows.Data;
7-
using System.Windows.Documents;
8-
using System.Windows.Input;
9-
using System.Windows.Media;
10-
using System.Windows.Media.Imaging;
11-
using System.Windows.Navigation;
12-
using System.Windows.Shapes;
1+
using System.Windows.Controls;
132

143
namespace youtube_dl_wpf
154
{

‎HomeViewModel.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.ComponentModel;
43
using System.Diagnostics;
54
using System.Text;
6-
using System.Threading;
7-
using System.Threading.Tasks;
85
using System.Windows.Input;
96

107
namespace youtube_dl_wpf
@@ -24,7 +21,7 @@ public HomeViewModel()
2421
if (!String.IsNullOrEmpty(AppSettings.settings.DlPath))
2522
UpdateDl();
2623
}
27-
24+
2825
private string _link;
2926
private bool _overrideFormats;
3027
private string _videoFormat;
File renamed without changes.

‎Link.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Diagnostics;
2+
using System.Runtime.InteropServices;
3+
4+
namespace youtube_dl_wpf
5+
{
6+
public static class Link
7+
{
8+
public static void OpenInBrowser(string url)
9+
{
10+
//https://github.com/dotnet/corefx/issues/10361
11+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
12+
{
13+
url = url.Replace("&", "^&");
14+
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
15+
}
16+
}
17+
}
18+
}

‎MainWindow.xaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@
5656
DockPanel.Dock="Right"
5757
PlacementMode="BottomAndAlignRightEdges">
5858
<StackPanel>
59-
<Button Content="Settings" IsEnabled="False"/>
60-
<Separator/>
61-
<Button Content="About" IsEnabled="False"/>
59+
<Button Content="About" Command="{Binding OpenMessageDialog}"/>
6260
</StackPanel>
6361
</materialDesign:PopupBox>
6462
<TextBlock

‎MainWindow.xaml.cs

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using MaterialDesignThemes.Wpf;
52
using System.Threading;
63
using System.Threading.Tasks;
74
using System.Windows;
8-
using System.Windows.Controls;
95
using System.Windows.Controls.Primitives;
10-
using System.Windows.Data;
11-
using System.Windows.Documents;
126
using System.Windows.Input;
137
using System.Windows.Media;
14-
using System.Windows.Media.Imaging;
15-
using System.Windows.Navigation;
16-
using System.Windows.Shapes;
17-
18-
using MaterialDesignThemes.Wpf;
198

209
namespace youtube_dl_wpf
2110
{

‎MainWindowViewModel.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using MaterialDesignThemes.Wpf;
2+
using System;
33
using System.Collections.ObjectModel;
4-
using System.Text;
5-
using MaterialDesignThemes.Wpf;
4+
using System.Windows.Input;
65

76
namespace youtube_dl_wpf
87
{
@@ -11,11 +10,25 @@ public class MainWindowViewModel : ViewModelBase
1110
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue)
1211
{
1312
_drawerItems = GenerateItems(snackbarMessageQueue);
13+
_openMessageDialog = new DelegateCommand(OnOpenMessageDialog, (object commandParameter) => true);
1414
}
15-
15+
1616
private ObservableCollection<DrawerItem> _drawerItems;
1717
private DrawerItem _selectedItem;
1818

19+
private readonly DelegateCommand _openMessageDialog;
20+
21+
private async void OnOpenMessageDialog(object commandParameter)
22+
{
23+
var aboutDialog = new AboutDialog
24+
{
25+
DataContext = this
26+
};
27+
await DialogHost.Show(aboutDialog, "RootDialog");
28+
}
29+
30+
public ICommand OpenMessageDialog => _openMessageDialog;
31+
1932
public ObservableCollection<DrawerItem> DrawerItems
2033
{
2134
get => _drawerItems;

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A simple GUI wrapper for [`youtube-dl`](https://github.com/ytdl-org/youtube-dl).
2222

2323
## To-Do
2424

25-
- Re-implement AppSettings using Event Aggregators.
25+
- Re-implement `AppSettings` using Event Aggregators.
2626

2727
## License
2828

‎Settings.xaml.cs

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Windows;
5-
using System.Windows.Controls;
6-
using System.Windows.Data;
7-
using System.Windows.Documents;
8-
using System.Windows.Input;
9-
using System.Windows.Media;
10-
using System.Windows.Media.Imaging;
11-
using System.Windows.Navigation;
12-
using System.Windows.Shapes;
1+
using System.Windows.Controls;
132

143
namespace youtube_dl_wpf
154
{

‎SettingsJson.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.IO;
4-
using System.Text;
1+
using System.IO;
52
using System.Text.Json;
6-
using System.Text.Json.Serialization;
73
using System.Threading.Tasks;
84

95
namespace youtube_dl_wpf

‎SettingsViewModel.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
1+
using MaterialDesignThemes.Wpf;
2+
using System;
43
using System.Windows.Input;
5-
using MaterialDesignThemes.Wpf;
64

75
namespace youtube_dl_wpf
86
{
@@ -15,7 +13,7 @@ public SettingsViewModel()
1513
_dlPath = AppSettings.settings.DlPath;
1614
_ffmpegPath = AppSettings.settings.FfmpegPath;
1715
_proxy = AppSettings.settings.Proxy;
18-
16+
1917
_paletteHelper = new PaletteHelper();
2018
_changeColorMode = new DelegateCommand(OnChangeColorMode, (object commandParameter) => true);
2119
_browseExe = new DelegateCommand(OnBrowseExe, (object commandParameter) => true);

‎youtube-dl-wpf.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
<RootNamespace>youtube_dl_wpf</RootNamespace>
77
<UseWPF>true</UseWPF>
88
<ApplicationManifest>app.manifest</ApplicationManifest>
9+
<Product>Cube YouTube Downloader</Product>
10+
<Company>database64128</Company>
11+
<Authors>database64128</Authors>
12+
<Version>0.5.0</Version>
13+
<ApplicationIcon>CubeYouTubeDownloader.ico</ApplicationIcon>
914
</PropertyGroup>
1015

1116
<ItemGroup>

0 commit comments

Comments
 (0)