Skip to content

Commit

Permalink
[Alpha 0.0.4] Update
Browse files Browse the repository at this point in the history
[Alpha 0.0.4] Update
  • Loading branch information
AuroraZiling authored Apr 14, 2024
2 parents e598954 + cab72be commit f85ec99
Show file tree
Hide file tree
Showing 45 changed files with 782 additions and 541 deletions.
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
param(
[string] $Architecture = "x64",
[string] $Version = "0.0.3.0"
[string] $Version = "0.0.4.0"
)

$ErrorActionPreference = "Stop";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.58" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.60" />
<PackageReference Include="Serilog" Version="3.1.1" />
</ItemGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/PipManager/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<ResourceDictionary.MergedDictionaries>
<ui:ThemesDictionary Theme="Dark" />
<ui:ControlsDictionary />


<ResourceDictionary Source="/Resources/Animations.xaml" />
<ResourceDictionary Source="/PipManager;component/Resources/Library/LibraryStyles.xaml" />
<ResourceDictionary Source="/PipManager;component/Resources/FluentDesignComplements.xaml" />
</ResourceDictionary.MergedDictionaries>
Expand Down
5 changes: 5 additions & 0 deletions src/PipManager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Windows.Threading;
using PipManager.ViewModels.Pages.Overlay;
using PipManager.Views.Pages.Overlay;
using Wpf.Ui;
using AboutViewModel = PipManager.ViewModels.Pages.About.AboutViewModel;
using ActionViewModel = PipManager.ViewModels.Pages.Action.ActionViewModel;
Expand Down Expand Up @@ -90,6 +92,9 @@ public partial class App
services.AddSingleton<LibraryInstallPage>();
services.AddSingleton<LibraryInstallViewModel>();

services.AddSingleton<OverlayPage>();
services.AddSingleton<OverlayViewModel>();

services.AddSingleton<ActionPage>();
services.AddSingleton<ActionViewModel>();
services.AddSingleton<ActionExceptionPage>();
Expand Down
38 changes: 20 additions & 18 deletions src/PipManager/AppStarting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,26 @@ public void LogDeletion()
if (!_config.Personalization.LogAutoDeletion || !Directory.Exists(AppInfo.LogDir)) return;
var fileList = Directory.GetFileSystemEntries(AppInfo.LogDir);
var logFileAmount = fileList.Count(file => File.Exists(file) && file.EndsWith(".txt"));
if (logFileAmount >= _config.Personalization.LogAutoDeletionTimes)
if (logFileAmount < _config.Personalization.LogAutoDeletionTimes)
{
var directoryInfo = new DirectoryInfo(AppInfo.LogDir);
var filesInfo = directoryInfo.GetFileSystemInfos();
foreach (var file in filesInfo)
return;
}

var directoryInfo = new DirectoryInfo(AppInfo.LogDir);
var filesInfo = directoryInfo.GetFileSystemInfos();
foreach (var file in filesInfo)
{
if (file.Extension != ".txt") continue;
try
{
File.Delete(file.FullName);
}
catch
{
if (file.Extension != ".txt") continue;
try
{
File.Delete(file.FullName);
}
catch
{
// ignored
}
Log.Warning("Failed to delete log: {FileFullName}", file.FullName);
}
Log.Information($"{logFileAmount} log file(s) deleted");
}
Log.Information($"{logFileAmount} log file(s) deleted");
}

