Skip to content

Commit

Permalink
Adding new source.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Umali committed May 3, 2020
1 parent d712b92 commit 1d4649b
Show file tree
Hide file tree
Showing 18 changed files with 765 additions and 97 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# IDE0055: Fix formatting
dotnet_diagnostic.IDE0055.severity = none
4 changes: 2 additions & 2 deletions NovelReader/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</startup>
<userSettings>
<NovelReader.Properties.Settings>
<setting name="Source" serializeAs="String">
<value>https://boxnovel.com/</value>
<setting name="SourceSite" serializeAs="String">
<value>0</value>
</setting>
</NovelReader.Properties.Settings>
</userSettings>
Expand Down
72 changes: 72 additions & 0 deletions NovelReader/Mainform.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 25 additions & 11 deletions NovelReader/Mainform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class MainForm : Form

string orderby = "alphabet";

string source = $"{Properties.Settings.Default.Source}";
int sourcesite = Properties.Settings.Default.SourceSite;
string previouslink = string.Empty, nextlink = string.Empty;
public MainForm()
{
Expand All @@ -33,7 +33,7 @@ private async void timer1_Tick(object sender, EventArgs e)
timer1.Stop();
if (DisposeCard(flowLayoutPanel1))
{
await LoadNovelDataToCardAsync(source, false);
await LoadNovelDataToCardAsync(SourcePickerMethod.GetSourceUrl((SourcePickerMethod.Source)sourcesite), false);
lblNovelIndicator.Text = "true";
}
}
Expand All @@ -42,13 +42,15 @@ private async void timer1_Tick(object sender, EventArgs e)
private List<NovelDataModel> PrepareNovelData(string url, bool isSearch)
{
GetSiteLink(url);
List<NovelDataModel> novelDatas = NovelReaderWebScrapper.Website.BoxNovelScrapper.GetBoxNovelData($"{url}", isSearch);
Console.WriteLine(url);
List<NovelDataModel> novelDatas = SourcePickerMethod.GetNovelDataModels
($"{url}", isSearch, (SourcePickerMethod.Scrapper)sourcesite);
return novelDatas;
}

private SiteLinkModel PrepareSiteLinkData(string url)
{
SiteLinkModel siteLinkDatas = NovelReaderWebScrapper.Website.BoxNovelScrapper.GetPreviosNextLinkAndResult($"{url}");
SiteLinkModel siteLinkDatas = SourcePickerMethod.GetSiteLinkModel($"{url}", (SourcePickerMethod.Scrapper)sourcesite);
return siteLinkDatas;
}

Expand All @@ -67,18 +69,17 @@ private void GetSiteLink(string url)
private async Task LoadNovelDataToCardAsync(string url, bool isSearch)
{
List<NovelDataModel> novelDatas = PrepareNovelData($"{url}", isSearch);

List<Task<NovelReaderUserControlLibrary.NovelCard>> novelTasks = new List<Task<NovelReaderUserControlLibrary.NovelCard>>();

foreach(NovelDataModel novelitem in novelDatas)
foreach (NovelDataModel novelitem in novelDatas)
{
novelTasks.Add(Task.Run(() => AddNovelCardValue(novelitem.Title, novelitem.LatestChapter,
novelitem.Link, novelitem.ImgLink, novelitem.Rating)));
novelTasks.Add(Task.Run(() => AddNovelCardValue(novelitem.Title, novelitem.LatestChapter,
novelitem.Link, novelitem.ImgLink, novelitem.Rating)));
}

var result = await Task.WhenAll(novelTasks);

foreach(var item in result)
foreach (var item in result)
{
await Task.Run(() => NovelCardToPanel(item));
}
Expand Down Expand Up @@ -215,13 +216,13 @@ private async void guna2Button1_Click(object sender, EventArgs e)
if (!string.IsNullOrEmpty(nextlink))
{
await LoadNovelDataToCardAsync
($"https://boxnovel.com/?s={txtSearch.Text}&post_type=wp-manga&m_orderby={orderby}", true);
($"{SourcePickerMethod.GetSourceUrl((SourcePickerMethod.Source)sourcesite)}?s={txtSearch.Text}&post_type=wp-manga&m_orderby={orderby}", true);
lblNovelIndicator.Text = "true";
}
else
{
await LoadNovelDataToCardAsync
($"{source}", false);
($"{SourcePickerMethod.GetSourceUrl((SourcePickerMethod.Source)sourcesite)}", false);
lblNovelIndicator.Text = "true";
}
}
Expand All @@ -233,6 +234,19 @@ private void guna2Button1_Click_1(object sender, EventArgs e)
orderby = btn.Tag.ToString();
}

