Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b780c6a116 | ||
|
|
67c98c7c0a |
No files matched your search
@@ -2,6 +2,30 @@
|
||||
|
||||
Alle noemenswaardige wijzigingen in kniip staan in dit bestand. De nieuwste versie staat bovenaan.
|
||||
|
||||
## 1.1.4 - 2026-11-09
|
||||
|
||||
### Nieuw
|
||||
|
||||
- **Melding bij een nieuwe versie.** kniip kijkt bij het starten en daarna elke dag of er een nieuwere versie is. Is die er, dan staat er een blauwe stip op de knop **Instellingen** in de editor en op de tab **Update** in de instellingen. Wil je dat niet, zet dan in de tab **Update** het vinkje **Automatisch controleren op nieuwe versies** uit.
|
||||
- **Uitgebreid rechtermuisknopmenu in de editor.** Klik met rechts op het canvas, ook op een leeg stuk, voor een menu met iconen en sneltoetsen. Wat op dat moment niet kan, staat grijs.
|
||||
- **Ongedaan maken** en **Opnieuw**.
|
||||
- **Verwijder**, **Verwijder alles** (Shift+Delete, de afbeelding blijft staan) en **Samenvoegen** (Ctrl+Shift+F). Samenvoegen maakt de annotaties deel van de afbeelding en kun je ongedaan maken.
|
||||
- **Knip** (Ctrl+X), **Kopieer** (Ctrl+Shift+C), **Plak** (Ctrl+V) en **Dupliceren** (Ctrl+D). Plak via het menu zet de annotatie op de plek waar je rechts klikte. Kopiëren en plakken werkt ook tussen twee editorvensters.
|
||||
- **Naar voorgrond** (Home), **Naar voren** (PageUp), **Naar achteren** (PageDown) en **Naar achtergrond** (End).
|
||||
- **Werkbalken verbergen** (Ctrl+H). Via hetzelfde menu of Ctrl+H haal je ze terug. Bij een nieuwe start zijn ze er altijd weer.
|
||||
- **Lijnen en pijlen buigen.** Selecteer een lijn of pijl. Midden op elk stuk staat dan een klein rondje. Sleep dat rondje en het wordt een buigpunt. De lijn loopt daarna als vloeiende kromme door alle punten. Zo kun je zoveel buigpunten toevoegen als je wilt.
|
||||
- Dubbelklik op een buigpunt om het weer te verwijderen.
|
||||
- Bij een pijl draait de punt mee met de richting van het laatste stuk.
|
||||
- Met Shift springen begin- en eindpunt in stappen van 45°, gemeten vanaf het buigpunt ernaast.
|
||||
- Toevoegen, verschuiven en verwijderen van buigpunten kun je ongedaan maken.
|
||||
|
||||
### Gewijzigd
|
||||
|
||||
- kniip zoekt nu standaard zelf op de achtergrond naar updates. Tot nu toe gebeurde dat alleen als je de tab **Update** opende of op **Opnieuw controleren** klikte. Een mislukte controle, bijvoorbeeld zonder internet, geeft geen foutmelding.
|
||||
- **Ctrl+V** plakt nu eerst een gekopieerde annotatie. Heb je daarna iets anders gekopieerd, dan opent Ctrl+V zoals voorheen de afbeelding van het klembord.
|
||||
- Het rechtermuisknopmenu van de werkbalk heeft dezelfde nieuwe stijl gekregen.
|
||||
- **Testversie naast kniip.** `build.ps1` maakt nu ook `KniipTest-<versie>.exe`. Die testversie heeft eigen instellingen en registervermeldingen, zodat hij naast de geïnstalleerde kniip kan draaien zonder die te raken. De testversie werkt zichzelf niet bij. Met `-SkipTest` sla je hem over.
|
||||
|
||||
## 1.1.3 - 2026-11-09
|
||||
|
||||
### Nieuw
|
||||
|
||||
@@ -24,7 +24,7 @@ kniip is een annotatie-editor die naast het Windows Knipprogramma werkt. Maak ee
|
||||
|
||||
| Versie | Installer |
|
||||
| ------ | --------- |
|
||||
| 1.1.3 | [Kniip-Setup-1.1.3.exe](https://git.hibbit.net/rogier/kniip/releases/download/1.1.3/Kniip-Setup-1.1.3.exe) |
|
||||
| 1.1.4 | [Kniip-Setup-1.1.4.exe](https://git.hibbit.net/rogier/kniip/releases/download/1.1.4/Kniip-Setup-1.1.4.exe) |
|
||||
|
||||
Oudere versies vind je bij [alle releases](https://git.hibbit.net/rogier/kniip/releases).
|
||||
|
||||
@@ -70,7 +70,7 @@ Vereisten:
|
||||
Bouwen:
|
||||
|
||||
```powershell
|
||||
.\build.ps1 # versie 1.1.3
|
||||
.\build.ps1 # versie 1.1.4
|
||||
.\build.ps1 -Version 1.2.0 # andere versie
|
||||
```
|
||||
|
||||
@@ -79,6 +79,20 @@ Het script levert op:
|
||||
- `artifacts\publish\Kniip.exe`: zelfstandige exe, draait zonder installatie
|
||||
- `artifacts\Kniip-<versie>.exe`: dezelfde exe, met het versienummer in de naam
|
||||
- `artifacts\Kniip-Setup-<versie>.exe`: de installer (alleen als Inno Setup 6 gevonden is)
|
||||
- `artifacts\KniipTest-<versie>.exe`: testversie (overslaan met `-SkipTest`)
|
||||
|
||||
### Testversie
|
||||
|
||||
De testversie draait naast de geïnstalleerde kniip en raakt die niet aan. Hij gebruikt overal `KniipTest` in plaats van `Kniip`: de autostartregel, de 'Openen met'-registratie (`KniipTest.Image`), de instellingenmap `%APPDATA%\KniipTest` en de single-instance-mutex. Bij de eerste start kopieert hij de instellingen van de gewone kniip. Zichzelf bijwerken doet hij niet, want de installer zou de gewone kniip overschrijven.
|
||||
|
||||
Opruimen hoeft alleen als je in de testversie autostart of 'Openen met' hebt aangezet:
|
||||
|
||||
```powershell
|
||||
.\artifacts\KniipTest-<versie>.exe --unregister
|
||||
Remove-Item "$env:APPDATA\KniipTest" -Recurse # optioneel: instellingen van de testversie
|
||||
```
|
||||
|
||||
Draaien beide versies tegelijk, dan reageren ze allebei op dezelfde sneltoetsen en knipsels. Sluit de gewone kniip tijdens het testen, of kies in de testversie andere sneltoetsen.
|
||||
|
||||
## Een nieuwe versie publiceren
|
||||
|
||||
@@ -91,6 +105,8 @@ Het script levert op:
|
||||
|
||||
Onder **Instellingen > Update** controleert kniip via de API van git.hibbit.net of er een nieuwere release is en toont de changelog van alle nieuwere versies. **Updaten** downloadt de installer, sluit kniip, installeert stil en start kniip opnieuw. De eerder gekozen integraties blijven behouden.
|
||||
|
||||
kniip controleert ook zelf bij het starten en daarna elke 24 uur. Is er een nieuwere versie, dan staat er een blauwe stip op de knop **Instellingen** in de editor en op de tab **Update**. Dit zet je uit met **Automatisch controleren op nieuwe versies** in die tab.
|
||||
|
||||
Voorwaarden:
|
||||
|
||||
- De repository `rogier/kniip` is publiek; kniip gebruikt geen token.
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
# Publiceert kniip als zelfstandige single-file exe (geen .NET-installatie nodig op de doel-pc)
|
||||
# Publiceert kniip als zelfstandige single-file exe (geen .NET-installatie nodig op de doel-pc)
|
||||
# en bouwt de installer als Inno Setup 6 aanwezig is.
|
||||
# ScreenRecorderLib (screencasts) is een C++/CLI-assembly die niet uit de bundel geladen kan worden;
|
||||
# IncludeAllContentForSelfExtract pakt daarom bij de eerste start alles uit naar %TEMP%\.net.
|
||||
#
|
||||
# .\build.ps1 -> artifacts\publish\Kniip.exe (+ installer indien mogelijk)
|
||||
#
|
||||
# Elke build levert ook artifacts\KniipTest-<versie>.exe: een testversie met eigen register-, instellingen-
|
||||
# en mutexnamen (KniipTest), die naast de geïnstalleerde kniip draait zonder diens registratie te raken.
|
||||
#
|
||||
# .\build.ps1 -> artifacts\publish\Kniip.exe (+ installer indien mogelijk) + testexe
|
||||
# .\build.ps1 -Version 1.2.0
|
||||
# .\build.ps1 -SkipTest -> zonder testexe
|
||||
|
||||
param(
|
||||
[string]$Version = "1.1.3",
|
||||
[string]$Runtime = "win-x64"
|
||||
[string]$Version = "1.1.4",
|
||||
[string]$Runtime = "win-x64",
|
||||
[switch]$SkipTest
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = $PSScriptRoot
|
||||
$project = Join-Path $root "src\Kniip\Kniip.csproj"
|
||||
$publishDir = Join-Path $root "artifacts\publish"
|
||||
$testPublishDir = Join-Path $root "artifacts\publish-test"
|
||||
|
||||
# Gebruik een SDK in het gebruikersprofiel als er geen systeembrede SDK is.
|
||||
$localDotnet = Join-Path $env:LOCALAPPDATA "Microsoft\dotnet"
|
||||
@@ -22,9 +30,10 @@ if (-not (dotnet --list-sdks 2>$null) -and (Test-Path (Join-Path $localDotnet "d
|
||||
$env:PATH = "$localDotnet;$env:PATH"
|
||||
}
|
||||
|
||||
if (Test-Path $publishDir) { Remove-Item $publishDir -Recurse -Force }
|
||||
function Publish-Kniip([string]$outputDir, [bool]$test) {
|
||||
if (Test-Path $outputDir) { Remove-Item $outputDir -Recurse -Force }
|
||||
|
||||
dotnet publish (Join-Path $root "src\Kniip\Kniip.csproj") `
|
||||
dotnet publish $project `
|
||||
-c Release -r $Runtime --self-contained true `
|
||||
-p:PublishSingleFile=true `
|
||||
-p:IncludeNativeLibrariesForSelfExtract=true `
|
||||
@@ -32,8 +41,12 @@ dotnet publish (Join-Path $root "src\Kniip\Kniip.csproj") `
|
||||
-p:EnableCompressionInSingleFile=true `
|
||||
-p:DebugType=none `
|
||||
-p:Version=$Version `
|
||||
-o $publishDir
|
||||
if ($LASTEXITCODE -ne 0) { throw "dotnet publish is mislukt." }
|
||||
-p:KniipTest=$($test.ToString().ToLowerInvariant()) `
|
||||
-o $outputDir
|
||||
if ($LASTEXITCODE -ne 0) { throw "dotnet publish is mislukt." }
|
||||
}
|
||||
|
||||
Publish-Kniip $publishDir $false
|
||||
|
||||
Write-Host "Gepubliceerd: $publishDir\Kniip.exe" -ForegroundColor Green
|
||||
|
||||
@@ -55,3 +68,10 @@ if ($iscc) {
|
||||
} else {
|
||||
Write-Host "Inno Setup 6 niet gevonden; installer overgeslagen (winget install JRSoftware.InnoSetup)." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
if (-not $SkipTest) {
|
||||
Publish-Kniip $testPublishDir $true
|
||||
$testExe = Join-Path $root "artifacts\KniipTest-$Version.exe"
|
||||
Copy-Item (Join-Path $testPublishDir "Kniip.exe") $testExe -Force
|
||||
Write-Host "Testversie: $testExe" -ForegroundColor Green
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#define AppName "kniip"
|
||||
#define AppExe "Kniip.exe"
|
||||
#ifndef AppVersion
|
||||
#define AppVersion "1.1.3"
|
||||
#define AppVersion "1.1.4"
|
||||
#endif
|
||||
#ifndef PublishDir
|
||||
#define PublishDir "..\artifacts\publish"
|
||||
|
||||
@@ -293,6 +293,92 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Contextmenu's: icoon, tekst, sneltoets en eventueel een submenu -->
|
||||
<Style TargetType="ContextMenu">
|
||||
<Setter Property="FontFamily" Value="Segoe UI" />
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="Foreground" Value="{StaticResource InkBrush}" />
|
||||
<Setter Property="HasDropShadow" Value="False" />
|
||||
<Setter Property="Grid.IsSharedSizeScope" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ContextMenu">
|
||||
<Border Background="{StaticResource ToolbarBrush}" BorderBrush="#D6D6D6" BorderThickness="1" CornerRadius="8"
|
||||
Padding="4" Margin="0,0,10,10" MinWidth="220">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="12" ShadowDepth="2" Opacity="0.18" />
|
||||
</Border.Effect>
|
||||
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="Separator">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Separator">
|
||||
<Border Height="1" Margin="6,4" Background="{StaticResource DividerBrush}" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="MenuItem">
|
||||
<Setter Property="Foreground" Value="{StaticResource InkBrush}" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="MenuItem">
|
||||
<Border x:Name="Bd" Background="Transparent" CornerRadius="4" Padding="8,6" SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="28" />
|
||||
<ColumnDefinition Width="*" SharedSizeGroup="MenuHeader" />
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuGesture" />
|
||||
<ColumnDefinition Width="16" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter x:Name="IconHost" ContentSource="Icon" VerticalAlignment="Center" HorizontalAlignment="Left" />
|
||||
<TextBlock x:Name="Check" Text="" FontFamily="{StaticResource IconFont}" FontSize="12"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left" Visibility="Collapsed" />
|
||||
<ContentPresenter Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="24,0,0,0"
|
||||
Foreground="{StaticResource SubtleTextBrush}" VerticalAlignment="Center" HorizontalAlignment="Right" />
|
||||
<TextBlock x:Name="Arrow" Grid.Column="3" Text="" FontFamily="{StaticResource IconFont}" FontSize="10"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Visibility="Collapsed" />
|
||||
<Popup x:Name="PART_Popup" Placement="Right" HorizontalOffset="6" VerticalOffset="-6" AllowsTransparency="True"
|
||||
Focusable="False" PopupAnimation="Fade" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<Border Background="{StaticResource ToolbarBrush}" BorderBrush="#D6D6D6" BorderThickness="1" CornerRadius="8"
|
||||
Padding="4" Margin="0,0,10,10" MinWidth="180" Grid.IsSharedSizeScope="True">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="12" ShadowDepth="2" Opacity="0.18" />
|
||||
</Border.Effect>
|
||||
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" />
|
||||
</Border>
|
||||
</Popup>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="Check" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="IconHost" Property="Visibility" Value="Collapsed" />
|
||||
</Trigger>
|
||||
<Trigger Property="HasItems" Value="True">
|
||||
<Setter TargetName="Arrow" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsHighlighted" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{StaticResource HoverBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value="0.4" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PropCombo" TargetType="ComboBox">
|
||||
<Setter Property="MinWidth" Value="80" />
|
||||
<Setter Property="Height" Value="28" />
|
||||
|
||||
@@ -38,6 +38,9 @@ public partial class App : Application
|
||||
/// <summary>Toetsenbordhaak voor alle sneltoetsen (knipsels en screencasts).</summary>
|
||||
internal GlobalHotkeyHook? HotkeyHook { get; private set; }
|
||||
|
||||
/// <summary>Achtergrondcontrole op nieuwe versies; stuurt de blauwe stip bij Instellingen.</summary>
|
||||
public UpdateNotifier Updates { get; } = new();
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
@@ -105,6 +108,7 @@ public partial class App : Application
|
||||
|
||||
HotkeyHook = new GlobalHotkeyHook(Dispatcher);
|
||||
ApplyHotkeys();
|
||||
Updates.Apply(Settings.CheckForUpdates);
|
||||
|
||||
_singleInstance.StartServer(received => Dispatcher.BeginInvoke(() => HandleArguments(received, false)));
|
||||
HandleArguments(args, true);
|
||||
@@ -150,7 +154,7 @@ public partial class App : Application
|
||||
if (isFirstStart)
|
||||
{
|
||||
string? hotkey = HotkeyDisplay(Settings.SnipHotkey);
|
||||
_tray?.ShowBalloon("kniip is actief", hotkey == null
|
||||
_tray?.ShowBalloon($"{AppIdentity.DisplayName} is actief", hotkey == null
|
||||
? "Maak een knipsel met Win + Shift + S. kniip biedt het daarna aan om te bewerken."
|
||||
: $"Druk op {hotkey} en sleep een rechthoek om te knippen en te bewerken.");
|
||||
}
|
||||
@@ -440,6 +444,7 @@ public partial class App : Application
|
||||
SettingsStore.Save(Settings);
|
||||
Capture.ApplySettings(Settings);
|
||||
ApplyHotkeys();
|
||||
Updates.Apply(Settings.CheckForUpdates);
|
||||
}
|
||||
|
||||
private static void BringToFront(Window window)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using Kniip.Editor.Annotations;
|
||||
|
||||
namespace Kniip.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Gekopieerde annotatie, gedeeld tussen editorvensters. Op het Windows-klembord staat alleen een markering,
|
||||
/// zodat iets wat daarna in een ander programma wordt gekopieerd bij plakken voorgaat.
|
||||
/// </summary>
|
||||
internal static class AnnotationClipboard
|
||||
{
|
||||
private const string MarkerFormat = "Kniip.Annotation";
|
||||
|
||||
private static Annotation? _item;
|
||||
private static string? _token;
|
||||
|
||||
public static bool Set(Annotation item)
|
||||
{
|
||||
string token = Guid.NewGuid().ToString("N");
|
||||
if (!ClipboardWriter.SetMarker(MarkerFormat, token))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_item = item.Clone();
|
||||
_token = token;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Een kopie van de annotatie, of null als het klembord inmiddels iets anders bevat.</summary>
|
||||
public static Annotation? Get()
|
||||
{
|
||||
if (_item == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Clipboard.GetData(MarkerFormat) as string == _token ? _item.Clone() : null;
|
||||
}
|
||||
catch (ExternalException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ namespace Kniip.Editor;
|
||||
public sealed class AnnotationSurface : FrameworkElement
|
||||
{
|
||||
private static readonly Brush AccentBrush = RenderHelpers.Freeze(new SolidColorBrush(Palette.Accent));
|
||||
private static readonly Brush GhostHandleBrush = RenderHelpers.Freeze(new SolidColorBrush(Color.FromArgb(170, 255, 255, 255)));
|
||||
private static readonly Brush CropShadeBrush = RenderHelpers.Freeze(new SolidColorBrush(Color.FromArgb(120, 0, 0, 0)));
|
||||
|
||||
public EditorDocument? Document { get; set; }
|
||||
@@ -74,8 +75,16 @@ public sealed class AnnotationSurface : FrameworkElement
|
||||
|
||||
double size = HandleSize;
|
||||
var pen = new Pen(AccentBrush, 1.2 / ViewScale);
|
||||
foreach (Point h in handles)
|
||||
for (int i = 0; i < handles.Count; i++)
|
||||
{
|
||||
Point h = handles[i];
|
||||
if (item.IsGhostHandle(i))
|
||||
{
|
||||
double radius = size * 0.35;
|
||||
dc.DrawEllipse(GhostHandleBrush, pen, h, radius, radius);
|
||||
continue;
|
||||
}
|
||||
|
||||
dc.DrawRoundedRectangle(Brushes.White, pen, new Rect(h.X - size / 2, h.Y - size / 2, size, size),
|
||||
1.5 / ViewScale, 1.5 / ViewScale);
|
||||
}
|
||||
@@ -90,14 +99,20 @@ public sealed class AnnotationSurface : FrameworkElement
|
||||
{
|
||||
IReadOnlyList<Point> handles = item.GetHandles();
|
||||
double tolerance = HandleSize / 2 + 2 / ViewScale;
|
||||
int ghost = -1;
|
||||
for (int i = handles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (System.Math.Abs(handles[i].X - p.X) <= tolerance && System.Math.Abs(handles[i].Y - p.Y) <= tolerance)
|
||||
{
|
||||
if (!item.IsGhostHandle(i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
ghost = i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return ghost;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,9 @@ public abstract class Annotation
|
||||
|
||||
public virtual IReadOnlyList<Point> GetHandles() => Array.Empty<Point>();
|
||||
|
||||
/// <summary>Een greep die pas iets wordt als je hem sleept, zoals het middenpunt om een lijn te buigen.</summary>
|
||||
public virtual bool IsGhostHandle(int index) => false;
|
||||
|
||||
public virtual void BeginHandleDrag(int index)
|
||||
{
|
||||
}
|
||||
@@ -41,6 +44,8 @@ public abstract class Annotation
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool RemoveHandle(int index) => false;
|
||||
|
||||
/// <summary>Te klein om te bewaren na het tekenen (bijv. een losse klik met het rechthoek-gereedschap).</summary>
|
||||
public virtual bool IsDegenerate => false;
|
||||
|
||||
|
||||
@@ -5,8 +5,16 @@ using System.Windows.Media;
|
||||
|
||||
namespace Kniip.Editor.Annotations;
|
||||
|
||||
/// <summary>
|
||||
/// Lijn of pijl. Met buigpunten wordt het een vloeiende kromme die door alle punten loopt.
|
||||
/// </summary>
|
||||
public sealed class LineAnnotation : Annotation
|
||||
{
|
||||
private const int SamplesPerSegment = 16;
|
||||
|
||||
private int _dragBend = -1;
|
||||
private int _pendingGhost = -1;
|
||||
|
||||
public LineAnnotation(bool isArrow)
|
||||
{
|
||||
IsArrow = isArrow;
|
||||
@@ -18,27 +26,124 @@ public sealed class LineAnnotation : Annotation
|
||||
|
||||
public Point End { get; set; }
|
||||
|
||||
/// <summary>Tussenpunten waar de kromme doorheen loopt, in volgorde van begin naar eind.</summary>
|
||||
public List<Point> Bends { get; set; } = new();
|
||||
|
||||
public override ToolKind Kind => IsArrow ? ToolKind.Arrow : ToolKind.Line;
|
||||
|
||||
public override Rect Bounds
|
||||
{
|
||||
get
|
||||
{
|
||||
var r = new Rect(Start, End);
|
||||
List<Point> points = Flatten();
|
||||
var r = new Rect(points[0], points[0]);
|
||||
foreach (Point p in points)
|
||||
{
|
||||
r.Union(p);
|
||||
}
|
||||
|
||||
double pad = Style.Thickness / 2 + (IsArrow ? HeadLength / 2 : 0);
|
||||
r.Inflate(pad, pad);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDegenerate => (End - Start).Length < 4;
|
||||
public override bool IsDegenerate => Bends.Count == 0 && (End - Start).Length < 4;
|
||||
|
||||
private double HeadLength => Math.Max(12, Style.Thickness * 4);
|
||||
|
||||
private readonly record struct Segment(Point A, Point C1, Point C2, Point B)
|
||||
{
|
||||
public Point At(double t)
|
||||
{
|
||||
double u = 1 - t;
|
||||
double a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
|
||||
return new Point(
|
||||
a * A.X + b * C1.X + c * C2.X + d * B.X,
|
||||
a * A.Y + b * C1.Y + c * C2.Y + d * B.Y);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Point> ThroughPoints()
|
||||
{
|
||||
var points = new List<Point>(Bends.Count + 2) { Start };
|
||||
points.AddRange(Bends);
|
||||
points.Add(End);
|
||||
return points;
|
||||
}
|
||||
|
||||
/// <summary>Catmull-Rom door alle punten, omgezet naar kubische Bezier-segmenten.</summary>
|
||||
private List<Segment> Segments()
|
||||
{
|
||||
List<Point> p = ThroughPoints();
|
||||
int last = p.Count - 1;
|
||||
var segments = new List<Segment>(last);
|
||||
for (int i = 0; i < last; i++)
|
||||
{
|
||||
Point prev = p[Math.Max(i - 1, 0)];
|
||||
Point next = p[Math.Min(i + 2, last)];
|
||||
segments.Add(new Segment(p[i], p[i] + (p[i + 1] - prev) / 6, p[i + 1] - (next - p[i]) / 6, p[i + 1]));
|
||||
}
|
||||
|
||||
return segments;
|
||||
}
|
||||
|
||||
private List<Point> Flatten()
|
||||
{
|
||||
if (Bends.Count == 0)
|
||||
{
|
||||
return new List<Point> { Start, End };
|
||||
}
|
||||
|
||||
var points = new List<Point> { Start };
|
||||
foreach (Segment s in Segments())
|
||||
{
|
||||
for (int k = 1; k <= SamplesPerSegment; k++)
|
||||
{
|
||||
points.Add(s.At(k / (double)SamplesPerSegment));
|
||||
}
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
private static double PathLength(List<Point> points)
|
||||
{
|
||||
double length = 0;
|
||||
for (int i = 1; i < points.Count; i++)
|
||||
{
|
||||
length += (points[i] - points[i - 1]).Length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
private Geometry BuildGeometry(List<Segment> segments)
|
||||
{
|
||||
var geometry = new StreamGeometry();
|
||||
using (StreamGeometryContext ctx = geometry.Open())
|
||||
{
|
||||
ctx.BeginFigure(segments[0].A, false, false);
|
||||
foreach (Segment s in segments)
|
||||
{
|
||||
if (Bends.Count == 0)
|
||||
{
|
||||
ctx.LineTo(s.B, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx.BezierTo(s.C1, s.C2, s.B, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
geometry.Freeze();
|
||||
return geometry;
|
||||
}
|
||||
|
||||
public override void Render(DrawingContext dc, EditorDocument document)
|
||||
{
|
||||
Vector v = End - Start;
|
||||
double length = v.Length;
|
||||
double length = PathLength(Flatten());
|
||||
if (length < 1)
|
||||
{
|
||||
return;
|
||||
@@ -50,18 +155,26 @@ public sealed class LineAnnotation : Annotation
|
||||
return;
|
||||
}
|
||||
|
||||
var geometry = new GeometryGroup { FillRule = FillRule.Nonzero };
|
||||
Brush? headFill = null;
|
||||
List<Segment> segments = Segments();
|
||||
|
||||
if (IsArrow)
|
||||
{
|
||||
Segment lastSegment = segments[^1];
|
||||
Vector v = lastSegment.B - lastSegment.C2;
|
||||
if (v.Length < 1e-6)
|
||||
{
|
||||
v = lastSegment.B - lastSegment.A;
|
||||
}
|
||||
|
||||
v.Normalize();
|
||||
double headLength = Math.Min(HeadLength, length);
|
||||
double halfWidth = headLength * 0.45;
|
||||
Point basePoint = End - v * headLength;
|
||||
var normal = new Vector(-v.Y, v.X);
|
||||
|
||||
geometry.Children.Add(new LineGeometry(Start, basePoint + v * Math.Min(2, headLength / 4)));
|
||||
Point lineEnd = basePoint + v * Math.Min(2, headLength / 4);
|
||||
Vector shift = lineEnd - End;
|
||||
segments[^1] = lastSegment with { C2 = lastSegment.C2 + shift, B = lineEnd };
|
||||
|
||||
var head = new StreamGeometry();
|
||||
using (StreamGeometryContext ctx = head.Open())
|
||||
@@ -72,39 +185,105 @@ public sealed class LineAnnotation : Annotation
|
||||
}
|
||||
|
||||
head.Freeze();
|
||||
headFill = RenderHelpers.BrushOrNull(Style.Stroke);
|
||||
Brush? headFill = RenderHelpers.BrushOrNull(Style.Stroke);
|
||||
|
||||
// Lijn en punt apart tekenen zodat de punt gevuld en niet gestippeld wordt.
|
||||
RenderHelpers.DrawWithShadow(dc, geometry, null, pen, Style.Shadow);
|
||||
RenderHelpers.DrawWithShadow(dc, BuildGeometry(segments), null, pen, Style.Shadow);
|
||||
var headPen = RenderHelpers.CreatePen(Style.Stroke, Math.Max(1, Style.Thickness / 3), LineDash.Solid);
|
||||
RenderHelpers.DrawWithShadow(dc, head, headFill, headPen, Style.Shadow);
|
||||
return;
|
||||
}
|
||||
|
||||
geometry.Children.Add(new LineGeometry(Start, End));
|
||||
RenderHelpers.DrawWithShadow(dc, geometry, null, pen, Style.Shadow);
|
||||
RenderHelpers.DrawWithShadow(dc, BuildGeometry(segments), null, pen, Style.Shadow);
|
||||
}
|
||||
|
||||
public override bool HitTest(Point point, double tolerance) =>
|
||||
RenderHelpers.DistanceToSegment(point, Start, End) <= tolerance + Style.Thickness / 2 + (IsArrow ? 4 : 0);
|
||||
public override bool HitTest(Point point, double tolerance)
|
||||
{
|
||||
double limit = tolerance + Style.Thickness / 2 + (IsArrow ? 4 : 0);
|
||||
List<Point> points = Flatten();
|
||||
for (int i = 1; i < points.Count; i++)
|
||||
{
|
||||
if (RenderHelpers.DistanceToSegment(point, points[i - 1], points[i]) <= limit)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Move(Vector delta)
|
||||
{
|
||||
Start += delta;
|
||||
End += delta;
|
||||
for (int i = 0; i < Bends.Count; i++)
|
||||
{
|
||||
Bends[i] += delta;
|
||||
}
|
||||
}
|
||||
|
||||
public override IReadOnlyList<Point> GetHandles() => new[] { Start, End };
|
||||
/// <summary>Volgorde: begin, eind, buigpunten, en daarna één spook-greep midden op elk segment.</summary>
|
||||
public override IReadOnlyList<Point> GetHandles()
|
||||
{
|
||||
var handles = new List<Point> { Start, End };
|
||||
handles.AddRange(Bends);
|
||||
foreach (Segment s in Segments())
|
||||
{
|
||||
handles.Add(s.At(0.5));
|
||||
}
|
||||
|
||||
return handles;
|
||||
}
|
||||
|
||||
public override bool IsGhostHandle(int index) => index >= 2 + Bends.Count;
|
||||
|
||||
public override void BeginHandleDrag(int index)
|
||||
{
|
||||
_pendingGhost = IsGhostHandle(index) ? index - 2 - Bends.Count : -1;
|
||||
_dragBend = index >= 2 && _pendingGhost < 0 ? index - 2 : -1;
|
||||
}
|
||||
|
||||
public override void MoveHandle(int index, Point point, bool constrain)
|
||||
{
|
||||
if (index == 0)
|
||||
// Het buigpunt pas bij de eerste beweging invoegen, zodat een losse klik de lijn niet verandert.
|
||||
if (_pendingGhost >= 0)
|
||||
{
|
||||
Start = constrain ? RenderHelpers.SnapAngle(End, point) : point;
|
||||
Bends.Insert(_pendingGhost, point);
|
||||
_dragBend = _pendingGhost;
|
||||
_pendingGhost = -1;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (_dragBend >= 0)
|
||||
{
|
||||
End = constrain ? RenderHelpers.SnapAngle(Start, point) : point;
|
||||
Bends[_dragBend] = point;
|
||||
}
|
||||
else if (index == 0)
|
||||
{
|
||||
Start = constrain ? RenderHelpers.SnapAngle(Bends.Count > 0 ? Bends[0] : End, point) : point;
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
End = constrain ? RenderHelpers.SnapAngle(Bends.Count > 0 ? Bends[^1] : Start, point) : point;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool RemoveHandle(int index)
|
||||
{
|
||||
int bend = index - 2;
|
||||
if (bend < 0 || bend >= Bends.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Bends.RemoveAt(bend);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Annotation Clone()
|
||||
{
|
||||
var clone = (LineAnnotation)base.Clone();
|
||||
clone.Bends = new List<Point>(Bends);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,13 @@ public sealed class EditorDocument
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Vervangt het knipsel door de platgemaakte versie; de annotaties zitten daarna in de pixels.</summary>
|
||||
public void Flatten(BitmapSource rendered)
|
||||
{
|
||||
SetPixels(PixelUtil.ToOpaqueBgra(rendered), rendered.PixelWidth, rendered.PixelHeight);
|
||||
Items = new List<Annotation>();
|
||||
}
|
||||
|
||||
public string GetStepLabel(StepAnnotation step)
|
||||
{
|
||||
int ordinal = 0;
|
||||
|
||||
@@ -315,9 +315,14 @@
|
||||
<TextBlock Text="" Style="{StaticResource IconText}" />
|
||||
</Button>
|
||||
<local:ToolbarSeparator local:ToolbarPanel.ItemId="Sep5" />
|
||||
<Button local:ToolbarPanel.ItemId="Settings" local:ToolbarPanel.Title="Instellingen"
|
||||
<Button x:Name="SettingsButton" local:ToolbarPanel.ItemId="Settings" local:ToolbarPanel.Title="Instellingen"
|
||||
Style="{StaticResource FlatButton}" ToolTip="Instellingen" Click="Settings_Click">
|
||||
<Grid>
|
||||
<TextBlock Text="" Style="{StaticResource IconText}" />
|
||||
<Ellipse x:Name="SettingsBadge" Width="8" Height="8" Fill="{StaticResource AccentBrush}" Stroke="White"
|
||||
StrokeThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,-2,-3,0"
|
||||
IsHitTestVisible="False" Visibility="Collapsed" />
|
||||
</Grid>
|
||||
</Button>
|
||||
<Button x:Name="SaveButton" local:ToolbarPanel.ItemId="Save" local:ToolbarPanel.Title="Opslaan"
|
||||
Style="{StaticResource SecondaryButton}" ToolTip="Opslaan (Ctrl+S); Shift+klik of Ctrl+Shift+S = opslaan als" Click="Save_Click">
|
||||
@@ -344,7 +349,7 @@
|
||||
</Border>
|
||||
|
||||
<!-- Eigenschappen van het actieve gereedschap of het geselecteerde object -->
|
||||
<Border DockPanel.Dock="Top" Background="White" BorderBrush="{StaticResource DividerBrush}" BorderThickness="0,0,0,1"
|
||||
<Border x:Name="PropsBar" DockPanel.Dock="Top" Background="White" BorderBrush="{StaticResource DividerBrush}" BorderThickness="0,0,0,1"
|
||||
Padding="12,4" MinHeight="42">
|
||||
<WrapPanel x:Name="PropsPanel" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||
<StackPanel x:Name="StrokeGroup" Style="{StaticResource PropGroup}">
|
||||
|
||||
@@ -22,6 +22,8 @@ public partial class EditorWindow : Window
|
||||
{
|
||||
private enum DragMode { None, Creating, Moving, Handle, Cropping }
|
||||
|
||||
private enum ZOrder { Front, Forward, Backward, Back }
|
||||
|
||||
private static readonly double[] ThicknessValues = { 0, 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32 };
|
||||
private static readonly double[] FontSizeValues = { 10, 12, 14, 16, 18, 20, 24, 28, 32, 40, 48, 64 };
|
||||
private static readonly double[] SizeValues = { 16, 20, 24, 28, 32, 40, 48, 56, 64, 80 };
|
||||
@@ -68,6 +70,7 @@ public partial class EditorWindow : Window
|
||||
private bool _dirty;
|
||||
private bool _discarding;
|
||||
private bool _exported;
|
||||
private bool _toolbarsHidden;
|
||||
private readonly string? _windowName;
|
||||
|
||||
/// <param name="windowName">Programmanaam van het geknipte venster, voor %V in het naamsjabloon.</param>
|
||||
@@ -117,6 +120,10 @@ public partial class EditorWindow : Window
|
||||
DpiChanged += (_, _) => ApplyZoom();
|
||||
PreviewKeyDown += OnPreviewKeyDown;
|
||||
|
||||
App.Instance.Updates.AvailabilityChanged += OnUpdateAvailabilityChanged;
|
||||
Closed += (_, _) => App.Instance.Updates.AvailabilityChanged -= OnUpdateAvailabilityChanged;
|
||||
ShowUpdateBadge();
|
||||
|
||||
InitializeToolbar();
|
||||
ApplySaveButton();
|
||||
_suppressStyleEvents = false;
|
||||
@@ -452,6 +459,14 @@ public partial class EditorWindow : Window
|
||||
if (_selected != null)
|
||||
{
|
||||
int handle = Surface.HitHandle(_selected, p);
|
||||
if (handle >= 0 && e.ClickCount == 2 && _selected.RemoveHandle(handle))
|
||||
{
|
||||
Commit(_pending);
|
||||
_pending = null;
|
||||
Surface.InvalidateVisual();
|
||||
return;
|
||||
}
|
||||
|
||||
if (handle >= 0)
|
||||
{
|
||||
_handleIndex = handle;
|
||||
@@ -723,26 +738,53 @@ public partial class EditorWindow : Window
|
||||
private void Surface_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CommitTextEdit();
|
||||
Annotation? hit = HitTest(e.GetPosition(Surface));
|
||||
if (hit == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Point point = e.GetPosition(Surface);
|
||||
Annotation? hit = HitTest(point);
|
||||
SetSelected(hit);
|
||||
bool has = hit != null;
|
||||
int index = hit != null ? _doc.Items.IndexOf(hit) : -1;
|
||||
int last = _doc.Items.Count - 1;
|
||||
|
||||
var menu = new ContextMenu { PlacementTarget = Surface };
|
||||
menu.Items.Add(MenuItem("Naar voren", () => Reorder(hit, toFront: true)));
|
||||
menu.Items.Add(MenuItem("Naar achteren", () => Reorder(hit, toFront: false)));
|
||||
menu.Items.Add(MenuItem("Dupliceren", () => Duplicate(hit)));
|
||||
menu.Items.Add(MenuItem("Ongedaan maken", "\uE7A7", "Ctrl+Z", Undo, _undo.CanUndo));
|
||||
menu.Items.Add(MenuItem("Opnieuw", "\uE7A6", "Ctrl+Y", Redo, _undo.CanRedo));
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(MenuItem("Verwijderen", DeleteSelected));
|
||||
menu.Items.Add(MenuItem("Verwijder", "\uE74D", "Delete", DeleteSelected, has));
|
||||
menu.Items.Add(MenuItem("Verwijder alles", "\uE894", "Shift+Delete", DeleteAll, last >= 0));
|
||||
menu.Items.Add(MenuItem("Samenvoegen", "\uE81E", "Ctrl+Shift+F", Flatten, last >= 0));
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(MenuItem("Knip", "\uE8C6", "Ctrl+X", () => CutAnnotation(hit!), has));
|
||||
menu.Items.Add(MenuItem("Kopieer", "\uE8C8", "Ctrl+Shift+C", () => CopyAnnotation(hit!), has));
|
||||
menu.Items.Add(MenuItem("Plak", "\uE77F", "Ctrl+V", () => Paste(point), CanPaste()));
|
||||
menu.Items.Add(MenuItem("Dupliceren", "\uE710", "Ctrl+D", () => Duplicate(hit!), has));
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(MenuItem("Naar voorgrond", "\uE898", "Home", () => Reorder(hit!, ZOrder.Front), has && index < last));
|
||||
menu.Items.Add(MenuItem("Naar voren", "\uE74A", "PageUp", () => Reorder(hit!, ZOrder.Forward), has && index < last));
|
||||
menu.Items.Add(MenuItem("Naar achteren", "\uE74B", "PageDown", () => Reorder(hit!, ZOrder.Backward), has && index > 0));
|
||||
menu.Items.Add(MenuItem("Naar achtergrond", "\uE896", "End", () => Reorder(hit!, ZOrder.Back), has && index > 0));
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(_toolbarsHidden
|
||||
? MenuItem("Werkbalken tonen", "\uE7B3", "Ctrl+H", ToggleToolbars)
|
||||
: MenuItem("Werkbalken verbergen", "\uED1A", "Ctrl+H", ToggleToolbars));
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private static MenuItem MenuItem(string header, Action action)
|
||||
private static MenuItem MenuItem(string header, string glyph, string gesture, Action action, bool isEnabled = true)
|
||||
{
|
||||
var item = new MenuItem { Header = header };
|
||||
var item = new MenuItem
|
||||
{
|
||||
Header = header,
|
||||
InputGestureText = gesture,
|
||||
IsEnabled = isEnabled,
|
||||
Icon = new TextBlock
|
||||
{
|
||||
Text = glyph,
|
||||
FontFamily = (FontFamily)Application.Current.FindResource("IconFont"),
|
||||
FontSize = 14,
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
}
|
||||
};
|
||||
item.Click += (_, _) => action();
|
||||
return item;
|
||||
}
|
||||
@@ -781,20 +823,121 @@ public partial class EditorWindow : Window
|
||||
SetSelected(null);
|
||||
}
|
||||
|
||||
private void Reorder(Annotation item, bool toFront)
|
||||
private void DeleteAll()
|
||||
{
|
||||
if (_doc.Items.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Commit(_doc.CaptureState());
|
||||
_doc.Items.Remove(item);
|
||||
if (toFront)
|
||||
_doc.Items.Clear();
|
||||
SetSelected(null);
|
||||
}
|
||||
|
||||
private void Flatten()
|
||||
{
|
||||
_doc.Items.Add(item);
|
||||
CommitTextEdit();
|
||||
if (_doc.Items.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Commit(_doc.CaptureState());
|
||||
_doc.Flatten(DocumentRenderer.Export(_doc));
|
||||
SetSelected(null);
|
||||
ShowTemporaryHint("Annotaties samengevoegd met de afbeelding.");
|
||||
}
|
||||
|
||||
private void Reorder(Annotation item, ZOrder order)
|
||||
{
|
||||
int index = _doc.Items.IndexOf(item);
|
||||
int last = _doc.Items.Count - 1;
|
||||
int target = order switch
|
||||
{
|
||||
ZOrder.Front => last,
|
||||
ZOrder.Forward => Math.Min(index + 1, last),
|
||||
ZOrder.Backward => Math.Max(index - 1, 0),
|
||||
_ => 0
|
||||
};
|
||||
if (index < 0 || target == index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Commit(_doc.CaptureState());
|
||||
_doc.Items.RemoveAt(index);
|
||||
_doc.Items.Insert(target, item);
|
||||
Surface.InvalidateVisual();
|
||||
}
|
||||
|
||||
private void CopyAnnotation(Annotation item)
|
||||
{
|
||||
if (!AnnotationClipboard.Set(item))
|
||||
{
|
||||
ShowTemporaryHint("Kopiëren mislukt: het klembord is bezet. Probeer het opnieuw.");
|
||||
}
|
||||
}
|
||||
|
||||
private void CutAnnotation(Annotation item)
|
||||
{
|
||||
if (AnnotationClipboard.Set(item))
|
||||
{
|
||||
SetSelected(item);
|
||||
DeleteSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
_doc.Items.Insert(0, item);
|
||||
ShowTemporaryHint("Knippen mislukt: het klembord is bezet. Probeer het opnieuw.");
|
||||
}
|
||||
}
|
||||
|
||||
Surface.InvalidateVisual();
|
||||
/// <param name="at">Middelpunt voor de geplakte annotatie; zonder punt een kleine verschuiving.</param>
|
||||
private void Paste(Point? at = null)
|
||||
{
|
||||
if (AnnotationClipboard.Get() is not { } copy)
|
||||
{
|
||||
PasteImage();
|
||||
return;
|
||||
}
|
||||
|
||||
Commit(_doc.CaptureState());
|
||||
Rect bounds = copy.Bounds;
|
||||
Vector offset = at is { } point
|
||||
? point - new Point(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2)
|
||||
: new Vector(12 / Surface.ViewScale, 12 / Surface.ViewScale);
|
||||
copy.Move(offset);
|
||||
_doc.Items.Add(copy);
|
||||
SetSelected(copy);
|
||||
}
|
||||
|
||||
private static bool CanPaste()
|
||||
{
|
||||
if (AnnotationClipboard.Get() != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Clipboard.ContainsImage() || Clipboard.ContainsData("PNG") || Clipboard.ContainsFileDropList();
|
||||
}
|
||||
catch (System.Runtime.InteropServices.ExternalException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleToolbars()
|
||||
{
|
||||
_toolbarsHidden = !_toolbarsHidden;
|
||||
Visibility visibility = _toolbarsHidden ? Visibility.Collapsed : Visibility.Visible;
|
||||
Toolbar.Visibility = visibility;
|
||||
PropsBar.Visibility = visibility;
|
||||
if (_toolbarsHidden)
|
||||
{
|
||||
ShowTemporaryHint("Werkbalken verborgen. Ctrl+H of rechtsklik op het canvas om ze terug te halen.");
|
||||
}
|
||||
}
|
||||
|
||||
private void Duplicate(Annotation item)
|
||||
@@ -1539,6 +1682,15 @@ public partial class EditorWindow : Window
|
||||
|
||||
private void Settings_Click(object sender, RoutedEventArgs e) => App.Instance.ShowSettings();
|
||||
|
||||
private void OnUpdateAvailabilityChanged(object? sender, EventArgs e) => ShowUpdateBadge();
|
||||
|
||||
private void ShowUpdateBadge()
|
||||
{
|
||||
bool available = App.Instance.Updates.IsUpdateAvailable;
|
||||
SettingsBadge.Visibility = available ? Visibility.Visible : Visibility.Collapsed;
|
||||
SettingsButton.ToolTip = available ? "Instellingen - nieuwe versie beschikbaar" : "Instellingen";
|
||||
}
|
||||
|
||||
private void NewSnip_Click(object sender, RoutedEventArgs e) => DiscardAndStartNewSnip();
|
||||
|
||||
private void Clear_Click(object sender, RoutedEventArgs e) => DiscardAndStartBlank();
|
||||
@@ -1728,10 +1880,26 @@ public partial class EditorWindow : Window
|
||||
break;
|
||||
case Key.Z:
|
||||
Undo();
|
||||
break;
|
||||
case Key.C when shift:
|
||||
if (_selected != null)
|
||||
{
|
||||
CopyAnnotation(_selected);
|
||||
}
|
||||
|
||||
break;
|
||||
case Key.C:
|
||||
CopyToClipboard();
|
||||
break;
|
||||
case Key.X when _selected != null:
|
||||
CutAnnotation(_selected);
|
||||
break;
|
||||
case Key.F when shift:
|
||||
Flatten();
|
||||
break;
|
||||
case Key.H:
|
||||
ToggleToolbars();
|
||||
break;
|
||||
case Key.S when shift:
|
||||
SaveAs();
|
||||
break;
|
||||
@@ -1748,7 +1916,7 @@ public partial class EditorWindow : Window
|
||||
DiscardAndStartBlank();
|
||||
break;
|
||||
case Key.V:
|
||||
PasteImage();
|
||||
Paste();
|
||||
break;
|
||||
case Key.O:
|
||||
OpenImageFile();
|
||||
@@ -1788,10 +1956,25 @@ public partial class EditorWindow : Window
|
||||
double step = shift ? 10 : 1;
|
||||
switch (key)
|
||||
{
|
||||
case Key.Delete when shift:
|
||||
DeleteAll();
|
||||
break;
|
||||
case Key.Delete:
|
||||
case Key.Back:
|
||||
DeleteSelected();
|
||||
break;
|
||||
case Key.Home when _selected != null:
|
||||
Reorder(_selected, ZOrder.Front);
|
||||
break;
|
||||
case Key.PageUp when _selected != null:
|
||||
Reorder(_selected, ZOrder.Forward);
|
||||
break;
|
||||
case Key.PageDown when _selected != null:
|
||||
Reorder(_selected, ZOrder.Backward);
|
||||
break;
|
||||
case Key.End when _selected != null:
|
||||
Reorder(_selected, ZOrder.Back);
|
||||
break;
|
||||
case Key.Escape:
|
||||
if (_drag != DragMode.None)
|
||||
{
|
||||
@@ -1877,8 +2060,8 @@ public partial class EditorWindow : Window
|
||||
ToolKind.Select => "Klik om te selecteren, sleep om te verplaatsen. Dubbelklik op tekst om te bewerken. Pijltoetsen verschuiven.",
|
||||
ToolKind.Rectangle => "Sleep om een rechthoek te tekenen. Shift = vierkant.",
|
||||
ToolKind.Ellipse => "Sleep om een ellips te tekenen. Shift = cirkel.",
|
||||
ToolKind.Line => "Sleep om een lijn te tekenen. Shift = hoeken van 45°.",
|
||||
ToolKind.Arrow => "Sleep om een pijl te tekenen. Shift = hoeken van 45°.",
|
||||
ToolKind.Line => "Sleep om een lijn te tekenen. Shift = hoeken van 45°. Sleep een middenpunt om te buigen; dubbelklik op een buigpunt om het te verwijderen.",
|
||||
ToolKind.Arrow => "Sleep om een pijl te tekenen. Shift = hoeken van 45°. Sleep een middenpunt om te buigen; dubbelklik op een buigpunt om het te verwijderen.",
|
||||
ToolKind.Text => "Klik om een tekstkader te plaatsen, of klik op bestaande tekst om die te bewerken.",
|
||||
ToolKind.Step => "Klik om een genummerde stap te plaatsen. De nummering loopt automatisch door.",
|
||||
ToolKind.Cursor => "Klik om een cursor te plaatsen; de punt komt precies op de klikplek.",
|
||||
|
||||
@@ -70,6 +70,14 @@ internal static class ClipboardWriter
|
||||
return TrySet(data);
|
||||
}
|
||||
|
||||
/// <summary>Alleen een eigen markering op het klembord, zonder afbeelding of tekst.</summary>
|
||||
public static bool SetMarker(string format, string value)
|
||||
{
|
||||
var data = new DataObject();
|
||||
data.SetData(format, value);
|
||||
return TrySet(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tekst gaat rechtstreeks via Win32 op het klembord. De OLE-route van WPF moet het klembord
|
||||
/// daarna nog leegspoelen, en dat mislukt zodra een klembordbeheerder het meteen opent.
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace Kniip.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// Namen waaronder kniip zich in Windows inschrijft. De testbuild (<c>-p:KniipTest=true</c>) gebruikt eigen
|
||||
/// namen voor register, instellingen, mutex en tijdelijke bestanden, zodat hij naast de geïnstalleerde
|
||||
/// kniip kan draaien en die nooit overschrijft.
|
||||
/// </summary>
|
||||
internal static class AppIdentity
|
||||
{
|
||||
#if KNIIP_TEST
|
||||
public static bool IsTest => true;
|
||||
public const string Key = "KniipTest";
|
||||
public const string DisplayName = "kniip test";
|
||||
#else
|
||||
public static bool IsTest => false;
|
||||
public const string Key = "Kniip";
|
||||
public const string DisplayName = "kniip";
|
||||
#endif
|
||||
}
|
||||
@@ -9,10 +9,10 @@ namespace Kniip.Infrastructure;
|
||||
/// </summary>
|
||||
internal static class ShellIntegration
|
||||
{
|
||||
private const string ProgId = "Kniip.Image";
|
||||
private const string AppKeyName = "Kniip.exe";
|
||||
private const string ProgId = AppIdentity.Key + ".Image";
|
||||
private const string AppKeyName = AppIdentity.Key + ".exe";
|
||||
private const string RunKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
|
||||
private const string RunValueName = "Kniip";
|
||||
private const string RunValueName = AppIdentity.Key;
|
||||
|
||||
public static readonly string[] ImageExtensions = { ".png", ".jpg", ".jpeg", ".bmp", ".gif" };
|
||||
|
||||
@@ -32,8 +32,8 @@ internal static class ShellIntegration
|
||||
{
|
||||
using (var prog = Registry.CurrentUser.CreateSubKey($@"Software\Classes\{ProgId}"))
|
||||
{
|
||||
prog.SetValue(null, "kniip afbeelding");
|
||||
prog.SetValue("FriendlyTypeName", "kniip afbeelding");
|
||||
prog.SetValue(null, $"{AppIdentity.DisplayName} afbeelding");
|
||||
prog.SetValue("FriendlyTypeName", $"{AppIdentity.DisplayName} afbeelding");
|
||||
}
|
||||
using (var icon = Registry.CurrentUser.CreateSubKey($@"Software\Classes\{ProgId}\DefaultIcon"))
|
||||
{
|
||||
@@ -46,7 +46,7 @@ internal static class ShellIntegration
|
||||
|
||||
using (var app = Registry.CurrentUser.CreateSubKey($@"Software\Classes\Applications\{AppKeyName}"))
|
||||
{
|
||||
app.SetValue("FriendlyAppName", "kniip editor");
|
||||
app.SetValue("FriendlyAppName", $"{AppIdentity.DisplayName} editor");
|
||||
}
|
||||
using (var appCmd = Registry.CurrentUser.CreateSubKey($@"Software\Classes\Applications\{AppKeyName}\shell\open\command"))
|
||||
{
|
||||
@@ -89,6 +89,11 @@ internal static class ShellIntegration
|
||||
/// </summary>
|
||||
public static void MigrateLegacyRegistration()
|
||||
{
|
||||
if (AppIdentity.IsTest)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const string legacyProgId = "KnipPlus.Image";
|
||||
const string legacyAppKeyName = "KnipPlus.exe";
|
||||
const string legacyRunValueName = "KnipPlus";
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Kniip.Infrastructure;
|
||||
/// </summary>
|
||||
internal sealed class SingleInstance : IDisposable
|
||||
{
|
||||
private static readonly string BaseName = "Kniip-" + Environment.UserName;
|
||||
private static readonly string BaseName = AppIdentity.Key + "-" + Environment.UserName;
|
||||
private static readonly string PipeName = BaseName + "-pipe";
|
||||
|
||||
private readonly CancellationTokenSource _cts = new();
|
||||
|
||||
@@ -56,7 +56,7 @@ internal sealed class TrayIcon : IDisposable
|
||||
_icon = new NotifyIcon
|
||||
{
|
||||
Icon = LoadIcon(),
|
||||
Text = "kniip - annotaties voor het Knipprogramma",
|
||||
Text = IdleText,
|
||||
ContextMenuStrip = menu,
|
||||
Visible = true
|
||||
};
|
||||
@@ -86,9 +86,13 @@ internal sealed class TrayIcon : IDisposable
|
||||
{
|
||||
_recordItem.Text = text ?? RecordText;
|
||||
_gifItem.Visible = text == null;
|
||||
_icon.Text = recording ? "kniip - opname loopt" : "kniip - annotaties voor het Knipprogramma";
|
||||
_icon.Text = recording ? $"{AppIdentity.DisplayName} - opname loopt" : IdleText;
|
||||
}
|
||||
|
||||
private static string IdleText => AppIdentity.IsTest
|
||||
? $"{AppIdentity.DisplayName} {Kniip.Update.UpdateChecker.CurrentVersion}"
|
||||
: "kniip - annotaties voor het Knipprogramma";
|
||||
|
||||
public void ShowBalloon(string title, string text) =>
|
||||
_icon.ShowBalloonTip(4000, title, text, ToolTipIcon.Info);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Product>kniip</Product>
|
||||
<Description>Annotatie-editor naast het Windows Knipprogramma</Description>
|
||||
<Version>1.1.3</Version>
|
||||
<Version>1.1.4</Version>
|
||||
<SatelliteResourceLanguages>nl;en</SatelliteResourceLanguages>
|
||||
<!-- WPF regelt DPI via app.manifest; de WinForms-analyzer is hier niet van toepassing. -->
|
||||
<NoWarn>$(NoWarn);WFAC010</NoWarn>
|
||||
@@ -26,6 +26,12 @@
|
||||
<AllowedReferenceRelatedFileExtensions>.none</AllowedReferenceRelatedFileExtensions>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Testbuild (build.ps1, -p:KniipTest=true): eigen register- en instellingennamen, zie AppIdentity. -->
|
||||
<PropertyGroup Condition="'$(KniipTest)' == 'true'">
|
||||
<DefineConstants>$(DefineConstants);KNIIP_TEST</DefineConstants>
|
||||
<Product>kniip test</Product>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="AppIcon.ico" />
|
||||
<Resource Include="Assets\Emoji\emoji.json;Assets\Emoji\twemoji-64.png" />
|
||||
|
||||
@@ -15,7 +15,7 @@ internal sealed record RecordingOptions(bool SystemAudio, bool Microphone, bool
|
||||
/// <summary>Eén opname naar een tijdelijk MP4-bestand. Gebeurtenissen komen binnen op de UI-thread.</summary>
|
||||
internal sealed class RecordingSession : IDisposable
|
||||
{
|
||||
public static string TempFolder { get; } = Path.Combine(Path.GetTempPath(), "Kniip");
|
||||
public static string TempFolder { get; } = Path.Combine(Path.GetTempPath(), Infrastructure.AppIdentity.Key);
|
||||
|
||||
private readonly Dispatcher _dispatcher;
|
||||
private readonly RecordingRegion _region;
|
||||
|
||||
@@ -99,6 +99,9 @@ public sealed class AppSettings
|
||||
/// <summary>Zipline-server waar Uploaden naartoe gaat; leeg betekent geen uploadknop.</summary>
|
||||
public UploaderConfig? Uploader { get; set; }
|
||||
|
||||
/// <summary>Bij het starten en daarna dagelijks op de achtergrond kijken of er een nieuwere versie is.</summary>
|
||||
public bool CheckForUpdates { get; set; } = true;
|
||||
|
||||
public StyleSet StyleFor(ToolKind tool)
|
||||
{
|
||||
if (!ToolStyles.TryGetValue(tool, out StyleSet? style))
|
||||
|
||||
@@ -7,19 +7,24 @@ using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Windows.Media;
|
||||
using Kniip.Infrastructure;
|
||||
|
||||
namespace Kniip.Settings;
|
||||
|
||||
public static class SettingsStore
|
||||
{
|
||||
public static string Folder { get; } =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Kniip");
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AppIdentity.Key);
|
||||
|
||||
private static string FilePath => Path.Combine(Folder, "settings.json");
|
||||
|
||||
/// <summary>Instellingen van voor de hernoeming van Knip+ naar kniip.</summary>
|
||||
/// <summary>
|
||||
/// Startpunt als er nog geen instellingen zijn: voor kniip die van voor de hernoeming van Knip+,
|
||||
/// voor de testbuild een kopie van die van de gewone kniip.
|
||||
/// </summary>
|
||||
private static string LegacyFilePath =>
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "KnipPlus", "settings.json");
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
AppIdentity.IsTest ? "Kniip" : "KnipPlus", "settings.json");
|
||||
|
||||
private static readonly JsonSerializerOptions Options = new()
|
||||
{
|
||||
|
||||
@@ -256,10 +256,19 @@
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem x:Name="UpdateTab" Header="Update">
|
||||
<TabItem x:Name="UpdateTab">
|
||||
<TabItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Update" />
|
||||
<Ellipse x:Name="UpdateTabBadge" Width="8" Height="8" Fill="{StaticResource AccentBrush}" Stroke="White"
|
||||
StrokeThickness="1" Margin="6,0,0,0" VerticalAlignment="Center" Visibility="Collapsed"
|
||||
ToolTip="Er is een nieuwe versie beschikbaar" />
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Update" Style="{StaticResource CardTitle}" />
|
||||
<TextBlock x:Name="CurrentVersionText" Margin="0,0,0,2" />
|
||||
<CheckBox x:Name="AutoUpdateCheckBox" Content="Automatisch controleren op nieuwe versies (bij starten en dagelijks)" />
|
||||
<TextBlock x:Name="UpdateStatus" Style="{StaticResource Hint}" Margin="0,0,0,8" />
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,8">
|
||||
<Button x:Name="UpdateButton" Style="{StaticResource AccentButton}" Click="Update_Click" Margin="0,0,6,0"
|
||||
|
||||
@@ -45,6 +45,7 @@ public partial class SettingsWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
_settings = settings;
|
||||
Title = $"{AppIdentity.DisplayName} instellingen";
|
||||
|
||||
FolderText.Text = CaptureCoordinator.ScreenshotsFolder ?? "Map Schermafbeeldingen niet gevonden.";
|
||||
AutostartBox.IsChecked = ShellIntegration.IsAutostartEnabled();
|
||||
@@ -70,11 +71,14 @@ public partial class SettingsWindow : Window
|
||||
? HotkeyHintText
|
||||
: "De toetsenbordhaak kon niet worden gestart; de sneltoetsen werken nu niet.";
|
||||
Deactivated += (_, _) => StopListening();
|
||||
App.Instance.Updates.AvailabilityChanged += OnUpdateAvailabilityChanged;
|
||||
Closed += (_, _) =>
|
||||
{
|
||||
StopListening();
|
||||
_updateCts?.Cancel();
|
||||
App.Instance.Updates.AvailabilityChanged -= OnUpdateAvailabilityChanged;
|
||||
};
|
||||
ShowUpdateBadge();
|
||||
|
||||
CurrentVersionText.Text = $"Geïnstalleerde versie: {UpdateChecker.CurrentVersion}";
|
||||
LoadFrom(settings);
|
||||
@@ -93,6 +97,7 @@ public partial class SettingsWindow : Window
|
||||
ActionOpenRadio.IsChecked = settings.Action == CaptureAction.OpenEditor;
|
||||
ActionNothingRadio.IsChecked = settings.Action == CaptureAction.Nothing;
|
||||
StraightHighlightBox.IsChecked = settings.StraightHighlight;
|
||||
AutoUpdateCheckBox.IsChecked = settings.CheckForUpdates;
|
||||
|
||||
_snipFolder = settings.SnipSaveFolder;
|
||||
_videoFolder = settings.VideoSaveFolder;
|
||||
@@ -436,6 +441,7 @@ public partial class SettingsWindow : Window
|
||||
: ActionNothingRadio.IsChecked == true ? CaptureAction.Nothing
|
||||
: CaptureAction.Notify;
|
||||
_settings.StraightHighlight = StraightHighlightBox.IsChecked == true;
|
||||
_settings.CheckForUpdates = AutoUpdateCheckBox.IsChecked == true;
|
||||
StopListening();
|
||||
_settings.SnipHotkey = _hotkeys["Snip"];
|
||||
_settings.WindowHotkey = _hotkeys["Window"];
|
||||
@@ -504,6 +510,11 @@ public partial class SettingsWindow : Window
|
||||
|
||||
private void CheckUpdate_Click(object sender, RoutedEventArgs e) => _ = CheckForUpdatesAsync();
|
||||
|
||||
private void OnUpdateAvailabilityChanged(object? sender, EventArgs e) => ShowUpdateBadge();
|
||||
|
||||
private void ShowUpdateBadge() =>
|
||||
UpdateTabBadge.Visibility = App.Instance.Updates.IsUpdateAvailable ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
private void ReleasePage_Click(object sender, RoutedEventArgs e) => OpenUrl(UpdateChecker.ReleasesPage);
|
||||
|
||||
private async System.Threading.Tasks.Task CheckForUpdatesAsync()
|
||||
@@ -547,6 +558,7 @@ public partial class SettingsWindow : Window
|
||||
{
|
||||
Version current = UpdateChecker.CurrentVersion;
|
||||
List<ReleaseInfo> newer = releases.Where(r => r.Version > current).ToList();
|
||||
App.Instance.Updates.Report(newer.FirstOrDefault());
|
||||
if (newer.Count == 0)
|
||||
{
|
||||
UpdateStatus.Text = releases.Count == 0
|
||||
@@ -557,6 +569,14 @@ public partial class SettingsWindow : Window
|
||||
return;
|
||||
}
|
||||
|
||||
if (AppIdentity.IsTest)
|
||||
{
|
||||
UpdateStatus.Text = $"Versie {newer[0].Version} is beschikbaar. Deze testversie werkt zichzelf niet bij; " +
|
||||
"de installer zou de gewone kniip overschrijven.";
|
||||
ShowChangelog(newer, null);
|
||||
return;
|
||||
}
|
||||
|
||||
_update = newer.FirstOrDefault(r => r.InstallerUrl != null);
|
||||
if (_update != null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Kniip.Update;
|
||||
|
||||
/// <summary>Kijkt op de achtergrond of er een nieuwere versie is en meldt dat aan de vensters.</summary>
|
||||
public sealed class UpdateNotifier
|
||||
{
|
||||
private static readonly TimeSpan FirstCheckDelay = TimeSpan.FromSeconds(10);
|
||||
private static readonly TimeSpan CheckInterval = TimeSpan.FromHours(24);
|
||||
|
||||
private readonly DispatcherTimer _timer = new();
|
||||
private bool _enabled;
|
||||
private bool _checking;
|
||||
|
||||
public UpdateNotifier()
|
||||
{
|
||||
_timer.Tick += async (_, _) =>
|
||||
{
|
||||
_timer.Interval = CheckInterval;
|
||||
await CheckAsync();
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Nieuwste versie die nieuwer is dan deze exe; null als er niets nieuws is.</summary>
|
||||
public ReleaseInfo? Available { get; private set; }
|
||||
|
||||
public bool IsUpdateAvailable => Available != null;
|
||||
|
||||
/// <summary>Wordt op de UI-thread afgevuurd als <see cref="Available"/> verandert.</summary>
|
||||
public event EventHandler? AvailabilityChanged;
|
||||
|
||||
public void Apply(bool enabled)
|
||||
{
|
||||
if (enabled == _enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_enabled = enabled;
|
||||
_timer.Stop();
|
||||
if (enabled)
|
||||
{
|
||||
_timer.Interval = FirstCheckDelay;
|
||||
_timer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
Report(null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Resultaat van een controle elders (de tab Update), zodat de melding gelijkloopt.</summary>
|
||||
public void Report(ReleaseInfo? newest)
|
||||
{
|
||||
if (newest != null && newest.Version <= UpdateChecker.CurrentVersion)
|
||||
{
|
||||
newest = null;
|
||||
}
|
||||
|
||||
bool changed = Available?.Version != newest?.Version;
|
||||
Available = newest;
|
||||
if (changed)
|
||||
{
|
||||
AvailabilityChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CheckAsync()
|
||||
{
|
||||
if (_checking)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_checking = true;
|
||||
try
|
||||
{
|
||||
IReadOnlyList<ReleaseInfo> releases = await UpdateChecker.GetReleasesAsync();
|
||||
if (_enabled)
|
||||
{
|
||||
Report(releases.FirstOrDefault(r => r.Version > UpdateChecker.CurrentVersion));
|
||||
}
|
||||
}
|
||||
catch (UpdateException)
|
||||
{
|
||||
// Een mislukte achtergrondcontrole is geen melding waard; de volgende poging komt vanzelf.
|
||||
}
|
||||
finally
|
||||
{
|
||||
_checking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$knownNames = @("Kniip", "KnipPlus")
|
||||
$exePattern = '(?i)(^|[\\/"])(Kniip|KnipPlus)\.exe(\b|")'
|
||||
$knownNames = @("Kniip", "KniipTest", "KnipPlus")
|
||||
$exePattern = '(?i)(^|[\\/"])(Kniip(Test)?(-[\d.]+)?|KnipPlus)\.exe(\b|")'
|
||||
|
||||
function Test-KniipCommand([string]$text) {
|
||||
return [bool]($text -match $exePattern)
|
||||
|
||||
Reference in new issue
Block a user