-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
270 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.