Skip to content

Commit

Permalink
Finish task and publish 1.2.210.0 version
Browse files Browse the repository at this point in the history
1.Finish task and publish 1.2.210.0 version
2.Add shortcut action support: Create desktop shortcuts, pin to Start, pin to taskbar (still exploring)
3.Re-implemented the helper class for mouse pointer modification: CursorHelper
  • Loading branch information
Gaoyifei1011 committed Feb 10, 2023
1 parent cc07248 commit 6dc4a1a
Show file tree
Hide file tree
Showing 50 changed files with 1,434 additions and 86 deletions.
1 change: 1 addition & 0 deletions GetStoreApp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<ResourceDictionary Source="ms-appx:///Styles/Pivot.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/TeachingTip.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/TextBlock.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/ToggleSwitch.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/WindowChrome.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand Down
9 changes: 9 additions & 0 deletions GetStoreApp/Extensions/DataType/Enums/QuickOperationType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace GetStoreApp.Extensions.DataType.Enums
{
public enum QuickOperationType
{
DesktopShortcut = 0,
StartScreen = 1,
Taskbar = 2,
}
}
16 changes: 12 additions & 4 deletions GetStoreApp/GetStoreApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<EnableMsixTooling>false</EnableMsixTooling>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<FileAlignment>512</FileAlignment>
<FileVersion>1.1.204.0</FileVersion>
<FileVersion>1.2.210.0</FileVersion>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<IncludeSymbols>False</IncludeSymbols>
Expand All @@ -28,7 +28,7 @@
<PublishProtocol>FileSystem</PublishProtocol>
<PublishReadyToRun>True</PublishReadyToRun>
<!--调试时需要设置该选项为false-->
<PublishSingleFile>false</PublishSingleFile>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<RootNamespace>GetStoreApp</RootNamespace>
Expand All @@ -40,7 +40,7 @@
<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<TrimMode>partial</TrimMode>
<Version>1.1.204.0</Version>
<Version>1.2.210.0</Version>
<UseWindowsForms>False</UseWindowsForms>
<UseWinUI>true</UseWinUI>
<UseWPF>False</UseWPF>
Expand Down Expand Up @@ -176,6 +176,7 @@
<None Remove="Styles\Pivot.xaml" />
<None Remove="Styles\TeachingTip.xaml" />
<None Remove="Styles\TextBlock.xaml" />
<None Remove="Styles\ToggleSwitch.xaml" />
<None Remove="Styles\WindowChrome.xaml" />

<None Remove="UI\Controls\About\HeaderControl.xaml" />
Expand Down Expand Up @@ -248,6 +249,7 @@
<None Remove="UI\Notifications\HistoryCopyNotification.xaml" />
<None Remove="UI\Notifications\LanguageChangeNotification.xaml" />
<None Remove="UI\Notifications\NetWorkErrorNotification.xaml" />
<None Remove="UI\Notifications\QuickOperationNotification.xaml" />
<None Remove="UI\Notifications\ResultContentCopyNotification.xaml" />
<None Remove="UI\Notifications\ResultIDCopyNotification.xaml" />
<None Remove="UI\Notifications\ResultLinkCopyNotification.xaml" />
Expand Down Expand Up @@ -333,6 +335,9 @@
<Page Update="Styles\TextBlock.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Styles\ToggleSwitch.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Styles\WindowChrome.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down Expand Up @@ -516,6 +521,9 @@
<Page Update="UI\Notifications\NetWorkErrorNotification.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="UI\Notifications\QuickOperationNotification.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="UI\Notifications\ResultContentCopyNotification.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down Expand Up @@ -578,7 +586,7 @@

<TrimmableAssembly Include="Microsoft.Windows.Widgets.Projection" />
</ItemGroup>

