Added pasting new memes, fixed offsets and changed out tray icon.
This commit is contained in:
@@ -11,7 +11,9 @@ namespace EbbesMemeClipboard.ViewModels;
|
||||
/// </summary>
|
||||
public partial class MemeTileViewModel : ObservableObject
|
||||
{
|
||||
private const int ThumbnailPixelWidth = 150;
|
||||
// Comfortably above the ~126px logical tile width so thumbnails stay sharp at 150-200%
|
||||
// display scaling, without decoding anything near full resolution.
|
||||
private const int ThumbnailPixelWidth = 240;
|
||||
|
||||
private readonly IGifCacheService? _cache;
|
||||
private string? _localPath;
|
||||
|
||||
@@ -188,6 +188,54 @@ public partial class PickerViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronous peek so the Ctrl+V key handler can decide immediately whether to swallow the
|
||||
/// keystroke (image on the clipboard) or let it through to the search box (plain text).
|
||||
/// </summary>
|
||||
public ClipboardImportPayload? ReadClipboardImage()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _clipboard.TryReadImage();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Another process holding the clipboard shouldn't break the keystroke entirely.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ImportClipboardAsync(ClipboardImportPayload payload)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (payload.HasFiles)
|
||||
{
|
||||
await ImportPathsAsync(payload.FilePaths!);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!payload.HasBytes) return;
|
||||
|
||||
var name = $"pasted-{DateTime.Now:yyyy-MM-dd-HHmmss}{payload.Extension}";
|
||||
var record = await _library.ImportBytesAsync(payload.Data!, payload.Extension!, name);
|
||||
|
||||
if (record is null)
|
||||
{
|
||||
StatusMessage = "Couldn't add that image.";
|
||||
return;
|
||||
}
|
||||
|
||||
ActiveSource = MemeSource.Local;
|
||||
RefreshLocalItems();
|
||||
StatusMessage = $"Pasted {name}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusMessage = $"Couldn't paste image: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ImportPathsAsync(IEnumerable<string> paths)
|
||||
{
|
||||
var candidates = paths
|
||||
|
||||
Reference in New Issue
Block a user