Skip to content

Commit

Permalink
Fixes for v2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
NickeManarin committed Mar 18, 2018
1 parent cf2f157 commit b8e801c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
13 changes: 7 additions & 6 deletions ScreenToGif/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
<DropShadowEffect x:Key="Shadow.Black.Dark" ShadowDepth="0" Color="#FF000000" Opacity=".5" BlurRadius="2" RenderingBias="Quality"/>
<DropShadowEffect x:Key="Shadow.Black.Large" ShadowDepth="0" Color="#FF000000" Opacity=".35" BlurRadius="5" RenderingBias="Quality"/>

<DropShadowEffect x:Key="Shadow.Grey" ShadowDepth="0" Color="#FFBEBEBE" Opacity=".5" BlurRadius="2" RenderingBias="Quality"/>
<DropShadowEffect x:Key="Shadow.Grey" ShadowDepth="0" Color="#FFBEBEBE" Opacity=".5" BlurRadius="3" RenderingBias="Quality"/>

<DropShadowEffect x:Key="Shadow.Foreground.Large" ShadowDepth="0" Color="{Binding ForegroundColor, RelativeSource={RelativeSource TemplatedParent}}" Opacity=".35" BlurRadius="5" RenderingBias="Quality"/>
<DropShadowEffect x:Key="Shadow.Foreground" ShadowDepth="0" Color="{Binding ForegroundColor, RelativeSource={RelativeSource TemplatedParent}}" Opacity=".35" BlurRadius="3" RenderingBias="Quality"/>
<DropShadowEffect x:Key="Shadow.Foreground.Normal" ShadowDepth="0" Color="{Binding ForegroundColor, RelativeSource={RelativeSource TemplatedParent}}" Opacity=".2" BlurRadius="3" RenderingBias="Quality"/>
Expand Down Expand Up @@ -359,11 +359,12 @@
<Setter Property="Foreground" Value="#FF5D5D5D"/>
<Setter Property="MinWidth" Value="20"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Effect" Value="{DynamicResource Shadow.Grey}"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolTip}">
<Border BorderBrush="#FFBEBEBE" BorderThickness="1" Effect="{DynamicResource Shadow.Grey}" Margin="2" Background="White" Padding="5">
<Border BorderBrush="#FFBEBEBE" BorderThickness="1" Margin="2" Background="White" Padding="5">
<ContentPresenter Content="{TemplateBinding Content}" Width="Auto" HorizontalAlignment="Center"/>
</Border>
</ControlTemplate>
Expand All @@ -377,12 +378,13 @@
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Grid.IsSharedSizeScope" Value="true" />
<Setter Property="Placement" Value="Bottom"/>
<Setter Property="HorizontalOffset" Value="-5"/>
<Setter Property="HorizontalOffset" Value="-3"/>
<Setter Property="Effect" Value="{DynamicResource Shadow.Grey}"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border x:Name="Border" BorderBrush="#FFBEBEBE" BorderThickness="1" Effect="{DynamicResource Shadow.Grey}" Margin="2" Background="White">
<Border x:Name="Border" BorderBrush="#FFBEBEBE" BorderThickness="1" Margin="2" Background="White">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
</Border>
</ControlTemplate>
Expand Down Expand Up @@ -1087,7 +1089,6 @@
</ContextMenu>
</n:NotifyIcon.ContextMenu>
</n:NotifyIcon>

</ResourceDictionary>
</Application.Resources>
</Application>
2 changes: 1 addition & 1 deletion ScreenToGif/Controls/NotifyIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private void RemoveTaskbarIcon()

public Native.PointW GetDeviceCoordinates(Native.PointW point)
{
var dpi = this.Scale();
var dpi = Other.ScaleOfSystem();
return new Native.PointW { X = (int)(point.X / dpi), Y = (int)(point.Y / dpi) };
}

Expand Down
8 changes: 0 additions & 8 deletions ScreenToGif/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,3 @@ _VS 2017 and .Net 4.6.1 or newer required._
♠ When saving a gif using the overwrite option while the output file has a usage lock, no error appears.
♠ The Cinemagraph feature is broken for high DPI PCs.
♠ The Gifski integration does not accept saving something in a path with Chinese characters, for example: "回复".



### To Test:

• When removing a setting from the settings file, try removing from a unformatted file.
• DoubleBox (decimals stuff).
• Progress percentage (localization).
23 changes: 21 additions & 2 deletions ScreenToGif/Util/Other.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
Expand Down Expand Up @@ -186,6 +185,16 @@ public static double Dpi(this Window window)
return 96d;
}

/// <summary>
/// Gets the DPI of the system.
/// </summary>
/// <returns>The DPI of the system.</returns>
public static double DpiOfSystem()
{
using (var source = new HwndSource(new HwndSourceParameters()))
return 96d * (source.CompositionTarget?.TransformToDevice.M11 ?? 1D);
}

/// <summary>
/// Gets the scale of the current window.
/// </summary>
Expand All @@ -201,10 +210,20 @@ public static double Scale(this Visual window)
return 1d;
}

/// <summary>
/// Gets the scale of the system.
/// </summary>
/// <returns>The scale of the system.</returns>
public static double ScaleOfSystem()
{
using (var source = new HwndSource(new HwndSourceParameters()))
return source.CompositionTarget?.TransformToDevice.M11 ?? 1D;
}

public static string Remove(this string text, params string[] keys)
{
if (text == null)
throw new ArgumentNullException("text", "The text should not be null.");
throw new ArgumentNullException(nameof(text), "The text should not be null.");

foreach (var key in keys)
text = text.Replace(key, string.Empty);
Expand Down

0 comments on commit b8e801c

Please sign in to comment.