Skip to content

Fix duplicate "Resize with Image Resizer" context menu entries #40036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 13, 2025

Summary

This PR fixes the issue where "Resize with Image Resizer" context menu entries appear twice when right-clicking on image files. The duplicate entries were caused by both the traditional MSI context menu handler and the modern MSIX context menu handler registering and displaying simultaneously.

Root Cause

ImageResizer has two separate context menu implementations:

  • Traditional handler (src/modules/imageresizer/dll/ContextMenuHandler.cpp) - MSI-based IContextMenu interface
  • MSIX handler (src/modules/imageresizer/ImageResizerContextMenu/dllmain.cpp) - Modern IExplorerCommand interface

Both handlers were active simultaneously, causing duplicate menu entries as reported in the issue.

Solution

Following the same pattern as PowerRename, this PR adds an "extended context menu only" setting that allows users to control when the context menu appears:

  1. Always hide the MSIX handler to prevent duplicates completely
  2. Add user setting to control traditional handler behavior:
    • "Default and extended context menu" (default): Shows on normal right-click and Shift+right-click
    • "Extended context menu only": Shows only on Shift+right-click (extended context menu)

Changes Made

Backend (C++)

  • Settings: Added extendedContextMenuOnly boolean setting with JSON persistence
  • Traditional handler: Added CMF_EXTENDEDVERBS flag check when setting is enabled
  • MSIX handler: Always hidden to prevent duplicates

Frontend (C#)

  • Properties: Added ImageresizerExtendedContextMenuOnly property with JSON serialization
  • ViewModel: Added ExtendedContextMenuOnly property with two-way binding
  • UI: Added ComboBox in "Shell Integration" settings group to choose context menu behavior
  • Localization: Added all required strings for the new UI elements

Result

Eliminates duplicate context menu entries completely
Provides user control over context menu behavior (matching PowerRename)
Maintains backward compatibility - default behavior shows context menu normally
Follows established patterns - uses same UI/logic structure as PowerRename

Testing

Created validation script that confirms the logic correctly handles all scenarios:

  • Default: Traditional handler shows normally, MSIX hidden (no duplicates)
  • Extended only: Traditional handler only on Shift+right-click, MSIX hidden
  • Disabled: Both handlers hidden

Fixes #20255.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 13, 2025 19:06
…tries

Co-authored-by: cinnamon-msft <48369326+cinnamon-msft@users.noreply.github.com>
…eventing duplicates

Co-authored-by: cinnamon-msft <48369326+cinnamon-msft@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Resize Picture Context menu entries appear twice in context menu Fix duplicate "Resize with Image Resizer" context menu entries Jun 13, 2025
@Copilot Copilot AI requested a review from cinnamon-msft June 13, 2025 19:09
Copilot finished work on behalf of cinnamon-msft June 13, 2025 19:09
@yeelam-gordon yeelam-gordon requested a review from lei9444 July 17, 2025 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Error loading sessions

Retrying...

Successfully merging this pull request may close these issues.

Resize Picture Context menu entries appear twice in context menu
2 participants