-
-
Notifications
You must be signed in to change notification settings - Fork 446
Use ResultContextMenu instead of ContextMenu #3600
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -80,8 +80,8 @@ | |||||
public MainWindow() | ||||||
{ | ||||||
_settings = Ioc.Default.GetRequiredService<Settings>(); | ||||||
_theme = Ioc.Default.GetRequiredService<Theme>(); | ||||||
_viewModel = Ioc.Default.GetRequiredService<MainViewModel>(); | ||||||
DataContext = _viewModel; | ||||||
|
||||||
InitializeComponent(); | ||||||
|
@@ -108,7 +108,7 @@ | |||||
{ | ||||||
var handle = Win32Helper.GetWindowHandle(this, true); | ||||||
_hwndSource = HwndSource.FromHwnd(handle); | ||||||
_hwndSource.AddHook(WndProc); | ||||||
Win32Helper.HideFromAltTab(this); | ||||||
Win32Helper.DisableControlBox(this); | ||||||
} | ||||||
|
@@ -295,14 +295,14 @@ | |||||
// QueryTextBox.Text change detection (modified to only work when character count is 1 or higher) | ||||||
QueryTextBox.TextChanged += (s, e) => UpdateClockPanelVisibility(); | ||||||
|
||||||
// Detecting ContextMenu.Visibility changes | ||||||
// Detecting ResultContextMenu.Visibility changes | ||||||
DependencyPropertyDescriptor | ||||||
.FromProperty(VisibilityProperty, typeof(ContextMenu)) | ||||||
.AddValueChanged(ContextMenu, (s, e) => UpdateClockPanelVisibility()); | ||||||
.FromProperty(VisibilityProperty, typeof(ResultListBox)) | ||||||
.AddValueChanged(ResultContextMenu, (s, e) => UpdateClockPanelVisibility()); | ||||||
|
||||||
// Detect History.Visibility changes | ||||||
DependencyPropertyDescriptor | ||||||
.FromProperty(VisibilityProperty, typeof(StackPanel)) | ||||||
.FromProperty(VisibilityProperty, typeof(ResultListBox)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The owner type for the History subscription should match the actual control type (e.g., StackPanel or Border) rather than ResultListBox, otherwise the Descriptor may not fire when History.Visibility changes.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Jack251970 is this relevant? |
||||||
.AddValueChanged(History, (s, e) => UpdateClockPanelVisibility()); | ||||||
|
||||||
// Initialize query state | ||||||
|
@@ -333,7 +333,7 @@ | |||||
{ | ||||||
try | ||||||
{ | ||||||
_hwndSource.RemoveHook(WndProc); | ||||||
} | ||||||
catch (Exception) | ||||||
{ | ||||||
|
@@ -457,7 +457,7 @@ | |||||
} | ||||||
} | ||||||
|
||||||
#pragma warning restore VSTHRD100 // Avoid async void methods | ||||||
|
||||||
#endregion | ||||||
|
||||||
|
@@ -472,7 +472,7 @@ | |||||
|
||||||
#region Window Context Menu Event | ||||||
|
||||||
#pragma warning disable VSTHRD100 // Avoid async void methods | ||||||
|
||||||
private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e) | ||||||
{ | ||||||
|
@@ -484,13 +484,13 @@ | |||||
App.API.OpenSettingDialog(); | ||||||
} | ||||||
|
||||||
#pragma warning restore VSTHRD100 // Avoid async void methods | ||||||
|
||||||
#endregion | ||||||
|
||||||
#region Window WndProc | ||||||
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) | ||||||
{ | ||||||
if (msg == Win32Helper.WM_ENTERSIZEMOVE) | ||||||
{ | ||||||
|
@@ -561,7 +561,7 @@ | |||||
|
||||||
private void InitSoundEffects() | ||||||
{ | ||||||
if (_settings.WMPInstalled) | ||||||
{ | ||||||
animationSoundWMP?.Close(); | ||||||
animationSoundWMP = new MediaPlayer(); | ||||||
|
@@ -1016,7 +1016,7 @@ | |||||
|
||||||
private void UpdateClockPanelVisibility() | ||||||
{ | ||||||
if (QueryTextBox == null || ContextMenu == null || History == null || ClockPanel == null) | ||||||
if (QueryTextBox == null || ResultContextMenu == null || History == null || ClockPanel == null) | ||||||
{ | ||||||
return; | ||||||
} | ||||||
|
@@ -1031,20 +1031,20 @@ | |||||
}; | ||||||
var animationDuration = TimeSpan.FromMilliseconds(animationLength * 2 / 3); | ||||||
|
||||||
// ✅ Conditions for showing ClockPanel (No query input & ContextMenu, History are closed) | ||||||
// ✅ Conditions for showing ClockPanel (No query input / ResultContextMenu & History are closed) | ||||||
var shouldShowClock = QueryTextBox.Text.Length == 0 && | ||||||
ContextMenu.Visibility != Visibility.Visible && | ||||||
ResultContextMenu.Visibility != Visibility.Visible && | ||||||
History.Visibility != Visibility.Visible; | ||||||
|
||||||
// ✅ 1. When ContextMenu opens, immediately set Visibility.Hidden (force hide without animation) | ||||||
if (ContextMenu.Visibility == Visibility.Visible) | ||||||
// ✅ 1. When ResultContextMenu opens, immediately set Visibility.Hidden (force hide without animation) | ||||||
if (ResultContextMenu.Visibility == Visibility.Visible) | ||||||
{ | ||||||
_viewModel.ClockPanelVisibility = Visibility.Hidden; | ||||||
_viewModel.ClockPanelOpacity = 0.0; // Set to 0 in case Opacity animation affects it | ||||||
return; | ||||||
} | ||||||
|
||||||
// ✅ 2. When ContextMenu is closed, keep it Hidden if there's text in the query (remember previous state) | ||||||
// ✅ 2. When ResultContextMenu is closed, keep it Hidden if there's text in the query (remember previous state) | ||||||
else if (QueryTextBox.Text.Length > 0) | ||||||
{ | ||||||
_viewModel.ClockPanelVisibility = Visibility.Hidden; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -479,7 +479,7 @@ | |
<MultiDataTrigger.Conditions> | ||
<!-- | ||
<Condition Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Collapsed" /> | ||
<Condition Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Collapsed" />--> | ||
<Condition Binding="{Binding ElementName=ResultContextMenu, Path=Visibility}" Value="Collapsed" />--> | ||
Comment on lines
480
to
+482
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The comment block opens on line 480 but closes here, which can be hard to follow; consider using a single-line comment ( Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
<Condition Binding="{Binding ElementName=History, Path=Visibility}" Value="Collapsed" /> | ||
<Condition Binding="{Binding ElementName=ResultListBox, Path=Items.Count}" Value="0" /> | ||
</MultiDataTrigger.Conditions> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Rename result list instance to
ResultContextMenu
This
ResultListBox
instance has been renamed, aligning with the new naming convention. Please ensure corresponding bindings and any code-behind references inMainWindow.xaml.cs
are also updated.Run this script to verify no residual
<ContextMenu>
references remain:🏁 Script executed:
Length of output: 223
Review leftover
<ContextMenu>
definitionsThe search for
<ContextMenu
shows remaining definitions in:Please verify and update as needed:
<ContextMenu>
at MainWindow.xaml:262 is the one for your renamedResultContextMenu
, adjust itsx:Name
, bindings and any code‐behind references to match.TextBoxContextMenu
in CustomControlTemplate.xaml is unrelated, you can leave it intact. Otherwise, rename or refactor it to fit the new naming convention.🧰 Tools
🪛 GitHub Actions: Check Spelling
[warning] 460-31:
VSTHRD
is not a recognized word. (unrecognized-spelling)[warning] 475-31:
VSTHRD
is not a recognized word. (unrecognized-spelling)[warning] 487-31:
VSTHRD
is not a recognized word. (unrecognized-spelling)[warning] 491-27:
Wnd
is not a recognized word. (unrecognized-spelling)[warning] 493-27:
Wnd
is not a recognized word. (unrecognized-spelling)[warning] 564-30:
WMP
is not a recognized word. (unrecognized-spelling)[warning] 566-34:
WMP
is not a recognized word. (unrecognized-spelling)[warning] 567-34:
WMP
is not a recognized word. (unrecognized-spelling)[warning] 568-34:
WMP
is not a recognized word. (unrecognized-spelling)[warning] 648-25:
gamemode
is not a recognized word. (unrecognized-spelling)[warning] 649-25:
gamemode
is not a recognized word. (unrecognized-spelling)[warning] 652-32:
gamemode
is not a recognized word. (unrecognized-spelling)[warning] 655-30:
positionreset
is not a recognized word. (unrecognized-spelling)[warning] 658-37:
positionreset
is not a recognized word. (unrecognized-spelling)[warning] 674-21:
gamemode
is not a recognized word. (unrecognized-spelling)[warning] 675-26:
positionreset
is not a recognized word. (unrecognized-spelling)[warning] 680-26:
positionreset
is not a recognized word. (unrecognized-spelling)[warning] 790-64:
XRatio
is not a recognized word. (unrecognized-spelling)[warning] 791-63:
YRatio
is not a recognized word. (unrecognized-spelling)[warning] 1005-20:
clocksb
is not a recognized word. (unrecognized-spelling)[warning] 1006-20:
clocksb
is not a recognized word. (unrecognized-spelling)[warning] 1007-19:
iconsb
is not a recognized word. (unrecognized-spelling)[warning] 1008-19:
iconsb
is not a recognized word. (unrecognized-spelling)[warning] 1013-20:
clocksb
is not a recognized word. (unrecognized-spelling)[warning] 1014-19:
iconsb
is not a recognized word. (unrecognized-spelling)🤖 Prompt for AI Agents