mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
[Peek]Fix icons, removed unneeded RTL code, ui tweaks and code suggestions (#32087)
* Force file pickers to open modal * remove unneeded RTL code * better icons and analyzer suggestions * additions for preview controls * more code improvs * two nits in strings * Adressing feedback icon margin, drive usage bar, TitleBarHeightOption
This commit is contained in:
parent
83aecff13b
commit
8a210865ff
@ -1157,14 +1157,7 @@ namespace PowerLauncher.ViewModel
|
||||
{
|
||||
bool isCurrentLanguageRightToLeft = System.Windows.Input.InputLanguageManager.Current.CurrentInputLanguage.TextInfo.IsRightToLeft;
|
||||
|
||||
if (isCurrentLanguageRightToLeft)
|
||||
{
|
||||
return FlowDirection.RightToLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FlowDirection.LeftToRight;
|
||||
}
|
||||
return isCurrentLanguageRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
|
@ -9,7 +9,5 @@ namespace Peek.Common.Constants
|
||||
public const double MaxWindowToMonitorRatio = 0.80;
|
||||
public const double MinWindowHeight = 500;
|
||||
public const double MinWindowWidth = 500;
|
||||
public const double WindowWidthContentPadding = 7;
|
||||
public const double WindowHeightContentPadding = 16;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace Peek.Common.Extensions
|
||||
public static Size? GetSvgSize(this IFileSystemItem item)
|
||||
{
|
||||
Size? size = null;
|
||||
using (FileStream stream = new FileStream(item.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
using (FileStream stream = new(item.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
{
|
||||
XmlReaderSettings settings = new XmlReaderSettings();
|
||||
settings.Async = true;
|
||||
@ -39,37 +39,35 @@ namespace Peek.Common.Extensions
|
||||
settings.IgnoreProcessingInstructions = true;
|
||||
settings.IgnoreWhitespace = true;
|
||||
|
||||
using (XmlReader reader = XmlReader.Create(stream, settings))
|
||||
using XmlReader reader = XmlReader.Create(stream, settings);
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
if (reader.NodeType == XmlNodeType.Element && reader.Name == "svg")
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element && reader.Name == "svg")
|
||||
string? width = reader.GetAttribute("width");
|
||||
string? height = reader.GetAttribute("height");
|
||||
if (width != null && height != null)
|
||||
{
|
||||
string? width = reader.GetAttribute("width");
|
||||
string? height = reader.GetAttribute("height");
|
||||
if (width != null && height != null)
|
||||
int widthValue = int.Parse(Regex.Match(width, @"\d+").Value, NumberFormatInfo.InvariantInfo);
|
||||
int heightValue = int.Parse(Regex.Match(height, @"\d+").Value, NumberFormatInfo.InvariantInfo);
|
||||
size = new Size(widthValue, heightValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
string? viewBox = reader.GetAttribute("viewBox");
|
||||
if (viewBox != null)
|
||||
{
|
||||
int widthValue = int.Parse(Regex.Match(width, @"\d+").Value, NumberFormatInfo.InvariantInfo);
|
||||
int heightValue = int.Parse(Regex.Match(height, @"\d+").Value, NumberFormatInfo.InvariantInfo);
|
||||
size = new Size(widthValue, heightValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
string? viewBox = reader.GetAttribute("viewBox");
|
||||
if (viewBox != null)
|
||||
var viewBoxValues = viewBox.Split(' ');
|
||||
if (viewBoxValues.Length == 4)
|
||||
{
|
||||
var viewBoxValues = viewBox.Split(' ');
|
||||
if (viewBoxValues.Length == 4)
|
||||
{
|
||||
int viewBoxWidth = int.Parse(viewBoxValues[2], NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
int viewBoxHeight = int.Parse(viewBoxValues[3], NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
size = new Size(viewBoxWidth, viewBoxHeight);
|
||||
}
|
||||
int viewBoxWidth = int.Parse(viewBoxValues[2], NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
int viewBoxHeight = int.Parse(viewBoxValues[3], NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
size = new Size(viewBoxWidth, viewBoxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,21 +78,19 @@ namespace Peek.Common.Extensions
|
||||
public static Size? GetQoiSize(this IFileSystemItem item)
|
||||
{
|
||||
Size? size = null;
|
||||
using (FileStream stream = new FileStream(item.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
using (FileStream stream = new(item.Path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
{
|
||||
if (stream.Length >= 12)
|
||||
{
|
||||
stream.Position = 4;
|
||||
|
||||
using (var reader = new BinaryReader(stream))
|
||||
{
|
||||
uint widthValue = BinaryPrimitives.ReadUInt32BigEndian(reader.ReadBytes(4));
|
||||
uint heightValue = BinaryPrimitives.ReadUInt32BigEndian(reader.ReadBytes(4));
|
||||
using var reader = new BinaryReader(stream);
|
||||
uint widthValue = BinaryPrimitives.ReadUInt32BigEndian(reader.ReadBytes(4));
|
||||
uint heightValue = BinaryPrimitives.ReadUInt32BigEndian(reader.ReadBytes(4));
|
||||
|
||||
if (widthValue > 0 && heightValue > 0)
|
||||
{
|
||||
size = new Size(widthValue, heightValue);
|
||||
}
|
||||
if (widthValue > 0 && heightValue > 0)
|
||||
{
|
||||
size = new Size(widthValue, heightValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,22 +100,13 @@ namespace Peek.Common.Extensions
|
||||
|
||||
public static async Task<string> GetContentTypeAsync(this IFileSystemItem item)
|
||||
{
|
||||
string contentType = string.Empty;
|
||||
|
||||
var storageItem = await item.GetStorageItemAsync();
|
||||
switch (storageItem)
|
||||
string contentType = storageItem switch
|
||||
{
|
||||
case StorageFile storageFile:
|
||||
contentType = storageFile.DisplayType;
|
||||
break;
|
||||
case StorageFolder storageFolder:
|
||||
contentType = storageFolder.DisplayType;
|
||||
break;
|
||||
default:
|
||||
contentType = item.FileType;
|
||||
break;
|
||||
}
|
||||
|
||||
StorageFile storageFile => storageFile.DisplayType,
|
||||
StorageFolder storageFolder => storageFolder.DisplayType,
|
||||
_ => item.FileType,
|
||||
};
|
||||
return contentType;
|
||||
}
|
||||
}
|
||||
|
@ -27,19 +27,10 @@ namespace Peek.Common.Extensions
|
||||
|
||||
try
|
||||
{
|
||||
PropVariant propVar;
|
||||
|
||||
propertyStore.GetValue(ref key, out propVar);
|
||||
propertyStore.GetValue(ref key, out PropVariant propVar);
|
||||
|
||||
// VT_UI4 Indicates a 4-byte unsigned integer formatted in little-endian byte order.
|
||||
if ((VarEnum)propVar.Vt == VarEnum.VT_UI4)
|
||||
{
|
||||
return propVar.UlVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (VarEnum)propVar.Vt == VarEnum.VT_UI4 ? propVar.UlVal : null;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -63,19 +54,10 @@ namespace Peek.Common.Extensions
|
||||
|
||||
try
|
||||
{
|
||||
PropVariant propVar;
|
||||
|
||||
propertyStore.GetValue(ref key, out propVar);
|
||||
propertyStore.GetValue(ref key, out PropVariant propVar);
|
||||
|
||||
// VT_UI8 Indicates an 8-byte unsigned integer formatted in little-endian byte order.
|
||||
if ((VarEnum)propVar.Vt == VarEnum.VT_UI8)
|
||||
{
|
||||
return propVar.UhVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (VarEnum)propVar.Vt == VarEnum.VT_UI8 ? propVar.UhVal : null;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -98,18 +80,9 @@ namespace Peek.Common.Extensions
|
||||
|
||||
try
|
||||
{
|
||||
PropVariant propVar;
|
||||
propertyStore.GetValue(ref key, out PropVariant propVar);
|
||||
|
||||
propertyStore.GetValue(ref key, out propVar);
|
||||
|
||||
if ((VarEnum)propVar.Vt == VarEnum.VT_LPWSTR)
|
||||
{
|
||||
return Marshal.PtrToStringUni(propVar.P) ?? string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (VarEnum)propVar.Vt == VarEnum.VT_LPWSTR ? Marshal.PtrToStringUni(propVar.P) ?? string.Empty : null;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ namespace Peek.Common.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime? dateModified = null;
|
||||
DateTime? dateModified;
|
||||
try
|
||||
{
|
||||
dateModified = System.IO.File.GetCreationTime(Path);
|
||||
|
@ -17,7 +17,7 @@
|
||||
AutomationProperties.Name="{x:Bind Name}"
|
||||
IsExpanded="{x:Bind IsExpanded}"
|
||||
ItemsSource="{x:Bind Children}">
|
||||
<Grid ColumnSpacing="10">
|
||||
<Grid ColumnSpacing="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
<DataTemplate x:Key="FileTemplate" x:DataType="models:ArchiveItem">
|
||||
<TreeViewItem AutomationProperties.Name="{x:Bind Name}">
|
||||
<Grid ColumnSpacing="10">
|
||||
<Grid ColumnSpacing="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
@ -77,7 +77,6 @@
|
||||
</ScrollViewer>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
MinWidth="300"
|
||||
Margin="16"
|
||||
HorizontalAlignment="Center"
|
||||
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
|
||||
@ -100,7 +99,7 @@
|
||||
TextWrapping="Wrap" />
|
||||
<Border
|
||||
Grid.Column="1"
|
||||
BorderBrush="{ThemeResource TextFillColorPrimaryBrush}"
|
||||
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
|
||||
BorderThickness="0,0,1,0" />
|
||||
<TextBlock
|
||||
Grid.Column="2"
|
||||
@ -110,7 +109,7 @@
|
||||
TextWrapping="Wrap" />
|
||||
<Border
|
||||
Grid.Column="3"
|
||||
BorderBrush="{ThemeResource TextFillColorPrimaryBrush}"
|
||||
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
|
||||
BorderThickness="0,0,1,0" />
|
||||
<TextBlock
|
||||
Grid.Column="4"
|
||||
|
@ -10,15 +10,12 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<tkconverters:StringVisibilityConverter x:Key="StringVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid
|
||||
MaxWidth="800"
|
||||
Margin="16"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="24"
|
||||
VerticalAlignment="Center"
|
||||
ColumnSpacing="24"
|
||||
RowSpacing="24">
|
||||
@ -34,7 +31,6 @@
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="24,0,0,0"
|
||||
HorizontalAlignment="Right"
|
||||
BorderBrush="{ThemeResource SurfaceStrokeColorDefaultBrush}"
|
||||
BorderThickness="1"
|
||||
@ -45,14 +41,12 @@
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,24,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Spacing="5">
|
||||
Spacing="4">
|
||||
<TextBlock
|
||||
FontSize="26"
|
||||
FontWeight="SemiBold"
|
||||
MaxLines="3"
|
||||
Style="{StaticResource TitleTextBlockStyle}"
|
||||
Text="{x:Bind Source.Title, Mode=OneWay}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="Wrap">
|
||||
@ -87,7 +81,6 @@
|
||||
x:Name="PlayerElement"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
VerticalAlignment="Top"
|
||||
AreTransportControlsEnabled="True"
|
||||
AutoPlay="True"
|
||||
Source="{x:Bind Source.MediaSource, Mode=OneWay}">
|
||||
@ -96,8 +89,7 @@
|
||||
</MediaPlayerElement.KeyboardAccelerators>
|
||||
<MediaPlayerElement.TransportControls>
|
||||
<MediaTransportControls
|
||||
MaxWidth="900"
|
||||
Margin="0"
|
||||
MaxWidth="800"
|
||||
IsCompact="True"
|
||||
IsZoomButtonVisible="False" />
|
||||
</MediaPlayerElement.TransportControls>
|
||||
|
@ -12,11 +12,11 @@
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid
|
||||
MaxWidth="1000"
|
||||
Margin="48"
|
||||
MaxWidth="800"
|
||||
Margin="24"
|
||||
VerticalAlignment="Center"
|
||||
ColumnSpacing="16"
|
||||
RowSpacing="16">
|
||||
ColumnSpacing="24"
|
||||
RowSpacing="24">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
@ -30,20 +30,14 @@
|
||||
Grid.Column="0"
|
||||
Width="180"
|
||||
Height="180"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Source="{x:Bind Source.IconPreview, Mode=OneWay}" />
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Spacing="5">
|
||||
<TextBlock
|
||||
FontSize="26"
|
||||
FontWeight="SemiBold"
|
||||
Text="{x:Bind Source.Name, Mode=OneWay}"
|
||||
TextTrimming="CharacterEllipsis">
|
||||
Spacing="4">
|
||||
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="{x:Bind Source.Name, Mode=OneWay}">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{x:Bind Source.Name, Mode=OneWay}" />
|
||||
</ToolTipService.ToolTip>
|
||||
@ -68,29 +62,25 @@
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
RowSpacing="5">
|
||||
RowSpacing="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border
|
||||
x:Name="CapacityBar"
|
||||
Grid.Row="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Height="20"
|
||||
Background="{ThemeResource AccentFillColorDisabledBrush}"
|
||||
CornerRadius="10" />
|
||||
Height="16"
|
||||
Background="{ThemeResource SurfaceStrokeColorDefaultBrush}"
|
||||
CornerRadius="8" />
|
||||
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Height="20"
|
||||
Height="16"
|
||||
Background="{ThemeResource AccentFillColorDefaultBrush}"
|
||||
CornerRadius="10">
|
||||
CornerRadius="8">
|
||||
<Border.Clip>
|
||||
<RectangleGeometry Rect="{x:Bind SpaceBarClip, Mode=OneWay}" />
|
||||
</Border.Clip>
|
||||
@ -99,15 +89,12 @@
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Text="{x:Bind FormatUsedSpace(Source.UsedSpace), Mode=OneWay}" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Text="{x:Bind FormatFreeSpace(Source.FreeSpace), Mode=OneWay}" />
|
||||
</Grid>
|
||||
|
@ -70,7 +70,7 @@ namespace Peek.FilePreviewer.Controls
|
||||
if (Source != null && Source.PercentageUsage > 0)
|
||||
{
|
||||
var usedWidth = CapacityBar.ActualWidth * Source!.PercentageUsage;
|
||||
SpaceBarClip = new(0, 0, usedWidth, 20);
|
||||
SpaceBarClip = new(0, 0, usedWidth, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Grid ColumnSpacing="24" RowSpacing="24">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
@ -18,19 +18,17 @@
|
||||
|
||||
<IconSourceElement
|
||||
Grid.Row="0"
|
||||
Margin="3"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource TextFillColorSecondaryBrush}">
|
||||
<IconSourceElement.IconSource>
|
||||
<FontIconSource FontSize="135" Glyph="" />
|
||||
<FontIconSource FontSize="128" Glyph="" />
|
||||
</IconSourceElement.IconSource>
|
||||
</IconSourceElement>
|
||||
|
||||
<TextBlock
|
||||
x:Uid="FailedFallbackTextBlock"
|
||||
Grid.Row="1"
|
||||
Margin="3"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource TextFillColorSecondaryBrush}"
|
||||
@ -39,7 +37,6 @@
|
||||
<HyperlinkButton
|
||||
x:Uid="FailedFallbackReportBugHyperlinkButton"
|
||||
Grid.Row="2"
|
||||
Margin="3"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
NavigateUri="https://aka.ms/powerToysReportBug" />
|
||||
|
@ -9,7 +9,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<Grid ColumnSpacing="24">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="Icon" Width="Auto" />
|
||||
<ColumnDefinition x:Name="FileInfo" Width="*" />
|
||||
@ -20,19 +20,19 @@
|
||||
Grid.Column="0"
|
||||
Width="180"
|
||||
Height="180"
|
||||
Margin="0,24,24,24"
|
||||
Source="{x:Bind Source.IconPreview, Mode=OneWay}" />
|
||||
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Spacing="5">
|
||||
Spacing="4">
|
||||
|
||||
<TextBlock
|
||||
FontSize="26"
|
||||
FontWeight="SemiBold"
|
||||
MaxLines="3"
|
||||
Style="{StaticResource TitleTextBlockStyle}"
|
||||
Text="{x:Bind Source.FileName, Mode=OneWay}"
|
||||
TextTrimming="CharacterEllipsis">
|
||||
TextTrimming="CharacterEllipsis"
|
||||
TextWrapping="Wrap">
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{x:Bind Source.FileName, Mode=OneWay}" />
|
||||
</ToolTipService.ToolTip>
|
||||
|
@ -13,7 +13,7 @@
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid
|
||||
Margin="48"
|
||||
Margin="24"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center">
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
x:Name="VideoPreview"
|
||||
AreTransportControlsEnabled="True"
|
||||
AutoPlay="True"
|
||||
FlowDirection="LeftToRight"
|
||||
Source="{x:Bind VideoPreviewer.Preview, Mode=OneWay}"
|
||||
ToolTipService.ToolTip="{x:Bind InfoTooltip, Mode=OneWay}"
|
||||
Visibility="{x:Bind IsPreviewVisible(VideoPreviewer, Previewer.State), Mode=OneWay}">
|
||||
@ -47,7 +48,7 @@
|
||||
<MediaTransportControls
|
||||
x:Name="mediaTransport"
|
||||
Width="auto"
|
||||
MaxWidth="420"
|
||||
MaxWidth="800"
|
||||
IsCompact="True" />
|
||||
</MediaPlayerElement.TransportControls>
|
||||
</MediaPlayerElement>
|
||||
@ -62,6 +63,7 @@
|
||||
x:Name="BrowserPreview"
|
||||
x:Load="True"
|
||||
DOMContentLoaded="BrowserPreview_DOMContentLoaded"
|
||||
FlowDirection="LeftToRight"
|
||||
IsDevFilePreview="{x:Bind BrowserPreviewer.IsDevFilePreview, Mode=OneWay}"
|
||||
NavigationCompleted="PreviewBrowser_NavigationCompleted"
|
||||
Source="{x:Bind BrowserPreviewer.Preview, Mode=OneWay}"
|
||||
|
@ -162,15 +162,6 @@ namespace Peek.FilePreviewer
|
||||
DrivePreview.Visibility = Visibility.Collapsed;
|
||||
UnsupportedFilePreview.Visibility = Visibility.Collapsed;
|
||||
|
||||
ImagePreview.FlowDirection = FlowDirection.LeftToRight;
|
||||
VideoPreview.FlowDirection = FlowDirection.LeftToRight;
|
||||
|
||||
AudioPreview.FlowDirection = FlowDirection.LeftToRight;
|
||||
BrowserPreview.FlowDirection = FlowDirection.LeftToRight;
|
||||
ArchivePreview.FlowDirection = FlowDirection.LeftToRight;
|
||||
DrivePreview.FlowDirection = FlowDirection.LeftToRight;
|
||||
UnsupportedFilePreview.FlowDirection = FlowDirection.LeftToRight;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -231,7 +222,6 @@ namespace Peek.FilePreviewer
|
||||
VideoPreview.MediaPlayer.Pause();
|
||||
VideoPreview.MediaPlayer.Source = null;
|
||||
VideoPreview.Source = null;
|
||||
|
||||
AudioPreview.Source = null;
|
||||
ImagePreview.Source = null;
|
||||
ArchivePreview.Source = null;
|
||||
|
@ -4,8 +4,7 @@
|
||||
<Application
|
||||
x:Class="Peek.UI.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:Peek.UI">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
@ -89,7 +89,7 @@ namespace Peek.UI
|
||||
var cmdArgs = Environment.GetCommandLineArgs();
|
||||
if (cmdArgs?.Length > 1)
|
||||
{
|
||||
if (int.TryParse(cmdArgs[cmdArgs.Length - 1], out int powerToysRunnerPid))
|
||||
if (int.TryParse(cmdArgs[^1], out int powerToysRunnerPid))
|
||||
{
|
||||
RunnerHelper.WaitForPowerToysRunner(powerToysRunnerPid, () =>
|
||||
{
|
||||
|
@ -11,12 +11,13 @@
|
||||
xmlns:views="using:Peek.UI.Views"
|
||||
xmlns:winuiex="using:WinUIEx"
|
||||
Title="{x:Bind ViewModel.WindowTitle, Mode=OneWay}"
|
||||
MinWidth="450"
|
||||
MinHeight="400"
|
||||
MinWidth="480"
|
||||
MinHeight="320"
|
||||
mc:Ignorable="d">
|
||||
<Window.SystemBackdrop>
|
||||
<MicaBackdrop />
|
||||
</Window.SystemBackdrop>
|
||||
|
||||
<Grid KeyboardAcceleratorPlacementMode="Hidden">
|
||||
<Grid.KeyboardAccelerators>
|
||||
<KeyboardAccelerator Key="Left" Invoked="PreviousNavigationInvoked" />
|
||||
@ -31,7 +32,7 @@
|
||||
</Grid.KeyboardAccelerators>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace Peek.UI
|
||||
{
|
||||
public MainWindowViewModel ViewModel { get; }
|
||||
|
||||
private ThemeListener? themeListener;
|
||||
private readonly ThemeListener? themeListener;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@ -47,6 +47,8 @@ namespace Peek.UI
|
||||
ViewModel = Application.Current.GetService<MainWindowViewModel>();
|
||||
|
||||
TitleBarControl.SetTitleBarToWindow(this);
|
||||
AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
|
||||
AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
|
||||
AppWindow.SetIcon("Assets/Peek/Icon.ico");
|
||||
|
||||
AppWindow.Closing += AppWindow_Closing;
|
||||
@ -85,14 +87,7 @@ namespace Peek.UI
|
||||
{
|
||||
AppWindow appWindow = this.AppWindow;
|
||||
|
||||
if (ThemeHelpers.GetAppTheme() == AppTheme.Light)
|
||||
{
|
||||
appWindow.TitleBar.ButtonForegroundColor = Colors.DarkSlateGray;
|
||||
}
|
||||
else
|
||||
{
|
||||
appWindow.TitleBar.ButtonForegroundColor = Colors.White;
|
||||
}
|
||||
appWindow.TitleBar.ButtonForegroundColor = ThemeHelpers.GetAppTheme() == AppTheme.Light ? Colors.DarkSlateGray : Colors.White;
|
||||
}
|
||||
|
||||
private void PeekWindow_Activated(object sender, WindowActivatedEventArgs args)
|
||||
@ -159,16 +154,16 @@ namespace Peek.UI
|
||||
// If no size is requested, try to fit to the monitor size.
|
||||
Size requestedSize = e.PreviewSize.MonitorSize ?? monitorSize;
|
||||
var contentScale = e.PreviewSize.UseEffectivePixels ? 1 : monitorScale;
|
||||
Size scaledRequestedSize = new Size(requestedSize.Width / contentScale, requestedSize.Height / contentScale);
|
||||
Size scaledRequestedSize = new(requestedSize.Width / contentScale, requestedSize.Height / contentScale);
|
||||
|
||||
// TODO: Investigate why portrait images do not perfectly fit edge-to-edge
|
||||
// TODO: Investigate why portrait images do not perfectly fit edge-to-edge --> WindowHeightContentPadding can be 0 (or close to that) if custom? [Jay]
|
||||
Size monitorMinContentSize = GetMonitorMinContentSize(monitorScale);
|
||||
Size monitorMaxContentSize = GetMonitorMaxContentSize(monitorSize, monitorScale);
|
||||
Size adjustedContentSize = scaledRequestedSize.Fit(monitorMaxContentSize, monitorMinContentSize);
|
||||
|
||||
var titleBarHeight = TitleBarControl.ActualHeight;
|
||||
var desiredWindowHeight = adjustedContentSize.Height + titleBarHeight + WindowConstants.WindowWidthContentPadding;
|
||||
var desiredWindowWidth = adjustedContentSize.Width + WindowConstants.WindowHeightContentPadding;
|
||||
var desiredWindowWidth = adjustedContentSize.Width;
|
||||
var desiredWindowHeight = adjustedContentSize.Height + titleBarHeight;
|
||||
|
||||
if (!TitleBarControl.Pinned)
|
||||
{
|
||||
@ -220,12 +215,7 @@ namespace Peek.UI
|
||||
|
||||
var fileExplorerSelectedItemPath = selectedItems.GetItemAt(0).ToIFileSystemItem().Path;
|
||||
var currentItemPath = ViewModel.CurrentItem?.Path;
|
||||
if (fileExplorerSelectedItemPath == null || currentItemPath == null || fileExplorerSelectedItemPath == currentItemPath)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return fileExplorerSelectedItemPath != null && currentItemPath != null && fileExplorerSelectedItemPath != currentItemPath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -6,20 +6,24 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Peek.UI.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
FlowDirection="{x:Bind TitleBarFlowDirection, Mode=OneWay}"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid x:Name="TitleBarRootContainer" Height="48">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="SystemLeftPaddingColumn" Width="0" />
|
||||
<ColumnDefinition x:Name="DraggableColumn" Width="*" />
|
||||
<ColumnDefinition x:Name="LaunchAppButtonColumn" Width="Auto" />
|
||||
<ColumnDefinition x:Name="AppRightPaddingColumn" Width="8" />
|
||||
<ColumnDefinition x:Name="PinButtonColumn" Width="Auto" />
|
||||
<ColumnDefinition x:Name="SystemRightPaddingColumn" Width="180" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid
|
||||
x:Name="AppIconAndFileTitleContainer"
|
||||
Margin="8,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
ColumnSpacing="4">
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="AppIconColumn" Width="32" />
|
||||
<ColumnDefinition x:Name="AppIconColumn" Width="Auto" />
|
||||
<ColumnDefinition x:Name="FileTitleColumn" Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
@ -27,35 +31,32 @@
|
||||
x:Name="PeekLogo"
|
||||
x:Uid="PeekLogo"
|
||||
Grid.Column="0"
|
||||
Width="24"
|
||||
Height="24"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Source="../../Assets/Peek/AppList.scale-400.png"
|
||||
Width="16"
|
||||
Height="16"
|
||||
Margin="16,0"
|
||||
Source="../../Assets/Peek/Icon.ico"
|
||||
Stretch="UniformToFill" />
|
||||
|
||||
<Grid
|
||||
x:Name="FileCountAndNameContainer"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
ColumnSpacing="4">
|
||||
VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="FileCountColumn" Width="auto" />
|
||||
<ColumnDefinition x:Name="FileCountColumn" Width="Auto" />
|
||||
<ColumnDefinition x:Name="FileNameColumn" Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
x:Name="AppTitle_FileCount"
|
||||
x:Uid="AppTitle_FileCount"
|
||||
Grid.Column="0"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,8,0"
|
||||
FontWeight="SemiBold"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind FileCountText, Mode=OneWay}"
|
||||
Visibility="{x:Bind IsMultiSelection, Mode=OneWay}" />
|
||||
|
||||
<TextBlock
|
||||
x:Name="AppTitle_FileName"
|
||||
x:Uid="AppTitle_FileName"
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind Item.Name, Mode=OneWay}"
|
||||
@ -65,7 +66,7 @@
|
||||
|
||||
<Button
|
||||
x:Name="LaunchAppButton"
|
||||
x:Uid="LaunchAppButton"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Command="{x:Bind LaunchDefaultAppButtonCommand, Mode=OneWay}"
|
||||
ToolTipService.ToolTip="{x:Bind OpenWithAppToolTip, Mode=OneWay}"
|
||||
@ -74,12 +75,10 @@
|
||||
<StackPanel Orientation="Horizontal" Spacing="4">
|
||||
<FontIcon
|
||||
x:Name="LaunchAppButton_Icon"
|
||||
x:Uid="LaunchAppButton_Icon"
|
||||
FontSize="{StaticResource CaptionTextBlockFontSize}"
|
||||
FontSize="16"
|
||||
Glyph="" />
|
||||
<TextBlock
|
||||
x:Name="LaunchAppButton_Text"
|
||||
x:Uid="LaunchAppButton_Text"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind OpenWithAppText, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
@ -91,15 +90,14 @@
|
||||
|
||||
<Button
|
||||
x:Name="PinButton"
|
||||
x:Uid="PinButton"
|
||||
Grid.Column="4"
|
||||
VerticalAlignment="Center"
|
||||
Command="{x:Bind PinCommand, Mode=OneWay}"
|
||||
ToolTipService.ToolTip="{x:Bind PinToolTip(Pinned), Mode=OneWay}">
|
||||
<Button.Content>
|
||||
<FontIcon
|
||||
x:Name="PinButton_Icon"
|
||||
x:Uid="PinButton_Icon"
|
||||
FontSize="{StaticResource CaptionTextBlockFontSize}"
|
||||
FontSize="16"
|
||||
Glyph="{x:Bind PinGlyph(Pinned), Mode=OneWay}" />
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
@ -71,13 +71,6 @@ namespace Peek.UI.Views
|
||||
[ObservableProperty]
|
||||
private bool pinned = false;
|
||||
|
||||
private ColumnDefinition systemLeftPaddingColumn = new() { Width = new GridLength(0) };
|
||||
private ColumnDefinition draggableColumn = new() { Width = new GridLength(1, GridUnitType.Star) };
|
||||
private ColumnDefinition launchAppButtonColumn = new() { Width = GridLength.Auto };
|
||||
private ColumnDefinition appRightPaddingColumn = new() { Width = new GridLength(65) };
|
||||
private ColumnDefinition pinButtonColumn = new() { Width = new GridLength(40) };
|
||||
private ColumnDefinition systemRightPaddingColumn = new() { Width = new GridLength(0) };
|
||||
|
||||
public TitleBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -150,7 +143,7 @@ namespace Peek.UI.Views
|
||||
PowerToysTelemetry.Log.WriteEvent(new OpenWithEvent() { App = DefaultAppName ?? string.Empty });
|
||||
|
||||
// StorageFile objects can't represent files that are ".lnk", ".url", or ".wsh" file types.
|
||||
// https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefile?view=winrt-22621
|
||||
// https://learn.microsoft.com/uwp/api/windows.storage.storagefile?view=winrt-22621
|
||||
if (storageFile == null)
|
||||
{
|
||||
options.DisplayApplicationPicker = true;
|
||||
@ -177,7 +170,7 @@ namespace Peek.UI.Views
|
||||
|
||||
public string PinGlyph(bool pinned)
|
||||
{
|
||||
return pinned ? "\xE841" : "\xE77A";
|
||||
return pinned ? "\xE77A" : "\xE718";
|
||||
}
|
||||
|
||||
public string PinToolTip(bool pinned)
|
||||
@ -191,54 +184,6 @@ namespace Peek.UI.Views
|
||||
Pinned = !Pinned;
|
||||
}
|
||||
|
||||
public FlowDirection TitleBarFlowDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
var direction = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ?
|
||||
FlowDirection.RightToLeft :
|
||||
FlowDirection.LeftToRight;
|
||||
SetupGridColumnDefinitions(direction);
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupGridColumnDefinitions(FlowDirection direction)
|
||||
{
|
||||
TitleBarRootContainer.ColumnDefinitions.Clear();
|
||||
|
||||
if (direction == FlowDirection.LeftToRight)
|
||||
{
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(systemLeftPaddingColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(draggableColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(launchAppButtonColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(appRightPaddingColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(pinButtonColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(systemRightPaddingColumn);
|
||||
|
||||
Grid.SetColumn(AppIconAndFileTitleContainer, 1);
|
||||
FileCountAndNameContainer.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
Grid.SetColumn(LaunchAppButton, 2);
|
||||
Grid.SetColumn(PinButton, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(systemRightPaddingColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(pinButtonColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(appRightPaddingColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(launchAppButtonColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(draggableColumn);
|
||||
TitleBarRootContainer.ColumnDefinitions.Add(systemLeftPaddingColumn);
|
||||
|
||||
Grid.SetColumn(AppIconAndFileTitleContainer, 4);
|
||||
FileCountAndNameContainer.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
Grid.SetColumn(LaunchAppButton, 3);
|
||||
LaunchAppButton.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
Grid.SetColumn(PinButton, 1);
|
||||
PinButton.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
}
|
||||
}
|
||||
|
||||
private void TitleBarRootContainer_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
UpdateDragRegion();
|
||||
@ -256,37 +201,22 @@ namespace Peek.UI.Views
|
||||
{
|
||||
var scale = MainWindow.GetMonitorScale();
|
||||
|
||||
systemRightPaddingColumn.Width = new GridLength(appWindow.TitleBar.RightInset / scale);
|
||||
systemLeftPaddingColumn.Width = new GridLength(appWindow.TitleBar.LeftInset / scale);
|
||||
SystemLeftPaddingColumn.Width = new GridLength(appWindow.TitleBar.LeftInset / scale);
|
||||
SystemRightPaddingColumn.Width = new GridLength(appWindow.TitleBar.RightInset / scale);
|
||||
|
||||
var dragRectsList = new List<RectInt32>();
|
||||
RectInt32 dragRectangleLeft;
|
||||
RectInt32 dragRectangleRight;
|
||||
|
||||
if (TitleBarFlowDirection == FlowDirection.LeftToRight)
|
||||
{
|
||||
dragRectangleLeft.X = (int)(systemLeftPaddingColumn.ActualWidth * scale);
|
||||
dragRectangleLeft.Y = 0;
|
||||
dragRectangleLeft.Height = (int)(TitleBarRootContainer.ActualHeight * scale);
|
||||
dragRectangleLeft.Width = (int)(draggableColumn.ActualWidth * scale);
|
||||
dragRectangleLeft.X = (int)(SystemLeftPaddingColumn.ActualWidth * scale);
|
||||
dragRectangleLeft.Y = 0;
|
||||
dragRectangleLeft.Width = (int)(DraggableColumn.ActualWidth * scale);
|
||||
dragRectangleLeft.Height = (int)(TitleBarRootContainer.ActualHeight * scale);
|
||||
|
||||
dragRectangleRight.X = (int)((systemLeftPaddingColumn.ActualWidth + draggableColumn.ActualWidth + launchAppButtonColumn.ActualWidth) * scale);
|
||||
dragRectangleRight.Y = 0;
|
||||
dragRectangleRight.Height = (int)(TitleBarRootContainer.ActualHeight * scale);
|
||||
dragRectangleRight.Width = (int)(appRightPaddingColumn.ActualWidth * scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
dragRectangleRight.X = (int)(pinButtonColumn.ActualWidth * scale);
|
||||
dragRectangleRight.Y = 0;
|
||||
dragRectangleRight.Height = (int)(TitleBarRootContainer.ActualHeight * scale);
|
||||
dragRectangleRight.Width = (int)(appRightPaddingColumn.ActualWidth * scale);
|
||||
|
||||
dragRectangleLeft.X = (int)((pinButtonColumn.ActualWidth + appRightPaddingColumn.ActualWidth + launchAppButtonColumn.ActualWidth) * scale);
|
||||
dragRectangleLeft.Y = 0;
|
||||
dragRectangleLeft.Height = (int)(TitleBarRootContainer.ActualHeight * scale);
|
||||
dragRectangleLeft.Width = (int)(draggableColumn.ActualWidth * scale);
|
||||
}
|
||||
dragRectangleRight.X = (int)((SystemLeftPaddingColumn.ActualWidth + DraggableColumn.ActualWidth + LaunchAppButtonColumn.ActualWidth) * scale);
|
||||
dragRectangleRight.Y = 0;
|
||||
dragRectangleRight.Width = (int)(AppRightPaddingColumn.ActualWidth * scale);
|
||||
dragRectangleRight.Height = (int)(TitleBarRootContainer.ActualHeight * scale);
|
||||
|
||||
dragRectsList.Add(dragRectangleLeft);
|
||||
dragRectsList.Add(dragRectangleRight);
|
||||
@ -303,14 +233,7 @@ namespace Peek.UI.Views
|
||||
appWindow.TitleBar.ExtendsContentIntoTitleBar = true;
|
||||
appWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent;
|
||||
appWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
|
||||
if (ThemeHelpers.GetAppTheme() == AppTheme.Light)
|
||||
{
|
||||
appWindow.TitleBar.ButtonForegroundColor = Colors.DarkSlateGray;
|
||||
}
|
||||
else
|
||||
{
|
||||
appWindow.TitleBar.ButtonForegroundColor = Colors.White;
|
||||
}
|
||||
appWindow.TitleBar.ButtonForegroundColor = ThemeHelpers.GetAppTheme() == AppTheme.Light ? Colors.DarkSlateGray : Colors.White;
|
||||
|
||||
mainWindow.SetTitleBar(this);
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Peek.UI
|
||||
{
|
||||
public interface IUserSettings
|
||||
|
@ -27,12 +27,7 @@ namespace Peek.UI
|
||||
IsMultipleFilesActivation = hasMoreThanOneItem;
|
||||
|
||||
var neighboringItemsShellArray = hasMoreThanOneItem ? selectedItemsShellArray : FileExplorerHelper.GetItems(foregroundWindowHandle);
|
||||
if (neighboringItemsShellArray == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new NeighboringItems(neighboringItemsShellArray);
|
||||
return neighboringItemsShellArray == null ? null : new NeighboringItems(neighboringItemsShellArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace Peek.UI
|
||||
|
||||
private readonly SettingsUtils _settingsUtils;
|
||||
private readonly IFileSystemWatcher _watcher;
|
||||
private readonly object _loadingSettingsLock = new object();
|
||||
private readonly object _loadingSettingsLock = new();
|
||||
|
||||
public bool CloseAfterLosingFocus { get; private set; }
|
||||
|
||||
|
@ -194,7 +194,7 @@
|
||||
<comment>Date Modified label for the tooltip of preview. {0} is the date.</comment>
|
||||
</data>
|
||||
<data name="PreviewTooltip_Dimensions" xml:space="preserve">
|
||||
<value>Dimensions: {0} x {1}</value>
|
||||
<value>Dimensions: {0} × {1}</value>
|
||||
<comment>Dimensions label for the tooltip of preview. {0} is the width, {1} is the height.</comment>
|
||||
</data>
|
||||
<data name="PreviewTooltip_FileSize" xml:space="preserve">
|
||||
@ -206,7 +206,7 @@
|
||||
<comment>Tooltip of preview when there's no file info available.</comment>
|
||||
</data>
|
||||
<data name="PinButton_Tooltip" xml:space="preserve">
|
||||
<value>Pin the window to the current location</value>
|
||||
<value>Pin the window to the current size</value>
|
||||
<comment>Tooltip for button to pin the Peek window.</comment>
|
||||
</data>
|
||||
<data name="UnpinButton_ToolTip" xml:space="preserve">
|
||||
@ -266,7 +266,7 @@
|
||||
<comment>Title of the Peek window. {0} is the name of the currently previewed item."Peek" is the name of the utility.</comment>
|
||||
</data>
|
||||
<data name="Drive_FreeSpace" xml:space="preserve">
|
||||
<value>{0} free</value>
|
||||
<value>{0} available</value>
|
||||
<comment>{0} is the free space of the drive</comment>
|
||||
</data>
|
||||
<data name="Drive_UsedSpace" xml:space="preserve">
|
||||
|
@ -36,7 +36,7 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
/// <summary>
|
||||
/// Use UISettings to get system colors and scroll bar size.
|
||||
/// </summary>
|
||||
private static UISettings _uISettings = new UISettings();
|
||||
private static readonly UISettings _uISettings = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PdfPreviewHandlerControl"/> class.
|
||||
@ -66,7 +66,7 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
|
||||
try
|
||||
{
|
||||
if (!(dataSource is string filePath))
|
||||
if (dataSource is not string filePath)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(dataSource)} for {nameof(PdfPreviewHandlerControl)} must be a string but was a '{typeof(T)}'");
|
||||
}
|
||||
@ -97,28 +97,26 @@ namespace Microsoft.PowerToys.PreviewHandler.Pdf
|
||||
// Only show first 10 pages.
|
||||
for (uint i = 0; i < pdf.PageCount && i < 10; i++)
|
||||
{
|
||||
using (var page = pdf.GetPage(i))
|
||||
using var page = pdf.GetPage(i);
|
||||
var image = PageToImage(page);
|
||||
|
||||
var picturePanel = new Panel()
|
||||
{
|
||||
var image = PageToImage(page);
|
||||
Name = "picturePanel",
|
||||
Margin = new Padding(6, 6, 6, 0),
|
||||
Size = CalculateSize(image),
|
||||
BorderStyle = BorderStyle.FixedSingle,
|
||||
};
|
||||
|
||||
var picturePanel = new Panel()
|
||||
{
|
||||
Name = "picturePanel",
|
||||
Margin = new Padding(6, 6, 6, 0),
|
||||
Size = CalculateSize(image),
|
||||
BorderStyle = BorderStyle.FixedSingle,
|
||||
};
|
||||
var picture = new PictureBox
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
Image = image,
|
||||
SizeMode = PictureBoxSizeMode.Zoom,
|
||||
};
|
||||
|
||||
var picture = new PictureBox
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
Image = image,
|
||||
SizeMode = PictureBoxSizeMode.Zoom,
|
||||
};
|
||||
|
||||
picturePanel.Controls.Add(picture);
|
||||
_flowLayoutPanel.Controls.Add(picturePanel);
|
||||
}
|
||||
picturePanel.Controls.Add(picture);
|
||||
_flowLayoutPanel.Controls.Add(picturePanel);
|
||||
}
|
||||
|
||||
if (pdf.PageCount > 10)
|
||||
|
Loading…
Reference in New Issue
Block a user