public void CrushesDeletion()
Expand All @@ -106,7 +108,7 @@ public void CrushesDeletion()
}
catch
{
// ignored
Log.Warning("Failed to delete crush file: {FileFullName}", file.FullName);
}
}
Log.Information($"{crushFileAmount} crush file(s) deleted");
Expand All @@ -124,9 +126,9 @@ public void CachesDeletion()
{
subDir.Delete(true);
}
catch (Exception)
catch
{
// ignored
Log.Warning("Failed to delete cache directory: {DirFullName}", subDir.FullName);
}
}
foreach (var file in filesInfo)
Expand All @@ -143,7 +145,7 @@ public void CachesDeletion()
}
catch
{
// ignored
Log.Warning("Failed to delete cache file: {FileFullName}", file.FullName);
}
}
Log.Information($"{cacheFileAmount} cache file(s) deleted");
Expand Down
45 changes: 13 additions & 32 deletions src/PipManager/Controls/Toast.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,13 @@ namespace PipManager.Controls
{
public class ToastOptions
{
public double ToastWidth { get; set; }
public double ToastHeight { get; set; }
public double TextWidth { get; set; }
public int Time { get; set; } = 2000;
public SymbolRegular Icon { get; set; } = SymbolRegular.Info24;
public Brush Foreground { get; set; } = new SolidColorBrush(Colors.Black);
public Brush IconForeground { get; set; } = new SolidColorBrush(Colors.Black);
public FontFamily FontFamily { get; set; } = new("Microsoft YaHei");
public FontWeight FontWeight { get; set; } = SystemFonts.MenuFontWeight;
public Brush BorderBrush { get; set; } = new SolidColorBrush(Color.FromRgb(229, 229, 229));
public Thickness BorderThickness { get; set; } = new(2);
public Brush Background { get; set; } = new SolidColorBrush(Color.FromArgb(40, 0, 255, 0));
public ApplicationTheme Theme { get; set; } = ApplicationTheme.Light;
public ToastType ToastType { get; set; } = ToastType.Info;
public EventHandler<EventArgs>? Closed { get; internal set; }
public EventHandler<EventArgs>? Click { get; internal set; }
public Thickness ToastMargin { get; set; } = new(0, 120, 0, 0);
public int Time { get; init; } = 2000;
public FontFamily FontFamily { get; } = new(new Uri("pack://application:,,,/"), "./Resources/Fonts/MiSans-Regular.ttf#MiSans");
public FontWeight FontWeight { get; } = SystemFonts.MenuFontWeight;
public Thickness BorderThickness { get; } = new(2);
public ApplicationTheme Theme { get; init; } = ApplicationTheme.Light;
public ToastType ToastType { get; init; } = ToastType.Info;
public Thickness ToastMargin { get; } = new(0, 120, 0, 0);
}

public enum ToastType
Expand All @@ -34,10 +24,7 @@ public enum ToastType
Error,
Success
}

/// <summary>
/// Toast.xaml 的交互逻辑
/// </summary>

