Remove some stuff we don't use

This commit is contained in:
Kristen Schau
2024-09-17 14:38:34 -04:00
parent 3403031505
commit 1748b78034
4 changed files with 6 additions and 119 deletions

View File

@@ -8,48 +8,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Closed="MainWindow_Closed"
mc:Ignorable="d">
<Grid x:Name="RootGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid
x:Name="AppTitleBar"
Height="0"
Background="Transparent">
<!-- Width of the padding columns is set in LayoutMetricsChanged handler. -->
<!--
Using padding columns instead of Margin ensures that the background
paints the area under the caption control buttons (for transparent buttons).
-->
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftPaddingColumn" Width="0" />
<ColumnDefinition />
<ColumnDefinition x:Name="RightPaddingColumn" Width="0" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Image
Width="16"
Height="16"
Margin="8,0,0,0"
HorizontalAlignment="Left"
Source="Assets/WindowIcon.png" />
<TextBlock
x:Name="AppTitleTextBlock"
Grid.Column="1"
Margin="28,0,0,0"
VerticalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}"
Text="App title"
Visibility="Collapsed" />
</StackPanel>
</Grid>
<Grid
x:Name="ContentGrid"
Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<cmdpal:MainPage x:Name="MainPage" />
</Grid>
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<cmdpal:MainPage x:Name="MainPage" />
</Grid>
</Window>

View File

@@ -7,15 +7,11 @@ using System.Text.RegularExpressions;
using Microsoft.CmdPal.Common.Contracts;
using Microsoft.CmdPal.Common.Extensions;
using Microsoft.CmdPal.Common.Services;
using Microsoft.UI;
using Microsoft.UI.Composition;
using Microsoft.UI.Composition.SystemBackdrops;
using Microsoft.UI.Input;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using Microsoft.Win32;
using Windows.ApplicationModel;
using Windows.Foundation;
using Windows.Graphics;
using Windows.System;
@@ -95,15 +91,11 @@ public sealed partial class MainWindow : Window
_appWindow = AppWindow;
Activated += MainWindow_Activated;
AppTitleBar.SizeChanged += AppTitleBar_SizeChanged;
SetAcrylic();
ExtendsContentIntoTitleBar = true;
// Hide our titlebar. We'll make the sides draggable later
_appWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Collapsed;
AppTitleTextBlock.Text = AppInfo.Current.DisplayInfo.DisplayName;
_appWindow.Title = AppTitleTextBlock.Text;
Application.Current.GetService<ILocalSettingsService>().SaveSettingAsync("ThisIsAVeryBizarreString", true);
@@ -204,61 +196,6 @@ public sealed partial class MainWindow : Window
Windows.Win32.PInvoke.ShowWindow(hwnd, Windows.Win32.UI.WindowsAndMessaging.SHOW_WINDOW_CMD.SW_HIDE);
}
private void AppTitleBar_Loaded(object sender, RoutedEventArgs e)
{
if (ExtendsContentIntoTitleBar == true)
{
// Set the initial interactive regions.
SetRegionsForCustomTitleBar();
}
}
private void AppTitleBar_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (ExtendsContentIntoTitleBar == true)
{
// Update interactive regions if the size of the window changes.
SetRegionsForCustomTitleBar();
}
}
private void SetRegionsForCustomTitleBar()
{
// Specify the interactive regions of the title bar.
var scaleAdjustment = AppTitleBar.XamlRoot.RasterizationScale;
RightPaddingColumn.Width = new GridLength(_appWindow.TitleBar.RightInset / scaleAdjustment);
LeftPaddingColumn.Width = new GridLength(_appWindow.TitleBar.LeftInset / scaleAdjustment);
//// Get the rectangle around the content
GeneralTransform transform = MainPage.TransformToVisual(null);
Rect bounds = transform.TransformBounds(new Rect(
0,
0,
MainPage.ActualWidth,
MainPage.ActualHeight));
var contentRect = GetRect(bounds, scaleAdjustment);
var rectArray = new RectInt32[] { contentRect };
InputNonClientPointerSource nonClientInputSrc =
InputNonClientPointerSource.GetForWindowId(this.AppWindow.Id);
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, rectArray);
// Add four drag-able regions, around the sides of our content
var w = ContentGrid.ActualWidth;
var h = ContentGrid.ActualHeight;
var dragSides = new RectInt32[]
{
GetRect(new Rect(0, 0, w, 24), scaleAdjustment),
GetRect(new Rect(0, h - 24, ContentGrid.ActualWidth, 24), scaleAdjustment),
GetRect(new Rect(0, 0, 24, h), scaleAdjustment),
GetRect(new Rect(w - 24, 0, 24, h), scaleAdjustment),
};
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Caption, dragSides);
}
private static RectInt32 GetRect(Rect bounds, double scale)
{
return new RectInt32(
@@ -272,8 +209,6 @@ public sealed partial class MainWindow : Window
{
if (args.WindowActivationState == WindowActivationState.Deactivated)
{
AppTitleTextBlock.Foreground = (SolidColorBrush)App.Current.Resources["WindowCaptionForegroundDisabled"];
_configurationSource.IsInputActive = false;
// If there's a debugger attached...
@@ -289,7 +224,6 @@ public sealed partial class MainWindow : Window
}
else
{
AppTitleTextBlock.Foreground = (SolidColorBrush)App.Current.Resources["WindowCaptionForeground"];
_configurationSource.IsInputActive = true;
}
}

View File

@@ -7,13 +7,8 @@
xmlns:local="using:WindowsCommandPalette.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="Transparent"
Loaded="Page_Loaded"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary />
</Page.Resources>
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"

View File

@@ -69,15 +69,11 @@ public sealed partial class MainPage : Page
}
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
}
private async Task LoadAllCommands()
{
ViewModel.ResetTopLevel();
// Load builtins syncronously...
// Load builtins synchronously...
await LoadBuiltinCommandsAsync();
// ...and extensions on a fire_and_forget