<ItemGroup>
<Page Update="Views\ModalDialogs\ExitPromptControl.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down
127 changes: 114 additions & 13 deletions GetStoreApp/Helpers/Controls/Extensions/CursorHelper.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,140 @@
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
using System;
using System.Linq.Expressions;
using System.Reflection;

namespace GetStoreApp.Helpers.Controls.Extensions
{
/// <summary>
/// 附加属性:设置指针位于控件上时显示的游标
/// </summary>
public class CursorHelper
public static class CursorHelper
{
public static InputSystemCursorShape GetCursor(DependencyObject obj)
private static object locker = new object();
private static Action<UIElement, InputCursor> setCursorFunc;
private static Func<UIElement, InputCursor> getCursorFunc;

public static InputSystemCursorShape? GetCursor(DependencyObject obj)
{
return (InputSystemCursorShape)obj.GetValue(CursorProperty);
if (obj.GetValue(CursorOverrideStateProperty) is 0)
{
EnsureCursorFunctions();
var cursor = GetFrameworkElementCursor((FrameworkElement)obj);

obj.SetValue(CursorOverrideStateProperty, 1);

var shape = cursor switch
{
InputSystemCursor inputSystemCursor => (InputSystemCursorShape?)inputSystemCursor.CursorShape,
_ => null
};

SetCursor(obj, shape);

return shape;
}

return (InputSystemCursorShape?)obj.GetValue(CursorProperty);
}

public static void SetCursor(DependencyObject obj, InputSystemCursorShape value)
public static void SetCursor(DependencyObject obj, InputSystemCursorShape? value)
{
obj.SetValue(CursorProperty, value);
}

// Using a DependencyProperty as the backing store for CursorProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CursorProperty =
DependencyProperty.RegisterAttached("Cursor", typeof(InputSystemCursorShape), typeof(CursorHelper), new PropertyMetadata(InputSystemCursorShape.Arrow, OnPropertyChanged));
DependencyProperty.RegisterAttached("Cursor", typeof(InputSystemCursorShape?), typeof(CursorHelper), new PropertyMetadata(InputSystemCursorShape.Arrow, (s, a) =>
{
if (!Equals(a.NewValue, a.OldValue) && s is FrameworkElement sender)
{
EnsureCursorFunctions();
if (sender.GetValue(CursorOverrideStateProperty) is int state)
{
if (state == 0 || state == 1)
{
sender.SetValue(CursorOverrideStateProperty, 2);
}
if (state == 0 || state == 2)
{
var cursor = a.NewValue switch
{
InputSystemCursorShape shape => InputSystemCursor.Create(shape),
_ => null
};
SetFrameworkElementCursor(sender, cursor);
}
}
}
}));

public static readonly DependencyProperty CursorOverrideStateProperty =
DependencyProperty.RegisterAttached("CursorOverrideState", typeof(int), typeof(CursorHelper), new PropertyMetadata(0));

private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
private static void EnsureCursorFunctions()
{
FrameworkElement element = d as FrameworkElement;
if (element is not null)
if (getCursorFunc == null || setCursorFunc == null)
{
element.Loaded += (sender, e) =>
lock (locker)
{
FrameworkElement element = sender as FrameworkElement;
typeof(FrameworkElement).GetProperty("ProtectedCursor", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(element, InputSystemCursor.Create((InputSystemCursorShape)args.NewValue));
};
if (getCursorFunc == null || setCursorFunc == null)
{
var uiElementType = typeof(UIElement);
var inputCursorType = typeof(InputCursor);

var protectedCursorProp = uiElementType.GetProperty("ProtectedCursor", BindingFlags.Instance | BindingFlags.NonPublic);

var p1 = Expression.Parameter(uiElementType, "element");

if (getCursorFunc == null)
{
var body = Expression.Property(p1, protectedCursorProp);

getCursorFunc = Expression.Lambda<Func<UIElement, InputCursor>>(body, p1)
.Compile();
}

if (setCursorFunc == null)
{
var p2 = Expression.Parameter(inputCursorType, "cursor");

var body = Expression.Assign(Expression.Property(p1, protectedCursorProp), p2);

setCursorFunc = Expression.Lambda<Action<UIElement, InputCursor>>(body, p1, p2)
.Compile();
}
}
}
}
}

private static void SetFrameworkElementCursor(FrameworkElement element, InputCursor cursor)
{
EnsureCursorFunctions();

if (element.IsLoaded)
{
setCursorFunc(element, cursor);
}
else
{
element.Loaded += OnLoaded;
}

void OnLoaded(object sender, RoutedEventArgs e)
{
element.Loaded -= OnLoaded;
setCursorFunc(element, cursor);
}
}

private static InputCursor GetFrameworkElementCursor(FrameworkElement element)
{
EnsureCursorFunctions();

return getCursorFunc(element);
}
}
}
4 changes: 2 additions & 2 deletions GetStoreApp/Helpers/Root/IOHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public static async Task<bool> CleanFolderAsync(StorageFolder folder)
// 删除当前文件夹下所有文件
foreach (StorageFile subFile in await folder.GetFilesAsync())
{
await subFile.DeleteAsync();
await subFile.DeleteAsync(StorageDeleteOption.PermanentDelete);
}

