Skip to content
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

Context menu styling + fixes #461

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions RetroBar/Controls/ContextMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using ManagedShell.Common.Helpers;
using System.Windows;
using System.Windows.Controls;

namespace RetroBar.Controls
{
public partial class ContextMenu : System.Windows.Controls.ContextMenu
{
public ContextMenu()
{
SetResourceReference(StyleProperty, typeof(System.Windows.Controls.ContextMenu));
}

protected override void OnOpened(RoutedEventArgs e)
{
base.OnOpened(e);
SoundHelper.PlaySystemSound(".Default", "MenuPopup");

foreach (var item in Items)
{
if (item is MenuItem menuItem)
{
menuItem.Click -= MenuItem_Click;
menuItem.Click += MenuItem_Click;

menuItem.SubmenuOpened -= MenuItem_SubmenuOpened;
menuItem.SubmenuOpened += MenuItem_SubmenuOpened;
}
}
}

private void MenuItem_Click(object sender, RoutedEventArgs e)
{
if (!IsOpen)
{
SoundHelper.PlaySystemSound(".Default", "MenuCommand");
}
}

private void MenuItem_SubmenuOpened(object sender, RoutedEventArgs e)
{
SoundHelper.PlaySystemSound(".Default", "MenuPopup");
}
}
}
5 changes: 3 additions & 2 deletions RetroBar/Controls/ShowDesktopButton.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<UserControl x:Class="RetroBar.Controls.ShowDesktopButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:RetroBar.Controls"
xmlns:Settings="clr-namespace:RetroBar.Utilities"
Loaded="UserControl_Loaded"
Unloaded="UserControl_Unloaded">
Expand All @@ -13,7 +14,7 @@
<Image Name="ShowDesktopIcon"
Style="{DynamicResource ShowDesktopIcon}" />
<ToggleButton.ContextMenu>
<ContextMenu Opened="ContextMenu_Opened">
<controls:ContextMenu Opened="ContextMenu_Opened">
<MenuItem Style="{DynamicResource ShowDesktopItem}"
Name="ShowDesktopItem"
Click="ShowDesktop_OnClick" />
Expand All @@ -24,7 +25,7 @@
<MenuItem Header="{DynamicResource tray_properties}"
Name="PropertiesItem"
Click="PropertiesItem_OnClick" />
</ContextMenu>
</controls:ContextMenu>
</ToggleButton.ContextMenu>
</ToggleButton>
</UserControl>
Expand Down
13 changes: 4 additions & 9 deletions RetroBar/Controls/TaskButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,11 @@
</TextBlock>
</Grid>
<Button.ContextMenu>
<ContextMenu>
<controls:ContextMenu>
<MenuItem Header="{DynamicResource restore}"
Click="RestoreMenuItem_OnClick"
Name="RestoreMenuItem">
<MenuItem.Icon>
<TextBlock FontFamily="Marlett"
Text="&#x32;"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</MenuItem.Icon>
Name="RestoreMenuItem"
Style="{DynamicResource RestoreMenuItem}">
</MenuItem>
<MenuItem Header="{DynamicResource move}"
Click="MoveMenuItem_OnClick"
Expand Down Expand Up @@ -93,7 +88,7 @@
VerticalAlignment="Center" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</controls:ContextMenu>
</Button.ContextMenu>
<Button.ToolTip>
<ToolTip>
Expand Down
42 changes: 30 additions & 12 deletions RetroBar/Controls/TaskButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,50 +108,68 @@ private void AppButton_OnContextMenuOpening(object sender, ContextMenuEventArgs
int ws = Window.WindowStyles;

// disable window operations depending on current window state. originally tried implementing via bindings but found there is no notification we get regarding maximized state
MaximizeMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
MinimizeMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowMinimized && (ws & (int)NativeMethods.WindowStyles.WS_MINIMIZEBOX) != 0);
if (RestoreMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowNormal))
MaximizeMenuItem.StaysOpenOnClick = !(wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
MinimizeMenuItem.StaysOpenOnClick = !(wss != NativeMethods.WindowShowStyle.ShowMinimized && (ws & (int)NativeMethods.WindowStyles.WS_MINIMIZEBOX) != 0);
if (!(RestoreMenuItem.StaysOpenOnClick = wss == NativeMethods.WindowShowStyle.ShowNormal))
{
CloseMenuItem.FontWeight = FontWeights.Normal;
RestoreMenuItem.FontWeight = FontWeights.Bold;
}
if (!RestoreMenuItem.IsEnabled || RestoreMenuItem.IsEnabled && !MaximizeMenuItem.IsEnabled)
if (RestoreMenuItem.StaysOpenOnClick || !RestoreMenuItem.StaysOpenOnClick && MaximizeMenuItem.StaysOpenOnClick)
{
CloseMenuItem.FontWeight = FontWeights.Bold;
RestoreMenuItem.FontWeight = FontWeights.Normal;
}
MoveMenuItem.IsEnabled = wss == NativeMethods.WindowShowStyle.ShowNormal;
SizeMenuItem.IsEnabled = (wss == NativeMethods.WindowShowStyle.ShowNormal && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
MoveMenuItem.StaysOpenOnClick = wss != NativeMethods.WindowShowStyle.ShowNormal;
SizeMenuItem.StaysOpenOnClick = !(wss == NativeMethods.WindowShowStyle.ShowNormal && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
}

private void CloseMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Close();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Close();
}
}

