Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
NickeManarin committed Mar 24, 2024
2 parents 4baa71b + 1037dae commit eea0d53
Show file tree
Hide file tree
Showing 29 changed files with 254 additions and 63 deletions.
4 changes: 3 additions & 1 deletion ScreenToGif.Model/Enums/MouseButtons.cs
Expand Up @@ -5,5 +5,7 @@ public enum MouseButtons
None,
Left,
Middle,
Right
Right,
FirstExtra,
SecondExtra,
}
2 changes: 1 addition & 1 deletion ScreenToGif.Model/ScreenToGif.Domain.csproj
Expand Up @@ -6,7 +6,7 @@
<DebugType>embedded</DebugType>
<UseWPF>True</UseWPF>
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
<Version>2.40.1</Version>
<Version>2.41.0</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<UseVSHostingProcess>true</UseVSHostingProcess>
Expand Down
2 changes: 1 addition & 1 deletion ScreenToGif.Native/ScreenToGif.Native.csproj
Expand Up @@ -6,7 +6,7 @@
<UseWindowsForms>True</UseWindowsForms>
<DebugType>embedded</DebugType>
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
<Version>2.40.1</Version>
<Version>2.41.0</Version>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
Expand Up @@ -18,8 +18,7 @@ public static class InstanceSwitcherChannel

private static PipeServer<InstanceSwitcherMessage> _server;
private static Action<object, InstanceSwitcherMessage> _receivedAction;



public static void RegisterServer(Action<object, InstanceSwitcherMessage> receivedAction)
{
try
Expand Down
19 changes: 13 additions & 6 deletions ScreenToGif.Util/InterProcessChannel/PipeServer.cs
Expand Up @@ -35,16 +35,23 @@ public void Stop()

private async void ServerLoop()
{
while (true)
while (!_source.IsCancellationRequested)
{
await _pipe.WaitForConnectionAsync(_source.Token);
try
{
await _pipe.WaitForConnectionAsync(_source.Token);

var message = await JsonSerializer.DeserializeAsync<TMessage>(_pipe, (JsonSerializerOptions) null, _source.Token);
var message = await JsonSerializer.DeserializeAsync<TMessage>(_pipe, (JsonSerializerOptions)null, _source.Token);

_pipe.Disconnect();
_pipe.Disconnect();

if (message != null)
_synchronizationContext.Post(OnMessageReceived, message);
if (message != null)
_synchronizationContext.Post(OnMessageReceived, message);
}
catch (Exception)
{
//Ignore.
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions ScreenToGif.Util/ScreenToGif.Util.csproj
Expand Up @@ -5,12 +5,12 @@
<UseWPF>True</UseWPF>
<DebugType>embedded</DebugType>
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
<Version>2.40.1</Version>
<Version>2.41.0</Version>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
<!--<UseWindowsForms>True</UseWindowsForms>-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="KGySoft.CoreLibraries" Version="7.0.0" />
<PackageReference Include="KGySoft.CoreLibraries" Version="8.1.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
18 changes: 18 additions & 0 deletions ScreenToGif.Util/Settings/UserSettings.cs
Expand Up @@ -759,6 +759,12 @@ public bool CheckForUpdates
set => SetValue(value);
}

public bool DownloadWithMeteredNetwork
{
get => (bool)GetValue();
set => SetValue(value);
}

public bool PortableUpdate
{
get => (bool)GetValue();
Expand Down Expand Up @@ -2400,6 +2406,18 @@ public Color MiddleMouseButtonClicksColor
set => SetValue(value);
}

public Color FirstExtraMouseButtonClicksColor
{
get => (Color)GetValue();
set => SetValue(value);
}

public Color SecondExtraMouseButtonClicksColor
{
get => (Color)GetValue();
set => SetValue(value);
}

public double MouseEventsWidth
{
get => (double)GetValue();
Expand Down
Expand Up @@ -31,6 +31,7 @@ public class KGySoftGifPreset : GifPreset
private bool _allowDeltaFrames = true;
private bool _allowClippedFrames = true;
private byte _deltaTolerance;
private bool _linearColorSpace;

#endregion

Expand All @@ -45,36 +46,43 @@ public class KGySoftGifPreset : GifPreset
{
new KGySoftGifPreset
{
TitleKey = "S.Preset.Gif.KGySoft.Balanced.Title",
DescriptionKey = "S.Preset.Gif.KGySoft.Balanced.Description",
TitleKey = "S.Preset.Gif.KGySoft.Default.Title",
DescriptionKey = "S.Preset.Gif.KGySoft.Default.Description",
HasAutoSave = true,
IsSelected = true,
IsDefault = true,
IsSelectedForEncoder = true,
CreationDate = new DateTime(2021, 12, 15),
QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.Wu)}",
CreationDate = new DateTime(2024, 1, 25),
QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.MedianCut)}",
},
// Leaving here for reference because if someone already has a saved config with it, then it's still relevant.
//new KGySoftGifPreset
//{
// TitleKey = "S.Preset.Gif.KGySoft.Balanced.Title",
// DescriptionKey = "S.Preset.Gif.KGySoft.Balanced.Description",
// HasAutoSave = true,
// IsDefault = true,
// CreationDate = new DateTime(2021, 12, 15),
// QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.Wu)}",
//},
new KGySoftGifPreset
{
TitleKey = "S.Preset.Gif.KGySoft.High.Title",
DescriptionKey = "S.Preset.Gif.KGySoft.High.Description",
HasAutoSave = true,
IsSelected = true,
IsDefault = true,
IsSelectedForEncoder = true,
CreationDate = new DateTime(2021, 12, 15),
QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.Wu)}",
DithererId = $"{nameof(ErrorDiffusionDitherer)}.{nameof(ErrorDiffusionDitherer.FloydSteinberg)}",
BitLevel = 7,
LinearColorSpace = true
},
new KGySoftGifPreset
{
TitleKey = "S.Preset.Gif.KGySoft.Fast.Title",
DescriptionKey = "S.Preset.Gif.KGySoft.Fast.Description",
HasAutoSave = true,
IsSelected = true,
IsDefault = true,
IsSelectedForEncoder = true,
CreationDate = new DateTime(2021, 12, 15),
QuantizerId = $"{nameof(PredefinedColorsQuantizer)}.{nameof(PredefinedColorsQuantizer.SystemDefault8BppPalette)}",
DithererId = $"{nameof(OrderedDitherer)}.{nameof(OrderedDitherer.Bayer8x8)}",
Expand Down Expand Up @@ -155,6 +163,15 @@ public int PaletteSize
set => SetProperty(ref _bitLevel, value);
}