private void rdoBoxnovel_CheckedChanged(object sender, EventArgs e)
{
Guna.UI2.WinForms.Guna2RadioButton rdo = (Guna.UI2.WinForms.Guna2RadioButton)sender;
ChangeSource(Convert.ToInt32(rdo.Tag.ToString()));
}
private void ChangeSource(int sourcevalue)
{
sourcesite = sourcevalue;
Properties.Settings.Default.SourceSite = sourcevalue;
Properties.Settings.Default.Save();

timer1.Start();
}
private async void btnPrev_Click(object sender, EventArgs e)
{
if (DisposeCard(flowLayoutPanel1))
Expand Down
1 change: 1 addition & 0 deletions NovelReader/NovelChapterReaderForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions NovelReader/NovelChapterReaderForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public partial class NovelChapterReaderForm : Form
private string _link;
private string previouschapterlink = string.Empty, nextchapterlink = string.Empty;
private string yourfont = "Segoe UI";

private List<string> fontNames = FontFamily.Families.Select(f => f.Name).ToList();

int sourcesite = Properties.Settings.Default.SourceSite;

SpeechSynthesizer speech = new SpeechSynthesizer();
public NovelChapterReaderForm(string link)
{
Expand All @@ -33,7 +37,7 @@ private void NovelChapterReaderForm_Load(object sender, EventArgs e)
}
private NovelReaderWebScrapper.Model.ChapterTextModel LoadChapterTextData(string url)
{
NovelReaderWebScrapper.Model.ChapterTextModel chapterText = NovelReaderWebScrapper.Website.BoxNovelScrapper.GetChapterText($"{url}");
NovelReaderWebScrapper.Model.ChapterTextModel chapterText = SourcePickerMethod.GetChapterTextModel($"{url}", (SourcePickerMethod.Scrapper)sourcesite);
return chapterText;
}
private async void timer1_Tick(object sender, EventArgs e)
Expand All @@ -56,12 +60,12 @@ private async Task LoadChapterData(string url)
NovelReaderWebScrapper.Model.ChapterTextModel chapterdata = LoadChapterTextData($"{url}");

await Task.Run(() => LoadChapterTextData(chapterdata.ChapterText,
chapterdata.PreviousChapterLink, chapterdata.NextChapterLink));
chapterdata.PreviousChapterLink, chapterdata.NextChapterLink));
}

private void LoadChapterTextData(string chaptertext, string _previouschapterlink, string _nextchapterlink)
{
if(this.txtChapterText.InvokeRequired)
if (this.txtChapterText.InvokeRequired)
{
this.txtChapterText.Invoke(new MethodInvoker(delegate ()
{
Expand All @@ -77,20 +81,20 @@ private void LoadChapterTextData(string chaptertext, string _previouschapterlink
nextchapterlink = _nextchapterlink;
}
}
private void btnNext_Click(object sender, EventArgs e)
private async void btnNext_Click(object sender, EventArgs e)
{
speech.SpeakAsyncCancelAll();

if (!string.IsNullOrEmpty(nextchapterlink))
LoadChapterData($"{nextchapterlink}");
await LoadChapterData($"{nextchapterlink}");
}

private void btnPrev_Click(object sender, EventArgs e)
private async void btnPrev_Click(object sender, EventArgs e)
{
speech.SpeakAsyncCancelAll();

if (!string.IsNullOrEmpty(previouschapterlink))
LoadChapterData($"{previouschapterlink}");
await LoadChapterData($"{previouschapterlink}");
}

#region Text Settings..
Expand Down Expand Up @@ -157,10 +161,10 @@ private void btnContinue_Click(object sender, EventArgs e)
}
}

private void btnReload_Click(object sender, EventArgs e)
private async void btnReload_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
LoadChapterData(_link);
await LoadChapterData(_link);
Cursor.Current = Cursors.Default;
}

Expand Down
13 changes: 5 additions & 8 deletions NovelReader/NovelInformationForm.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using NovelReaderWebScrapper.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NovelReader
Expand All @@ -10,6 +9,7 @@ public partial class NovelInformationForm : Form
{
string _title, _link, _rating = string.Empty;
private Guna.UI2.WinForms.Guna2ShadowForm shadowForm = new Guna.UI2.WinForms.Guna2ShadowForm();
int sourcesite = Properties.Settings.Default.SourceSite;
public NovelInformationForm(string title, string link, string rating)
{
InitializeComponent();
Expand Down Expand Up @@ -38,7 +38,7 @@ NovelReaderWebScrapper.Model.NovelSummaryModel NovelDataSummary
lblrelease.Text = $"{NovelDataSummary.Release} - {NovelDataSummary.Status}";
pictureBox1.LoadAsync(NovelDataSummary.ImgLink);

timer2.Start();
timer2.Start();
}

private void timer2_Tick(object sender, EventArgs e)
Expand All @@ -48,12 +48,12 @@ private void timer2_Tick(object sender, EventArgs e)
}
private NovelSypnosisModel PrepareSypnosisData(string url)
{
NovelSypnosisModel novelSypnosis = NovelReaderWebScrapper.Website.BoxNovelScrapper.GetBoxNovelSypnosis($"{url}");
NovelSypnosisModel novelSypnosis = SourcePickerMethod.GetNovelSypnosisModel(url, (SourcePickerMethod.Scrapper)sourcesite);
return novelSypnosis;
}
private NovelSummaryModel PrepareNovelSummaryData(string url)
{
NovelSummaryModel novelSummary = NovelReaderWebScrapper.Website.BoxNovelScrapper.GetBoxNovelSummary($"{url}");
NovelSummaryModel novelSummary = SourcePickerMethod.GetNovelSummaryModel(url, (SourcePickerMethod.Scrapper)sourcesite);
return novelSummary;
}

Expand All @@ -67,10 +67,7 @@ private async void btnLoad_Click(object sender, EventArgs e)
}
private List<NovelChapterModel> PrepareNovelChapterData(string url)
{
return NovelReaderWebScrapper
.Website
.BoxNovelScrapper
.GetBoxNovelChapterList($"{url}");
return SourcePickerMethod.GetNovelChapterModels(url, (SourcePickerMethod.Scrapper)sourcesite);
}

private async Task LoadChapterDataAsync()
Expand Down
13 changes: 13 additions & 0 deletions NovelReader/NovelReaderUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SourcePickerMethod.cs" />
<Compile Include="Test.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Test.Designer.cs">
<DependentUpon>Test.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -97,6 +104,12 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Test.resx">
<DependentUpon>Test.cs</DependentUpon>
</EmbeddedResource>
<None Include="..\.editorconfig">
<Link>.editorconfig</Link>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
8 changes: 4 additions & 4 deletions NovelReader/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1d4649b

Please sign in to comment.