Skip to content

Commit

Permalink
add download view
Browse files Browse the repository at this point in the history
  • Loading branch information
yaronzz committed Aug 1, 2020
1 parent 4cc3982 commit ad26f6f
Show file tree
Hide file tree
Showing 17 changed files with 270 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Download from [GitHub Releases](https://github.com/yaronzz/Suda/releases) and in

## User Interface

<img src="https://cdn.jsdelivr.net/gh/yaronzz/Suda/Screenshot/1.jpg" alt="image" style="zoom: 50%;" />
<img src="https://cdn.jsdelivr.net/gh/yaronzz/Suda/Screenshot/2.jpg" alt="image" style="zoom: 50%;" />

## Support

Expand Down
2 changes: 1 addition & 1 deletion README_CHN.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

## 🦄 用户界面

<img src="https://cdn.jsdelivr.net/gh/yaronzz/Suda/Screenshot/1.jpg" alt="image" style="zoom: 50%;" />
<img src="https://cdn.jsdelivr.net/gh/yaronzz/Suda/Screenshot/2.jpg" alt="image" style="zoom: 50%;" />

## 🤝 支持

Expand Down
8 changes: 4 additions & 4 deletions Suda/Else/CoverCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static async Task<ObservableCollection<CoverCard>> GetList()
{
try
{
Result result = await HttpHelper.GetOrPostAsync("https://cdn.jsdelivr.net/gh/yaronzz/CDN/app/todayplaylist.json");
Result result = await HttpHelper.GetOrPostAsync("https://cdn.jsdelivr.net/gh/yaronzz/CDN/app/suda/todayplaylist.json");
if(result.sData.IsNotBlank())
{
ObservableCollection<CoverCard> pList = JsonHelper.ConverStringToObject<ObservableCollection<CoverCard>>(result.sData);
Expand All @@ -38,21 +38,21 @@ private static ObservableCollection<CoverCard> GetDefaultList()
{
CoverCard card1 = new CoverCard()
{
ImgUrl = "https://i.scdn.co/image/ab67706f000000039921a400ba34f282317e2c3a",
ImgUrl = "https://cdn.jsdelivr.net/gh/yaronzz/CDN/app/suda/1.jpg",
Title = "Today's Top Hits",
Platform = "Spotify",
Url = "https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M",
};
CoverCard card2 = new CoverCard()
{
ImgUrl = "https://thisis-images.scdn.co/37i9dQZF1DZ06evO3NSzPI-large.jpg",
ImgUrl = "https://cdn.jsdelivr.net/gh/yaronzz/CDN/app/suda/2.jpg",
Title = "This Is back number",
Platform = "Spotify",
Url = "https://open.spotify.com/playlist/37i9dQZF1DZ06evO3NSzPI",
};
CoverCard card3 = new CoverCard()
{
ImgUrl = "https://thisis-images.scdn.co/37i9dQZF1DZ06evO1Dy2vS-large.jpg",
ImgUrl = "https://cdn.jsdelivr.net/gh/yaronzz/CDN/app/suda/3.jpg",
Title = "This Is 陳奕迅",
Platform = "Spotify",
Url = "https://open.spotify.com/playlist/37i9dQZF1DZ06evO1Dy2vS",
Expand Down
2 changes: 2 additions & 0 deletions Suda/Else/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -22,6 +23,7 @@ public class Global : ViewMoudleBase
public static string PATH_CACHE = PATH_BASE + "cache.json";
public static string PATH_SETTINGS = PATH_BASE + "settings.json";
public static string PATH_SUDA_PLAYLIST = PATH_BASE + "sudaplaylist.json";
public static string PATH_REQUIRE = Path.GetFullPath("./") + "require.zip";

//Token
public static string TOKEN_PLATFORM = "PlatformToken";
Expand Down
4 changes: 0 additions & 4 deletions Suda/Pages/AboutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ namespace Suda.Pages
{
public class AboutViewModel : Suda.Else.ModelBase
{
#if DEBUG
public string Type { get; set; } = "(DEBUG)";
#else
public string Type { get; set; } = "(BETA)";
#endif
public string Version { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

public void GotoGithub() => NetHelper.OpenWeb("https://github.com/yaronzz/Suda");
Expand Down
71 changes: 71 additions & 0 deletions Suda/Pages/DownloadView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<UserControl x:Class="Suda.Pages.DownloadView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Suda.Pages"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:aigsc="clr-namespace:AIGS.Control;assembly=AIGS"
xmlns:aigs="clr-namespace:AIGS.Common;assembly=AIGS"
xmlns:sudaelse="clr-namespace:Suda.Else"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:DownloadViewModel}">
<Grid Visibility="{Binding ViewVisibility}">
<Grid Background="Black" Opacity="0.3"></Grid>
<Border Style="{StaticResource BorderRegion}" Effect="{DynamicResource EffectShadow3}" VerticalAlignment="Center" HorizontalAlignment="Center">
<Grid Margin="10,0,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="AUTO"/>
<RowDefinition Height="AUTO"/>
</Grid.RowDefinitions>

<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>

<Image Source="/Properties/img/favicon.ico" Height="180" Width="180"></Image>
<DockPanel Grid.Column="1" Margin="15,0,0,0" VerticalAlignment="Center">
<TextBlock Text="SUDA" DockPanel.Dock="Top" FontSize="40" VerticalAlignment="Top" FontWeight="ExtraBlack" Margin="0,15,0,15" />
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<TextBlock Text="MADE WITH ♥ BY " Foreground="Gray" FontSize="15" VerticalAlignment="Center" Height="25" Margin="0" FontFamily="Global Monospace" />
<TextBlock Text="YARONZZ" Foreground="BlueViolet" FontSize="15" VerticalAlignment="Center" Height="25" Margin="0" FontFamily="Global Monospace" />
</StackPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
<TextBlock Text="{DynamicResource strVERSION}" Foreground="Gray" FontSize="14" FontFamily="Global Monospace" VerticalAlignment="Center" TextWrapping="Wrap" Margin="0,0,5,0" />
<TextBlock Text="{Binding Version}" Foreground="BlueViolet" FontSize="14" FontFamily="Global Monospace" VerticalAlignment="Center" TextWrapping="Wrap" />
<TextBlock Text="{Binding Type}" Foreground="BlueViolet" FontSize="14" FontFamily="Global Monospace" VerticalAlignment="Center" TextWrapping="Wrap" />
</StackPanel>
<DockPanel DockPanel.Dock="Bottom" VerticalAlignment="Bottom" Margin="0,20,0,20">
<Button Content="Github" Command="{s:Action GotoGithub}" hc:IconElement.Geometry="{StaticResource GithubGeometry}" DockPanel.Dock="Left" Margin="0,0,10,0" Padding="15,6" HorizontalAlignment="Left" ></Button>
<Button Content="{DynamicResource strFeedback}" Command="{s:Action Feedback}" hc:IconElement.Geometry="{StaticResource IssuesGeometry}" DockPanel.Dock="Left" Margin="0,0,10,0" Padding="15,6" HorizontalAlignment="Left" ></Button>
<Button Content="{DynamicResource strGroup}" Command="{s:Action Telegram}" hc:IconElement.Geometry="{StaticResource TelegramGeometry}" DockPanel.Dock="Left" Margin="0,0,10,0" Padding="15,6" HorizontalAlignment="Left" ></Button>
</DockPanel>
</DockPanel>
</Grid>

<Grid Grid.Row="1" Margin="10,10,0,0" >
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<hc:Divider Margin="0,1"></hc:Divider>
<StackPanel Grid.Row="1">
<StackPanel Orientation="Horizontal" Margin="0,10,0,10">
<TextBlock Text="Download Require" FontSize="14" Foreground="Gray" ></TextBlock>
<TextBlock Text=" : " FontSize="14" Foreground="Gray" ></TextBlock>
<TextBlock Text="{Binding TotalSize}" FontSize="14" Foreground="Gray" ></TextBlock>
<TextBlock Text=" \ " FontSize="14" Foreground="Gray" ></TextBlock>
<TextBlock Text="{Binding DownloadSize}" FontSize="14" Foreground="Gray" ></TextBlock>
<TextBlock Text=" m" FontSize="14" Foreground="Gray" ></TextBlock>
</StackPanel>
<ProgressBar Margin="0,0,0,10" Value="{Binding ProgressValue}"/>
</StackPanel>
</Grid>
</Grid>
</Border>
</Grid>
</UserControl>
28 changes: 28 additions & 0 deletions Suda/Pages/DownloadView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Suda.Pages
{
/// <summary>
/// DownloadView.xaml 的交互逻辑
/// </summary>
public partial class DownloadView : UserControl
{
public DownloadView()
{
InitializeComponent();
}
}
}
103 changes: 103 additions & 0 deletions Suda/Pages/DownloadViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using AIGS.Common;
using AIGS.Helper;
using ICSharpCode.SharpZipLib.Zip;
using Suda.Else;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Suda.Pages
{
public class DownloadViewModel : Suda.Else.ModelBase
{
public string Type { get; set; } = "(BETA)";
public string Version { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
public void GotoGithub() => NetHelper.OpenWeb("https://github.com/yaronzz/Suda");
public void Feedback() => NetHelper.OpenWeb("https://github.com/yaronzz/Suda/issues");
public void Telegram() => NetHelper.OpenWeb("https://t.me/suda_group");

public int ProgressValue { get; set; }
public string TotalSize { get; set; } //M
public string DownloadSize { get; set; }
public Action<object> Action { get; set; }

public bool CheckRequire()
{
string file = "./libcef.dll";
return File.Exists(file);
}

public bool DownloadRequire(Action<object> action)
{
ProgressValue = 0;
TotalSize = null;
DownloadSize = null;
Action = action;

if(UnzipRequire())
{
Action((true, "Unzip require success!"));
return false;
}

string url = "https://onedrive.gimhoy.com/1drv/aHR0cHM6Ly8xZHJ2Lm1zL3UvcyFBc3h5VUd1Q0w4SGFoWXdkdGxRM25rSVdZeFlpQ2c/ZT1sZG5xRVY=.zip";
DownloadFileHepler.StartAsync(url, Global.PATH_REQUIRE, null, UpdateDownloadNotify, CompleteDownloadNotify, ErrDownloadNotify, 3);
return true;
}

public bool UnzipRequire()
{
try
{
FastZip fz = new FastZip();
if (File.Exists(Global.PATH_REQUIRE))
{
fz.ExtractZip(Global.PATH_REQUIRE, Path.GetFullPath("./"), null);
if (CheckRequire())
return true;
}
}
catch (Exception e)
{
string msg = e.Message;
}
return false;
}

public bool UpdateDownloadNotify(long lTotalSize, long lAlreadyDownloadSize, long lIncreSize, object data)
{
int progress = (int)(lAlreadyDownloadSize * 100 / lTotalSize);
if (progress > ProgressValue)
ProgressValue = progress;

float Size;
if (TotalSize.IsBlank())
{
Size = (float)lTotalSize / 1048576;
TotalSize = Size.ToString("#0.00");
}

Size = (float)lAlreadyDownloadSize / 1048576;
DownloadSize = Size.ToString("#0.00");
return true;
}

public void CompleteDownloadNotify(long lTotalSize, object data)
{
ProgressValue = 100;

if(UnzipRequire())
Action((true, "Download success!"));
else
Action((false, "Unzip failed!"));
}

public void ErrDownloadNotify(long lTotalSize, long lAlreadyDownloadSize, string sErrMsg, object data)
{
Action((false,"Download failed!"));
}
}
}
2 changes: 2 additions & 0 deletions Suda/Pages/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
<local:SettingsView Padding="10,0,10,10" Grid.Row="1" Grid.Column="1" s:View.Model="{Binding VMSettings}" />
<!--About-->
<local:AboutView Padding="0" Grid.RowSpan="3" Grid.ColumnSpan="3" s:View.Model="{Binding VMAbout}" />
<!--Download-->
<local:DownloadView Padding="0" Grid.RowSpan="3" Grid.ColumnSpan="3" s:View.Model="{Binding VMDownload}" />
<!--Upload-->
<hc:TransitioningContentControl Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="2" HorizontalContentAlignment="Right">
<local:UploadView s:View.Model="{Binding VMUpload}" HorizontalAlignment="Right" />
Expand Down
Loading

0 comments on commit ad26f6f

Please sign in to comment.