private void RestoreMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Restore();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Restore();
}
}

private void MoveMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Move();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Move();
}
}

private void SizeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Size();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Size();
}
}

private void MinimizeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Minimize();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Minimize();
}
}

private void MaximizeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Maximize();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Maximize();
}
}

private void AppButton_OnClick(object sender, RoutedEventArgs e)
Expand Down
10 changes: 8 additions & 2 deletions RetroBar/Controls/TaskList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,16 @@ private void SetScrollable(bool canScroll)

private void TasksScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
if (!isScrollable)
if (e.Delta > 0)
{
e.Handled = true;
TasksScrollViewer.PageUp();
}
if (e.Delta < 0)
{
TasksScrollViewer.PageDown();
}

e.Handled = true;
}
}
}
38 changes: 19 additions & 19 deletions RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@
<AccessText Text="{DynamicResource language_text}"
ToolTip="{DynamicResource language_tip}" />
</Label>
<ComboBox Name="cboLanguageSelect"
<ComboBox x:Name="cboLanguageSelect"
SelectedValue="{Binding Source={x:Static Settings:Settings.Instance}, Path=Language, UpdateSourceTrigger=PropertyChanged}"
SelectionChanged="cboLanguageSelect_SelectionChanged" />
SelectionChanged="CboLanguageSelect_SelectionChanged" />
</DockPanel>
<DockPanel>
<Label VerticalAlignment="Center"
Target="{Binding ElementName=cboThemeSelect}">
<AccessText Text="{DynamicResource theme_text}"
ToolTip="{DynamicResource theme_tip}" />
</Label>
<ComboBox Name="cboThemeSelect"
<ComboBox x:Name="cboThemeSelect"
SelectedValue="{Binding Source={x:Static Settings:Settings.Instance}, Path=Theme, UpdateSourceTrigger=PropertyChanged}" />
</DockPanel>
<DockPanel>
Expand All @@ -198,10 +198,10 @@
<AccessText Text="{DynamicResource location_text}"
ToolTip="{DynamicResource location_tip}" />
</Label>
<ComboBox Name="cboEdgeSelect"
<ComboBox x:Name="cboEdgeSelect"
ItemsSource="{DynamicResource location_values}"
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=Edge, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource enumConverter}}"
SelectionChanged="cboEdgeSelect_SelectionChanged" />
SelectionChanged="CboEdgeSelect_SelectionChanged" />
</DockPanel>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=AllowFontSmoothing, UpdateSourceTrigger=PropertyChanged}">
<Label Content="{DynamicResource allow_font_smoothing}" />
Expand Down Expand Up @@ -250,7 +250,7 @@
DockPanel.Dock="Right">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal">
<ToggleButton Name="NotifyIconToggleButton"
<ToggleButton x:Name="NotifyIconToggleButton"
Focusable="False"
Visibility="{Binding Source={x:Static Settings:Settings.Instance}, Path=CollapseNotifyIcons, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource boolToVisibilityConverter}}"
Style="{DynamicResource TrayToggleButton}"/>
Expand Down Expand Up @@ -307,9 +307,9 @@
Margin="10">
<StackPanel Orientation="Vertical"
Margin="0,0,0,10">
<CheckBox Checked="AutoStartCheckBox_OnChecked"
Unchecked="AutoStartCheckBox_OnChecked"
Name="AutoStartCheckBox">
<CheckBox x:Name="cbAutoStart"
Checked="CbAutoStart_OnChecked"
Unchecked="CbAutoStart_OnChecked">
<Label Content="{DynamicResource autostart}" />
</CheckBox>
<CheckBox x:Name="cbUseSoftwareRendering"
Expand All @@ -329,14 +329,14 @@
Target="{Binding ElementName=cboInvertIconsMode}">
<AccessText Text="{DynamicResource invert_system_icons}" />
</Label>
<ComboBox Name="cboInvertIconsMode"
<ComboBox x:Name="cboInvertIconsMode"
ItemsSource="{DynamicResource invert_system_icons_values}"
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=InvertIconsMode, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource enumConverter}}"
SelectionChanged="cboInvertIconsMode_SelectionChanged" />
SelectionChanged="CboInvertIconsMode_SelectionChanged" />
</DockPanel>
<Button HorizontalAlignment="Right"
Content="{DynamicResource customize}"
Click="CustomizeNotifications_OnClick" />
Content="{DynamicResource customize}"
Click="CustomizeNotifications_OnClick" />
<DockPanel>
<Label VerticalAlignment="Center"
Target="{Binding ElementName=cboMiddleMouseAction}">
Expand All @@ -345,7 +345,7 @@
<ComboBox x:Name="cboMiddleMouseAction"
ItemsSource="{DynamicResource middle_mouse_task_action_values}"
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=TaskMiddleClickAction, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource enumConverter}}"
SelectionChanged="cboMiddleMouseAction_SelectionChanged" />
SelectionChanged="CboMiddleMouseAction_SelectionChanged" />
</DockPanel>
</StackPanel>
<GroupBox Header="{DynamicResource multiple_displays}"
Expand All @@ -360,11 +360,11 @@
Target="{Binding ElementName=cboMultiMonMode}">
<AccessText Text="{DynamicResource show_tasks_on}" />
</Label>
<ComboBox Name="cboMultiMonMode"
<ComboBox x:Name="cboMultiMonMode"
IsEnabled="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowMultiMon, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{DynamicResource show_tasks_on_values}"
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=MultiMonMode, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource enumConverter}}"
SelectionChanged="cboMultiMonMode_SelectionChanged" />
SelectionChanged="CboMultiMonMode_SelectionChanged" />
</DockPanel>
</StackPanel>
</GroupBox>
Expand All @@ -373,7 +373,7 @@
<DockPanel Margin="20,0">
<Label DockPanel.Dock="Left" Content="{DynamicResource taskbar_scale_1x}" />
<Label DockPanel.Dock="Right" Content="{DynamicResource taskbar_scale_2x}" />
<Slider Name="sldTaskbarScale"
<Slider x:Name="sldTaskbarScale"
Orientation="Horizontal"
IsSnapToTickEnabled="True"
Value="{Binding Source={x:Static Settings:Settings.Instance}, Path=TaskbarScale, UpdateSourceTrigger=PropertyChanged}"
Expand All @@ -382,7 +382,7 @@
TickFrequency="0.05"
TickPlacement="BottomRight" />
</DockPanel>
<TextBlock Name="txtCurrentScale"
<TextBlock x:Name="txtCurrentScale"
HorizontalAlignment="Center">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource doubleToPercentConverter}" UpdateSourceTrigger="PropertyChanged">
Expand All @@ -394,7 +394,7 @@
</StackPanel>
</GroupBox>
<DockPanel Margin="0,10,0,0">
<TextBlock Name="txtVersion"
<TextBlock x:Name="txtVersion"
DockPanel.Dock="Left"
Margin="0,0,10,0" />
<TextBlock DockPanel.Dock="Right"
Expand Down
Loading