Merge branch 'develop' of https://github.com/SteamTools-Team/SteamTools into develop

This commit is contained in:
Mossimo
2021-08-06 13:55:49 +08:00
36 changed files with 559 additions and 244 deletions
@@ -199,11 +199,9 @@ namespace System.Application.Services.Implementation
TNotificationType notificationType,
bool autoCancel,
string? title,
TEntrance entrance)
TEntrance? entrance)
{
var notificationEntrance = entrance != null ?
GetActivityType(entrance).GetJClass() :
R.activities.entrance;
var notificationEntrance = (entrance != null ? GetActivityType(entrance)?.GetJClass() : null) ?? R.activities.entrance;
var context = AndroidApplication.Context;
var manager = NotificationManagerCompat.From(context);
var builder = BuildNotify(context, manager, text, notificationType,
@@ -213,24 +211,25 @@ namespace System.Application.Services.Implementation
}
public Progress<float> NotifyDownload(
string text,
Func<string> text,
TNotificationType notificationType,
string? title)
{
var context = AndroidApplication.Context;
var manager = NotificationManagerCompat.From(context);
var builder = BuildNotify(context, manager,
text: text.Format(0),
text: text(),
notificationType,
title: title);
// 进度单位说明
// 通用层采用 float 浮点数作为进度值,范围从0~100,保留两位小数
// 平台层采用 int 整型作为进度值,范围从0~10000,转换需要 乘 100
const int unit_convert_multiple = 100; // 从float到int转换单位倍数
const int PROGRESS_MAX = 100 * unit_convert_multiple; // 进度条满值
const float PROGRESS_MAX = IAppUpdateService.MaxProgressValue * unit_convert_multiple; // 进度条满值
int PROGRESS_MAX_INT32 = PROGRESS_MAX.ToInt32();
// 发出零进度的初始通知
// Issue the initial notification with zero progress
builder.SetProgress(PROGRESS_MAX, 0, false);
builder.SetProgress(PROGRESS_MAX_INT32, 0, false);
var notifyId = GetNotifyId(notificationType);
manager.Notify(notifyId, builder.Build());
// 在这里完成跟踪进度的工作。
@@ -248,7 +247,7 @@ namespace System.Application.Services.Implementation
void Handler(float current)
{
var currentInt32 = (current * unit_convert_multiple).ToInt32();
if (currentInt32 >= PROGRESS_MAX)
if (currentInt32 >= PROGRESS_MAX_INT32)
{
// 这将使100%时直接取消通知,并不会在UI上显示
// 报告进度值满的操作应当是幂等的
@@ -266,8 +265,8 @@ namespace System.Application.Services.Implementation
// 在报告进度值满后不可再更改进度
if (builder == null) throw new ArgumentNullException(nameof(builder));
if (manager == null) throw new ArgumentNullException(nameof(manager));
builder.SetProgress(PROGRESS_MAX, currentInt32, false);
builder.SetContentText(text.Format(currentInt32));
builder.SetProgress(PROGRESS_MAX_INT32, currentInt32, false);
builder.SetContentText(text());
manager.Notify(notifyId, builder.Build());
}
}
@@ -45,7 +45,7 @@ namespace System.Application.Services
/// 下载进度通知
/// </summary>
Progress<float> NotifyDownload(
string text,
Func<string> text,
TNotificationType notificationType,
string? title = default);
}
+2
View File
@@ -75,6 +75,8 @@ namespace System
public const string MPO = ".mpo";
public const string DownloadCache = ".download_cache";
public static string Clean(string extension, bool trimLeadingPeriod = false)
{
if (string.IsNullOrWhiteSpace(extension))
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
@@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net472</TargetFramework>
<ApplicationManifest>..\..\ST.Client.Desktop.Avalonia.App\Properties\app.manifest</ApplicationManifest>
<AssemblyName>Steam++.Launcher</AssemblyName>
<RootNamespace>System</RootNamespace>
@@ -31,5 +31,14 @@
<Compile Include="..\..\Common.CoreLib\Properties\ThisAssembly.Version.cs">
<Link>Properties\ThisAssembly.Version.cs</Link>
</Compile>
<Compile Include="..\..\ST.Client.Desktop\Services\IDesktopPlatformService.SystemBootRunArguments.cs">
<Link>Application\Services\IDesktopPlatformService.SystemBootRunArguments.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
<PackageReference Include="System.Runtime.WindowsRuntime.UI.Xaml" Version="4.7.0" />
</ItemGroup>
</Project>
@@ -1,17 +1,30 @@
using System;
using System.Diagnostics;
using System.IO;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using static System.Application.Services.IDesktopPlatformService;
static string? OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.StartupTask)
{
// 静默启动(不弹窗口)
return SystemBootRunArguments;
}
return default;
}
var activatedArgs = AppInstance.GetActivatedEventArgs();
try
{
Process.Start(new ProcessStartInfo()
{
FileName = Path.Combine(AppContext.BaseDirectory, "..", "Steam++.exe"),
Arguments = string.Join(" ", args),
UseShellExecute = false,
Arguments = (activatedArgs == default ? default : OnActivated(activatedArgs)) ?? string.Join(" ", args),
UseShellExecute = default,
});
}
catch (FileNotFoundException)
{
}
@@ -211,6 +211,7 @@ namespace System.Application.UI
#region NotifyIcon
var notifyIcon = INotifyIcon.Instance;
notifyIcon.Visible = true;
notifyIcon.ToolTipText = ThisAssembly.AssemblyTrademark;
switch (DI.Platform)
{
@@ -255,8 +256,6 @@ namespace System.Application.UI
.Select(x => new MenuItem { Header = x.Key, Command = x.Value }).ToList();
notifyIcon.ContextMenu = NotifyIconContextMenu;
#endif
notifyIcon.Visible = true;
notifyIcon.Click += NotifyIcon_Click;
notifyIcon.DoubleClick += NotifyIcon_Click;
compositeDisposable.Add(() =>
@@ -270,8 +269,6 @@ namespace System.Application.UI
#if WINDOWS
JumpLists.Init();
#endif
IsNotOfficialChannelPackageDetectionHelper.Check();
}
desktop.MainWindow =
@@ -301,6 +298,7 @@ namespace System.Application.UI
#if StartupTrace
StartupTrace.Restart("Desktop_Startup.Start");
#endif
IsNotOfficialChannelPackageDetectionHelper.Check();
#if WINDOWS
if (isOfficialChannelPackage)
{
+11 -11
View File
@@ -12,15 +12,15 @@ namespace System.Application.UI
static readonly object lock_global_ex_log = new();
#if WINDOWS_DESKTOP_BRIDGE
static string[] OnActivated(string[] main_args, global::Windows.ApplicationModel.Activation.IActivatedEventArgs args)
{
if (args.Kind == global::Windows.ApplicationModel.Activation.ActivationKind.StartupTask)
{
// 静默启动(不弹窗口)
return IDesktopPlatformService.SystemBootRunArguments.Split(' ');
}
return main_args;
}
//static string[] OnActivated(string[] main_args, global::Windows.ApplicationModel.Activation.IActivatedEventArgs args)
//{
// if (args.Kind == global::Windows.ApplicationModel.Activation.ActivationKind.StartupTask)
// {
// // 静默启动(不弹窗口)
// return IDesktopPlatformService.SystemBootRunArguments.Split(' ');
// }
// return main_args;
//}
#endif
// Initialization code. Don't use any Avalonia, third-party APIs or any
@@ -34,8 +34,8 @@ namespace System.Application.UI
{
#if WINDOWS_DESKTOP_BRIDGE
if (!DesktopBridgeHelper.Init()) return 0;
var activatedArgs = global::Windows.ApplicationModel.AppInstance.GetActivatedEventArgs();
if (activatedArgs != null) args = OnActivated(args, activatedArgs);
//var activatedArgs = global::Windows.ApplicationModel.AppInstance.GetActivatedEventArgs();
//if (activatedArgs != null) args = OnActivated(args, activatedArgs);
#elif !__MOBILE__
#if MAC
AppDelegateHelper.Init(args);
@@ -1,3 +1,4 @@
using System.Application.UI;
using System.Properties;
namespace System.Application.Services.Implementation
@@ -16,20 +17,32 @@ namespace System.Application.Services.Implementation
public void Cancel(NotificationType notificationType)
{
if (DI.Platform == Platform.Windows)
{
INotifyIcon.Instance.HideBalloonTip();
}
}
public void CancelAll()
{
if (DI.Platform == Platform.Windows)
{
INotifyIcon.Instance.HideBalloonTip();
}
}
public void Notify(string text, NotificationType notificationType, bool autoCancel, string? title, Entrance entrance)
{
title ??= ThisAssembly.AssemblyTrademark;
// 调用托盘显示通知
throw new NotImplementedException(title);
if (DI.Platform == Platform.Windows)
{
INotifyIcon.Instance.ShowBalloonTip(title, text);
}
}
public Progress<float> NotifyDownload(string text, NotificationType notificationType, string? title)
public Progress<float> NotifyDownload(Func<string> text, NotificationType notificationType, string? title)
{
// 桌面端不支持带进度的通知,下载新版本改用桌面端的窗口进度条控件,由更新服务桌面端版实现
//title ??= ThisAssembly.AssemblyTrademark;
@@ -159,12 +159,13 @@ namespace System.Application.Services.Implementation
TWindowViewModel? viewModel = null,
string title = "",
ResizeModeCompat resizeMode = ResizeModeCompat.NoResize,
bool isDialog = true)
bool isDialog = true,
bool isParent = true)
where TWindowViewModel : WindowViewModel, new()
{
DialogWindowViewModel? dialogWindowViewModel = null;
await Show(typeof(TWindowViewModel), isDialog, customWindow,
title, viewModel, resizeMode, true, dwvm =>
title, viewModel, resizeMode, isParent, dwvm =>
{
dialogWindowViewModel = dwvm;
});
@@ -239,7 +239,7 @@
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<StackPanel Spacing="8">
<StackPanel Spacing="5">
<Border DockPanel.Dock="Top"
Cursor="Hand"
x:Name="AppAvater"
@@ -7,57 +7,62 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="System.Application.UI.Views.Pages.Settings_Steam">
<ScrollViewer>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Stretch"
Spacing="20">
<StackPanel.Styles>
<Style Selector="TextBlock">
<Setter Property="FontSize" Value="{StaticResource FontSizeH7}"/>
<Setter Property="Foreground" Value="{DynamicResource HighlightForegroundBrushKey}" />
</Style>
<Style Selector="DockPanel > TextBlock">
<Setter Property="Margin" Value="0 0 20 0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="(DockPanel.Dock)" Value="Left" />
</Style>
<Style Selector="DockPanel > ToggleSwitch">
<Setter Property="Margin" Value="0 0 -12 0" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="OnContent" Value="{x:Null}" />
<Setter Property="OffContent" Value="{x:Null}" />
</Style>
</StackPanel.Styles>
<ScrollViewer>
<StackPanel Orientation="Vertical"
HorizontalAlignment="Stretch"
Spacing="20">
<StackPanel.Styles>
<Style Selector="TextBlock">
<Setter Property="FontSize" Value="{StaticResource FontSizeH7}"/>
<Setter Property="Foreground" Value="{DynamicResource HighlightForegroundBrushKey}" />
</Style>
<Style Selector="DockPanel > TextBlock">
<Setter Property="Margin" Value="0 0 20 0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="(DockPanel.Dock)" Value="Left" />
</Style>
<Style Selector="DockPanel > ToggleSwitch">
<Setter Property="Margin" Value="0 0 -12 0" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="OnContent" Value="{x:Null}" />
<Setter Property="OffContent" Value="{x:Null}" />
</Style>
</StackPanel.Styles>
<DockPanel>
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam_AutoRunSteam,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:SteamSettings.IsAutoRunSteam},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<DockPanel>
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam_AutoRunSteam,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:SteamSettings.IsAutoRunSteam},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<DockPanel>
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam_RuningMinimize,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:SteamSettings.IsRunSteamMinimized},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<DockPanel>
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam_RuningMinimize,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:SteamSettings.IsRunSteamMinimized},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<DockPanel>
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam_NotCheckUpdate,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:SteamSettings.IsRunSteamNoCheckUpdate},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<DockPanel>
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam_NotCheckUpdate,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:SteamSettings.IsRunSteamNoCheckUpdate},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<Separator Classes="Separator"/>
<DockPanel>
<TextBlock Text="{ReflectionBinding Path=Res.Settings_Steam_CheckSteamRuningNotification,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
<ToggleSwitch IsChecked="{ReflectionBinding Source={x:Static ms:SteamSettings.IsEnableSteamLaunchNotification},Path=Value, Mode=TwoWay}"/>
</DockPanel>
<StackPanel Spacing="10">
<!--<TextBlock Text= "{ReflectionBinding Path=Res.Settings_Steam_SteamStratParameter,Mode=OneWay,Source={x:Static resx:R.Current}}" />-->
<TextBox Watermark="{ReflectionBinding Path=Res.Settings_Steam_SteamStratParameter,Mode=OneWay,Source={x:Static resx:R.Current}}"
UseFloatingWatermark="True"
Text="{ReflectionBinding Source={x:Static ms:SteamSettings.SteamStratParameter},Path=Value, Mode=TwoWay}"
MinHeight="150"
AcceptsReturn="True"
TextWrapping="Wrap"></TextBox>
</StackPanel>
<Separator Classes="Separator"/>
<Separator Classes="Separator"/>
</StackPanel>
</ScrollViewer>
<StackPanel Spacing="10">
<!--<TextBlock Text= "{ReflectionBinding Path=Res.Settings_Steam_SteamStratParameter,Mode=OneWay,Source={x:Static resx:R.Current}}" />-->
<TextBox Watermark="{ReflectionBinding Path=Res.Settings_Steam_SteamStratParameter,Mode=OneWay,Source={x:Static resx:R.Current}}"
UseFloatingWatermark="True"
Text="{ReflectionBinding Source={x:Static ms:SteamSettings.SteamStratParameter},Path=Value, Mode=TwoWay}"
MinHeight="150"
AcceptsReturn="True"
TextWrapping="Wrap"></TextBox>
</StackPanel>
<Separator Classes="Separator"/>
</StackPanel>
</ScrollViewer>
</UserControl>
@@ -72,7 +72,7 @@
OffContent=""
HorizontalAlignment="Right"
Margin="5 0 0 5"
IsChecked="{Binding Source={x:Static service:SteamConnectService.Current},Path=IsAutoAFKApps}"
IsChecked="{ReflectionBinding Source={x:Static ms:GameLibrarySettings.IsAutoAFKApps},Path=Value}"
ToolTip.Tip="{ReflectionBinding Path=Res.GameList_AutoAFK,Mode=OneWay,Source={x:Static resx:R.Current}}"
VerticalAlignment="Center">
</ToggleSwitch>
@@ -2,7 +2,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
mc:Ignorable="d"
d:DesignWidth="720" d:DesignHeight="400"
MinWidth="720" MinHeight="400"
Width="720" Height="400"
x:Class="System.Application.UI.Views.Windows.AddAuthWindow"
xmlns:resx="clr-namespace:System.Application.UI.Resx;assembly=System.Application.SteamTools.Client.Desktop"
xmlns:vm="clr-namespace:System.Application.UI.ViewModels;assembly=System.Application.SteamTools.Client.Desktop"
@@ -10,8 +13,6 @@
xmlns:controls="clr-namespace:System.Application.UI.Views.Controls"
xmlns:ms="clr-namespace:System.Application.Models.Settings;assembly=System.Application.SteamTools.Client.Desktop"
FontFamily="{Binding Source={x:Static ms:UISettings.FontName},Path=Value, Mode=OneWay,Converter={StaticResource NameToFontFamilyConverter}}"
MinWidth="600"
MinHeight="400"
WindowStartupLocation="CenterOwner"
ExtendClientAreaTitleBarHeightHint="30"
Background="Transparent"
@@ -31,6 +31,13 @@ namespace System.Application.UI.Views.Windows
AvaloniaXamlLoader.Load(this);
}
protected override void OnOpened(EventArgs e)
{
base.OnOpened(e);
this.Topmost = true;
this.Topmost = false;
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
@@ -1,4 +1,4 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
// Slightly modified and extended version for the use in SQRLDotNetClientUI
@@ -18,8 +18,11 @@ namespace System
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad);
[DllImport("shell32", CharSet = CharSet.Auto)]
public static extern int Shell_NotifyIcon(NIM dwMessage, NOTIFYICONDATA lpData);
/// <summary>
/// Creates, updates or deletes the taskbar icon.
/// </summary>
[DllImport("shell32", CharSet = CharSet.Unicode)]
public static extern bool Shell_NotifyIcon(NIM cmd, NOTIFYICONDATA data);
[DllImport("user32.dll")]
public static extern void PostQuitMessage(int nExitCode);
@@ -113,7 +116,7 @@ namespace System
public uint dwTime;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public class NOTIFYICONDATA
{
public int cbSize = Marshal.SizeOf<NOTIFYICONDATA>();
@@ -126,12 +129,29 @@ namespace System
public string szTip;
public int dwState = 0;
public int dwStateMask = 0;
/// <summary>
/// String with the text for a balloon ToolTip. It can have a maximum of 255 characters.
/// To remove the ToolTip, set the NIF_INFO flag in uFlags and set szInfo to an empty string.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string szInfo;
public int uTimeoutOrVersion;
/// <summary>
/// String containing a title for a balloon ToolTip. This title appears in boldface
/// above the text. It can have a maximum of 63 characters.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string szInfoTitle;
public NIIF dwInfoFlags;
/// <summary>
/// Windows Vista (Shell32.dll version 6.0.6) and later. The handle of a customized
/// balloon icon provided by the application that should be used independently
/// of the tray icon. If this member is non-NULL and the <see cref="NIIF.USER"/>
/// flag is set, this icon is used as the balloon icon.<br/>
/// If this member is NULL, the legacy behavior is carried out.
/// </summary>
//public IntPtr CustomBalloonIconHandle;
}
public enum NIM : uint
@@ -143,33 +163,6 @@ namespace System
SETVERSION = 0x00000004
}
[Flags]
public enum NIF : uint
{
MESSAGE = 0x00000001,
ICON = 0x00000002,
TIP = 0x00000004,
STATE = 0x00000008,
INFO = 0x00000010,
GUID = 0x00000020,
REALTIME = 0x00000040,
SHOWTIP = 0x00000080
}
[Flags]
public enum NIIF : uint
{
NONE = 0x00000000,
INFO = 0x00000001,
WARNING = 0x00000002,
ERROR = 0x00000003,
USER = 0x00000004,
ICON_MASK = 0x0000000F,
NOSOUND = 0x00000010,
LARGE_ICON = 0x00000020,
RESPECT_QUIET_TIME = 0x00000080
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class MENUITEMINFO
{
@@ -2103,6 +2096,33 @@ namespace System
}
}
[Flags]
public enum NIF : uint
{
MESSAGE = 0x00000001,
ICON = 0x00000002,
TIP = 0x00000004,
STATE = 0x00000008,
INFO = 0x00000010,
GUID = 0x00000020,
REALTIME = 0x00000040,
SHOWTIP = 0x00000080
}
[Flags]
public enum NIIF : uint
{
NONE = 0x00000000,
INFO = 0x00000001,
WARNING = 0x00000002,
ERROR = 0x00000003,
USER = 0x00000004,
ICON_MASK = 0x0000000F,
NOSOUND = 0x00000010,
LARGE_ICON = 0x00000020,
RESPECT_QUIET_TIME = 0x00000080
}
[Flags]
internal enum DropEffect : int
{
+92 -10
View File
@@ -20,6 +20,11 @@ namespace System.Application.UI
string _toolTipText = string.Empty;
bool _visible = false;
bool _doubleClick = false;
/// <summary>
/// Represents the current icon data.
/// </summary>
private UnmanagedMethods.NOTIFYICONDATA iconData;
public event EventHandler<EventArgs>? Click;
public event EventHandler<EventArgs>? DoubleClick;
@@ -127,6 +132,17 @@ namespace System.Application.UI
{
_window = new NotifyIconWindow(this);
}
iconData = new UnmanagedMethods.NOTIFYICONDATA()
{
hWnd = _window.Handle,
uID = _uID,
uFlags = NIF.TIP | NIF.MESSAGE,
uCallbackMessage = (int)UnmanagedMethods.CustomWindowsMessage.WM_TRAYMOUSE,
hIcon = IntPtr.Zero,
uTimeoutOrVersion = 0,
szTip = ToolTipText,
};
}
~NotifyIcon()
@@ -141,20 +157,12 @@ namespace System.Application.UI
void UpdateIcon(bool remove = false)
{
if (_window == null) throw new ArgumentNullException(nameof(_window));
UnmanagedMethods.NOTIFYICONDATA iconData = new UnmanagedMethods.NOTIFYICONDATA()
{
hWnd = _window.Handle,
uID = _uID,
uFlags = UnmanagedMethods.NIF.TIP | UnmanagedMethods.NIF.MESSAGE,
uCallbackMessage = (int)UnmanagedMethods.CustomWindowsMessage.WM_TRAYMOUSE,
hIcon = IntPtr.Zero,
szTip = ToolTipText
};
if (!remove && _icon != null && Visible)
{
iconData.uFlags |= UnmanagedMethods.NIF.ICON;
iconData.uFlags |= NIF.ICON;
iconData.hIcon = _icon.Handle;
iconData.szTip = ToolTipText;
if (!_iconAdded)
{
@@ -242,6 +250,80 @@ namespace System.Application.UI
}
}
/// <summary>
/// Displays a balloon tip with the specified title,
/// text, and icon in the taskbar for the specified time period.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
public void ShowBalloonTip(string title, string message, NIIF flags)
{
ShowBalloonTip(title, message, flags, IntPtr.Zero);
}
/// <summary>
/// Displays a balloon tip with the specified title,
/// text, and icon in the taskbar for the specified time period.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
public void ShowBalloonTip(string title, string message)
{
ShowBalloonTip(title, message, NIIF.NONE, IntPtr.Zero);
}
/// <summary>
/// Displays a balloon tip with the specified title,
/// text, and a custom icon in the taskbar for the specified time period.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
/// <param name="customIcon">A custom icon.</param>
/// <param name="largeIcon">True to allow large icons (Windows Vista and later).</param>
/// <exception cref="ArgumentNullException">If <paramref name="customIcon"/>
/// is a null reference.</exception>
public void ShowBalloonTip(string title, string message, Icon customIcon, bool largeIcon = false)
{
if (customIcon == null) throw new ArgumentNullException(nameof(customIcon));
var flags = NIIF.USER;
if (largeIcon)
{
// ReSharper disable once BitwiseOperatorOnEnumWithoutFlags
flags |= NIIF.LARGE_ICON;
}
ShowBalloonTip(title, message, flags, customIcon.Handle);
}
/// <summary>
/// Invokes <see cref="UnmanagedMethods.Shell_NotifyIcon(UnmanagedMethods.NIM, ref UnmanagedMethods.NOTIFYICONDATA)"/> in order to display
/// a given balloon ToolTip.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
/// <param name="flags">Indicates what icon to use.</param>
/// <param name="balloonIconHandle">A handle to a custom icon, if any, or
/// <see cref="IntPtr.Zero"/>.</param>
public void ShowBalloonTip(string title, string message, NIIF flags, IntPtr balloonIconHandle)
{
iconData.szInfo = message ?? string.Empty;
iconData.szInfoTitle = title ?? string.Empty;
iconData.uFlags = NIF.INFO | NIF.ICON;
//iconData.CustomBalloonIconHandle = balloonIconHandle;
iconData.dwInfoFlags = flags;
var result = UnmanagedMethods.Shell_NotifyIcon(UnmanagedMethods.NIM.MODIFY, iconData);
}
/// <summary>
/// Hides a balloon ToolTip, if any is displayed.
/// </summary>
public void HideBalloonTip()
{
// reset balloon by just setting the info to an empty string
iconData.szInfo = iconData.szInfoTitle = string.Empty;
UnmanagedMethods.Shell_NotifyIcon(UnmanagedMethods.NIM.MODIFY, iconData);
}
/// <summary>
/// Handles the NotifyIcon-specific window messages sent by the notification icon.
/// </summary>
@@ -57,9 +57,9 @@ namespace System.Application.Models.Settings
= GetProperty(defaultValue: false, autoSave: true);
/// <summary>
/// 检测到Steam启动时弹出消息通知
/// 检测到Steam登录时弹出消息通知
/// </summary>
public static SerializableProperty<bool> IsEnableSteamLaunchNotification { get; }
= GetProperty(defaultValue: false, autoSave: true);
= GetProperty(defaultValue: true, autoSave: true);
}
}
@@ -0,0 +1,19 @@
namespace System.Application.Services
{
#if NETFRAMEWORK
static
#endif
partial
#if NETFRAMEWORK
class
#else
interface
#endif
IDesktopPlatformService
{
#if NETFRAMEWORK
public
#endif
const string SystemBootRunArguments = "-clt c -silence";
}
}
@@ -8,7 +8,7 @@ using System.Windows;
namespace System.Application.Services
{
public interface IDesktopPlatformService : IPlatformService
public partial interface IDesktopPlatformService : IPlatformService
{
protected new const string TAG = "DesktopPlatformS";
@@ -126,8 +126,6 @@ namespace System.Application.Services
/// <returns></returns>
string? GetFileName(TextReaderProvider provider);
const string SystemBootRunArguments = "-clt c -silence";
/// <summary>
/// 设置开机自启动
/// </summary>
@@ -231,7 +229,6 @@ namespace System.Application.Services
void FixFluentWindowStyleOnWin7(IntPtr hWnd)
{
}
}
}
@@ -57,7 +57,8 @@ namespace System.Application.Services
TWindowViewModel? viewModel = null,
string title = "",
ResizeModeCompat resizeMode = ResizeModeCompat.NoResize,
bool isDialog = true)
bool isDialog = true,
bool isParent = true)
where TWindowViewModel : WindowViewModel, new();
@@ -105,10 +105,11 @@ namespace System.Application.Services
}
}
}
#endregion
#region 是否已经释放SteamClient
private bool _IsDisposedClient = true;
/// <summary>
/// 是否已经释放SteamClient
/// </summary>
public bool IsDisposedClient
{
get => _IsDisposedClient;
@@ -136,22 +137,13 @@ namespace System.Application.Services
}
}
}
public bool IsAutoAFKApps
{
get => GameLibrarySettings.IsAutoAFKApps.Value;
set
{
GameLibrarySettings.IsAutoAFKApps.Value = value;
this.RaisePropertyChanged(nameof(IsAutoAFKApps));
}
}
public void RunAFKApps()
{
if (GameLibrarySettings.AFKAppList.Value?.Count > 0)
{
foreach (var item in GameLibrarySettings.AFKAppList.Value)
{
RuningSteamApps.TryGetValue(item.Key, out var runState);
if (runState == null)
RuningSteamApps.TryAdd(item.Key, new SteamApp
@@ -177,7 +169,7 @@ namespace System.Application.Services
if (!SteamTool.IsRunningSteamProcess && SteamSettings.IsAutoRunSteam.Value)
SteamTool.StartSteam(SteamSettings.SteamStratParameter.Value);
var t = new Task(async () =>
Task.Factory.StartNew(async () =>
{
Thread.CurrentThread.IsBackground = true;
try
@@ -206,10 +198,19 @@ namespace System.Application.Services
CurrentSteamUser.IPCountry = ApiService.GetIPCountry();
IsSteamChinaLauncher = ApiService.IsSteamChinaLauncher();
if (IsAutoAFKApps)
RunAFKApps();
#region 初始化需要steam启动才能使用的功能
if (SteamSettings.IsEnableSteamLaunchNotification.Value)
{
INotificationService.Instance.Notify($"{AppResources.Steam_CheckStarted}{(IsSteamChinaLauncher ? AppResources.Steam_SteamChina : AppResources.Steam_SteamWorld)}{Environment.NewLine}{AppResources.Steam_CurrentUser}{CurrentSteamUser.SteamNickName}{Environment.NewLine}{AppResources.Steam_CurrentIPCountry}{CurrentSteamUser.IPCountry}", NotificationType.Announcement);
}
if (GameLibrarySettings.IsAutoAFKApps.Value)
{
RunAFKApps();
}
//仅在有游戏数据情况下加载登录用户的游戏
if (SteamApps.Items.Any())
{
LoadGames(ApiService.OwnsApps(await ISteamService.Instance.GetAppInfos()));
@@ -234,13 +235,10 @@ namespace System.Application.Services
}
catch (Exception ex)
{
Log.Error(nameof(SteamConnectService), ex, "Task LongRunning");
Log.Error(nameof(SteamConnectService), ex, "SteamConnect Task LongRunning");
ToastService.Current.Notify(ex.Message);
}
}, TaskCreationOptions.LongRunning);
//t.Forget();
t.Start();
}, TaskCreationOptions.LongRunning).ConfigureAwait(false);
}
public bool Initialize(int appid)
@@ -256,7 +254,7 @@ namespace System.Application.Services
{
SteamApps.Clear();
if (apps.Any_Nullable())
SteamApps.AddOrUpdate(apps);
SteamApps.AddOrUpdate(apps!);
}
public async void InitializeGameList()
@@ -267,29 +265,10 @@ namespace System.Application.Services
IsLoadingGameList = false;
}
// public void UpdateGamesImage()
// {
//#if DEBUG
// if (BuildConfig.IsDebuggerAttached)
// {
// return;
// }
//#endif
// //if (SteamApps.Items.Any())
// //{
// // Parallel.ForEach(SteamApps.Items, new ParallelOptions
// // {
// // MaxDegreeOfParallelism = (Environment.ProcessorCount / 2) + 1
// // }, async app =>
// // {
// // await ISteamService.Instance.LoadAppImageAsync(app);
// // //app.LibraryLogoStream = await IHttpService.Instance.GetImageAsync(app.LibraryLogoUrl, ImageChannelType.SteamGames);
// // //app.LibraryHeaderStream = await IHttpService.Instance.GetImageAsync(app.LibraryHeaderUrl, ImageChannelType.SteamGames);
// // //app.LibraryNameStream = await IHttpService.Instance.GetImageAsync(app.LibraryNameUrl, ImageChannelType.SteamGames);
// // //app.HeaderLogoStream = await IHttpService.Instance.GetImageAsync(app.HeaderLogoUrl, ImageChannelType.SteamGames);
// // });
// //}
// }
public async void InitializeDownloadGameList()
{
}
private bool _IsRefreshing;
public /*async*/ void RefreshGamesList()
@@ -299,7 +278,7 @@ namespace System.Application.Services
_IsRefreshing = true;
if (SteamTool.IsRunningSteamProcess)
{
var t = new Task(() =>
Task.Factory.StartNew(() =>
{
Thread.CurrentThread.IsBackground = true;
try
@@ -331,8 +310,7 @@ namespace System.Application.Services
Log.Error(nameof(SteamConnectService), ex, "Task RefreshGamesList");
ToastService.Current.Notify(ex.Message);
}
}, TaskCreationOptions.LongRunning);
t.Start();
}, TaskCreationOptions.DenyChildAttach | TaskCreationOptions.PreferFairness).Forget().ConfigureAwait(false);
}
else
{
+15
View File
@@ -53,11 +53,26 @@ namespace System.Application.UI
/// </summary>
event EventHandler<EventArgs> RightClick;
public interface IUIFrameworkHelper
{
Stream OpenAsset(Uri uri);
void ForEachMenuItems(TContextMenu menu, Action<(object menuItem, string header, Action activated)> action);
}
/// <summary>
/// Displays a balloon tip with the specified title,
/// text, and icon in the taskbar for the specified time period.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
/// <param name="flags">A symbol that indicates the severity.</param>
void ShowBalloonTip(string title, string message);
/// <summary>
/// Hides a balloon ToolTip, if any is displayed.
/// </summary>
void HideBalloonTip();
}
}
+54
View File
@@ -3222,6 +3222,15 @@ namespace System.Application.UI.Resx {
}
}
/// <summary>
/// 查找类似 当Steam客户端登录时弹出通知 的本地化字符串。
/// </summary>
public static string Settings_Steam_CheckSteamRuningNotification {
get {
return ResourceManager.GetString("Settings_Steam_CheckSteamRuningNotification", resourceCulture);
}
}
/// <summary>
/// 查找类似 Steam启动时不检查更新 的本地化字符串。
/// </summary>
@@ -3339,6 +3348,33 @@ namespace System.Application.UI.Resx {
}
}
/// <summary>
/// 查找类似 检测到启动: 的本地化字符串。
/// </summary>
public static string Steam_CheckStarted {
get {
return ResourceManager.GetString("Steam_CheckStarted", resourceCulture);
}
}
/// <summary>
/// 查找类似 Steam客户端登录区域: 的本地化字符串。
/// </summary>
public static string Steam_CurrentIPCountry {
get {
return ResourceManager.GetString("Steam_CurrentIPCountry", resourceCulture);
}
}
/// <summary>
/// 查找类似 Steam登录用户: 的本地化字符串。
/// </summary>
public static string Steam_CurrentUser {
get {
return ResourceManager.GetString("Steam_CurrentUser", resourceCulture);
}
}
/// <summary>
/// 查找类似 输入图中验证码 的本地化字符串。
/// </summary>
@@ -3357,6 +3393,24 @@ namespace System.Application.UI.Resx {
}
}
/// <summary>
/// 查找类似 Steam国服 的本地化字符串。
/// </summary>
public static string Steam_SteamChina {
get {
return ResourceManager.GetString("Steam_SteamChina", resourceCulture);
}
}
/// <summary>
/// 查找类似 Steam国际服 的本地化字符串。
/// </summary>
public static string Steam_SteamWorld {
get {
return ResourceManager.GetString("Steam_SteamWorld", resourceCulture);
}
}
/// <summary>
/// 查找类似 Steam用户名 的本地化字符串。
/// </summary>
@@ -1519,4 +1519,22 @@
<data name="SetBootAutoStartTrueFail_" xml:space="preserve">
<value>启用开机自启动失败,原因: {0}</value>
</data>
<data name="Settings_Steam_CheckSteamRuningNotification" xml:space="preserve">
<value>当Steam客户端登录时弹出通知</value>
</data>
<data name="Steam_CheckStarted" xml:space="preserve">
<value>检测到启动:</value>
</data>
<data name="Steam_CurrentIPCountry" xml:space="preserve">
<value>Steam客户端登录区域:</value>
</data>
<data name="Steam_CurrentUser" xml:space="preserve">
<value>Steam登录用户:</value>
</data>
<data name="Steam_SteamChina" xml:space="preserve">
<value>Steam国服</value>
</data>
<data name="Steam_SteamWorld" xml:space="preserve">
<value>Steam国际服</value>
</data>
</root>
@@ -277,7 +277,7 @@ namespace System.Application.UI.ViewModels
// FileShareTest();
// }
//#endif
INotificationService.Instance.Notify("测试Test🎆🎇→→", NotificationType.Announcement);
ShowDialogButton_Click1();
}
@@ -119,7 +119,7 @@ namespace System.Application.UI.ViewModels
EnableAFKAutoUpdateCommand = ReactiveCommand.Create(() =>
{
AFKAutoUpdate?.CheckmarkChange(SteamConnectService.Current.IsAutoAFKApps = !SteamConnectService.Current.IsAutoAFKApps);
AFKAutoUpdate?.CheckmarkChange(GameLibrarySettings.IsAutoAFKApps.Value = !GameLibrarySettings.IsAutoAFKApps.Value);
});
MenuItems = new ObservableCollection<MenuItemViewModel>()
@@ -135,7 +135,7 @@ namespace System.Application.UI.ViewModels
IconKey ="ClockArrowDownloadDrawing", Command = SteamShutdownCommand },
};
AFKAutoUpdate?.CheckmarkChange(SteamConnectService.Current.IsAutoAFKApps);
AFKAutoUpdate?.CheckmarkChange(GameLibrarySettings.IsAutoAFKApps.Value);
}
public ReactiveCommand<Unit, Unit> EnableAFKAutoUpdateCommand { get; }
@@ -1,7 +1,11 @@
using DynamicData;
using Newtonsoft.Json.Linq;
using ReactiveUI;
using System.Application.Models;
using System.Application.UI.Resx;
using System.Collections.ObjectModel;
using System.Properties;
using System.Reactive.Linq;
namespace System.Application.UI.ViewModels
{
@@ -10,8 +14,21 @@ namespace System.Application.UI.ViewModels
public SteamShutdownWindowViewModel() : base()
{
Title = ThisAssembly.AssemblyTrademark + " | " + AppResources.GameList_SteamShutdown;
_DownloadingAppSourceList = new SourceList<SteamApp>();
_DownloadingAppSourceList
.Connect()
.ObserveOn(RxApp.MainThreadScheduler)
//.Sort(SortExpressionComparer<SteamApp>.Descending(x => x.))
.Bind(out _DownloadingApps)
.Subscribe();
}
private readonly ReadOnlyObservableCollection<SteamApp>? _DownloadingApps;
public ReadOnlyObservableCollection<SteamApp>? DownloadingApps => _DownloadingApps;
private readonly SourceList<SteamApp> _DownloadingAppSourceList;
}
}
@@ -6,13 +6,16 @@ using System.Application.Models;
using System.Windows;
using XEPlatform = Xamarin.Essentials.Platform;
using static System.Application.UI.Resx.AppResources;
using static System.Application.Services.IAppUpdateService;
namespace System.Application.Services.Implementation
{
internal sealed partial class MobileAppUpdateServiceImpl : AppUpdateServiceImpl
{
public MobileAppUpdateServiceImpl(IToast toast, ICloudServiceClient client, IOptions<AppSettings> options) : base(toast, client, options)
readonly INotificationService notification;
public MobileAppUpdateServiceImpl(INotificationService notification, IToast toast, ICloudServiceClient client, IOptions<AppSettings> options) : base(toast, client, options)
{
this.notification = notification;
}
protected override Version OSVersion =>
@@ -46,5 +49,26 @@ namespace System.Application.Services.Implementation
throw new NotImplementedException();
#endif
}
IProgress<float>? progress;
protected override void OnReport(float value, string str)
{
base.OnReport(value, str);
if (value == 0)
{
progress?.Report(MaxProgressValue);
progress = notification.NotifyDownload(() => ProgressString,
NotificationType.NewVersionDownloadProgress);
}
else if (value == MaxProgressValue)
{
progress?.Report(MaxProgressValue);
progress = null;
}
else
{
progress?.Report(value);
}
}
}
}
@@ -13,6 +13,8 @@ using XEPlatform = Xamarin.Essentials.Platform;
using XEVersionTracking = Xamarin.Essentials.VersionTracking;
using System.Application.Models.Settings;
using AndroidX.AppCompat.App;
using System.Application.Services;
using System.Application.Services.Implementation;
#if DEBUG
using Square.LeakCanary;
#endif
@@ -79,7 +81,16 @@ namespace System.Application.UI
Startup.Init(level);
if (IsMainProcess)
{
if (INotificationService.Instance is PlatformNotificationServiceImpl notification)
{
notification.InitNotificationChannels(this);
}
XEVersionTracking.Track();
if (XEVersionTracking.IsFirstLaunchForCurrentVersion)
{
// 当前版本第一次启动时,清除存放升级包缓存文件夹的目录
IAppUpdateService.ClearAllPackCacheDir();
}
ImageLoader.Init(this);
UISettings.Theme.Subscribe(x =>
{
@@ -1,4 +1,4 @@
using System.Application.Properties;
using System.Application.Properties;
using System.Application.Services;
namespace System.Application
+7 -7
View File
@@ -23,16 +23,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="QRCoder" Version="1.4.1"/>
<PackageReference Include="QRCoder" Version="1.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\references\ArchiSteamFarm\ArchiSteamFarm.Library\ArchiSteamFarm.Library.csproj"/>
<ProjectReference Include="..\..\references\Titanium-Web-Proxy\src\Titanium.Web.Proxy\Titanium.Web.Proxy.csproj"/>
<ProjectReference Include="..\Repositories.sqlite-net-pcl\Repositories.sqlite-net-pcl.csproj"/>
<ProjectReference Include="..\ST.Services.CloudService\ST.Services.CloudService.csproj"/>
<ProjectReference Include="..\Common.ClientLib\Common.ClientLib.csproj"/>
<ProjectReference Include="..\ST\ST.csproj"/>
<ProjectReference Include="..\..\references\ArchiSteamFarm\ArchiSteamFarm.Library\ArchiSteamFarm.Library.csproj" />
<ProjectReference Include="..\..\references\Titanium-Web-Proxy\src\Titanium.Web.Proxy\Titanium.Web.Proxy.csproj" />
<ProjectReference Include="..\Repositories.sqlite-net-pcl\Repositories.sqlite-net-pcl.csproj" />
<ProjectReference Include="..\ST.Services.CloudService\ST.Services.CloudService.csproj" />
<ProjectReference Include="..\Common.ClientLib\Common.ClientLib.csproj" />
<ProjectReference Include="..\ST\ST.csproj" />
</ItemGroup>
<ItemGroup>
@@ -1,4 +1,6 @@
using System.Application.Models;
using System.IO;
using System.Security.Cryptography;
using System.Threading.Tasks;
using System.Windows.Input;
@@ -13,6 +15,11 @@ namespace System.Application.Services
const float MaxProgressValue = 100f;
/// <summary>
/// 升级包存放文件夹名称
/// </summary>
const string PackDirName = "UpgradePackages";
/// <summary>
/// 进度值
/// </summary>
@@ -57,6 +64,67 @@ namespace System.Application.Services
Task CheckUpdateAsync(bool force = false, bool showIsExistUpdateFalse = true);
ICommand StartUpdateCommand { get; }
/// <summary>
/// 根据新版本信息获取升级包路径名
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
protected static string GetPackName(AppVersionDTO m, bool isDirOrFile) => $"{m.Version}@{Hashs.String.Crc32(m.Id.ToByteArray())}{(isDirOrFile ? "" : $"{FileEx.TAR_GZ}")}";
/// <summary>
/// 获取存放升级包缓存文件夹的目录
/// </summary>
/// <param name="onNotExistsCreateDirectory">当目录不存在时是否创建目录</param>
/// <param name="exists">目录是否存在</param>
/// <returns></returns>
protected static string GetPackCacheDirPath(bool onNotExistsCreateDirectory, out bool exists)
{
var dirPath = Path.Combine(IOPath.CacheDirectory, PackDirName);
exists = Directory.Exists(dirPath);
if (!exists && onNotExistsCreateDirectory)
{
Directory.CreateDirectory(dirPath);
}
return dirPath;
}
/// <summary>
/// 获取存放升级包缓存文件夹的目录
/// </summary>
/// <param name="clear">是否需要清理之前的缓存</param>
/// <returns></returns>
protected static string GetPackCacheDirPath(bool clear)
{
var dirPath = GetPackCacheDirPath(true, out var exists);
if (exists && clear)
{
var files = Directory.GetFiles(dirPath, "*" + FileEx.DownloadCache);
foreach (var item in files)
{
IOPath.FileTryDelete(item);
}
}
return dirPath;
}
/// <summary>
/// 清理存放升级包缓存文件夹的目录
/// </summary>
/// <returns></returns>
static void ClearAllPackCacheDir()
{
var dirPath = GetPackCacheDirPath(true, out var exists);
if (exists)
{
var files = Directory.GetFiles(dirPath);
foreach (var item in files)
{
IOPath.FileTryDelete(item);
}
}
}
}
#if DEBUG
@@ -147,43 +147,6 @@ namespace System.Application.Services.Implementation
isCheckUpdateing = false;
}
/// <summary>
/// 升级包存放文件夹名称
/// </summary>
const string PackDirName = "UpgradePackages";
public const string FileExDownloadCache = ".download_cache";
/// <summary>
/// 根据新版本信息获取升级包路径名
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
static string GetPackName(AppVersionDTO m, bool isDirOrFile) => $"{m.Version}@{Hashs.String.Crc32(m.Id.ToByteArray())}{(isDirOrFile ? "" : $"{FileEx.TAR_GZ}")}";
/// <summary>
/// 获取存放升级包缓存文件夹的目录
/// </summary>
/// <param name="clear">是否需要清理之前的缓存</param>
/// <returns></returns>
static string GetPackCacheDirPath(bool clear)
{
var dirPath = Path.Combine(IOPath.CacheDirectory, PackDirName);
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
else if (clear)
{
var files = Directory.GetFiles(dirPath, "*" + FileExDownloadCache);
foreach (var item in files)
{
IOPath.FileTryDelete(item);
}
}
return dirPath;
}
static bool isDownloading;
/// <summary>
@@ -211,7 +174,7 @@ namespace System.Application.Services.Implementation
protected void OnReportCalcHashing(float value) => OnReport(value, SR.CalcHashing_.Format(MathF.Round(value, 2)));
protected void OnReportDecompressing(float value) => OnReport(value, SR.Decompressing_.Format(MathF.Round(value, 2)));
protected void OnReport(float value = 0f) => OnReport(value, string.Empty);
protected void OnReport(float value, string str)
protected virtual void OnReport(float value, string str)
{
ProgressValue = value;
ProgressString = str;
@@ -362,7 +325,7 @@ namespace System.Application.Services.Implementation
#endregion
#region 下载文件,并加入 hashFiles 中
var cacheFileDownloadPath = downloadPath + FileExDownloadCache;
var cacheFileDownloadPath = downloadPath + FileEx.DownloadCache;
var requestUri = GetSingleFileUrl(item.FileId!);
var rsp = await client.Download(
@@ -505,7 +468,7 @@ namespace System.Application.Services.Implementation
requestUri = GetSingleFileUrl(download.FileIdOrUrl!);
}
var cacheFilePath = packFilePath + FileExDownloadCache;
var cacheFilePath = packFilePath + FileEx.DownloadCache;
OnReportDownloading(0f);
var rsp = await client.Download(
isAnonymous: true,
@@ -362,7 +362,7 @@ namespace System.Application.Services.Implementation
var jspath = await DI.Get<IScriptManagerService>().DownloadScript(basicsInfo.Content.UpdateLink);
if (jspath.state)
{
var build = await DI.Get<IScriptManagerService>().AddScriptAsync(jspath.path,item, build: false, order: 1, deleteFile: true, pid: basicsInfo.Content.Id, ignoreCache: true);
var build = await DI.Get<IScriptManagerService>().AddScriptAsync(jspath.path, item, build: false, order: 1, deleteFile: true, pid: basicsInfo.Content.Id, ignoreCache: true);
if (build.state && build.model?.Content != null)
item.Content = build.model!.Content;
}
@@ -394,7 +394,7 @@ namespace System.Application.Services.Implementation
try
{
var md5 = Hashs.String.MD5(scriptInfo);
var cachePath = Path.Combine(IOPath.CacheDirectory, TAG, $"{md5}{AppUpdateServiceImpl.FileExDownloadCache}");
var cachePath = Path.Combine(IOPath.CacheDirectory, TAG, md5 + FileEx.DownloadCache);
var fileInfo = new FileInfo(cachePath);
if (!fileInfo.Directory.Exists)
{
+2 -2
View File
@@ -1,4 +1,4 @@
namespace System.Application
namespace System.Application
{
/// <summary>
/// 通知类型
@@ -17,7 +17,7 @@
/// </item>
/// </list>
/// <para>添加新的枚举常量注意事项:</para>
/// <para>(客户端)如果要显示在设备的通知栏上,则需要在<see cref="NotificationType_Channel_EnumExtensions.GetChannel(NotificationType)"/>中添加对应渠道</para>
/// <para>(客户端)如果要显示在设备的通知栏上,则需要在 src\ST.Client\Extensions\NotificationType_Channel_EnumExtensions.cs 中添加或指定已有渠道</para>
/// </summary>
public enum NotificationType
{