Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified to avoid binding-related warning messages when running the editor #974

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ScreenToGif/ScreenToGif.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@
<Compile Include="Model\ExportPresets\Video\Webm\FfmpegWebmPreset.cs" />
<Compile Include="Model\ExportPresets\Video\Webm\WebmPreset.cs" />
<Compile Include="Settings\Migrations\Migration2_31_0To2_32_0.cs" />
<Compile Include="Util\Converters\DoubleToNotNanDouble.cs" />
<Compile Include="ViewModel\FrameViewModel.cs" />
<Compile Include="ViewModel\Tasks\ResizeViewModel.cs" />
<Compile Include="ViewModel\Tasks\ShadowViewModel.cs" />
Expand Down
33 changes: 33 additions & 0 deletions ScreenToGif/Util/Converters/DoubleToNotNanDouble.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace ScreenToGif.Util.Converters
{
/// <summary>
/// Double to NotNanDouble converter.
/// </summary>
public class DoubleToNotNanDouble : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var number = value as double?;

if (!number.HasValue || Double.IsNaN(number.Value))
return DependencyProperty.UnsetValue;

return number;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var number = value as double?;

if (!number.HasValue || Double.IsNaN(number.Value))
return DependencyProperty.UnsetValue;

return number;
}
}
}
5 changes: 3 additions & 2 deletions ScreenToGif/Windows/Editor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<c:BoolAndToVisibility x:Key="BoolAndToVisibility"/>
<c:IntToBool x:Key="IntToBool"/>
<c:BoolAndOrOrToVisibility x:Key="BoolAndOrOrToVisibility"/>
<c:DoubleToNotNanDouble x:Key="DoubleToNotNanDouble"/>

<Storyboard x:Key="ShowPanelStoryboard">
<BooleanAnimationUsingKeyFrames Storyboard.TargetName="ActionGrid" Storyboard.TargetProperty="IsHitTestVisible" Duration="0:0:0" >
Expand Down Expand Up @@ -1335,8 +1336,8 @@
<Grid x:Name="BorderPreviewGrid" VerticalAlignment="Center" HorizontalAlignment="Center"
Visibility="{Binding ElementName=BorderGrid, Path=Visibility}" Background="White">
<Border x:Name="BorderBehindOverlayBorder" VerticalAlignment="Center" HorizontalAlignment="Center"
MinWidth="{Binding ElementName=CaptionOverlayGrid, Path=Width, FallbackValue=0}"
MinHeight="{Binding ElementName=CaptionOverlayGrid, Path=Height, FallbackValue=0}"
MinWidth="{Binding ElementName=CaptionOverlayGrid, Path=Width, FallbackValue=0, Converter={StaticResource DoubleToNotNanDouble}}"
MinHeight="{Binding ElementName=CaptionOverlayGrid, Path=Height, FallbackValue=0, Converter={StaticResource DoubleToNotNanDouble}}"
BorderBrush="{Binding ElementName=BorderColorBox, Path=SelectedBrush}">
<Border.BorderThickness>
<MultiBinding Converter="{StaticResource DoubleToThicknessConverter}" ConverterParameter="-">
Expand Down