Skip to content

Commit

Permalink
整理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Nov 4, 2023
1 parent 9b8f7e0 commit 5780957
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CoreAppUWP/CoreAppUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@
<ItemGroup>
<ProjectReference Include="..\CoreAppUWP.WinRT\CoreAppUWP.WinRT.vcxproj" />
</ItemGroup>

<ItemGroup>
<Content Include="favicon.ico" />
</ItemGroup>
</Project>
6 changes: 0 additions & 6 deletions CoreAppUWP/Pages/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
NavigationView_Navigate("Home", new EntranceNavigationTransitionInfo());
SystemNavigationManager.GetForCurrentView().BackRequested += System_BackRequested;
CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += TitleBar_LayoutMetricsChanged;

}

private void Current_Closed(object sender, WindowEventArgs args)
{

}

protected override void OnNavigatedFrom(NavigationEventArgs e)
Expand Down
35 changes: 20 additions & 15 deletions CoreAppUWP/Pages/SettingsPages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,27 @@
Content="Exit" />
</StackPanel>
</controls:Setting>
<controls:Setting
ActionIcon="&#xE8A7;"
Click="Button_Click"
Description="Create a new UWP window."
<controls:SettingExpander
Description="Create a new window."
Header="Multiple Window"
Icon="&#xE78B;"
IsClickEnabled="True"
Tag="NewWindow" />
<controls:Setting
ActionIcon="&#xE8A7;"
Click="Button_Click"
Description="Create a new desktop window."
Header="Desktop Window"
Icon="&#xE78B;"
IsClickEnabled="True"
Tag="NewDesktopWindow" />
Icon="&#xE78B;">
<controls:Setting
ActionIcon="&#xE8A7;"
Click="Button_Click"
Description="Create a new CoreWindow."
Header="CoreWindow"
IsClickEnabled="True"
Style="{StaticResource ClickableSettingExpanderItemStyle}"
Tag="NewWindow" />
<controls:Setting
ActionIcon="&#xE8A7;"
Click="Button_Click"
Description="Create a new AppWindow."
Header="Desktop Window"
IsClickEnabled="True"
Style="{StaticResource ClickableSettingExpanderItemStyle}"
Tag="NewAppWindow" />
</controls:SettingExpander>
<controls:Setting
x:Name="SettingsFlyoutSettings"
x:Load="{x:Bind common:SettingsPaneRegister.IsSettingsPaneSupported}"
Expand Down
28 changes: 19 additions & 9 deletions CoreAppUWP/Pages/SettingsPages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
using CoreAppUWP.Common;
using CoreAppUWP.Helpers;
using CoreAppUWP.ViewModels.SettingsPages;
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel.Search;
using Windows.Storage;
using Windows.System;
using Windows.UI;
using Windows.UI.ApplicationSettings;
using Windows.UI.ViewManagement;

Expand Down Expand Up @@ -90,13 +93,25 @@ private async void Button_Click(object sender, RoutedEventArgs e)
ThemeHelper.Initialize(window);
_ = _frame.Navigate(typeof(MainPage), null, new DrillInNavigationTransitionInfo());
});
break;
case "NewAppWindow":
AppWindow window = AppWindow.Create();
window.Closing += (sender, args) => sender.Destroy();
if (AppWindowTitleBar.IsCustomizationSupported())
{
AppWindowTitleBar TitleBar = window.TitleBar;

Color ForegroundColor = Colors.Black;
Color BackgroundColor = Colors.White;

break;
case "NewDesktopWindow":
var window = AppWindow.Create();
TitleBar.ExtendsContentIntoTitleBar = true;
TitleBar.ForegroundColor = TitleBar.ButtonForegroundColor = ForegroundColor;
TitleBar.BackgroundColor = TitleBar.InactiveBackgroundColor = BackgroundColor;
TitleBar.ButtonBackgroundColor = TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
}
window.Title = Package.Current.DisplayName;
window.SetIcon("favicon.ico");
window.Show();
window.Closing += Window_Closing;
break;
case "SearchFlyout" when SettingsPaneRegister.IsSearchPaneSupported:
SearchPane.GetForCurrentView().Show();
Expand All @@ -109,11 +124,6 @@ private async void Button_Click(object sender, RoutedEventArgs e)
}
}

Check notice on line 126 in CoreAppUWP/Pages/SettingsPages/SettingsPage.xaml.cs

View check run for this annotation

codefactor.io / CodeFactor

CoreAppUWP/Pages/SettingsPages/SettingsPage.xaml.cs#L64-L126

Complex Method
private void Window_Closing(AppWindow sender, AppWindowClosingEventArgs args)
{
sender.Destroy();
}

private async void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
switch ((sender as FrameworkElement).Tag.ToString())
Expand Down

0 comments on commit 5780957

Please sign in to comment.