set limit to button size

This commit is contained in:
Paddy Xu
2017-07-29 22:28:48 +03:00
parent 19773884de
commit 882078cd60
3 changed files with 50 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
// Copyright © 2017 Paddy Xu
//
// This file is part of QuickLook program.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Globalization;
using System.Windows.Data;
namespace QuickLook.Converters
{
public class ScaledValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double scalingFactor = 0;
if (parameter != null)
double.TryParse((string) parameter, out scalingFactor);
if (Math.Abs(scalingFactor) < 0.0001)
return double.NaN;
return (double) value * scalingFactor;
}
public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
throw new Exception("The method or operation is not implemented.");
}
}
}

View File

@@ -19,6 +19,7 @@
<converters:BooleanToResizeModeConverter x:Key="BooleanToResizeModeConverter" />
<converters:BooleanToResizeBorderThicknessConverter x:Key="BooleanToResizeBorderThicknessConverter" />
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converters:ScaledValueConverter x:Key="ScaledValueConverter" />
</Window.Resources>
<Window.ResizeMode>
<Binding Converter="{StaticResource BooleanToResizeModeConverter}" ElementName="mainWindow"
@@ -88,13 +89,14 @@
Width="14" Height="14" Margin="10,0,5,0" Foreground="#E5868686"
Cursor="Hand" />
<Button x:Name="buttonOpenWith" DockPanel.Dock="Right" Content="Open with..." Height="20"
Margin="10,0,0,0" Padding="5,0"
Margin="10,0,0,0" Padding="5,0"
MaxWidth="{Binding Width, ElementName=mainWindow, Converter={StaticResource ScaledValueConverter}, ConverterParameter='0.25'}"
Focusable="False" Cursor="Hand"
Background="#E5EEEEEE" BorderBrush="#E59A9A9A"
WindowChrome.IsHitTestVisibleInChrome="True" Foreground="#FF404040">
<Button.ContentTemplate>
<DataTemplate>
<ContentPresenter Content="{Binding}" RecognizesAccessKey="False" />
<TextBlock TextTrimming="CharacterEllipsis" Text="{Binding}" />
</DataTemplate>
</Button.ContentTemplate>
</Button>
@@ -172,7 +174,7 @@
<!-- set grid.background colour makes it clickable -->
<Grid x:Name="titleArea" Background="Transparent">
<TextBlock Text="{Binding ContextObject.Title, ElementName=mainWindow}" FontSize="14"
HorizontalAlignment="Center"
HorizontalAlignment="Center" TextTrimming="CharacterEllipsis"
VerticalAlignment="Center" Margin="5,0" />
</Grid>
</DockPanel>

View File

@@ -108,6 +108,7 @@
<Compile Include="Converters\BooleanToResizeModeConverter.cs" />
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
<Compile Include="Converters\BooleanToResizeBorderThicknessConverter.cs" />
<Compile Include="Converters\ScaledValueConverter.cs" />
<Compile Include="FocusMonitor.cs" />
<Compile Include="Helpers\AutoStartupHelper.cs" />
<Compile Include="Controls\BackgroundVisualHost.cs" />