// 删除当前文件夹下所有子文件夹(递归)
foreach (StorageFolder subFolder in await folder.GetFoldersAsync())
{
await subFolder.DeleteAsync();
await subFolder.DeleteAsync(StorageDeleteOption.PermanentDelete);
}

return true;
Expand Down
5 changes: 4 additions & 1 deletion GetStoreApp/Helpers/Root/ResourceDictionaryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public static class ResourceDictionaryHelper

public static ResourceDictionary TextBlockResourceDict { get; private set; }

public static ResourceDictionary ToggleSwitchResourceDict { get; private set; }

public static ResourceDictionary WindowChromeDict { get; private set; }

/// <summary>
Expand All @@ -69,7 +71,8 @@ public static async Task InitializeResourceDictionaryAsync()
PivotResourceDict = Program.ApplicationRoot.Resources.MergedDictionaries[17];
TeachingTipResourceDict = Program.ApplicationRoot.Resources.MergedDictionaries[18];
TextBlockResourceDict = Program.ApplicationRoot.Resources.MergedDictionaries[19];
WindowChromeDict = Program.ApplicationRoot.Resources.MergedDictionaries[20];
ToggleSwitchResourceDict = Program.ApplicationRoot.Resources.MergedDictionaries[20];
WindowChromeDict = Program.ApplicationRoot.Resources.MergedDictionaries[21];

await Task.CompletedTask;
}
Expand Down
1 change: 0 additions & 1 deletion GetStoreApp/Models/Controls/Settings/Common/RegionModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using GetStoreApp.WindowsAPI.PInvoke.Kernel32;
using System.Text;