/// <summary>
/// Gets or sets whether the quantizing is processed in the linear color space (as opposed to sRGB).
/// </summary>
public bool LinearColorSpace
{
get => _linearColorSpace;
set => SetProperty(ref _linearColorSpace, value);
}

#endregion

#region Ditherer Settings
Expand Down
4 changes: 2 additions & 2 deletions ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj
Expand Up @@ -5,11 +5,11 @@
<Nullable>disable</Nullable>
<DebugType>embedded</DebugType>
<Platforms>AnyCPU;ARM64;x64;x86</Platforms>
<Version>2.40.1</Version>
<Version>2.41.0</Version>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="KGySoft.Drawing.Core" Version="7.0.0" />
<PackageReference Include="KGySoft.Drawing.Core" Version="8.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ScreenToGif.Model\ScreenToGif.Domain.csproj" />
Expand Down
28 changes: 24 additions & 4 deletions ScreenToGif.ViewModel/Tasks/MouseEventsViewModel.cs
Expand Up @@ -7,10 +7,12 @@ namespace ScreenToGif.ViewModel.Tasks;

public class MouseEventsViewModel : BaseTaskViewModel
{
private Color _highlightForegroundColor;
private Color _leftButtonForegroundColor;
private Color _rightButtonForegroundColor;
private Color _middleButtonForegroundColor;
private Color _highlightForegroundColor;
private Color _firstExtraButtonForegroundColor;
private Color _secondExtraButtonForegroundColor;
private double _width;
private double _height;

Expand Down Expand Up @@ -43,6 +45,18 @@ public Color MiddleButtonForegroundColor
set => SetProperty(ref _middleButtonForegroundColor, value);
}

public Color FirstExtraButtonForegroundColor
{
get => _firstExtraButtonForegroundColor;
set => SetProperty(ref _firstExtraButtonForegroundColor, value);
}

public Color SecondExtraButtonForegroundColor
{
get => _secondExtraButtonForegroundColor;
set => SetProperty(ref _secondExtraButtonForegroundColor, value);
}

