Skip to content

Commit 998e619

Browse files
committed
Merge branch 'dev'
2 parents 22a10b4 + 60af34d commit 998e619

29 files changed

+562
-86
lines changed

ScreenToGif.Model/Enums/EncoderTypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ public enum EncoderTypes
55
ScreenToGif, //Gif, Apng
66
KGySoft, // Gif
77
System, //Gif, Video
8-
FFmpeg, //Gif, Webp, Apng, Video
8+
FFmpeg, //Gif, Webp, Apng, Avif, Video
99
Gifski //Gif
1010
}

ScreenToGif.Model/Enums/ExportFormats.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public enum ExportFormats
2222
/// </summary>
2323
Bpg,
2424

25+
/// <summary>
26+
/// AV1 Still Image Format.
27+
/// </summary>
28+
Avif,
2529

2630
/// <summary>
2731
/// Audio Video Interleaved.

ScreenToGif.Model/ScreenToGif.Domain.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<DebugType>embedded</DebugType>
77
<UseWPF>True</UseWPF>
88
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
9-
<Version>2.41.1</Version>
9+
<Version>2.41.2</Version>
1010
</PropertyGroup>
1111
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1212
<UseVSHostingProcess>true</UseVSHostingProcess>

ScreenToGif.Native/ScreenToGif.Native.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<UseWindowsForms>True</UseWindowsForms>
77
<DebugType>embedded</DebugType>
88
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
9-
<Version>2.41.1</Version>
9+
<Version>2.41.2</Version>
1010
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
1111
</PropertyGroup>
1212
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

ScreenToGif.Util/Converters/ShortcutSelection.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Globalization;
32
using System.Windows;
43
using System.Windows.Data;
@@ -61,7 +60,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
6160
return Key.F2;
6261
case 2:
6362
return Key.F3;
64-
case 13:
63+
case 3:
6564
return Key.F4;
6665
case 4:
6766
return Key.F5;
@@ -78,7 +77,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
7877
case 10:
7978
return Key.F11;
8079
case 11:
81-
return Key.F11;
80+
return Key.F12;
8281
}
8382

8483
return Key.F1;

