1.1.3
This commit is contained in:
1 parent
9b9ac36261
commit
5bdc851fa0
13 files changed
+129
-35
No files matched your search
@@ -298,11 +298,12 @@ public partial class App : Application
|
||||
Bind(Settings.WindowHotkey, BeginWindowSnip);
|
||||
Bind(Settings.RecordHotkey, () => Recorder.Toggle(ScreencastFormat.Mp4));
|
||||
Bind(Settings.GifHotkey, () => Recorder.Toggle(ScreencastFormat.Gif));
|
||||
Bind(Settings.ClipboardHotkey, OpenFromClipboard);
|
||||
HotkeyHook.Bindings = bindings;
|
||||
}
|
||||
|
||||
_tray?.SetHotkeys(HotkeyDisplay(Settings.SnipHotkey), HotkeyDisplay(Settings.WindowHotkey),
|
||||
HotkeyDisplay(Settings.RecordHotkey), HotkeyDisplay(Settings.GifHotkey));
|
||||
HotkeyDisplay(Settings.RecordHotkey), HotkeyDisplay(Settings.GifHotkey), HotkeyDisplay(Settings.ClipboardHotkey));
|
||||
}
|
||||
|
||||
/// <summary>Start een screencast: eerst het gebied kiezen, daarna de knoppenbalk.</summary>
|
||||
|
||||
@@ -41,33 +41,14 @@ internal static class ClipboardImageReader
|
||||
return null;
|
||||
}
|
||||
|
||||
if (includeFiles && TryReadFile(data) is { } fromFile)
|
||||
if (ReadData(data, includeFiles) is { } image)
|
||||
{
|
||||
return fromFile;
|
||||
return image;
|
||||
}
|
||||
|
||||
if (data.GetDataPresent("PNG") && data.GetData("PNG") is MemoryStream png)
|
||||
if (Clipboard.ContainsImage() && Clipboard.GetImage() is { } bitmap)
|
||||
{
|
||||
return PixelUtil.Decode(png);
|
||||
}
|
||||
|
||||
if (data.GetDataPresent(DataFormats.Dib) && data.GetData(DataFormats.Dib) is MemoryStream dib)
|
||||
{
|
||||
BitmapSource? fromDib = FromDib(dib.ToArray());
|
||||
if (fromDib != null)
|
||||
{
|
||||
return fromDib;
|
||||
}
|
||||
}
|
||||
|
||||
if (Clipboard.ContainsImage())
|
||||
{
|
||||
BitmapSource? image = Clipboard.GetImage();
|
||||
if (image != null)
|
||||
{
|
||||
var copy = PixelUtil.CreateBitmap(PixelUtil.ToOpaqueBgra(image), image.PixelWidth, image.PixelHeight);
|
||||
return copy;
|
||||
}
|
||||
return OpaqueCopy(bitmap);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is COMException or ExternalException or NotSupportedException or FileFormatException)
|
||||
@@ -78,6 +59,64 @@ internal static class ClipboardImageReader
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Snelle controle tijdens het slepen, zonder te decoderen.</summary>
|
||||
public static bool CanDrop(IDataObject data)
|
||||
{
|
||||
try
|
||||
{
|
||||
return data.GetDataPresent("PNG") || data.GetDataPresent(DataFormats.Dib) || data.GetDataPresent(DataFormats.Bitmap)
|
||||
|| (data.GetData(DataFormats.FileDrop) is string[] files && Array.Exists(files, IsImageFile));
|
||||
}
|
||||
catch (Exception ex) when (ex is COMException or ExternalException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Afbeelding uit iets dat in kniip is neergezet: een afbeeldingsbestand of afbeeldingsdata.</summary>
|
||||
public static BitmapSource? FromDrop(IDataObject data)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ReadData(data, includeFiles: true) is { } image)
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
return data.GetData(DataFormats.Bitmap) is BitmapSource bitmap ? OpaqueCopy(bitmap) : null;
|
||||
}
|
||||
catch (Exception ex) when (ex is COMException or ExternalException or NotSupportedException or FileFormatException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static BitmapSource? ReadData(IDataObject data, bool includeFiles)
|
||||
{
|
||||
if (includeFiles && TryReadFile(data) is { } fromFile)
|
||||
{
|
||||
return fromFile;
|
||||
}
|
||||
|
||||
if (data.GetDataPresent("PNG") && data.GetData("PNG") is MemoryStream png)
|
||||
{
|
||||
return PixelUtil.Decode(png);
|
||||
}
|
||||
|
||||
if (data.GetDataPresent(DataFormats.Dib) && data.GetData(DataFormats.Dib) is MemoryStream dib)
|
||||
{
|
||||
return FromDib(dib.ToArray());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BitmapSource OpaqueCopy(BitmapSource image) =>
|
||||
PixelUtil.CreateBitmap(PixelUtil.ToOpaqueBgra(image), image.PixelWidth, image.PixelHeight);
|
||||
|
||||
private static bool IsImageFile(string file) =>
|
||||
Array.IndexOf(ImageExtensions, Path.GetExtension(file).ToLowerInvariant()) >= 0;
|
||||
|
||||
private static BitmapSource? TryReadFile(IDataObject data)
|
||||
{
|
||||
if (!data.GetDataPresent(DataFormats.FileDrop) || data.GetData(DataFormats.FileDrop) is not string[] files)
|
||||
@@ -87,7 +126,7 @@ internal static class ClipboardImageReader
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (!File.Exists(file) || Array.IndexOf(ImageExtensions, Path.GetExtension(file).ToLowerInvariant()) < 0)
|
||||
if (!File.Exists(file) || !IsImageFile(file))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
Title="kniip" Width="1180" Height="780" MinWidth="760" MinHeight="420"
|
||||
WindowStartupLocation="CenterScreen" Background="{StaticResource WindowBrush}"
|
||||
FontFamily="Segoe UI" FontSize="13" UseLayoutRounding="True"
|
||||
Icon="pack://application:,,,/AppIcon.ico">
|
||||
Icon="pack://application:,,,/AppIcon.ico"
|
||||
AllowDrop="True" PreviewDragEnter="Window_PreviewDragOver" PreviewDragOver="Window_PreviewDragOver" PreviewDrop="Window_PreviewDrop">
|
||||
<Window.Resources>
|
||||
<local:CornerPreviewConverter x:Key="CornerPreview" />
|
||||
<local:CursorIconConverter x:Key="CursorIcon" />
|
||||
|
||||
@@ -1595,6 +1595,36 @@ public partial class EditorWindow : Window
|
||||
ReplaceWith(image, "Wil je doorgaan en de afbeelding van het klembord openen?");
|
||||
}
|
||||
|
||||
private void Window_PreviewDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
if (!ClipboardImageReader.CanDrop(e.Data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
e.Effects = DragDropEffects.Copy;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void Window_PreviewDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (!ClipboardImageReader.CanDrop(e.Data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
BitmapSource? image = ClipboardImageReader.FromDrop(e.Data);
|
||||
if (image == null)
|
||||
{
|
||||
ShowTemporaryHint("Deze afbeelding kon niet worden geopend.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Pas na het slepen vragen: een dialoog tijdens Drop blokkeert Verkenner.
|
||||
Dispatcher.BeginInvoke(() => ReplaceWith(image, "Wil je doorgaan en deze afbeelding openen?"));
|
||||
}
|
||||
|
||||
private void OpenImageFile()
|
||||
{
|
||||
CommitTextEdit();
|
||||
|
||||
@@ -9,6 +9,7 @@ internal sealed class TrayIcon : IDisposable
|
||||
private readonly NotifyIcon _icon;
|
||||
private const string RecordText = "Screencast opnemen (MP4)...";
|
||||
|
||||
private readonly ToolStripMenuItem _clipboardItem;
|
||||
private readonly ToolStripMenuItem _pauseItem;
|
||||
private readonly ToolStripMenuItem _snipItem;
|
||||
private readonly ToolStripMenuItem _windowItem;
|
||||
@@ -28,11 +29,11 @@ internal sealed class TrayIcon : IDisposable
|
||||
public TrayIcon()
|
||||
{
|
||||
var menu = new ContextMenuStrip();
|
||||
var openClipboard = new ToolStripMenuItem("Bewerken vanaf klembord", null, (_, _) => OpenFromClipboardRequested?.Invoke())
|
||||
_clipboardItem = new ToolStripMenuItem("Bewerken vanaf klembord", null, (_, _) => OpenFromClipboardRequested?.Invoke())
|
||||
{
|
||||
Font = new Font(SystemFonts.MenuFont ?? Control.DefaultFont, FontStyle.Bold)
|
||||
};
|
||||
menu.Items.Add(openClipboard);
|
||||
menu.Items.Add(_clipboardItem);
|
||||
menu.Items.Add("Afbeelding openen...", null, (_, _) => OpenFileRequested?.Invoke());
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
_snipItem = new ToolStripMenuItem("Rechthoek knippen", null, (_, _) => SnipRequested?.Invoke());
|
||||
@@ -71,8 +72,9 @@ internal sealed class TrayIcon : IDisposable
|
||||
public bool IsPaused => _pauseItem.Checked;
|
||||
|
||||
/// <summary>Toont de sneltoetsen naast de menu-items; null = geen sneltoets.</summary>
|
||||
public void SetHotkeys(string? snip, string? window, string? record, string? gif)
|
||||
public void SetHotkeys(string? snip, string? window, string? record, string? gif, string? clipboard)
|
||||
{
|
||||
_clipboardItem.ShortcutKeyDisplayString = clipboard;
|
||||
_snipItem.ShortcutKeyDisplayString = snip;
|
||||
_windowItem.ShortcutKeyDisplayString = window;
|
||||
_recordItem.ShortcutKeyDisplayString = record;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Product>kniip</Product>
|
||||
<Description>Annotatie-editor naast het Windows Knipprogramma</Description>
|
||||
<Version>1.1.2</Version>
|
||||
<Version>1.1.3</Version>
|
||||
<SatelliteResourceLanguages>nl;en</SatelliteResourceLanguages>
|
||||
<!-- WPF regelt DPI via app.manifest; de WinForms-analyzer is hier niet van toepassing. -->
|
||||
<NoWarn>$(NoWarn);WFAC010</NoWarn>
|
||||
|
||||
@@ -63,6 +63,9 @@ public sealed class AppSettings
|
||||
|
||||
/// <summary>Sneltoets voor een screencast die als GIF wordt aangeboden.</summary>
|
||||
public string GifHotkey { get; set; } = "Ctrl+Shift+G";
|
||||
|
||||
/// <summary>Sneltoets om de afbeelding op het klembord in de editor te openen; standaard geen.</summary>
|
||||
public string ClipboardHotkey { get; set; } = "";
|
||||
public bool RecordSystemAudio { get; set; } = true;
|
||||
public bool RecordMicrophone { get; set; }
|
||||
public bool RecordShowCursor { get; set; } = true;
|
||||
|
||||
@@ -127,13 +127,20 @@
|
||||
<Button Tag="Record" Style="{StaticResource FlatButton}" Content="Geen" Click="ClearHotkey_Click" Margin="6,0,0,0"
|
||||
ToolTip="Geen sneltoets gebruiken" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,4">
|
||||
<TextBlock Text="Screencast (GIF)" VerticalAlignment="Center" Width="150" />
|
||||
<Button x:Name="GifHotkeyButton" Tag="Gif" Style="{StaticResource SecondaryButton}" Width="170" Margin="0"
|
||||
Click="HotkeyButton_Click" ToolTip="Klik en druk daarna de gewenste toetscombinatie in" />
|
||||
<Button Tag="Gif" Style="{StaticResource FlatButton}" Content="Geen" Click="ClearHotkey_Click" Margin="6,0,0,0"
|
||||
ToolTip="Geen sneltoets gebruiken" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,6">
|
||||
<TextBlock Text="Vanaf klembord" VerticalAlignment="Center" Width="150" />
|
||||
<Button x:Name="ClipboardHotkeyButton" Tag="Clipboard" Style="{StaticResource SecondaryButton}" Width="170" Margin="0"
|
||||
Click="HotkeyButton_Click" ToolTip="Klik en druk daarna de gewenste toetscombinatie in; opent de afbeelding op het klembord" />
|
||||
<Button Tag="Clipboard" Style="{StaticResource FlatButton}" Content="Geen" Click="ClearHotkey_Click" Margin="6,0,0,0"
|
||||
ToolTip="Geen sneltoets gebruiken" />
|
||||
</StackPanel>
|
||||
<TextBlock x:Name="HotkeyHint" Style="{StaticResource Hint}" Margin="0,0,0,4" />
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
@@ -26,6 +26,7 @@ public partial class SettingsWindow : Window
|
||||
["Window"] = "venster knippen",
|
||||
["Record"] = "screencast (MP4)",
|
||||
["Gif"] = "screencast (GIF)",
|
||||
["Clipboard"] = "bewerken vanaf klembord",
|
||||
};
|
||||
|
||||
private readonly AppSettings _settings;
|
||||
@@ -62,6 +63,7 @@ public partial class SettingsWindow : Window
|
||||
["Window"] = WindowHotkeyButton,
|
||||
["Record"] = RecordHotkeyButton,
|
||||
["Gif"] = GifHotkeyButton,
|
||||
["Clipboard"] = ClipboardHotkeyButton,
|
||||
};
|
||||
|
||||
HotkeyHint.Text = App.Instance.HotkeyHook?.IsActive == true
|
||||
@@ -105,6 +107,7 @@ public partial class SettingsWindow : Window
|
||||
_hotkeys["Window"] = settings.WindowHotkey;
|
||||
_hotkeys["Record"] = settings.RecordHotkey;
|
||||
_hotkeys["Gif"] = settings.GifHotkey;
|
||||
_hotkeys["Clipboard"] = settings.ClipboardHotkey;
|
||||
foreach (string id in _hotkeys.Keys)
|
||||
{
|
||||
ShowHotkey(id);
|
||||
@@ -438,6 +441,7 @@ public partial class SettingsWindow : Window
|
||||
_settings.WindowHotkey = _hotkeys["Window"];
|
||||
_settings.RecordHotkey = _hotkeys["Record"];
|
||||
_settings.GifHotkey = _hotkeys["Gif"];
|
||||
_settings.ClipboardHotkey = _hotkeys["Clipboard"];
|
||||
_settings.RecordSystemAudio = SystemAudioBox.IsChecked == true;
|
||||
_settings.RecordMicrophone = MicrophoneBox.IsChecked == true;
|
||||
_settings.RecordShowCursor = ShowCursorBox.IsChecked == true;
|
||||
|
||||
Reference in new issue
Block a user