Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
NickeManarin committed Jun 20, 2021
2 parents f61ed91 + a5b4ce1 commit ca3c658
Show file tree
Hide file tree
Showing 72 changed files with 2,003 additions and 1,507 deletions.
86 changes: 86 additions & 0 deletions ScreenToGif/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<c:InvertedEnumToBool x:Key="InvertedEnumToBool"/>
<c:BoolAndToVisibility x:Key="BoolAndToVisibility"/>
<c:ContentToVisibility x:Key="ContentToVisibility"/>
<c:UriToBitmap x:Key="UriToBitmapConverter"/>

<!--Effects-->
<DropShadowEffect x:Key="Shadow.Invariant" ShadowDepth="0" Color="Transparent" Opacity="0" BlurRadius="0" RenderingBias="Performance"/>
Expand Down Expand Up @@ -1119,6 +1120,91 @@
</Setter.Value>
</Setter>

<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Padding" Value="4,1"/>
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource Style.FocusVisual.NoMargin}"/>

<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>

<Setter Property="Background" Value="{DynamicResource Item.MouseOver.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Item.MouseOver.Border}"/>
</MultiTrigger>

<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelectionActive" Value="False"/>
<Condition Property="IsSelected" Value="True"/>
</MultiTrigger.Conditions>

<Setter Property="Background" Value="{DynamicResource Item.SelectedInactive.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Item.SelectedInactive.Border}"/>
</MultiTrigger>

<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelectionActive" Value="True"/>
<Condition Property="IsSelected" Value="True"/>
</MultiTrigger.Conditions>

<Setter Property="Background" Value="{DynamicResource Item.SelectedActive.Background}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Item.SelectedActive.Border}"/>
</MultiTrigger>

<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.7"/>
</Trigger>
</Style.Triggers>
</Style>
</Setter.Value>
</Setter>

<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border x:Name="Bd" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem}, Path=BorderBrush}"
BorderThickness="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem}, Path=BorderThickness}"
Background="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem}, Path=Background}" MinWidth="80"
Padding="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem}, Path=Padding}" SnapsToDevicePixels="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Viewbox x:Name="ViewBoxInternal" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Uniform" StretchDirection="Both" MaxWidth="100" MaxHeight="100" Effect="{x:Null}">
<Image Source="{Binding Image, Converter={StaticResource UriToBitmapConverter}, ConverterParameter=100}" Width="Auto" Height="Auto" Effect="{DynamicResource Shadow.Border.Large}"/>
</Viewbox>

<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<TextBlock x:Name="NumberLabel" Text="{Binding Number, StringFormat={}{0:0}}" Foreground="{DynamicResource Element.Foreground.Gray112}"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" Padding="0"/>

<TextBlock x:Name="DelayLabel" Grid.Column="1" Text="{Binding Delay, StringFormat={}{0:0 'ms'}}" Foreground="{DynamicResource Element.Foreground.Gray112}"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" Padding="0" FontSize="11" FontWeight="Normal" FontStyle="Italic"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListView}">
Expand Down
53 changes: 16 additions & 37 deletions ScreenToGif/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ private void App_Startup(object sender, StartupEventArgs e)

if (version > new Version(4, 7, 2))
SetSecurityProtocol();

//Parse arguments.
Argument.Prepare(e.Args);
Arguments.Prepare(e.Args);

LocalizationHelper.SelectCulture(UserSettings.All.LanguageCode);
ThemeHelper.SelectTheme(UserSettings.All.MainTheme);
Expand All @@ -68,12 +68,12 @@ private void App_Startup(object sender, StartupEventArgs e)

#region Download mode