public partial class Toast
{
private readonly Window? _owner;
Expand All @@ -58,13 +45,7 @@ private Toast(Window? owner, string title, string message, ToastOptions? options
InitializeComponent();
if (options != null)
{
if (options.ToastWidth != 0) ToastWidth = options.ToastWidth;
if (options.ToastHeight != 0) ToastHeight = options.ToastHeight;
if (options.TextWidth != 0) TextWidth = options.TextWidth;

Time = options.Time;
Closed += options.Closed;
Click += options.Click;
FontFamily = options.FontFamily;
FontWeight = options.FontWeight;
BorderThickness = options.BorderThickness;
Expand Down Expand Up @@ -283,7 +264,7 @@ private static void SetPopupOffset(Popup? popup, Toast toast)
popup.VerticalOffset = margin.Top;
}

public void Close()
private void Close()
{
_timer?.Stop();
_timer = null;
Expand Down Expand Up @@ -357,7 +338,7 @@ private string Message
private double ToastWidth
{
get => (double)GetValue(ToastWidthProperty);
set => SetValue(ToastWidthProperty, value);
init => SetValue(ToastWidthProperty, value);
}

private static readonly DependencyProperty ToastWidthProperty =
Expand All @@ -366,7 +347,7 @@ private double ToastWidth
private double ToastHeight
{
get => (double)GetValue(ToastHeightProperty);
set => SetValue(ToastHeightProperty, value);
init => SetValue(ToastHeightProperty, value);
}

private static readonly DependencyProperty ToastHeightProperty =
Expand All @@ -384,7 +365,7 @@ private SymbolRegular Icon
private int Time
{
get => (int)GetValue(TimeProperty);
set => SetValue(TimeProperty, value);
init => SetValue(TimeProperty, value);
}

private static readonly DependencyProperty TimeProperty =
Expand All @@ -402,7 +383,7 @@ public double TextWidth
public Thickness ToastMargin
{
get => (Thickness)GetValue(ToastMarginProperty);
set => SetValue(ToastMarginProperty, value);
init => SetValue(ToastMarginProperty, value);
}

public static readonly DependencyProperty ToastMarginProperty =
Expand Down
42 changes: 39 additions & 3 deletions src/PipManager/Languages/Lang.Designer.cs

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

16 changes: 14 additions & 2 deletions src/PipManager/Languages/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@
<data name="Action_OperationCanceled_Success" xml:space="preserve">
<value>Action Cancelled</value>
</data>
<data name="Action_OperationCanceled_AlreadyRunning" xml:space="preserve">
<value>Action Already Running</value>
<data name="Action_OperationCanceled_Failed" xml:space="preserve">
<value>Failed to cancel</value>
</data>
<data name="Action_Operation_Cancel" xml:space="preserve">
<value>Cancel</value>
Expand Down Expand Up @@ -732,4 +732,16 @@
<data name="ContentDialog_Message_CacheClearFailed" xml:space="preserve">
<value>Failed to clear caches</value>
</data>
<data name="Dialog_Title_DownloadDistributions" xml:space="preserve">
<value>Open download folder (for wheel files)</value>
</data>
<data name="Overlay_Title_PackageUpdate" xml:space="preserve">
<value>New Versions Found</value>
</data>
<data name="Overlay_Button_Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="Overlay_Button_Update" xml:space="preserve">
<value>Update</value>
</data>
</root>
16 changes: 14 additions & 2 deletions src/PipManager/Languages/Lang.zh-cn.resx
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@
<data name="Action_OperationCanceled_Success" xml:space="preserve">
<value>任务已取消</value>
</data>
<data name="Action_OperationCanceled_AlreadyRunning" xml:space="preserve">
<value>任务已运行</value>
<data name="Action_OperationCanceled_Failed" xml:space="preserve">
<value>任务终止失败</value>
</data>
<data name="Action_Operation_Cancel" xml:space="preserve">
<value>取消</value>
Expand Down Expand Up @@ -732,4 +732,16 @@
<data name="ContentDialog_Message_CacheClearFailed" xml:space="preserve">
<value>清除缓存失败</value>
</data>
<data name="Dialog_Title_DownloadDistributions" xml:space="preserve">
<value>打开下载文件夹</value>
</data>
<data name="Overlay_Title_PackageUpdate" xml:space="preserve">
<value>发现新版本</value>
</data>
<data name="Overlay_Button_Cancel" xml:space="preserve">
<value>取消</value>
</data>
<data name="Overlay_Button_Update" xml:space="preserve">
<value>更新</value>
</data>
</root>
6 changes: 3 additions & 3 deletions src/PipManager/Models/Action/ActionListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace PipManager.Models.Action;

public partial class ActionListItem : ObservableObject
{
public ActionListItem(ActionType operationType, string[] operationCommand, string displayCommand = "", string path = "", string[]? extraParameters = null, bool progressIntermediate = false, int totalSubTaskNumber = 1)
public ActionListItem(ActionType operationType, string[] operationCommand, string displayCommand = "", string path = "", string[]? extraParameters = null, bool progressIntermediate = false)
{
OperationType = operationType;
OperationCommand = operationCommand;
ProgressIntermediate = progressIntermediate;
TotalSubTaskNumber = totalSubTaskNumber;
TotalSubTaskNumber = operationCommand.Length;
Path = path;
ExtraParameters = extraParameters;
DisplayCommand = displayCommand switch
Expand Down Expand Up @@ -68,7 +68,7 @@ public ActionListItem(ActionType operationType, string[] operationCommand, strin

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ProgressBarValue))]
private int _totalSubTaskNumber = 1;
private int _totalSubTaskNumber;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ProgressBarValue))]
Expand Down
2 changes: 1 addition & 1 deletion src/PipManager/Models/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace PipManager.Models;
public class AppConfig
{
[JsonProperty("currentEnvironment")] public EnvironmentItem? CurrentEnvironment { get; set; }
[JsonProperty("environments")] public List<EnvironmentItem> EnvironmentItems { get; set; } = new();
[JsonProperty("environments")] public List<EnvironmentItem> EnvironmentItems { get; set; } = [];
[JsonProperty("packageSource")] public PackageSource PackageSource { get; set; } = new();
[JsonProperty("personalization")] public Personalization Personalization { get; set; } = new();
}
8 changes: 0 additions & 8 deletions src/PipManager/Models/DataColor.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/PipManager/Models/ExceptionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
public enum ExceptionType
{
// Environment
Environment_Broken,
EnvironmentBroken,

// Process
Process_Error
ProcessError
}
Loading

0 comments on commit f85ec99

Please sign in to comment.