ScreenToGif.Util/PathHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ public static class PathHelper
1414
/// <returns>The name with the date and time.</returns>
1515
public static string ReplaceRegexInName(string name)
1616
{
17-
const string dateTimeFileNameRegEx = @"[?]([ymdhsfzgkt]+[-_ ]*)+[?]";
17+
//Less than 2 question marks? Then it's not valid.
18+
if (name.Split('?').Length - 1 < 2)
19+
return name;
20+
21+
const string dateTimeFileNameRegEx = "[?]([ymdhsfzgkt]{1,6}[-_ ]{0,2}){1,10}[?]";
1822

1923
if (!Regex.IsMatch(name, dateTimeFileNameRegEx, RegexOptions.IgnoreCase))
2024
return name;

ScreenToGif.Util/ScreenToGif.Util.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<UseWPF>True</UseWPF>
66
<DebugType>embedded</DebugType>
77
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
8-
<Version>2.41.1</Version>
8+
<Version>2.41.2</Version>
99
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
1010
<!--<UseWindowsForms>True</UseWindowsForms>-->
1111
</PropertyGroup>

ScreenToGif.Util/Settings/UserSettings.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,15 @@ private static ResourceDictionary Load(string path)
102102
#region Load settings from disk
103103

104104
var doc = XDocument.Parse(File.ReadAllText(path));
105-
var properties = doc.Root?.Elements().Select(GetProperty).ToList();
105+
var properties = doc.Root?.Elements().Select(GetProperty).ToList() ?? [];
106106

107107
#endregion
108108

109-
#region Migrate
110-
111-
var version = properties?.FirstOrDefault(f => f.Key == "Version")?.Value ?? "0.0";
109+
//Migrate
110+
var version = properties.FirstOrDefault(f => f.Key == "Version")?.Value ?? "0.0";
112111

113112
Migration.Migrate(properties, version);
114113

115-
#endregion
116-
117114
#region Parse settings
118115

119116
//Since the settings were migrated, add the current version.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using ScreenToGif.Domain.Enums;
2+
using ScreenToGif.ViewModel.ExportPresets.Video;
3+
4+
namespace ScreenToGif.ViewModel.ExportPresets.AnimatedImage.Avif;
5+
6+
public class AvifPreset : AnimatedImagePreset
7+
{
8+
public AvifPreset()
9+
{
10+
Type = ExportFormats.Avif;
11+
DefaultExtension = ".avif";
12+
Extension = ".avif";
13+
}
14+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
using ScreenToGif.Domain.Enums;
2+
using ScreenToGif.Domain.Interfaces;
3+
using ScreenToGif.ViewModel.ExportPresets.AnimatedImage.Webp;
4+
using System.Runtime.Serialization;
5+
6+
namespace ScreenToGif.ViewModel.ExportPresets.AnimatedImage.Avif;
7+
8+
public class FfmpegAvifPreset : AvifPreset, IFfmpegPreset
9+
{
10+
private VideoSettingsModes _settingsMode = VideoSettingsModes.Normal;
11+
private string _parameters = "-vsync passthrough \n{I} \n-c:v libaom-av1 \n-quality 75 \n-loop 0 \n-f avif \n{O}";
12+
private VideoCodecPresets _codecPreset = VideoCodecPresets.Default;
13+
private int _quality = 75; // A lower value may be better for the default
14+
private VideoCodecs _videoCodec = VideoCodecs.LibAom;
15+
private HardwareAccelerationModes _hardwareAcceleration = HardwareAccelerationModes.Auto;
16+
private VideoPixelFormats _pixelFormat = VideoPixelFormats.Auto;
17+
private Framerates _framerate = Framerates.Auto;
18+
private double _customFramerate = 25d;
19+
private Vsyncs _vsync = Vsyncs.Passthrough;
20+
21+
public VideoSettingsModes SettingsMode
22+
{
23+
get => _settingsMode;
24+
set => SetProperty(ref _settingsMode, value);
25+
}
26+
27+
[DataMember(EmitDefaultValue = false)]
28+
public string Parameters
29+
{
30+
get => _parameters;
31+
set => SetProperty(ref _parameters, value);
32+
}
33+
34+
public VideoCodecPresets CodecPreset
35+
{
36+
get => _codecPreset;
37+
set => SetProperty(ref _codecPreset, value);
38+
}
39+
40+
public int Quality
41+
{
42+
get => _quality;
43+
set => SetProperty(ref _quality, value);
44+
}
45+
46+
public VideoCodecs VideoCodec
47+
{
48+
get => _videoCodec;
49+
set => SetProperty(ref _videoCodec, value);
50+
}
51+
52+
public HardwareAccelerationModes HardwareAcceleration
53+
{
54+
get => _hardwareAcceleration;
55+
set => SetProperty(ref _hardwareAcceleration, value);
56+
}
57+
58+
public VideoPixelFormats PixelFormat
59+
{
60+
get => _pixelFormat;
61+
set => SetProperty(ref _pixelFormat, value);
62+
}
63+
64+
public Framerates Framerate
65+
{
66+
get => _framerate;
67+
set => SetProperty(ref _framerate, value);
68+
}
69+
70+
public double CustomFramerate
71+
{
72+
get => _customFramerate;
73+
set => SetProperty(ref _customFramerate, value);
74+
}
75+
76+
public Vsyncs Vsync
77+
{
78+
get => _vsync;
79+
set => SetProperty(ref _vsync, value);
80+
}
81+
82+
83+
public FfmpegAvifPreset()
84+
{
85+
Encoder = EncoderTypes.FFmpeg;
86+
ImageId = "Vector.Ffmpeg";
87+
IsEncoderExpanded = false;
88+
RequiresFfmpeg = true;
89+
}
90+
91+
public static List<FfmpegAvifPreset> Defaults => new()
92+
{
93+
new FfmpegAvifPreset
94+
{
95+
TitleKey = "S.Preset.Default.Title",
96+
DescriptionKey = "S.Preset.Default.Description",
97+
HasAutoSave = true,
98+
IsSelectedForEncoder = true,
99+
IsDefault = true,
100+
CreationDate = new DateTime(2024, 09, 18)
101+
},
102+
};
103+
}

ScreenToGif.ViewModel/ExportPresets/Video/Codecs/X265.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@ public X265()
1616
CodecPresets = new List<EnumItem<VideoCodecPresets>>
1717
{
1818
new(VideoCodecPresets.None, "S.SaveAs.VideoOptions.CodecPreset.None", ""),
19-
new(VideoCodecPresets.Default, "S.SaveAs.VideoOptions.CodecPreset.Default", "default"),
20-
new(VideoCodecPresets.Lossless, "S.SaveAs.VideoOptions.CodecPreset.Lossless", "lossless"),
21-
new(VideoCodecPresets.LosslessHP, "S.SaveAs.VideoOptions.CodecPreset.LosslessHp", "losslesshp"),
19+
new(VideoCodecPresets.Slow, "S.SaveAs.VideoOptions.CodecPreset.Placebo", "placebo"),
20+
new(VideoCodecPresets.Slow, "S.SaveAs.VideoOptions.CodecPreset.VerySlow", "veryslow"),
21+
new(VideoCodecPresets.Slow, "S.SaveAs.VideoOptions.CodecPreset.Slower", "slower"),
2222
new(VideoCodecPresets.Slow, "S.SaveAs.VideoOptions.CodecPreset.Slow", "slow"),
2323
new(VideoCodecPresets.Medium, "S.SaveAs.VideoOptions.CodecPreset.Medium", "medium"),
2424
new(VideoCodecPresets.Fast, "S.SaveAs.VideoOptions.CodecPreset.Fast", "fast"),
25-
new(VideoCodecPresets.HP, "S.SaveAs.VideoOptions.CodecPreset.Hp", "hp"),
26-
new(VideoCodecPresets.HQ, "S.SaveAs.VideoOptions.CodecPreset.Hq", "hq"),
27-
new(VideoCodecPresets.BD, "S.SaveAs.VideoOptions.CodecPreset.Bd", "bd"),
28-
new(VideoCodecPresets.LowLatency, "S.SaveAs.VideoOptions.CodecPreset.LowLatency", "ll"),
29-
new(VideoCodecPresets.LowLatencyHP, "S.SaveAs.VideoOptions.CodecPreset.LowLatencyHp", "llhp"),
30-
new(VideoCodecPresets.LowLatencyHQ, "S.SaveAs.VideoOptions.CodecPreset.LowLatencyHq", "llhq")
25+
new(VideoCodecPresets.Fast, "S.SaveAs.VideoOptions.CodecPreset.Faster", "faster"),
26+
new(VideoCodecPresets.Fast, "S.SaveAs.VideoOptions.CodecPreset.VeryFast", "veryfast"),
27+
new(VideoCodecPresets.Fast, "S.SaveAs.VideoOptions.CodecPreset.SuperFast", "superfast"),
28+
new(VideoCodecPresets.Fast, "S.SaveAs.VideoOptions.CodecPreset.UltraFast", "ultrafast"),
3129
};
3230
PixelFormats = new List<EnumItem<VideoPixelFormats>>
3331
{

ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Nullable>disable</Nullable>
66
<DebugType>embedded</DebugType>
77
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
8-
<Version>2.41.1</Version>
8+
<Version>2.41.2</Version>
99
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
1010
</PropertyGroup>
1111
<ItemGroup>

ScreenToGif/Controls/DynamicGrid.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ public class DynamicGrid : Grid
88
{
99
#region Dependency Properties
1010

11-
public static readonly DependencyProperty FirstColumnProperty = DependencyProperty.Register("FirstColumn", typeof(int), typeof(DynamicGrid),
11+
public static readonly DependencyProperty FirstColumnProperty = DependencyProperty.Register(nameof(FirstColumn), typeof(int), typeof(DynamicGrid),
1212
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsMeasure), ValidateFirstColumn);
1313

14-
public static readonly DependencyProperty ColumnsProperty = DependencyProperty.Register("Columns", typeof(int), typeof(DynamicGrid), new
14+
public static readonly DependencyProperty ColumnsProperty = DependencyProperty.Register(nameof(Columns), typeof(int), typeof(DynamicGrid), new
1515
FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsMeasure), ValidateColumns);
1616

17-
public static readonly DependencyProperty RowsProperty = DependencyProperty.Register("Rows", typeof(int), typeof(DynamicGrid),
17+
public static readonly DependencyProperty RowsProperty = DependencyProperty.Register(nameof(Rows), typeof(int), typeof(DynamicGrid),
1818
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsMeasure), ValidateRows);
1919

20-
public static readonly DependencyProperty IsReversedProperty = DependencyProperty.Register("IsReversed", typeof(bool), typeof(DynamicGrid),
21-
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsMeasure));
20+
public static readonly DependencyProperty IsReversedProperty = DependencyProperty.Register(nameof(IsReversed), typeof(bool), typeof(DynamicGrid),
21+
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange));
2222

2323
#endregion
2424

ScreenToGif/Controls/ExtendedUniformGrid.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ScreenToGif.Controls;
77
public class ExtendedUniformGrid : UniformGrid
88
{
99
public static readonly DependencyProperty IsReversedProperty = DependencyProperty.Register(nameof(IsReversed), typeof(bool), typeof(ExtendedUniformGrid),
10-
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsMeasure));
10+
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsArrange));
1111

