Skip to content

Commit

Permalink
Finish task and publish 1.4.120.0 version
Browse files Browse the repository at this point in the history
1.Finish task and publish 1.4.120.0 version
2.Use commandbarflyout to replace taskbar tray icon menuflyout
  • Loading branch information
Gaoyifei1011 committed Mar 20, 2023
1 parent fd9ec2f commit c4d7a9f
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 108 deletions.
4 changes: 2 additions & 2 deletions GetStoreApp/GetStoreApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<EnableMsixTooling>false</EnableMsixTooling>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<FileAlignment>512</FileAlignment>
<FileVersion>1.3.319.0</FileVersion>
<FileVersion>1.4.320.0</FileVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
Expand Down Expand Up @@ -43,7 +43,7 @@
<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<TrimMode>partial</TrimMode>
<Version>1.3.319.0</Version>
<Version>1.4.320.0</Version>
<UseWindowsForms>False</UseWindowsForms>
<UseWinUI>true</UseWinUI>
<UseWPF>False</UseWPF>
Expand Down
4 changes: 2 additions & 2 deletions GetStoreApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.3.319.0")]
[assembly: AssemblyFileVersion("1.3.319.0")]
[assembly: AssemblyVersion("1.4.320.0")]
[assembly: AssemblyFileVersion("1.4.320.0")]
2 changes: 1 addition & 1 deletion GetStoreApp/UI/Controls/About/ThanksControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Padding="0"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
DesiredWidth="120"
DesiredWidth="280"
ItemContainerStyle="{StaticResource GridViewItemStyle}"
ItemsSource="{x:Bind ViewModel.ThanksDict}"
OneRowModeEnabled="False"
Expand Down
2 changes: 0 additions & 2 deletions GetStoreAppHelper/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<!-- 资源字典顺序发生变化时,需要修改 ResourceDictionaryHelper 静态类的资源字典顺序 -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Mile.Xaml.Styles.SunValley.xbf" />

