Skip to content

Commit a6adc48

Browse files
committed
✏️ Rename DownloadPathItemView(Model) to HistoryItemView(Model)
The view can be used by other history views.
1 parent b530d64 commit a6adc48

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

YoutubeDl.Wpf/ViewModels/DownloadPathItemViewModel.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using ReactiveUI;
2+
using ReactiveUI.Fody.Helpers;
3+
using ReactiveUI.Validation.Helpers;
4+
using System;
5+
using System.Reactive;
6+
7+
namespace YoutubeDl.Wpf.ViewModels;
8+
9+
public class HistoryItemViewModel : ReactiveValidationObject
10+
{
11+
[Reactive]
12+
public string Text { get; set; }
13+
14+
public ReactiveCommand<HistoryItemViewModel, Unit> DeleteItemCommand { get; }
15+
16+
public HistoryItemViewModel(string text, Action<HistoryItemViewModel> action)
17+
{
18+
Text = text;
19+
DeleteItemCommand = ReactiveCommand.Create(action);
20+
}
21+
22+
public override string ToString() => Text;
23+
}

YoutubeDl.Wpf/ViewModels/HomeViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class HomeViewModel : ReactiveValidationObject
3939
/// This collection was first constructed from <see cref="ObservableSettings.DownloadPathHistory"/> in reverse order.
4040
/// So the newest path is always the first element.
4141
/// </summary>
42-
public ObservableCollection<DownloadPathItemViewModel> DownloadPathHistory { get; } = new();
42+
public ObservableCollection<HistoryItemViewModel> DownloadPathHistory { get; } = new();
4343

4444
/// <summary>
4545
/// Gets the collection of view models of the arguments area.
@@ -113,7 +113,7 @@ public HomeViewModel(ObservableSettings settings, BackendService backendService,
113113
Presets.AddRange(Preset.PredefinedPresets.Where(x => (x.SupportedBackends & SharedSettings.Backend) == SharedSettings.Backend));
114114
});
115115

116-
DownloadPathHistory.AddRange(SharedSettings.DownloadPathHistory.Select(x => new DownloadPathItemViewModel(x, DeleteDownloadPathItem)).Reverse());
116+
DownloadPathHistory.AddRange(SharedSettings.DownloadPathHistory.Select(x => new HistoryItemViewModel(x, DeleteDownloadPathItem)).Reverse());
117117

118118
DownloadArguments.AddRange(SharedSettings.BackendDownloadArguments.Select(x => new ArgumentChipViewModel(x, true, DeleteArgumentChip)));
119119
DownloadArguments.Add(new AddArgumentViewModel(AddArgument));
@@ -237,9 +237,9 @@ private void DeleteCustomPreset()
237237
SharedSettings.SelectedPreset = Presets.First();
238238
}
239239

240-
private void DeleteDownloadPathItem(DownloadPathItemViewModel item)
240+
private void DeleteDownloadPathItem(HistoryItemViewModel item)
241241
{
242-
SharedSettings.DownloadPathHistory.Remove(item.Path);
242+
SharedSettings.DownloadPathHistory.Remove(item.Text);
243243
DownloadPathHistory.Remove(item);
244244
}
245245

YoutubeDl.Wpf/Views/DownloadPathItemView.xaml renamed to YoutubeDl.Wpf/Views/HistoryItemView.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<reactiveui:ReactiveUserControl
2-
x:Class="YoutubeDl.Wpf.Views.DownloadPathItemView"
3-
x:TypeArguments="viewmodels:DownloadPathItemViewModel"
2+
x:Class="YoutubeDl.Wpf.Views.HistoryItemView"
3+
x:TypeArguments="viewmodels:HistoryItemViewModel"
44
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -9,15 +9,15 @@
99
xmlns:reactiveui="http://reactiveui.net"
1010
xmlns:viewmodels="clr-namespace:YoutubeDl.Wpf.ViewModels"
1111
mc:Ignorable="d"
12-
d:DataContext="{d:DesignInstance Type=viewmodels:DownloadPathItemViewModel}"
12+
d:DataContext="{d:DesignInstance Type=viewmodels:HistoryItemViewModel}"
1313
d:DesignHeight="30" d:DesignWidth="200">
1414
<Grid>
1515
<Grid.ColumnDefinitions>
1616
<ColumnDefinition Width="*" />
1717
<ColumnDefinition Width="Auto" />
1818
</Grid.ColumnDefinitions>
1919
<TextBlock Grid.Column="0"
20-
x:Name="pathTextBlock"
20+
x:Name="textBlock"
2121
VerticalAlignment="Center"/>
2222
<Button Grid.Column="1"
2323
x:Name="deleteButton"

YoutubeDl.Wpf/Views/DownloadPathItemView.xaml.cs renamed to YoutubeDl.Wpf/Views/HistoryItemView.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
namespace YoutubeDl.Wpf.Views;
66

77
/// <summary>
8-
/// Interaction logic for DownloadPathItemView.xaml
8+
/// Interaction logic for HistoryItemView.xaml
99
/// </summary>
10-
public partial class DownloadPathItemView
10+
public partial class HistoryItemView
1111
{
12-
public DownloadPathItemView()
12+
public HistoryItemView()
1313
{
1414
InitializeComponent();
1515

1616
this.WhenActivated(disposables =>
1717
{
1818
this.OneWayBind(ViewModel,
19-
viewModel => viewModel.Path,
20-
view => view.pathTextBlock.Text)
19+
viewModel => viewModel.Text,
20+
view => view.textBlock.Text)
2121
.DisposeWith(disposables);
2222

2323
this.BindCommand(ViewModel,

0 commit comments

Comments
 (0)