Skip to content

Commit 694713b

Browse files
committed
set limit to button size
1 parent a5df208 commit 694713b

3 files changed

Lines changed: 50 additions & 3 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright © 2017 Paddy Xu
2+
//
3+
// This file is part of QuickLook program.
4+
//
5+
// This program is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
using System;
19+
using System.Globalization;
20+
using System.Windows.Data;
21+
22+
namespace QuickLook.Converters
23+
{
24+
public class ScaledValueConverter : IValueConverter
25+
{
26+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
27+
{
28+
double scalingFactor = 0;
29+
if (parameter != null)
30+
double.TryParse((string) parameter, out scalingFactor);
31+
32+
if (Math.Abs(scalingFactor) < 0.0001)
33+
return double.NaN;
34+
35+
return (double) value * scalingFactor;
36+
}
37+
38+
public object ConvertBack(object value, Type targetType, object parameter,
39+
CultureInfo culture)
40+
{
41+
throw new Exception("The method or operation is not implemented.");
42+
}
43+
}
44+
}

QuickLook/MainWindowTransparent.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<converters:BooleanToResizeModeConverter x:Key="BooleanToResizeModeConverter" />
2020
<converters:BooleanToResizeBorderThicknessConverter x:Key="BooleanToResizeBorderThicknessConverter" />
2121
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
22+
<converters:ScaledValueConverter x:Key="ScaledValueConverter" />
2223
</Window.Resources>
2324
<Window.ResizeMode>
2425
<Binding Converter="{StaticResource BooleanToResizeModeConverter}" ElementName="mainWindow"
@@ -88,13 +89,14 @@
8889
Width="14" Height="14" Margin="10,0,5,0" Foreground="#E5868686"
8990
Cursor="Hand" />
9091
<Button x:Name="buttonOpenWith" DockPanel.Dock="Right" Content="Open with..." Height="20"
91-
Margin="10,0,0,0" Padding="5,0"
92+
Margin="10,0,0,0" Padding="5,0"
93+
MaxWidth="{Binding Width, ElementName=mainWindow, Converter={StaticResource ScaledValueConverter}, ConverterParameter='0.25'}"
9294
Focusable="False" Cursor="Hand"
9395
Background="#E5EEEEEE" BorderBrush="#E59A9A9A"
9496
WindowChrome.IsHitTestVisibleInChrome="True" Foreground="#FF404040">
9597
<Button.ContentTemplate>
9698
<DataTemplate>
97-
<ContentPresenter Content="{Binding}" RecognizesAccessKey="False" />
99+
<TextBlock TextTrimming="CharacterEllipsis" Text="{Binding}" />
98100
</DataTemplate>
99101
</Button.ContentTemplate>
100102
</Button>
@@ -172,7 +174,7 @@
172174
<!-- set grid.background colour makes it clickable -->
173175
<Grid x:Name="titleArea" Background="Transparent">
174176
<TextBlock Text="{Binding ContextObject.Title, ElementName=mainWindow}" FontSize="14"
175-
HorizontalAlignment="Center"
177+
HorizontalAlignment="Center" TextTrimming="CharacterEllipsis"
176178
VerticalAlignment="Center" Margin="5,0" />
177179
</Grid>
178180
</DockPanel>

QuickLook/QuickLook.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
<Compile Include="Converters\BooleanToResizeModeConverter.cs" />
109109
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
110110
<Compile Include="Converters\BooleanToResizeBorderThicknessConverter.cs" />
111+
<Compile Include="Converters\ScaledValueConverter.cs" />
111112
<Compile Include="FocusMonitor.cs" />
112113
<Compile Include="Helpers\AutoStartupHelper.cs" />
113114
<Compile Include="Controls\BackgroundVisualHost.cs" />

0 commit comments

Comments
 (0)