Skip to content

Commit 1a6a63d

Browse files
committed
Add Waiting Progress
1 parent ce9d4bf commit 1a6a63d

File tree

11 files changed

+219
-5
lines changed

11 files changed

+219
-5
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Data;
9+
10+
namespace NCodeParser.Control.Converter
11+
{
12+
public class VisibilityConverter : IValueConverter
13+
{
14+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15+
{
16+
if (value is bool)
17+
{
18+
bool visible = (bool) value;
19+
20+
return visible ? Visibility.Visible : Visibility.Hidden;
21+
}
22+
23+
return Visibility.Hidden;
24+
}
25+
26+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
27+
{
28+
throw new NotImplementedException();
29+
}
30+
}
31+
}

NCodeParser/Model/Novel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ public bool Merging
161161
}
162162
}
163163

164+
public bool ShowProgress
165+
{
166+
get
167+
{
168+
return _ShowProgress;
169+
}set
170+
{
171+
_ShowProgress = value;
172+
RaisePropertyChanged();
173+
}
174+
}
175+
164176
public ObservableCollection<Episode> Episodes
165177
{
166178
get; private set;
@@ -176,6 +188,7 @@ public ObservableCollection<Episode> Episodes
176188
private int _ProgressValue;
177189
private int _ProgressMax;
178190
private bool _Merging;
191+
private bool _ShowProgress;
179192

180193
public Novel()
181194
{

NCodeParser/NCodeParser.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<Generator>MSBuild:Compile</Generator>
7777
<SubType>Designer</SubType>
7878
</ApplicationDefinition>
79+
<Compile Include="Control\Converter\VisibilityConverter.cs" />
7980
<Compile Include="Enum.cs" />
8081
<Compile Include="Extensions.cs" />
8182
<Compile Include="IO\CookieAwareWebClient.cs">
@@ -86,7 +87,19 @@
8687
<Compile Include="Model\Episode.cs" />
8788
<Compile Include="Model\Novel.cs" />
8889
<Compile Include="Singleton.cs" />
90+
<Compile Include="ViewModel\LicenseViewModel.cs" />
8991
<Compile Include="ViewModel\MainViewModel.cs" />
92+
<Compile Include="ViewModel\SettingViewModel.cs" />
93+
<Compile Include="View\LicenseWindow.xaml.cs">
94+
<DependentUpon>LicenseWindow.xaml</DependentUpon>
95+
</Compile>
96+
<Compile Include="View\SettingWindow.xaml.cs">
97+
<DependentUpon>SettingWindow.xaml</DependentUpon>
98+
</Compile>
99+
<Page Include="View\LicenseWindow.xaml">
100+
<SubType>Designer</SubType>
101+
<Generator>MSBuild:Compile</Generator>
102+
</Page>
90103
<Page Include="View\MainWindow.xaml">
91104
<Generator>MSBuild:Compile</Generator>
92105
<SubType>Designer</SubType>
@@ -99,6 +112,10 @@
99112
<DependentUpon>MainWindow.xaml</DependentUpon>
100113
<SubType>Code</SubType>
101114
</Compile>
115+
<Page Include="View\SettingWindow.xaml">
116+
<SubType>Designer</SubType>
117+
<Generator>MSBuild:Compile</Generator>
118+
</Page>
102119
</ItemGroup>
103120
<ItemGroup>
104121
<Compile Include="Properties\AssemblyInfo.cs">
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Window x:Class="NCodeParser.View.LicenseWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:NCodeParser.View"
7+
WindowStartupLocation="CenterScreen"
8+
mc:Ignorable="d"
9+
Title="Licenses" Height="450" Width="800">
10+
<Grid>
11+
12+
</Grid>
13+
</Window>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Shapes;
14+
15+
namespace NCodeParser.View
16+
{
17+
/// <summary>
18+
/// Interaction logic for LicenseWindow.xaml
19+
/// </summary>
20+
public partial class LicenseWindow : Window
21+
{
22+
public LicenseWindow()
23+
{
24+
InitializeComponent();
25+
}
26+
}
27+
}

NCodeParser/View/MainWindow.xaml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:Converter="clr-namespace:NCodeParser.Control.Converter"
78
xmlns:ViewModel="clr-namespace:NCodeParser.ViewModel"
89
xmlns:local="clr-namespace:NCodeParser"
10+
WindowStartupLocation="CenterScreen"
911
mc:Ignorable="d"
1012
Title="NCodeParser"
1113
Width="1300"
@@ -20,6 +22,8 @@
2022
<Setter Property="HorizontalContentAlignment" Value="Center" />
2123
</Style>
2224

25+
<Converter:VisibilityConverter x:Key="VisibleConverter" />
26+
2327
<Style x:Key="DataGridCellStyle"
2428
TargetType="DataGridCell">
2529
<Setter Property="Template">
@@ -41,7 +45,23 @@
4145
</i:EventTrigger>
4246
</i:Interaction.Triggers>
4347

44-
<Grid>
48+
<DockPanel>
49+
<Menu DockPanel.Dock="Top">
50+
<MenuItem Header="File">
51+
<MenuItem Header="Exit" />
52+
</MenuItem>
53+
54+
<MenuItem Header="Settings" Command="{Binding SettingCommand}" />
55+
56+
<MenuItem Header="Help">
57+
<MenuItem Header="View License" />
58+
59+
<Separator />
60+
61+
<MenuItem Header="About NCodeParser" />
62+
</MenuItem>
63+
</Menu>
64+
4565
<Grid>
4666
<Grid.ColumnDefinitions>
4767
<ColumnDefinition Width="0.6*" />
@@ -176,12 +196,23 @@
176196
<TextBlock Grid.Row="0" Margin="2,0,0,4" Text="소설 개요" />
177197

178198
<Border Grid.Row="1" BorderBrush="LightGray" BorderThickness="1">
179-
<ScrollViewer>
180-
<TextBox IsReadOnly="True" TextWrapping="Wrap" Text="{Binding SelectedNovel.DescWithPrologue, Mode=OneWay}" />
181-
</ScrollViewer>
199+
<Grid>
200+
<ScrollViewer>
201+
<TextBox IsReadOnly="True" TextWrapping="Wrap" Text="{Binding SelectedNovel.DescWithPrologue, Mode=OneWay}" />
202+
</ScrollViewer>
203+
204+
<Grid Background="#11000000"
205+
Visibility="{Binding SelectedNovel.ShowProgress, Converter={StaticResource VisibleConverter}}">
206+
<ProgressBar HorizontalAlignment="Center"
207+
VerticalAlignment="Center"
208+
IsIndeterminate="True"
209+
Width="250"
210+
Height="20" />
211+
</Grid>
212+
</Grid>
182213
</Border>
183214
</Grid>
184215
</Grid>
185216
</Grid>
186-
</Grid>
217+
</DockPanel>
187218
</Window>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Window x:Class="NCodeParser.View.SettingWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:NCodeParser.View"
7+
WindowStartupLocation="CenterScreen"
8+
mc:Ignorable="d"
9+
Title="Setting" Height="450" Width="800">
10+
<Grid>
11+
12+
</Grid>
13+
</Window>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Shapes;
14+
15+
namespace NCodeParser.View
16+
{
17+
/// <summary>
18+
/// Interaction logic for SettingWindow.xaml
19+
/// </summary>
20+
public partial class SettingWindow : Window
21+
{
22+
public SettingWindow()
23+
{
24+
InitializeComponent();
25+
}
26+
}
27+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace NCodeParser.ViewModel
8+
{
9+
class LicenseViewModel
10+
{
11+
}
12+
}

NCodeParser/ViewModel/MainViewModel.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using GalaSoft.MvvmLight.CommandWpf;
99
using NCodeParser.IO;
1010
using NCodeParser.Model;
11+
using NCodeParser.View;
1112

1213
namespace NCodeParser.ViewModel
1314
{
@@ -44,6 +45,12 @@ public RelayCommand ClosingCommand
4445
private set;
4546
}
4647

48+
public RelayCommand SettingCommand
49+
{
50+
get;
51+
private set;
52+
}
53+
4754
public ObservableCollection<Novel> NovelList
4855
{
4956
get; private set;
@@ -151,6 +158,7 @@ private void InitInstance()
151158
SelectAllCommand = new RelayCommand(OnSelectAll, CanSelectAll);
152159
DownloadCommand = new RelayCommand(OnDownload, CanDownload);
153160
ClosingCommand = new RelayCommand(OnClosing);
161+
SettingCommand = new RelayCommand(OnSetting);
154162

155163
Downloader = new NovelDownloader();
156164
Downloader.ProgressChanged += Downloader_ProgressChanged;
@@ -202,12 +210,16 @@ private async void SelectNovel(Novel novel)
202210

203211
if (novel.Episodes.Count > 0 && string.IsNullOrWhiteSpace(novel.Episodes[0].Text))
204212
{
213+
novel.ShowProgress = true;
214+
205215
await Task.Run(() =>
206216
{
207217
Downloader.DownloadNovel(novel, 0, 0, false, true);
208218
});
209219

210220
novel.RaisePropertyChanged(nameof(novel.DescWithPrologue));
221+
222+
novel.ShowProgress = false;
211223
}
212224
}
213225

@@ -472,6 +484,12 @@ private void OnClosing()
472484
INIManager.SetNovels(NovelList);
473485
}
474486

487+
private void OnSetting()
488+
{
489+
var window = new SettingWindow();
490+
window.ShowDialog();
491+
}
492+
475493
private void Downloader_ProgressChanged(object sender, int Value)
476494
{
477495
var Novel = sender as Novel;

0 commit comments

Comments
 (0)