<ResourceDictionary Source="ms-appx:///Styles/HelperFontIcon.xaml" />
<ResourceDictionary Source="ms-appx:///Styles/HelperMenuFlyout.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
2 changes: 0 additions & 2 deletions GetStoreAppHelper/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ private void AppTimerElapsed(object sender, ElapsedEventArgs args)
/// </summary>
public void Run()
{
ResourceDictionaryHelper.InitializeResourceDictionaryAsync().Wait();

MainWindow = new MileWindow();
MainWindow.Content = new TrayMenuControl();
MainWindow.Title = ResourceService.GetLocalized("HelperResources/Title");
Expand Down
7 changes: 1 addition & 6 deletions GetStoreAppHelper/GetStoreAppHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<DisableXbfLineInfo>False</DisableXbfLineInfo>
<EnableTypeInfoReflection>true</EnableTypeInfoReflection>
<FileAlignment>512</FileAlignment>
<FileVersion>1.3.319.0</FileVersion>
<FileVersion>1.4.320.0</FileVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>latest</LangVersion>
<OutputType>WinExe</OutputType>
Expand Down Expand Up @@ -65,11 +65,6 @@
<SubType>Designer</SubType>
</Page>

<Page Update="Styles\HelperMenuFlyout.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
<SubType>Designer</SubType>
</Page>

<Page Update="UI\Controls\TrayMenuControl.xaml">
<SubType>Designer</SubType>
</Page>
Expand Down
20 changes: 0 additions & 20 deletions GetStoreAppHelper/Helpers/ResourceDictionaryHelper.cs

This file was deleted.

4 changes: 2 additions & 2 deletions GetStoreAppHelper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.3.319.0")]
[assembly: AssemblyFileVersion("1.3.319.0")]
[assembly: AssemblyVersion("1.4.320.0")]
[assembly: AssemblyFileVersion("1.4.320.0")]
Binary file removed GetStoreAppHelper/Resources/GetStoreApp.ico
Binary file not shown.
16 changes: 0 additions & 16 deletions GetStoreAppHelper/Styles/HelperMenuFlyout.xaml

This file was deleted.

95 changes: 50 additions & 45 deletions GetStoreAppHelper/UI/Controls/TrayMenuControl.xaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,72 @@
<ContentControl
x:Class="GetStoreAppHelper.UI.Controls.TrayMenuControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:GetStoreAppHelper.ViewModels.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:root="using:GetStoreAppHelper.Services"
xmlns:controls="using:GetStoreAppHelper.ViewModels.Controls"
mc:Ignorable="d">
<ContentControl.DataContext>
<controls:TrayMenuViewModel x:Name="ViewModel" x:FieldModifier="public" />
</ContentControl.DataContext>

<MenuFlyout x:Name="TrayMenuFlyout" Opened="{x:Bind ViewModel.OnOpened}">
<MenuFlyoutItem
MinHeight="40"
Command="{x:Bind ViewModel.ProjectDescriptionCommand}"
Text="{x:Bind root:ResourceService.GetLocalized('HelperResources/ProjectHomePage')}">
<CommandBarFlyout
x:Name="TrayMenuFlyout"
Opened="{x:Bind ViewModel.OnOpened}"
Placement="Full">
<CommandBarFlyout.SecondaryCommands>
<AppBarButton
Command="{x:Bind ViewModel.ProjectDescriptionCommand}"
Label="{x:Bind root:ResourceService.GetLocalized('HelperResources/ProjectHomePage')}"
RequestedTheme="{x:Bind ViewModel.CommandBarTheme, Mode=OneWay}">

<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE80f;" Style="{StaticResource SegoeFluentStyle}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<AppBarButton.Icon>
<FontIcon Glyph="&#xE80f;" Style="{StaticResource SegoeFluentStyle}" />
</AppBarButton.Icon>
</AppBarButton>

<MenuFlyoutItem
MinHeight="40"
Command="{x:Bind ViewModel.AboutAppCommand}"
Text="{x:Bind root:ResourceService.GetLocalized('HelperResources/AboutApp')}">
<AppBarButton
Command="{x:Bind ViewModel.AboutAppCommand}"
Label="{x:Bind root:ResourceService.GetLocalized('HelperResources/AboutApp')}"
RequestedTheme="{x:Bind ViewModel.CommandBarTheme, Mode=OneWay}">

<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE946;" Style="{StaticResource SegoeFluentStyle}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<AppBarButton.Icon>
<FontIcon Glyph="&#xE946;" Style="{StaticResource SegoeFluentStyle}" />
</AppBarButton.Icon>
</AppBarButton>

<MenuFlyoutSeparator />
<AppBarSeparator Loaded="{x:Bind ViewModel.OnLoaded}" RequestedTheme="{x:Bind ViewModel.CommandBarTheme, Mode=OneWay}" />

<MenuFlyoutItem
MinHeight="40"
Command="{x:Bind ViewModel.ShowOrHideWindowCommand}"
Text="{x:Bind root:ResourceService.GetLocalized('HelperResources/ShowOrHideWindow')}">
<AppBarButton
Command="{x:Bind ViewModel.ShowOrHideWindowCommand}"
Label="{x:Bind root:ResourceService.GetLocalized('HelperResources/ShowOrHideWindow')}"
RequestedTheme="{x:Bind ViewModel.CommandBarTheme, Mode=OneWay}">

<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE770;" Style="{StaticResource SegoeFluentStyle}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<AppBarButton.Icon>
<FontIcon Glyph="&#xE770;" Style="{StaticResource SegoeFluentStyle}" />
</AppBarButton.Icon>
</AppBarButton>

<MenuFlyoutItem
MinHeight="40"
Command="{x:Bind ViewModel.SettingsCommand}"
Text="{x:Bind root:ResourceService.GetLocalized('HelperResources/Settings')}">
<AppBarButton
Command="{x:Bind ViewModel.SettingsCommand}"
Label="{x:Bind root:ResourceService.GetLocalized('HelperResources/Settings')}"
RequestedTheme="{x:Bind ViewModel.CommandBarTheme, Mode=OneWay}">

<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE713;" Style="{StaticResource SegoeFluentStyle}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<AppBarButton.Icon>
<FontIcon Glyph="&#xE713;" Style="{StaticResource SegoeFluentStyle}" />
</AppBarButton.Icon>
</AppBarButton>

<MenuFlyoutItem
MinHeight="40"
Command="{x:Bind ViewModel.ExitCommand}"
Text="{x:Bind root:ResourceService.GetLocalized('HelperResources/Exit')}">
<AppBarButton
Command="{x:Bind ViewModel.ExitCommand}"
Label="{x:Bind root:ResourceService.GetLocalized('HelperResources/Exit')}"
RequestedTheme="{x:Bind ViewModel.CommandBarTheme, Mode=OneWay}">

<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE7e8;" Style="{StaticResource SegoeFluentStyle}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</MenuFlyout>
<AppBarButton.Icon>
<FontIcon Glyph="&#xE7e8;" Style="{StaticResource SegoeFluentStyle}" />
</AppBarButton.Icon>
</AppBarButton>
</CommandBarFlyout.SecondaryCommands>
</CommandBarFlyout>
</ContentControl>
11 changes: 9 additions & 2 deletions GetStoreAppHelper/UI/Controls/TrayMenuControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Windows.Graphics;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;

namespace GetStoreAppHelper.UI.Controls
{
Expand Down Expand Up @@ -49,11 +50,17 @@ public void ShowMenuFlyout(PointInt32 point)

if (InfoHelper.GetSystemVersion().BuildNumber >= 22000)
{
TrayMenuFlyout.ShowAt(null, new Point(x, y));
FlyoutShowOptions CommandBarOptions = new FlyoutShowOptions();
CommandBarOptions.ShowMode = FlyoutShowMode.Standard;
CommandBarOptions.Position = new Point(x, y);
TrayMenuFlyout.ShowAt(null, CommandBarOptions);
}
else
{
TrayMenuFlyout.ShowAt(null, new Point(point.X, point.Y));
FlyoutShowOptions CommandBarOptions = new FlyoutShowOptions();
CommandBarOptions.ShowMode = FlyoutShowMode.Standard;
CommandBarOptions.Position = new Point(point.X, point.Y);
TrayMenuFlyout.ShowAt(null, CommandBarOptions);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions GetStoreAppHelper/ViewModels/Base/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace GetStoreAppHelper.ViewModels.Base
{
/// <summary>
/// 该视图模型基类实现了InotifyPropertyChanged接口用于通知UI更新
/// </summary>
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
50 changes: 43 additions & 7 deletions GetStoreAppHelper/ViewModels/Controls/TrayMenuViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,37 @@
using GetStoreAppHelper.Extensions.Command;
using GetStoreAppHelper.Helpers;
using GetStoreAppHelper.Services;
using GetStoreAppHelper.ViewModels.Base;
using GetStoreAppHelper.WindowsAPI.PInvoke.User32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Media;

namespace GetStoreAppHelper.ViewModels.Controls
{
/// <summary>
/// 任务栏辅助部分:任务栏右键菜单浮出控件视图模型
/// </summary>
public class TrayMenuViewModel
public class TrayMenuViewModel : ViewModelBase
{
private ElementTheme _commandBarTheme;

public ElementTheme CommandBarTheme
{
get { return _commandBarTheme; }

set
{
_commandBarTheme = value;
OnPropertyChanged();
}
}

// 项目主页
public IRelayCommand ProjectDescriptionCommand => new RelayCommand(async () =>
{
Expand Down Expand Up @@ -174,6 +191,9 @@ public class TrayMenuViewModel
}
});

/// <summary>
/// 命令栏控件在即将打开的时候获取应用设置相应的主题值
/// </summary>
public async void OnOpened(object sender, object args)
{
await ThemeService.LoadNotifyIconMenuThemeAsync();
Expand All @@ -185,31 +205,47 @@ public async void OnOpened(object sender, object args)
{
if (Application.Current.RequestedTheme is ApplicationTheme.Light)
{
(sender as MenuFlyout).MenuFlyoutPresenterStyle = ResourceDictionaryHelper.MenuFlyoutResourceDict["AdaptiveFlyoutLightPresenter"] as Style;
CommandBarTheme = ElementTheme.Light;
}
else
{
(sender as MenuFlyout).MenuFlyoutPresenterStyle = ResourceDictionaryHelper.MenuFlyoutResourceDict["AdaptiveFlyoutDarkPresenter"] as Style;
CommandBarTheme = ElementTheme.Dark;
}
}
else if (ThemeService.AppTheme == Convert.ToString(ElementTheme.Light))
{
(sender as MenuFlyout).MenuFlyoutPresenterStyle = ResourceDictionaryHelper.MenuFlyoutResourceDict["AdaptiveFlyoutLightPresenter"] as Style;
CommandBarTheme = ElementTheme.Light;
}
else if (ThemeService.AppTheme == Convert.ToString(ElementTheme.Dark))
{
(sender as MenuFlyout).MenuFlyoutPresenterStyle = ResourceDictionaryHelper.MenuFlyoutResourceDict["AdaptiveFlyoutDarkPresenter"] as Style;
CommandBarTheme = ElementTheme.Dark;
}
}
else
{
if (RegistryHelper.GetRegistrySystemTheme() == ElementTheme.Light)
{
(sender as MenuFlyout).MenuFlyoutPresenterStyle = ResourceDictionaryHelper.MenuFlyoutResourceDict["AdaptiveFlyoutLightPresenter"] as Style;
CommandBarTheme = ElementTheme.Light;
}
else
{
(sender as MenuFlyout).MenuFlyoutPresenterStyle = ResourceDictionaryHelper.MenuFlyoutResourceDict["AdaptiveFlyoutDarkPresenter"] as Style;
CommandBarTheme = ElementTheme.Dark;
}
}
}

/// <summary>
/// 命令栏显示时设置相应的主题
/// </summary>
public void OnLoaded(object sender, RoutedEventArgs args)
{
IReadOnlyList<Popup> PopupRootList = VisualTreeHelper.GetOpenPopupsForXamlRoot(Program.ApplicationRoot.MainWindow.Content.XamlRoot);

foreach (Popup popupItem in PopupRootList)
{
if (popupItem.Child is FlyoutPresenter)
{
(popupItem.Child as FlyoutPresenter).RequestedTheme = CommandBarTheme;
}
}
}
Expand Down
Loading

0 comments on commit c4d7a9f

Please sign in to comment.