1212
//private static void IsReversed_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
1313
//{

ScreenToGif/Controls/NotifyIcon.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Windows.Interop;
1010
using System.Windows.Media;
1111
using ScreenToGif.Domain.Enums;
12+
using ScreenToGif.Domain.Enums.Native;
1213
using ScreenToGif.ImageUtil;
1314
using ScreenToGif.Native.External;
1415
using ScreenToGif.Native.Helpers;
@@ -275,7 +276,7 @@ private static void VisibilityPropertyChanged(DependencyObject o, DependencyProp
275276

276277
private static void DataContextPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
277278
{
278-
if (!(o is NotifyIcon control))
279+
if (o is not NotifyIcon control)
279280
return;
280281

281282
control.UpdateDataContext(control.NotifyToolTipElement, e.OldValue, e.NewValue);
@@ -286,7 +287,7 @@ private static void ContextMenuPropertyChanged(DependencyObject o, DependencyPro
286287
{
287288
var control = o as NotifyIcon;
288289

289-
if (!(e.NewValue is ContextMenu newValue))
290+
if (e.NewValue is not ContextMenu newValue)
290291
return;
291292

292293
control?.UpdateDataContext(newValue, null, control.DataContext);
@@ -303,7 +304,7 @@ private static void IconSourcePropertyChanged(DependencyObject d, DependencyProp
303304

304305
private static void ToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
305306
{
306-
if (!(d is NotifyIcon owner))
307+
if (d is not NotifyIcon owner)
307308
return;
308309

309310
owner.CreateCustomToolTip();
@@ -312,7 +313,7 @@ private static void ToolTipPropertyChanged(DependencyObject d, DependencyPropert
312313

313314
private static void ToolTipTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
314315
{
315-
if (!(d is NotifyIcon owner))
316+
if (d is not NotifyIcon owner)
316317
return;
317318

318319
if (owner.NotifyToolTip == null)
@@ -359,14 +360,11 @@ private void CreateTaskbarIcon()
359360
if (IsTaskbarIconCreated)
360361
return;
361362

362-
//Initial configuration.
363-
var status = NotifyIconHelper.WriteIconData(ref _iconData, Domain.Enums.Native.NotifyCommands.Add, Domain.Enums.Native.IconDataMembers.Message | Domain.Enums.Native.IconDataMembers.Icon | Domain.Enums.Native.IconDataMembers.Tip);
363+
_iconData.VersionOrTimeout = (uint)NotifyIconVersions.Vista;
364+
_iconData.ValidMembers = IconDataMembers.Icon | IconDataMembers.Tip | IconDataMembers.Message;
365+
_iconData.ToolTipText = NotifyToolTipText;
364366

365-
if (!status)
366-
return;
367-
368-
_iconData.VersionOrTimeout = (uint)Domain.Enums.Native.NotifyIconVersions.Vista;
369-
status = Shell32.Shell_NotifyIcon(Domain.Enums.Native.NotifyCommands.SetVersion, ref _iconData);
367+
var status = Shell32.Shell_NotifyIcon(NotifyCommands.Add, ref _iconData);
370368

371369
if (!status)
372370
return;
@@ -452,18 +450,17 @@ private void CreateCustomToolTip()
452450
UpdateDataContext(tt, null, DataContext);
453451

454452
//Store a reference to the used tooltip.
455-
SetValue(NotifyToolTipElementPropertyKey, tt);
453+
//SetValue(NotifyToolTipElementPropertyKey, tt);
456454
}
457455

458456
private void WriteToolTipSettings()
459457
{
460-
_iconData.ToolTipText = NotifyToolTipText;
461-
462-
//To get ToolTip events from the taskbar, set a dummy text.
463-
if (string.IsNullOrEmpty(_iconData.ToolTipText) && NotifyToolTipElement != null)
464-
_iconData.ToolTipText = "ToolTip";
465-
466-
NotifyIconHelper.WriteIconData(ref _iconData, Domain.Enums.Native.NotifyCommands.Modify, Domain.Enums.Native.IconDataMembers.Tip);
458+
lock (this)
459+
{
460+
_iconData.ToolTipText = NotifyToolTipText;
461+
462+
Shell32.Shell_NotifyIcon(NotifyCommands.Modify, ref _iconData);
463+
}
467464
}
468465

469466
public void RefreshVisual()

ScreenToGif/Resources/Localization/StringResources.cs.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,8 @@
14941494
<s:String x:Key="S.SaveAs.Gif.Info">Graphics Interchange Format</s:String>
14951495
<s:String x:Key="S.SaveAs.Webp">Webp</s:String>
14961496
<s:String x:Key="S.SaveAs.Webp.Info">Web Picture</s:String>
1497+
<s:String x:Key="S.SaveAs.Avif">Avif</s:String>
1498+
<s:String x:Key="S.SaveAs.Avif.Info">AV1 Image File Format</s:String>
14971499

14981500
<s:String x:Key="S.SaveAs.Avi">AVI</s:String>
14991501
<s:String x:Key="S.SaveAs.Avi.Info">Audio Video Interleave</s:String>

0 commit comments

Comments
 (0)