if (Argument.IsInDownloadMode)
if (Arguments.IsInDownloadMode)
{
var downloader = new Downloader
{
DownloadMode = Argument.DownloadMode,
DestinationPath = Argument.DownloadPath
DownloadMode = Arguments.DownloadMode,
DestinationPath = Arguments.DownloadPath
};
downloader.ShowDialog();

Expand All @@ -85,7 +85,7 @@ private void App_Startup(object sender, StartupEventArgs e)

#region Settings persistence mode

if (Argument.IsInSettingsMode)
if (Arguments.IsInSettingsMode)
{
SettingsPersistenceChannel.RegisterServer();
return;
Expand All @@ -98,7 +98,7 @@ private void App_Startup(object sender, StartupEventArgs e)
//The singleton works on a per-user and per-executable mode.
//Meaning that a different user and/or a different executable intances can co-exist.
//Part of this code wont work on debug mode, since the SetForegroundWindow() needs focus on the foreground window calling the method.
if (UserSettings.All.SingleInstance)
if (UserSettings.All.SingleInstance && !Arguments.NewInstance)
{
try
{
Expand Down Expand Up @@ -240,36 +240,10 @@ private void App_Startup(object sender, StartupEventArgs e)

#region Startup

//When starting minimized, the
if (UserSettings.All.StartMinimized)
return;

if (UserSettings.All.StartUp == 4 || Argument.FileNames.Any())
{
MainViewModel.OpenEditor.Execute(null);
return;
}

if (UserSettings.All.StartUp < 1 || UserSettings.All.StartUp > 4)
{
MainViewModel.OpenLauncher.Execute(null);
return;
}

if (UserSettings.All.StartUp == 1)
{
MainViewModel.OpenRecorder.Execute(null);
return;
}

if (UserSettings.All.StartUp == 2)
{
MainViewModel.OpenWebcamRecorder.Execute(null);
return;
}

if (UserSettings.All.StartUp == 3)
MainViewModel.OpenBoardRecorder.Execute(null);
if (Arguments.Open)
MainViewModel.Open.Execute(Arguments.WindownToOpen, true);
else
MainViewModel.Open.Execute(UserSettings.All.StartUp);

#endregion
}
Expand Down Expand Up @@ -334,7 +308,12 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
{
if (e.Category == UserPreferenceCategory.General)
{
ThemeHelper.SelectTheme(UserSettings.All.MainTheme);
var isSystemUsingDark = ThemeHelper.IsSystemUsingDarkTheme();
UserSettings.All.GridColor1 = isSystemUsingDark ? Constants.DarkEven : Constants.VeryLightEven;
UserSettings.All.GridColor2 = isSystemUsingDark ? Constants.DarkOdd : Constants.VeryLightOdd;
}
}

private void App_Exit(object sender, ExitEventArgs e)
Expand Down
87 changes: 0 additions & 87 deletions ScreenToGif/Controls/FrameListBoxItem.cs

This file was deleted.

6 changes: 6 additions & 0 deletions ScreenToGif/Controls/TextPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ protected override void OnRender(DrawingContext drawingContext)

protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
if (!IsVisible)
{
base.OnPropertyChanged(e);
return;
}

try
{
_textGeometry = new FormattedText(Text ?? "", Thread.CurrentThread.CurrentUICulture, FlowDirection.LeftToRight,
Expand Down
4 changes: 2 additions & 2 deletions ScreenToGif/ImageUtil/ImageMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ public static List<FrameInfo> CutUnchanged(List<FrameInfo> listToEncode, int id,
/// <param name="first">The first frame to compare.</param>
/// <param name="second">The second frame to compare.</param>
/// <returns>The similarity between the two frames in percentage.</returns>
public static double CalculateDifference(FrameInfo first, FrameInfo second)
public static decimal CalculateDifference(FrameInfo first, FrameInfo second)
{
using (var imageAux1 = first.Path.From())
using (var imageAux2 = second.Path.From())
Expand All @@ -1104,7 +1104,7 @@ public static double CalculateDifference(FrameInfo first, FrameInfo second)
.AsParallel()
.Count();

return MathHelper.CrossMultiplication(pixelCount, pixelCount - changedPixelCount, null);
return MathHelper.CrossMultiplication((decimal)pixelCount, pixelCount - changedPixelCount, null);
}
}

Expand Down
7 changes: 7 additions & 0 deletions ScreenToGif/Interfaces/IPersistent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace ScreenToGif.Interfaces
{
interface IPersistent
{
void Persist();
}
}
Loading

0 comments on commit ca3c658

Please sign in to comment.