mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-24 02:00:55 +08:00
add 1px border for keeping resizing
This commit is contained in:
@@ -22,19 +22,26 @@ using System.Windows.Data;
|
||||
|
||||
namespace QuickLook.Converters
|
||||
{
|
||||
public sealed class BooleanToResizeBorderThicknessConverter : DependencyObject, IValueConverter
|
||||
public sealed class BooleanAndWindowStateToThicknessConverter : DependencyObject, IMultiValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return 0;
|
||||
var zero = new Thickness();
|
||||
var def = parameter as Thickness? ?? new Thickness();
|
||||
|
||||
var v = (bool) value;
|
||||
if (values == null || values.Length != 2)
|
||||
return zero;
|
||||
|
||||
return v ? 6 : 0;
|
||||
var canResize = values[0] as bool? ?? false;
|
||||
var state = values[1] as WindowState? ?? WindowState.Normal;
|
||||
|
||||
if (!canResize)
|
||||
return zero;
|
||||
|
||||
return state == WindowState.Maximized ? zero : def;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
// 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;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace QuickLook.Converters
|
||||
{
|
||||
public sealed class BooleanToResizeModeConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return ResizeMode.CanResize;
|
||||
|
||||
var v = (bool) value;
|
||||
|
||||
return v ? ResizeMode.CanResize : ResizeMode.NoResize;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
// 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;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace QuickLook.Converters
|
||||
{
|
||||
public sealed class WindowStateToThicknessConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var def = parameter as Thickness? ?? new Thickness();
|
||||
|
||||
if (value == null)
|
||||
return def;
|
||||
|
||||
return (WindowState) value == WindowState.Maximized ? new Thickness(0) : def;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,8 +118,6 @@
|
||||
</Compile>
|
||||
<Compile Include="Controls\MainWindowBase.cs" />
|
||||
<Compile Include="Converters\BooleanToKeyTimeConverter.cs" />
|
||||
<Compile Include="Converters\WindowStateToThicknessConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToResizeModeConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToVisibilityCollapsedConverter.cs" />
|
||||
<Compile Include="Converters\BooleanToResizeBorderThicknessConverter.cs" />
|
||||
<Compile Include="Converters\ScaledValueConverter.cs" />
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<Thickness x:Key="MainWindowShadowMarginThinkness">1</Thickness>
|
||||
<Thickness x:Key="MainWindowResizeThinkness">6</Thickness>
|
||||
<system:Double x:Key="MainWindowCaptionHeight">32</system:Double>
|
||||
<Color x:Key="MainWindowShadowColor">Gray</Color>
|
||||
<SolidColorBrush x:Key="MainWindowBackground" Color="#FFFAFAFA" />
|
||||
|
||||
@@ -13,31 +13,41 @@
|
||||
MinWidth="400" MinHeight="200"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Focusable="False" WindowStyle="None"
|
||||
Background="Transparent"
|
||||
Background="{DynamicResource CaptionBackground}"
|
||||
ShowActivated="False" ShowInTaskbar="False">
|
||||
<controls:MainWindowBase.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:BooleanToResizeModeConverter x:Key="BooleanToResizeModeConverter" />
|
||||
<converters:WindowStateToThicknessConverter x:Key="WindowStateToThicknessConverter" />
|
||||
<converters:BooleanToResizeBorderThicknessConverter x:Key="BooleanToResizeBorderThicknessConverter" />
|
||||
<converters:BooleanAndWindowStateToThicknessConverter x:Key="BooleanAndWindowStateToThicknessConverter" />
|
||||
<converters:BooleanToVisibilityCollapsedConverter x:Key="BooleanToVisibilityCollapsedConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
</ResourceDictionary>
|
||||
</controls:MainWindowBase.Resources>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" CornerRadius="0" GlassFrameThickness="0,0,0,1"
|
||||
ResizeBorderThickness="{Binding ContextObject.CanResize, Converter={StaticResource BooleanToResizeBorderThicknessConverter}, ElementName=mainWindow}"
|
||||
UseAeroCaptionButtons="False" />
|
||||
UseAeroCaptionButtons="False">
|
||||
<WindowChrome.ResizeBorderThickness>
|
||||
<MultiBinding Converter="{StaticResource BooleanAndWindowStateToThicknessConverter}" ConverterParameter="{StaticResource MainWindowResizeThinkness}">
|
||||
<Binding ElementName="mainWindow" Path="ContextObject.CanResize" />
|
||||
<Binding ElementName="mainWindow" Path="WindowState" />
|
||||
</MultiBinding>
|
||||
</WindowChrome.ResizeBorderThickness>
|
||||
</WindowChrome>
|
||||
</WindowChrome.WindowChrome>
|
||||
<controls:MainWindowBase.Style>
|
||||
<Style TargetType="controls:MainWindowBase">
|
||||
<Setter Property="Foreground" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Style>
|
||||
</controls:MainWindowBase.Style>
|
||||
<Grid x:Name="windowFrameContainer" Background="{DynamicResource MainWindowBackground}">
|
||||
<Grid x:Name="windowFrameContainer" Background="{DynamicResource CaptionBackground}">
|
||||
<Grid.Margin>
|
||||
<MultiBinding Converter="{StaticResource BooleanAndWindowStateToThicknessConverter}" ConverterParameter="{StaticResource MainWindowShadowMarginThinkness}">
|
||||
<Binding ElementName="mainWindow" Path="ContextObject.CanResize" />
|
||||
<Binding ElementName="mainWindow" Path="WindowState" />
|
||||
</MultiBinding>
|
||||
</Grid.Margin>
|
||||
<Grid x:Name="viewerRootContainer" ZIndex="190">
|
||||
<Grid x:Name="windowCaptionContainer" Height="{StaticResource MainWindowCaptionHeight}"
|
||||
VerticalAlignment="Top"
|
||||
|
||||
@@ -138,7 +138,8 @@ namespace QuickLook
|
||||
|
||||
WindowState = WindowState.Normal;
|
||||
|
||||
DragMove();
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
DragMove();
|
||||
}
|
||||
|
||||
private void WindowDragMoveStart(object sender, MouseButtonEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user