public double Width
{
get => _width;
Expand All @@ -58,9 +72,11 @@ public double Height
public override string ToString()
{
return $"{LocalizationHelper.Get("S.MouseHighlight.Color")} #{HighlightForegroundColor.A:X2}{HighlightForegroundColor.R:X2}{HighlightForegroundColor.G:X2}{HighlightForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.MouseClicks.Color.Left")} #{LeftButtonForegroundColor.A:X2}{LeftButtonForegroundColor.R:X2}{LeftButtonForegroundColor.G:X2}{LeftButtonForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.MouseClicks.Color.Middle")} #{MiddleButtonForegroundColor.A:X2}{MiddleButtonForegroundColor.R:X2}{MiddleButtonForegroundColor.G:X2}{MiddleButtonForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.MouseClicks.Color.Left")} #{LeftButtonForegroundColor.A:X2}{LeftButtonForegroundColor.R:X2}{LeftButtonForegroundColor.G:X2}{LeftButtonForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.MouseClicks.Color.Right")} #{RightButtonForegroundColor.A:X2}{RightButtonForegroundColor.R:X2}{RightButtonForegroundColor.G:X2}{RightButtonForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.MouseClicks.Color.Middle")} #{MiddleButtonForegroundColor.A:X2}{MiddleButtonForegroundColor.R:X2}{MiddleButtonForegroundColor.G:X2}{MiddleButtonForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.MouseClicks.Color.FirstExtra")} #{FirstExtraButtonForegroundColor.A:X2}{FirstExtraButtonForegroundColor.R:X2}{FirstExtraButtonForegroundColor.G:X2}{FirstExtraButtonForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.MouseClicks.Color.SecondExtra")} #{SecondExtraButtonForegroundColor.A:X2}{SecondExtraButtonForegroundColor.R:X2}{SecondExtraButtonForegroundColor.G:X2}{SecondExtraButtonForegroundColor.B:X2}, " +
$"{LocalizationHelper.Get("S.FreeDrawing.Width")} {Width}, {LocalizationHelper.Get("S.FreeDrawing.Height")} {Height}";
}

Expand All @@ -72,6 +88,8 @@ public static MouseEventsViewModel Default()
LeftButtonForegroundColor = Color.FromArgb(120, 255, 255, 0),
RightButtonForegroundColor = Color.FromArgb(120, 255, 0, 0),
MiddleButtonForegroundColor = Color.FromArgb(120, 0, 255, 255),
FirstExtraButtonForegroundColor = Color.FromArgb(120, 255, 0, 128),
SecondExtraButtonForegroundColor = Color.FromArgb(120, 255, 128, 0),
Height = 12,
Width = 12
};
Expand All @@ -83,8 +101,10 @@ public static MouseEventsViewModel FromSettings()
{
HighlightForegroundColor = UserSettings.All.MouseHighlightColor,
LeftButtonForegroundColor = UserSettings.All.LeftMouseButtonClicksColor,
MiddleButtonForegroundColor = UserSettings.All.MiddleMouseButtonClicksColor,
RightButtonForegroundColor = UserSettings.All.RightMouseButtonClicksColor,
MiddleButtonForegroundColor = UserSettings.All.MiddleMouseButtonClicksColor,
FirstExtraButtonForegroundColor = UserSettings.All.FirstExtraMouseButtonClicksColor,
SecondExtraButtonForegroundColor = UserSettings.All.SecondExtraMouseButtonClicksColor,
Height = UserSettings.All.MouseEventsHeight,
Width = UserSettings.All.MouseEventsWidth
};
Expand Down
10 changes: 9 additions & 1 deletion ScreenToGif/Resources/Localization/StringResources.en.xaml
Expand Up @@ -261,6 +261,8 @@
<s:String x:Key="S.Options.App.General.PortableUpdate.Info">(Requires a manual installation by unzipping and replacing the executable)</s:String>
<s:String x:Key="S.Options.App.General.ForceUpdateAsAdmin">Force the update to run with elevated privileges.</s:String>
<s:String x:Key="S.Options.App.General.PromptToInstall">Prompt me before the installation starts.</s:String>
<s:String x:Key="S.Options.App.General.DownloadWithMeteredNetwork">Download updates on metered networks.</s:String>
<s:String x:Key="S.Options.App.General.DownloadWithMeteredNetwork.Info">(Allows download of updates on metered networks)</s:String>

