Fix #604: use an icon for "Open" to spare more space

This commit is contained in:
Paddy Xu
2020-03-25 15:15:56 +02:00
parent 8ed8f3459e
commit c0d8e79aad
2 changed files with 10 additions and 28 deletions

View File

@@ -193,18 +193,16 @@ namespace QuickLook
buttonShare.Visibility = ShareHelper.IsShareSupported(_path) ? Visibility.Visible : Visibility.Collapsed;
// open icon
buttonOpenText.Inlines.Clear();
if (Directory.Exists(_path))
{
AddToInlines("MW_BrowseFolder", Path.GetFileName(_path));
buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_BrowseFolder"), Path.GetFileName(_path));
return;
}
var isExe = FileHelper.IsExecutable(_path, out var appFriendlyName);
if (isExe)
{
AddToInlines("MW_Run", appFriendlyName);
buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_Run"), appFriendlyName);
return;
}
@@ -212,31 +210,12 @@ namespace QuickLook
var found = FileHelper.GetAssocApplication(_path, out appFriendlyName);
if (found)
{
AddToInlines("MW_OpenWith", appFriendlyName);
buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_OpenWith"), appFriendlyName);
return;
}
// assoc not found
AddToInlines("MW_Open", Path.GetFileName(_path));
void AddToInlines(string str, string replaceWith)
{
// limit str length
if (replaceWith.Length > 16)
replaceWith = replaceWith.Substring(0, 8) + "…" + replaceWith.Substring(replaceWith.Length - 8);
str = TranslationHelper.Get(str);
var elements = str.Split(new[] {"{0}"}, StringSplitOptions.None).ToList();
while (elements.Count < 2)
elements.Add(string.Empty);
buttonOpenText.Inlines.Add(
new Run(elements[0]) {FontWeight = FontWeights.Normal}); // text beforehand
buttonOpenText.Inlines.Add(
new Run(replaceWith) {FontWeight = FontWeights.SemiBold}); // appFriendlyName
buttonOpenText.Inlines.Add(
new Run(elements[1]) {FontWeight = FontWeights.Normal}); // text afterward
}
buttonOpen.ToolTip = string.Format(TranslationHelper.Get("MW_Open"), Path.GetFileName(_path));
}
internal void BeginHide()

View File

@@ -102,14 +102,17 @@
Content="&#xE72D;" ToolTip="Share" />
<Button DockPanel.Dock="Right" x:Name="buttonOpenWith" Style="{StaticResource CaptionButtonStyle}"
Content="&#xE7AC;" ToolTip="Open With" />
<Button x:Name="buttonOpen" DockPanel.Dock="Right"
Style="{StaticResource CaptionTextButtonStyle}">
<Button DockPanel.Dock="Right" x:Name="buttonOpen" Style="{StaticResource CaptionButtonStyle}"
Content="&#xE8E5;" ToolTip="Open with XXX" />
<!--<Button x:Name="buttonOpen" DockPanel.Dock="Right"
Style="{StaticResource CaptionTextButtonStyle}"
Visibility="{Binding ActualWidth, ElementName=windowCaptionContainer, Converter={StaticResource WidthToVisibilityCollapsedConverter}}">
<Button.Content>
<TextBlock x:Name="buttonOpenText" VerticalAlignment="Center">
Open with <Bold>AppName</Bold>
</TextBlock>
</Button.Content>
</Button>
</Button>-->
<Button DockPanel.Dock="Left" x:Name="buttonTop" Tag="Auto" ToolTip="Stay on Top">
<Button.Resources>
<Grid x:Key="ContentTop">