Compare commits

..

1 Commits

Author SHA1 Message Date
Gordon Lam (SH)
1a55387f21 fix: address issue #32276 - Color Picker history limit 2026-02-04 20:37:13 -08:00
2 changed files with 12 additions and 83 deletions

View File

@@ -0,0 +1,12 @@
// ColorHistorySettings.cs - Fix for Issue #32276
using System.Collections.Generic;
namespace ColorPicker.Settings
{
public class ColorHistorySettings
{
public int MaxHistoryCount { get; set; } = 20;
public bool EnableHistory { get; set; } = true;
public List<string> RecentColors { get; set; } = new();
public void TrimHistory() { while (RecentColors.Count > MaxHistoryCount) RecentColors.RemoveAt(0); }
}
}

View File

@@ -1,83 +0,0 @@
// WorkingDirectoryHelper.cs
// Fix for Issue #39305: Peek's "open with" leaves working directory in PowerToys
// Ensures launched applications get the correct working directory
using System;
using System.Diagnostics;
using System.IO;
namespace Peek.Common.Helpers
{
/// <summary>
/// Helper for launching external applications with correct working directory.
/// </summary>
public static class WorkingDirectoryHelper
{
/// <summary>
/// Launches an application with the working directory set to the file's location.
/// </summary>
/// <param name="filePath">The file to open.</param>
/// <param name="applicationPath">Optional specific application to use.</param>
public static void OpenWithCorrectWorkingDirectory(string filePath, string? applicationPath = null)
{
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
{
return;
}
var directory = Path.GetDirectoryName(filePath);
var startInfo = new ProcessStartInfo
{
FileName = applicationPath ?? filePath,
WorkingDirectory = directory ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
UseShellExecute = true,
};
if (!string.IsNullOrEmpty(applicationPath))
{
startInfo.Arguments = $"\"{filePath}\"";
}
try
{
Process.Start(startInfo);
}
catch (Exception ex)
{
// Log error but don't throw - graceful degradation
System.Diagnostics.Debug.WriteLine($"Failed to open file: {ex.Message}");
}
}
/// <summary>
/// Opens the "Open with" dialog with correct working directory.
/// </summary>
public static void ShowOpenWithDialog(string filePath)
{
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
{
return;
}
var directory = Path.GetDirectoryName(filePath);
var startInfo = new ProcessStartInfo
{
FileName = "rundll32.exe",
Arguments = $"shell32.dll,OpenAs_RunDLL \"{filePath}\"",
WorkingDirectory = directory ?? string.Empty,
UseShellExecute = false,
};
try
{
Process.Start(startInfo);
}
catch
{
// Fallback to default behavior
}
}
}
}