<!--Options • Recorder-->
<s:String x:Key="S.Options.Recorder.Interface">Interface</s:String>
Expand Down Expand Up @@ -795,6 +797,8 @@
<s:String x:Key="S.Preset.Gif.Embedded.Transparent.Description">Supports saving the animation with a transparent background.</s:String>
<s:String x:Key="S.Preset.Gif.Embedded.Graphics.Title">High quality • Graphics</s:String>
<s:String x:Key="S.Preset.Gif.Embedded.Graphics.Description">Better for recordings with a lower quantity of colors.</s:String>
<s:String x:Key="S.Preset.Gif.KGySoft.Default.Title">KGy SOFT • Default</s:String>
<s:String x:Key="S.Preset.Gif.KGySoft.Default.Description">Recommended for screen recording of regular UI. Uses Median Cut quantizer without dithering.</s:String>
<s:String x:Key="S.Preset.Gif.KGySoft.Balanced.Title">KGy SOFT • Balanced</s:String>
<s:String x:Key="S.Preset.Gif.KGySoft.Balanced.Description">Good quality for photo-like images using Wu's quantizer without dithering.</s:String>
<s:String x:Key="S.Preset.Gif.KGySoft.High.Title">KGy SOFT • High quality</s:String>
Expand Down Expand Up @@ -1389,6 +1393,8 @@
<s:String x:Key="S.MouseClicks.Color.Left">Left button color:</s:String>
<s:String x:Key="S.MouseClicks.Color.Middle">Middle button color:</s:String>
<s:String x:Key="S.MouseClicks.Color.Right">Right button color:</s:String>
<s:String x:Key="S.MouseClicks.Color.FirstExtra">1st extra button color:</s:String>
<s:String x:Key="S.MouseClicks.Color.SecondExtra">2nd extra button color:</s:String>

<!--Editor • Watermark-->
<s:String x:Key="S.Watermark.Image">Image</s:String>
Expand Down Expand Up @@ -1621,6 +1627,8 @@
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.CustomBitLevel">Custom bit level.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.CustomBitLevel.Info">When checked, the bit level can be configured manually.&#x0d;&#x0a;⚠️ Warning: The highest bit level might require a LOT of memory!</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.BitLevel.Info">Higher value means more accuracy, larger target color space, slower processing and larger memory usage.&#x0d;&#x0a;For example, if 1, then the result can have no more than 8 colors, or when 2, no more than 64 colors.&#x0d;&#x0a;For Octree and Wu quantizers it affects also maximum number of monochromatic shades.&#x0d;&#x0a;For example, if 5 (which is the default for Wu quantizer), only 32 monochromatic shades can be differentiated.&#x0d;&#x0a;⚠️ Caution: The Wu quantizer consumes at least 650 MB with the highest value.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.LinearColorSpace">Linear color space</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.LinearColorSpace.Info">When checked, some operations (alpha blending with background color, quantizing, dithering, looking up the nearest colors in the palette) are performed in the linear color space rather than the sRGB one.&#x0d;&#x0a;Working in the linear color space is slower but provides a better quality result, especially when the quantizer uses only a few colors.&#x0d;&#x0a;&#x0d;&#x0a;⚠️ Remark: When using just a few colors, the brightness of a possibly resized preview may be incorrect because WPF performs resizing in the sRGB color space.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.PredefinedColorsQuantizer.BlackAndWhite">Black and White</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.PredefinedColorsQuantizer.BlackAndWhite.Info">Fixed 1 bpp palette with the black and white colors.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Quantizer.PredefinedColorsQuantizer.Grayscale4">Grayscale 4 colors</s:String>
Expand Down Expand Up @@ -1700,7 +1708,7 @@
<s:String x:Key="S.SaveAs.KGySoft.Animation.LoopCount">Repeat Count:</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Animation.LoopCount.Info">Specifies how many times the animation will be played.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Animation.AllowDeltaFrames">Allow delta frames.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Animation.AllowDeltaFrames.Info">When checked, unchanged pixels are attempted to be detected during the encoding.&#x0d;&#x0a;When using with an optimized quantizer, this option makes possible for a frame to have more than 256 colors.&#x0d;&#x0a;This option is ignored if the quantizer does not use transparency and Allow Clipped Frames is unchecked.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Animation.AllowDeltaFrames.Info">When checked, unchanged pixels are attempted to be detected during the encoding.&#x0d;&#x0a;When using with an optimized quantizer, this option makes possible for a frame to have more than 256 colors.&#x0d;&#x0a;This option is ignored if the quantizer does not use transparency and Allow Clipped Frames is unchecked.&#x0d;&#x0a;&#x0d;&#x0a;⚠️ Remark: This option may cause noticeable artifacts in colors or in the dithering pattern.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Animation.DeltaTolerance">Delta Tolerance:</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Animation.DeltaTolerance.Info">Specifies the maximum tolerance when detecting changed pixels.&#x0d;&#x0a;If 0, then no difference is tolerated at all.&#x0d;&#x0a;If 255, then there might be frames (or even all of them) that are added with no content.&#x0d;&#x0a;Reasonable range is between 0 and 16 for an optimized quantizer. The ones with fixed colors can be used with somewhat larger values with dithering.</s:String>
<s:String x:Key="S.SaveAs.KGySoft.Animation.HighDeltaTolerance">If Delta Tolerance is too high the result might have poor quality. Click to reset delta tolerance.</s:String>
Expand Down

0 comments on commit eea0d53

Please sign in to comment.