Skip to content

Commit

Permalink
Bump v0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ProJend committed Apr 11, 2023
1 parent 90da1cd commit 90c6aa5
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# True Love
### About This APP
A UWP covering for Avicii website.
A UWP cover for Avicii website.

### About Avicii
Tim Bergling (8 September 1989 – 20 April 2018), better known by his stage name Avicii, was a Swedish DJ, remixer, record producer, musician, and songwriter who specialized in audio programming, remixing, and record producing.
Expand Down
8 changes: 5 additions & 3 deletions TrueLove.Lib/Models/Code/CommentItem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
namespace TrueLove.Lib.Models.Code
using System.Collections.ObjectModel;

namespace TrueLove.Lib.Models.Code
{
public class CommentItem
public class CommentItem : ObservableCollection<string>
{
public string name { get; set; }
public string comment { get; set; }
public string date { get; set; }
}

public class CommentManager
public class UpdateItem
{

}
Expand Down
6 changes: 3 additions & 3 deletions TrueLove.UWP/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="Tim" Publisher="CN=Admin" Version="0.3.0.0" />
<Identity Name="AviciiUWP" Publisher="CN=Admin" Version="0.4.0.0" />
<mp:PhoneIdentity PhoneProductId="cf0148d5-01bb-4b60-b53b-da3346bf8e5e" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>True Love - Tim Bergling Foundtion</DisplayName>
<DisplayName>True Love</DisplayName>
<PublisherDisplayName>ProJend</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
Expand All @@ -15,7 +15,7 @@
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="TrueLove.UWP.App">
<uap:VisualElements DisplayName="ms-resource:pDisplayName" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="True Love for UWP" BackgroundColor="black">
<uap:VisualElements DisplayName="ms-resource:pDisplayName" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="A UWP cover for Avicii website." BackgroundColor="black">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" ShortName="ms-resource:pDisplayName" Square310x310Logo="Assets\Square310x310Logo.png" Square71x71Logo="Assets\Square71x71Logo.png">
<uap:ShowNameOnTiles>
<uap:ShowOn Tile="square150x150Logo" />
Expand Down
81 changes: 46 additions & 35 deletions TrueLove.UWP/Spider/RefineData.cs
Original file line number Diff line number Diff line change
@@ -1,61 +1,72 @@
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using TrueLove.Lib.Models.Code;
using Windows.UI.Xaml.Media.Imaging;

namespace TrueLove.UWP.Spider
{
public class RefineData
{
public RefineData()
public ObservableCollection<CommentItem> UpdateComment(string src)
{

}
public List<CommentItem> RefineComment(string src)
{
var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(src);
List<CommentItem> currentList = new List<CommentItem>();
for (int i = 1; i <= 99; i++)
var currentList = new ObservableCollection<CommentItem>();
try
{
string namePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[1]/span";
string comPath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[2]";
string datePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[3]";
var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(src);
for (int i = 1; i <= 96; i++)
{
string namePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[1]/span";
string comPath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[2]";
string datePath = $"//*[@id=\"commentlist\"]/ul/li[{i}]/p[3]";

var nameText = htmlDocument.DocumentNode.SelectSingleNode(namePath).InnerText;
var comText = htmlDocument.DocumentNode.SelectSingleNode(comPath).InnerText;
var dateText = htmlDocument.DocumentNode.SelectSingleNode(datePath).InnerText;
var parsedDate = DateTime.Parse(dateText);
var nameText = htmlDocument.DocumentNode.SelectSingleNode(namePath).InnerText;
var comText = htmlDocument.DocumentNode.SelectSingleNode(comPath).InnerText;
var dateText = htmlDocument.DocumentNode.SelectSingleNode(datePath).InnerText;
var parsedDate = DateTime.Parse(dateText);

if (new[] { nameText, comText, dateText } != null)
{
currentList.Add(new CommentItem
if (new[] { nameText, comText, dateText } != null)
{
name = nameText,
comment = comText,
date = parsedDate.ToString("d"),
});
currentList.Add(new CommentItem
{
name = nameText,
comment = comText,
date = parsedDate.ToString("d"),
});
}
}
return currentList;
}
catch (NullReferenceException)
{
return currentList;
}
return currentList;
}
public List<BitmapImage> RefineImage(string src)
public ObservableCollection<BitmapImage> UpdateImage(string src)
{
var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(src);
List<BitmapImage> currentList = new List<BitmapImage>();
for (int i = 1; i <= 50; i++)
var currentList = new ObservableCollection<BitmapImage>();
try
{
string imagePath = $"//*[@id=\"instagramhashtag\"]/ul/li[{i}]/img";
var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(src);

var imageNode = htmlDocument.DocumentNode.SelectSingleNode(imagePath);
if (imageNode != null)
for (int i = 1; i <= 50; i++)
{
currentList.Add(new BitmapImage(new Uri("https://avicii.com" + imageNode.Attributes["src"].Value)));
string imagePath = $"//*[@id=\"instagramhashtag\"]/ul/li[{i}]/img";

var imageNode = htmlDocument.DocumentNode.SelectSingleNode(imagePath);
if (imageNode != null)
{
currentList.Add(new BitmapImage(new Uri("https://avicii.com" + imageNode.Attributes["src"].Value)));
}
}
return currentList;
}
catch
{
return currentList;
}
return currentList;
}
}
}
19 changes: 8 additions & 11 deletions TrueLove.UWP/Views/CommentsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using TrueLove.Lib.Models.Code;
using TrueLove.UWP.Spider;
using Windows.ApplicationModel;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand All @@ -16,15 +14,15 @@ namespace TrueLove.UWP.Views
/// </summary>
public sealed partial class CommentsPage : Page
{
private List<CommentItem> Comments;
private ObservableCollection<CommentItem> Comments;
public CommentsPage()
{
this.InitializeComponent();
Window.Current.Activated += OnWindowActivated; // 订阅窗口活动事件

var readHTML = new ReviewHTML(Package.Current.InstalledPath + "/Spider/CommentCodeSample.txt");
var reviewHTML = new ReviewHTML("https://avicii.com", false);
var refineData = new RefineData();
Comments = refineData.RefineComment(readHTML.StrHTML);
Comments = refineData.UpdateComment(reviewHTML.StrHTML);
}
/// <summary>
/// 返回顶部按钮。
Expand Down Expand Up @@ -62,14 +60,13 @@ private void hapticScrollViewer_ViewChanged(object sender, ScrollViewerViewChang

if (backgroundImageFixedHeight == 0)
backgroundImageFixedHeight = backgroundSubTitle.ActualHeight;
try
if (backgroundImageFixedHeight - scrlocation <= 0)
{
backgroundSubTitle.Height = backgroundImageFixedHeight - scrlocation;
backgroundSubTitle.Height = 0;
}
catch (ArgumentException)
else
{
// 快速滑动引起的参数修正
backgroundSubTitle.Height = 0;
backgroundSubTitle.Height = backgroundImageFixedHeight - scrlocation;
}
}

Expand Down
6 changes: 2 additions & 4 deletions TrueLove.UWP/Views/ImagesPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using TrueLove.UWP.Spider;
using Windows.ApplicationModel;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand All @@ -18,10 +17,9 @@ public ImagesPage()
this.InitializeComponent();
Window.Current.Activated += OnWindowActivated; // 订阅窗口活动事件

//var readHTML = new ReviewHTML("https://avicii.com", false, false);
var readHTML = new ReviewHTML(Package.Current.InstalledPath + "/Spider/ImageCodeSample.txt");
var reviewHTML = new ReviewHTML("https://avicii.com/images", false);
var refineData = new RefineData();
ImageView.ItemsSource = refineData.RefineImage(readHTML.StrHTML);
ImageView.ItemsSource = refineData.UpdateImage(reviewHTML.StrHTML);
}

/// <summary>
Expand Down

0 comments on commit 90c6aa5

Please sign in to comment.