Skip to content

Commit

Permalink
Add menu items: Show Desktop, Cascade/Tile, Undo
Browse files Browse the repository at this point in the history
  • Loading branch information
xoascf committed Jun 21, 2023
1 parent 271f59b commit 5310862
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 68 deletions.
2 changes: 2 additions & 0 deletions RetroBar/Controls/Clock.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MouseLeftButtonDown="Clock_OnMouseLeftButtonDown"
MouseDoubleClick="Clock_OnMouseDoubleClick"
Loaded="UserControl_Loaded"
Unloaded="UserControl_Unloaded"
Template="{DynamicResource ClockTemplateKey}">
<UserControl.ToolTip>
<TextBlock Text="{Binding Path=Now, StringFormat=D, Mode=OneWay}"
Expand Down
5 changes: 0 additions & 5 deletions RetroBar/Controls/Clock.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ private void SetTime()
Now = DateTime.Now;
}

public static void OpenDateTimeCpl()
{
ShellHelper.StartProcess("timedate.cpl");
}

private void Clock_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (EnvironmentHelper.IsWindows10OrBetter)
Expand Down
2 changes: 1 addition & 1 deletion RetroBar/Controls/ShowDesktopButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void ContextMenu_Opened(object sender, RoutedEventArgs e)
}
}

private void ToggleDesktop()
public static void ToggleDesktop()
{
NativeMethods.SendMessage(WindowHelper.FindWindowsTray(IntPtr.Zero),
(int)NativeMethods.WM.COMMAND, (IntPtr)TOGGLE_DESKTOP, IntPtr.Zero);
Expand Down
2 changes: 1 addition & 1 deletion RetroBar/Controls/TaskButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@
</ToolTip>
</Button.ToolTip>
</Button>
</UserControl>
</UserControl>
14 changes: 7 additions & 7 deletions RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
</Label>
<ComboBox 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,7 +198,7 @@
<ComboBox Name="cboEdgeSelect"
ItemsSource="{DynamicResource location_values}"
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=Edge, UpdateSourceTrigger=PropertyChanged}"
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 @@ -295,9 +295,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="cbMiddleMouseToClose"
Expand Down Expand Up @@ -329,7 +329,7 @@
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}"
SelectionChanged="cboMultiMonMode_SelectionChanged" />
SelectionChanged="CboMultiMonMode_SelectionChanged" />
</DockPanel>
</StackPanel>
</GroupBox>
Expand Down
12 changes: 6 additions & 6 deletions RetroBar/PropertiesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ private void LoadAutoStart()
{
if (rKeyValueNames.Contains("RetroBar"))
{
AutoStartCheckBox.IsChecked = true;
cbAutoStart.IsChecked = true;
}
else
{
AutoStartCheckBox.IsChecked = false;
cbAutoStart.IsChecked = false;
}
}
}
Expand Down Expand Up @@ -176,7 +176,7 @@ private void PropertiesWindow_OnContentRendered(object sender, EventArgs e)
UpdateWindowPosition();
}

private void AutoStartCheckBox_OnChecked(object sender, RoutedEventArgs e)
private void CbAutoStart_OnChecked(object sender, RoutedEventArgs e)
{
try
{
Expand All @@ -198,20 +198,20 @@ private void AutoStartCheckBox_OnChecked(object sender, RoutedEventArgs e)
}
}

private void cboLanguageSelect_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
private void CboLanguageSelect_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
LoadVersion();
}

private void cboEdgeSelect_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
private void CboEdgeSelect_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (cboEdgeSelect.SelectedItem == null)
{
cboEdgeSelect.SelectedValue = cboEdgeSelect.Items[Settings.Instance.Edge];
}
}