namespace GetStoreApp.Models.Controls.Settings.Common
{
Expand Down
18 changes: 18 additions & 0 deletions GetStoreApp/Strings/en-us/About.resw
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@
<data name="ConsoleLaunch" xml:space="preserve">
<value>Console program parameters</value>
</data>
<data name="CreateDesktopShortcut" xml:space="preserve">
<value>Create desktop shortcut</value>
</data>
<data name="CreateDesktopShortcutToolTip" xml:space="preserve">
<value>Create a shortcut to this app on your desktop</value>
</data>
<data name="DesktopApps" xml:space="preserve">
<value>Traditional desktop apps</value>
</data>
Expand Down Expand Up @@ -261,6 +267,18 @@
<data name="PaidAppsDescription" xml:space="preserve">
<value>Microsoft has restricted the operation of paid apps in Windows systems, and paid apps that have not been purchased cannot function properly after installation through offline installation packages. If you have a paid app that you've already purchased, download it from the Microsoft Store.</value>
</data>
<data name="PinToStartScreen" xml:space="preserve">
<value>Pin to the Start screen</value>
</data>
<data name="PinToStartScreenToolTip" xml:space="preserve">
<value>Pin the app to Start screen</value>
</data>
<data name="PinToTaskbar" xml:space="preserve">
<value>Pin to taskbar</value>
</data>
<data name="PinToTaskbarToolTip" xml:space="preserve">
<value>Pin the app to the taskbar</value>
</data>
<data name="Precaution" xml:space="preserve">
<value>Precautions</value>
</data>
Expand Down
18 changes: 18 additions & 0 deletions GetStoreApp/Strings/en-us/Notification.resw
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
<data name="CheckNetWorkConnection" xml:space="preserve">
<value>Check the network connection</value>
</data>
<data name="DesktopShortcutSuccessfully" xml:space="preserve">
<value>The desktop shortcut for the app was created successfully</value>
</data>
<data name="DesktopShortFailed" xml:space="preserve">
<value>The app's desktop shortcut failed to create, please create it manually</value>
</data>
<data name="DownloadCompleted" xml:space="preserve">
<value>&lt;toast launch="action=OpenApp"&gt;
&lt;visual&gt;
Expand Down Expand Up @@ -251,6 +257,18 @@
<data name="ResultLinkSelectedCopySuccessfully" xml:space="preserve">
<value>{0} download links has been successfully copied to the clipboard</value>
</data>
<data name="StartScreenFailed" xml:space="preserve">
<value>App pinning to Start screen failed, please pin it manually</value>
</data>
<data name="StartScreenSuccessfully" xml:space="preserve">
<value>You successfully pinned the app to the Start screen</value>
</data>
<data name="TaskbarFailed" xml:space="preserve">
<value>App pinning to taskbar failed, please pin manually</value>
</data>
<data name="TaskbarSuccessfully" xml:space="preserve">
<value>The app was successfully pinned to the taskbar</value>
</data>
<data name="WebCacheCleanChangeFailed" xml:space="preserve">
<value>Web page cache cleanup failed</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions GetStoreApp/Strings/en-us/Settings.resw
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,7 @@
<data name="WindowsColorSettings" xml:space="preserve">
<value>Windows color settings</value>
</data>
<data name="WindowsNotificationSettings" xml:space="preserve">
<value>Windows notification settings</value>
</data>
</root>
18 changes: 18 additions & 0 deletions GetStoreApp/Strings/zh-hans/About.resw
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@
<data name="ConsoleLaunch" xml:space="preserve">
<value>控制台程序参数</value>
</data>
<data name="CreateDesktopShortcut" xml:space="preserve">
<value>创建快捷方式</value>
</data>
<data name="CreateDesktopShortcutToolTip" xml:space="preserve">
<value>在电脑桌面创建此应用的快捷方式</value>
</data>
<data name="DesktopApps" xml:space="preserve">
<value>传统桌面应用不能获取</value>
</data>
Expand Down Expand Up @@ -258,6 +264,18 @@
<data name="PaidAppsDescription" xml:space="preserve">
<value>微软在 Windows 系统中对付费应用的运行进行了限制,没有购买的付费应用是不能通过离线安装包安装后正常运行的。如果您有已经购买的付费应用,请从 Microsoft Store 中下载。</value>
</data>
<data name="PinToStartScreen" xml:space="preserve">
<value>固定到”开始“屏幕</value>
</data>
<data name="PinToStartScreenToolTip" xml:space="preserve">
<value>将应用固定到“开始”屏幕</value>
</data>
<data name="PinToTaskbar" xml:space="preserve">
<value>固定到任务栏</value>
</data>
<data name="PinToTaskbarToolTip" xml:space="preserve">
<value>将应用固定到任务栏</value>
</data>
<data name="Precaution" xml:space="preserve">
<value>注意事项</value>
</data>
Expand Down
Loading

0 comments on commit 6dc4a1a

Please sign in to comment.