Skip to content

Commit f9f5eb6

Browse files
committed
Add Config Class
1 parent 7afebb9 commit f9f5eb6

File tree

7 files changed

+126
-9
lines changed

7 files changed

+126
-9
lines changed

NCodeParser/Config.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,35 @@
44
using System.Reflection;
55
using System.Text;
66
using System.Threading.Tasks;
7+
using NCodeParser.IO;
8+
using NCodeParser.Model;
79

810
namespace NCodeParser
911
{
1012
public static class Config
1113
{
1214
public static string ApplicationName = Assembly.GetEntryAssembly().GetName().Name;
15+
16+
public static INIManager INIManager
17+
{
18+
get;
19+
private set;
20+
}
21+
22+
public static List<Novel> NovelList = new List<Novel>();
23+
24+
public static string NovelDirectory = "";
25+
26+
public static void Init()
27+
{
28+
INIManager = new INIManager();
29+
30+
NovelList = INIManager.GetNovels();
31+
}
32+
33+
public static void Save()
34+
{
35+
INIManager.SetNovels(NovelList);
36+
}
1337
}
1438
}

NCodeParser/NCodeParser.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
<Compile Include="Model\Episode.cs" />
111111
<Compile Include="Model\Novel.cs" />
112112
<Compile Include="Singleton.cs" />
113+
<Compile Include="Translate\EZTranslator.cs" />
113114
<Compile Include="Translate\GSheetsTranslator.cs" />
114115
<Compile Include="ViewModel\LicenseViewModel.cs" />
115116
<Compile Include="ViewModel\MainViewModel.cs" />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using NCodeParser.Interface;
7+
8+
namespace NCodeParser.Translate
9+
{
10+
public class EZTranslator : ITranslator
11+
{
12+
public Task<string> Translate(string input)
13+
{
14+
throw new NotImplementedException();
15+
}
16+
}
17+
}

NCodeParser/View/SettingWindow.xaml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,49 @@
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:NCodeParser.View"
7+
xmlns:ViewModel="clr-namespace:NCodeParser.ViewModel"
78
WindowStartupLocation="CenterScreen"
89
mc:Ignorable="d"
9-
Title="Setting" Height="450" Width="800">
10+
Title="Options"
11+
Width="1010"
12+
Height="606">
13+
<Window.DataContext>
14+
<ViewModel:SettingViewModel />
15+
</Window.DataContext>
16+
1017
<Grid>
11-
12-
</Grid>
18+
<Grid.ColumnDefinitions>
19+
<ColumnDefinition Width="250" />
20+
<ColumnDefinition />
21+
</Grid.ColumnDefinitions>
22+
23+
<Grid.RowDefinitions>
24+
<RowDefinition />
25+
<RowDefinition Height="60" />
26+
</Grid.RowDefinitions>
27+
28+
<Grid Grid.Column="0"
29+
Grid.Row="0">
30+
<TreeView Margin="8,8,8,8">
31+
<TreeViewItem Header="기본설정">
32+
33+
</TreeViewItem>
34+
35+
<TreeViewItem Header="번역">
36+
37+
</TreeViewItem>
38+
</TreeView>
39+
</Grid>
40+
41+
<Grid Grid.Column="1"
42+
Grid.Row="0">
43+
44+
</Grid>
45+
46+
<Grid Grid.Column="1"
47+
Grid.Row="1">
48+
<Button HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,112,0" Content="OK" Width="85" Height="24" Command="{Binding SaveComamnd}" />
49+
<Button HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,16,0" Content="Cancel" Width="85" Height="24" Command="{Binding CancelCommand}" />
50+
</Grid>
51+
</Grid>
1352
</Window>

NCodeParser/ViewModel/LicenseViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using GalaSoft.MvvmLight;
67

78
namespace NCodeParser.ViewModel
89
{
9-
class LicenseViewModel
10+
public class LicenseViewModel : ViewModelBase
1011
{
12+
1113
}
1214
}

NCodeParser/ViewModel/MainViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ public string TitleText
175175
private int _UpdateCount;
176176

177177
private NovelDownloader Downloader;
178-
private INIManager INIManager;
179178
private ITranslator Translator;
180179

181180
public MainViewModel()
@@ -197,14 +196,14 @@ private void InitInstance()
197196
Downloader = new NovelDownloader();
198197
Downloader.ProgressChanged += Downloader_ProgressChanged;
199198

200-
INIManager = new INIManager();
201199
Translator = new GSheetsTranslator();
200+
Config.Init();
202201
}
203202

204203
private void InitControls()
205204
{
206205
NovelList = new ObservableCollection<Novel>();
207-
NovelList.AddAll(INIManager.GetNovels());
206+
NovelList.AddAll(Config.NovelList);
208207

209208
if (NovelList.Count > 0)
210209
{
@@ -516,7 +515,8 @@ private async void OnDownload()
516515

517516
private void OnClosing()
518517
{
519-
INIManager.SetNovels(NovelList);
518+
Config.NovelList = NovelList.ToList();
519+
Config.Save();
520520
}
521521

522522
private void OnSetting()

NCodeParser/ViewModel/SettingViewModel.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,44 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using GalaSoft.MvvmLight;
7+
using GalaSoft.MvvmLight.CommandWpf;
68

79
namespace NCodeParser.ViewModel
810
{
9-
class SettingViewModel
11+
public class SettingViewModel : ViewModelBase
1012
{
13+
public RelayCommand SaveComamnd
14+
{
15+
get;
16+
private set;
17+
}
18+
19+
public RelayCommand CancelCommand
20+
{
21+
get;
22+
private set;
23+
}
24+
25+
public SettingViewModel()
26+
{
27+
InitInstance();
28+
}
29+
30+
private void InitInstance()
31+
{
32+
SaveComamnd = new RelayCommand(OnSave);
33+
CancelCommand = new RelayCommand(OnCancel);
34+
}
35+
36+
private void OnSave()
37+
{
38+
39+
}
40+
41+
private void OnCancel()
42+
{
43+
44+
}
1145
}
1246
}

0 commit comments

Comments
 (0)