private void cboMultiMonMode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
private void CboMultiMonMode_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (cboMultiMonMode.SelectedItem == null)
{
Expand Down
31 changes: 31 additions & 0 deletions RetroBar/Taskbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
<converters:SettingsToTextFormattingModeConverter x:Key="textFormattingModeConverter" />
<converters:EdgeOrientationConverter x:Key="edgeOrientationConverter" />
<converters:DockOrientationConverter x:Key="dockOrientationConverter" />
<Style x:Key="UndoMenuItemStyle" TargetType="{x:Type MenuItem}">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<Trigger Property="Tag" Value="cascade">
<Setter Property="Header" Value="{DynamicResource undo_cascade}"/>
</Trigger>
<Trigger Property="Tag" Value="tile">
<Setter Property="Header" Value="{DynamicResource undo_tile}"/>
</Trigger>
<Trigger Property="Tag" Value="minimize">
<Setter Property="Header" Value="{DynamicResource undo_minimize_all}"/>
</Trigger>
</Style.Triggers>
</Style>
<MenuItem x:Shared="false" x:Key="ToolbarsItem" Header="{DynamicResource toolbars}">
<MenuItem Header="{DynamicResource quick_launch}" IsCheckable="true"
IsChecked="{Binding Source={x:Static utilities:Settings.Instance}, Path=ShowQuickLaunch, UpdateSourceTrigger=PropertyChanged}" />
Expand All @@ -26,6 +40,11 @@
</MenuItem>
<MenuItem x:Shared="false" x:Key="SetTimeMenuItem" Header="{DynamicResource set_time}" Click="SetTimeMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="CustomizeNotificationsMenuItem" Header="{DynamicResource customize_notifications_menu}" Click="CustomizeNotificationsMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="CascadeMenuItem" Header="{DynamicResource cascade}" Click="CascadeMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="HorizTileMenuItem" Header="{DynamicResource horiz_tile}" Click="HorizTileMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="VertTileMenuItem" Header="{DynamicResource vert_tile}" Click="VertTileMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="ToggleDesktopMenuItem" Header="{DynamicResource toggle_desktop}" Click="ToggleDesktopMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="UndoMenuItem" Style="{DynamicResource UndoMenuItemStyle}" Click="UndoMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="TaskManagerMenuItem" Style="{DynamicResource TaskManMenuItem}" Click="TaskManagerMenuItem_OnClick" />
<MenuItem x:Shared="false" x:Key="LockTaskbarMenuItem" Header="{DynamicResource lock_taskbar_menu}" IsCheckable="True" IsChecked="{Binding Source={x:Static utilities:Settings.Instance}, Path=LockTaskbar, UpdateSourceTrigger=PropertyChanged}" />
<MenuItem x:Shared="false" x:Key="PropertiesMenuItem" Header="{DynamicResource tray_properties}" Click="PropertiesMenuItem_OnClick" />
Expand Down Expand Up @@ -90,6 +109,12 @@
<StaticResourceExtension ResourceKey="SetTimeMenuItem" />
<StaticResourceExtension ResourceKey="CustomizeNotificationsMenuItem" />
<Separator />
<StaticResourceExtension ResourceKey="CascadeMenuItem" />
<StaticResourceExtension ResourceKey="HorizTileMenuItem" />
<StaticResourceExtension ResourceKey="VertTileMenuItem" />
<StaticResourceExtension ResourceKey="ToggleDesktopMenuItem" />
<StaticResourceExtension ResourceKey="UndoMenuItem" />
<Separator />
<StaticResourceExtension ResourceKey="TaskManagerMenuItem" />
<Separator />
<StaticResourceExtension ResourceKey="LockTaskbarMenuItem" />
Expand Down Expand Up @@ -123,6 +148,12 @@
<!-- TODO: Add when desk bands and additional taskbars are supported. -->
<!--StaticResourceExtension ResourceKey="ToolbarsItem" />
<Separator /-->
<StaticResourceExtension ResourceKey="CascadeMenuItem" />
<StaticResourceExtension ResourceKey="HorizTileMenuItem" />
<StaticResourceExtension ResourceKey="VertTileMenuItem" />
<StaticResourceExtension ResourceKey="ToggleDesktopMenuItem" />
<StaticResourceExtension ResourceKey="UndoMenuItem" />
<Separator />
<StaticResourceExtension ResourceKey="TaskManagerMenuItem" />
<Separator />
<MenuItem x:Name="UpdateAvailableMenuItem"
Expand Down
84 changes: 36 additions & 48 deletions RetroBar/Taskbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Windows.Controls;
using RetroBar.Utilities;
using Application = System.Windows.Application;
using RetroBar.Controls;
using System.Diagnostics;
using System.Windows.Input;
using ManagedShell.Common.Logging;
Expand All @@ -29,8 +28,6 @@ public bool IsLocked
}
}

