-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
dc883a9
commit 61595f7
Showing
18 changed files
with
1,012 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.8.34205.153 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMMS_Downloader", "SMMS_Downloader\SMMS_Downloader.csproj", "{3B72077F-D778-4489-A066-2A84BD8D63A9}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{3B72077F-D778-4489-A066-2A84BD8D63A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3B72077F-D778-4489-A066-2A84BD8D63A9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3B72077F-D778-4489-A066-2A84BD8D63A9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3B72077F-D778-4489-A066-2A84BD8D63A9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {6013876C-A5E5-4AB8-849C-B302407F85CE} | ||
EndGlobalSection | ||
EndGlobal |
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,8 @@ | ||
<Application | ||
x:Class="SMMS_Downloader.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:SMMS_Downloader" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources /> | ||
</Application> |
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,14 @@ | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Windows; | ||
|
||
namespace SMMS_Downloader | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
|
||
} |
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,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
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,37 @@ | ||
using SMMS_Downloader.ViewModels; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
using System.Windows.Media; | ||
|
||
namespace SMMS_Downloader.Converters | ||
{ | ||
public class StateToBrushConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
TaskState state = (TaskState)value; | ||
switch(state) | ||
{ | ||
case TaskState.Wait: | ||
return new SolidColorBrush(Color.FromArgb(50, 3, 169, 244)); | ||
case TaskState.Downloading: | ||
return new SolidColorBrush(Color.FromArgb(50, 63, 81, 181)); | ||
case TaskState.Error: | ||
return new SolidColorBrush(Color.FromArgb(50, 244, 67, 54)); | ||
case TaskState.Done: | ||
return new SolidColorBrush(Color.FromArgb(50, 76, 175, 80)); | ||
} | ||
return ""; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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,36 @@ | ||
using SMMS_Downloader.ViewModels; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace SMMS_Downloader.Converters | ||
{ | ||
public class StateToTextConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
TaskState state = (TaskState)value; | ||
switch(state) | ||
{ | ||
case TaskState.Wait: | ||
return "⏱️"; | ||
case TaskState.Downloading: | ||
return "▶️"; | ||
case TaskState.Error: | ||
return "❌"; | ||
case TaskState.Done: | ||
return "✅"; | ||
} | ||
return ""; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SMMS_Downloader.Extensions | ||
{ | ||
public static class FileSizeExtension | ||
{ | ||
public const long ChunkSize = 4 * 1024 * 1024; | ||
|
||
public static string PrettyPrint(this long value) | ||
{ | ||
if (value < 0) throw new Exception("WTF???"); | ||
double v = value; | ||
if (v < 1024) | ||
{ | ||
return $"{value} Bytes"; | ||
} | ||
else v = v / 1024; | ||
if (v < 1024) | ||
{ | ||
return $"{v.ToString("f2")} KB"; | ||
} | ||
else v = v / 1024; | ||
if (v < 1024) | ||
{ | ||
return $"{v.ToString("f2")} MB"; | ||
} | ||
else v = v / 1024; | ||
if (v < 1024) | ||
{ | ||
return $"{v.ToString("f2")} GB"; | ||
} | ||
else v = v / 1024; | ||
if (v < 1024) | ||
{ | ||
return $"{v.ToString("f2")} TB"; | ||
} | ||
else v = v / 1024; | ||
throw new Exception("WTF???"); | ||
} | ||
|
||
public static int GetChunkCount(this long size) | ||
{ | ||
var chunkCount = (int)(size / ChunkSize); | ||
chunkCount += chunkCount * ChunkSize == size ? 0 : 1; | ||
if (size == 0) | ||
chunkCount = 1; | ||
return chunkCount; | ||
} | ||
} | ||
} |
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,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using Microsoft.Xaml.Behaviors; | ||
|
||
namespace SMMS_Downloader.Extensions | ||
{ | ||
public class PassWordExtensions | ||
{ | ||
public static string GetPassWord(DependencyObject obj) | ||
{ | ||
return (string)obj.GetValue(PassWordProperty); | ||
} | ||
|
||
public static void SetPassWord(DependencyObject obj, string value) | ||
{ | ||
obj.SetValue(PassWordProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty PassWordProperty = | ||
DependencyProperty.RegisterAttached("PassWord", typeof(string), typeof(PassWordExtensions), new FrameworkPropertyMetadata(string.Empty, OnPassWordPropertyChanged)); | ||
|
||
static void OnPassWordPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) | ||
{ | ||
var passWord = sender as PasswordBox; | ||
string password = (string)e.NewValue; | ||
|
||
if (passWord != null && passWord.Password != password) | ||
passWord.Password = password; | ||
} | ||
} | ||
|
||
public class PasswordBehavior : Behavior<PasswordBox> | ||
{ | ||
protected override void OnAttached() | ||
{ | ||
base.OnAttached(); | ||
AssociatedObject.PasswordChanged += AssociatedObject_PasswordChanged; | ||
} | ||
|
||
private void AssociatedObject_PasswordChanged(object sender, RoutedEventArgs e) | ||
{ | ||
PasswordBox passwordBox = sender as PasswordBox; | ||
string password = PassWordExtensions.GetPassWord(passwordBox); | ||
|
||
if (passwordBox != null && passwordBox.Password != password) | ||
PassWordExtensions.SetPassWord(passwordBox, passwordBox.Password); | ||
} | ||
|
||
protected override void OnDetaching() | ||
{ | ||
base.OnDetaching(); | ||
AssociatedObject.PasswordChanged -= AssociatedObject_PasswordChanged; | ||
} | ||
} | ||
} |
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,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SMMS_Downloader.Helpers | ||
{ | ||
public static class LaunchHelper | ||
{ | ||
public static void OpenURL(string url) | ||
{ | ||
var psi = new ProcessStartInfo | ||
{ | ||
FileName = url, | ||
UseShellExecute = true | ||
}; | ||
Process.Start(psi); | ||
} | ||
} | ||
} |
Oops, something went wrong.