private bool _clockRightClicked;
private bool _notifyAreaRightClicked;
private bool _startMenuOpen;
private LowLevelMouseHook _mouseDragHook;
private Point? _mouseDragStart = null;
Expand Down Expand Up @@ -289,7 +286,7 @@ private void Taskbar_OnSizeChanged(object sender, SizeChangedEventArgs e)
StartButton?.UpdateFloatingStartCoordinates();
}

private void DateTimeMenuItem_OnClick(object sender, RoutedEventArgs e)
private void SetTimeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
ShellHelper.StartProcess("timedate.cpl");
}
Expand All @@ -300,9 +297,42 @@ private void CustomizeNotificationsMenuItem_OnClick(object sender, RoutedEventAr
propWindow.OpenCustomizeNotifications();
}

private void SetTimeMenuItem_OnClick(object sender, RoutedEventArgs e)
private void ChangeUndoMenuItem(string tag = "", Visibility v = Visibility.Visible)
{
Style undoMenuItemStyle = (Style)Resources["UndoMenuItemStyle"];
Style newMenuItemStyle = new Style(typeof(MenuItem), undoMenuItemStyle);
newMenuItemStyle.Setters.Add(new Setter(TagProperty, tag));
newMenuItemStyle.Setters.Add(new Setter(VisibilityProperty, v));
Resources["UndoMenuItemStyle"] = newMenuItemStyle;
}

private void CascadeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
WindowTiler.CascadeWindows();
ChangeUndoMenuItem("cascade");
}

private void HorizTileMenuItem_OnClick(object sender, RoutedEventArgs e)
{
WindowTiler.TileWindowsHorizontally();
ChangeUndoMenuItem("tile");
}

private void VertTileMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Clock.OpenDateTimeCpl();
WindowTiler.TileWindowsVertically();
ChangeUndoMenuItem("tile");
}

private void ToggleDesktopMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Controls.ShowDesktopButton.ToggleDesktop();
}

private void UndoMenuItem_OnClick(object sender, RoutedEventArgs e)
{
WindowTiler.RestoreWindowPositions();
ChangeUndoMenuItem(v: Visibility.Collapsed);
}

private void TaskManagerMenuItem_OnClick(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -389,38 +419,6 @@ private void ContextMenu_Opened(object sender, RoutedEventArgs e)
{
UpdateAvailableMenuItem.Visibility = Visibility.Visible;
}

// Some menu items should only be accessible when the clock is what was right-clicked

if (_clockRightClicked)
{
DateTimeMenuItem.Visibility = Visibility.Visible;
}
else
{
DateTimeMenuItem.Visibility = Visibility.Collapsed;
}

if(_notifyAreaRightClicked && Settings.Instance.CollapseNotifyIcons)
{
CustomizeNotificationsMenuItem.Visibility = Visibility.Visible;
}
else
{
CustomizeNotificationsMenuItem.Visibility = Visibility.Collapsed;
}

if (_clockRightClicked || (_notifyAreaRightClicked && Settings.Instance.CollapseNotifyIcons))
{
NotificationAreaSeparator.Visibility = Visibility.Visible;
}
else
{
NotificationAreaSeparator.Visibility = Visibility.Collapsed;
}

_clockRightClicked = false;
_notifyAreaRightClicked = false;
}

public void SetTrayHost()
Expand Down Expand Up @@ -449,16 +447,6 @@ public void SetStartMenuOpen(bool isOpen)
}
}

private void Clock_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
_clockRightClicked = true;
}

private void NotifyArea_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
_notifyAreaRightClicked = true;
}

private void Taskbar_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (!IsLocked)
Expand Down
Loading

0 comments on commit 5310862

Please sign in to comment.