Skip to content
Merged
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
31 changes: 31 additions & 0 deletions RetroBar/Controls/ShowDesktopButton.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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:Settings="clr-namespace:RetroBar.Utilities"
Loaded="UserControl_Loaded"
Unloaded="UserControl_Unloaded">
<ToggleButton Name="ShowDesktop"
ToolTip="{DynamicResource ShowDesktopButtonTip}"
Style="{DynamicResource ShowDesktopButton}"
Click="ShowDesktop_OnClick"
MouseEnter="ShowDesktop_OnMouseEnter"
MouseLeave="ShowDesktop_OnMouseLeave">
<Image Name="ShowDesktopIcon"
Style="{DynamicResource ShowDesktopIcon}" />
<ToggleButton.ContextMenu>
<ContextMenu Opened="ContextMenu_Opened">
<MenuItem Style="{DynamicResource ShowDesktopItem}"
Name="ShowDesktopItem"
Click="ShowDesktop_OnClick" />
<MenuItem Header="{DynamicResource peek_at_desktop}"
IsCheckable="True"
IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=PeekAtDesktop, UpdateSourceTrigger=PropertyChanged}"
Name="PeekAtDesktopItem" />
<MenuItem Header="{DynamicResource tray_properties}"
Name="PropertiesItem"
Click="PropertiesItem_OnClick" />
</ContextMenu>
</ToggleButton.ContextMenu>
</ToggleButton>
</UserControl>

132 changes: 132 additions & 0 deletions RetroBar/Controls/ShowDesktopButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
using ManagedShell.Common.Helpers;
using ManagedShell.Interop;
using ManagedShell.WindowsTasks;
using RetroBar.Utilities;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;

namespace RetroBar.Controls
{
/// <summary>
/// Interaction logic for ShowDesktopButton.xaml
/// </summary>
public partial class ShowDesktopButton : UserControl
{
private const int TOGGLE_DESKTOP = 407;
private IntPtr taskbarHandle = Process.GetCurrentProcess().MainWindowHandle;
private bool isWindows81OrBetter = EnvironmentHelper.IsWindows81OrBetter;
private bool isLoaded;

public static DependencyProperty TasksServiceProperty = DependencyProperty.Register("TasksService", typeof(TasksService), typeof(ShowDesktopButton));

public TasksService TasksService
{
get { return (TasksService)GetValue(TasksServiceProperty); }
set { SetValue(TasksServiceProperty, value); }
}

public ShowDesktopButton()
{
InitializeComponent();
}

private void SetIconSizeForDpi()
{
if (DpiHelper.DpiScale > 1)
{
ShowDesktopIcon.Source = (System.Windows.Media.ImageSource)FindResource("ShowDesktopIconImageLarge");
}
else
{
ShowDesktopIcon.Source = (System.Windows.Media.ImageSource)FindResource("ShowDesktopIconImageSmall");
}
}

private void ContextMenu_Opened(object sender, RoutedEventArgs e)
{
PeekAtDesktopItem.IsEnabled = true;
if (!NativeMethods.DwmIsCompositionEnabled())
{
PeekAtDesktopItem.IsEnabled = false;
}
}

private void ToggleDesktop()
{
NativeMethods.SendMessage(WindowHelper.FindWindowsTray(IntPtr.Zero),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be better to add this to ManagedShell instead of being here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. This could complement the other Aero Peek helper methods in ManagedShell.

(int)NativeMethods.WM.COMMAND, (IntPtr)TOGGLE_DESKTOP, IntPtr.Zero);
}

private void PeekAtDesktop(uint shouldPeek)
{
if (Settings.Instance.PeekAtDesktop && NativeMethods.DwmIsCompositionEnabled())
{
if (isWindows81OrBetter)
{
NativeMethods.DwmActivateLivePreview(shouldPeek, taskbarHandle,
IntPtr.Zero, NativeMethods.AeroPeekType.Desktop, IntPtr.Zero);
}
else
{
NativeMethods.DwmActivateLivePreview(shouldPeek, taskbarHandle,
IntPtr.Zero, NativeMethods.AeroPeekType.Desktop);
}
}
}

private void ShowDesktop_OnMouseEnter(object sender, RoutedEventArgs e)
{
PeekAtDesktop(1);
}

private void ShowDesktop_OnMouseLeave(object sender, RoutedEventArgs e)
{
PeekAtDesktop(0);
}

private void ShowDesktop_OnClick(object sender, RoutedEventArgs e)
{
// If the user activates a window other than the desktop, HandleWindowActivated will deselect the button.
ToggleDesktop();
}

private void OpenDisplayPropertiesCpl()
{
ShellHelper.StartProcess("desk.cpl");
}

private void PropertiesItem_OnClick(object sender, RoutedEventArgs e)
{
OpenDisplayPropertiesCpl();
}

private void HandleWindowActivated(object sender, WindowActivatedEventArgs e)
{
if (ShowDesktop.IsChecked == true)
{
ShowDesktop.IsChecked = false;
}
}

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
if (!isLoaded && TasksService != null)
{
SetIconSizeForDpi();
TasksService.WindowActivated += HandleWindowActivated;
isLoaded = true;
}
}

private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
if (isLoaded && TasksService != null)
{
TasksService.WindowActivated -= HandleWindowActivated;
isLoaded = false;
}
}
}
}
7 changes: 7 additions & 0 deletions RetroBar/Languages/English.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<s:String x:Key="show_window_previews">Show _window previews (thumbnails)</s:String>
<s:String x:Key="use_software_rendering">_Use software rendering</s:String>
<s:String x:Key="middle_mouse_to_close">_Middle-click to close taskbar items</s:String>
<s:String x:Key="add_show_desktop_button">Add the Show _Desktop button</s:String>
<s:String x:Key="multiple_displays">Multiple displays</s:String>
<s:String x:Key="show_tasks_on">S_how tasks on:</s:String>
<x:Array x:Key="show_tasks_on_values" Type="s:String">
Expand Down Expand Up @@ -76,6 +77,12 @@
<s:String x:Key="exit_retrobar">_Exit RetroBar</s:String>
<s:String x:Key="customize_notifications_menu">_Customize Notifications...</s:String>

<s:String x:Key="show_desktop_tip_95">Surface/Restore Desktop</s:String>
<s:String x:Key="show_desktop_tip">Show Desktop</s:String>
<s:String x:Key="show_desktop_95">_Desktop</s:String>
<s:String x:Key="show_desktop">_Show Desktop</s:String>
<s:String x:Key="peek_at_desktop">_Peek at desktop</s:String>

<s:String x:Key="restore">_Restore</s:String>
<s:String x:Key="move">_Move</s:String>
<s:String x:Key="size">_Size</s:String>
Expand Down
7 changes: 7 additions & 0 deletions RetroBar/Languages/español.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<s:String x:Key="show_window_previews">Mostrar _vistas previas de las ventanas (miniaturas)</s:String>
<s:String x:Key="use_software_rendering">Usar procesamiento por soft_ware</s:String>
<s:String x:Key="middle_mouse_to_close">_Cerrar elementos de la barra de tareas con el botón central</s:String>
<s:String x:Key="add_show_desktop_button">Agregar el botón Mostrar _escritorio</s:String>
<s:String x:Key="multiple_displays">Varias pantallas</s:String>
<s:String x:Key="show_tasks_on">Mostrar _tareas en:</s:String>
<x:Array x:Key="show_tasks_on_values" Type="s:String">
Expand Down Expand Up @@ -76,6 +77,12 @@
<s:String x:Key="exit_retrobar">_Salir de RetroBar</s:String>
<s:String x:Key="customize_notifications_menu">Personali_zar notificaciones...</s:String>

<s:String x:Key="show_desktop_tip_95">Emerger o restaurar escritorio</s:String>
<s:String x:Key="show_desktop_tip">Mostrar escritorio</s:String>
<s:String x:Key="show_desktop_95">_Escritorio</s:String>
<s:String x:Key="show_desktop">_Mostrar escritorio</s:String>
<s:String x:Key="peek_at_desktop">_Vistazo al escritorio</s:String>

<s:String x:Key="restore">_Restaurar</s:String>
<s:String x:Key="move">_Mover</s:String>
<s:String x:Key="size">_Tamaño</s:String>
Expand Down
24 changes: 24 additions & 0 deletions RetroBar/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions RetroBar/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@
<Setting Name="UseSoftwareRendering" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="MiddleMouseToClose" Type="System.Boolean" Scope="User">
<Setting Name="MiddleMouseToClose" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ShowDesktopButton" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="PeekAtDesktop" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>

<Setting Name="PinnedNotifyIcons" Type="System.String" Scope="User">
<Value Profile="(Default)">7820ae76-23e3-4229-82c1-e41cb67d5b9c|7820ae75-23e3-4229-82c1-e41cb67d5b9c|7820ae74-23e3-4229-82c1-e41cb67d5b9c|7820ae73-23e3-4229-82c1-e41cb67d5b9c</Value>
</Setting>
Expand Down
5 changes: 5 additions & 0 deletions RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
Converter="{StaticResource textRenderingModeConverter}" />
</TextOptions.TextRenderingMode>
<DockPanel>
<controls:ShowDesktopButton DockPanel.Dock="Right" HorizontalAlignment="Center" Visibility="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowDesktopButton, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource boolToVisibilityConverter}}" />
<GroupBox Style="{DynamicResource Tray}"
DockPanel.Dock="Right">
<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -253,6 +254,10 @@
IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowClock, UpdateSourceTrigger=PropertyChanged}">
<Label Content="{DynamicResource show_clock}" />
</CheckBox>
<CheckBox x:Name="cbShowDesktopButton"
IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowDesktopButton, UpdateSourceTrigger=PropertyChanged}">
<Label Content="{DynamicResource add_show_desktop_button}" />
</CheckBox>
<DockPanel>
<CheckBox x:Name="cbCollapseTrayIcons"
IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=CollapseNotifyIcons, UpdateSourceTrigger=PropertyChanged}">
Expand Down
Binary file added RetroBar/Resources/desktop95-lg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RetroBar/Resources/desktop95-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RetroBar/Resources/desktopMe2k-lg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RetroBar/Resources/desktopMe2k-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RetroBar/Resources/desktopxp-lg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RetroBar/Resources/desktopxp-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion RetroBar/RetroBar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
</ItemGroup>

<ItemGroup>
<None Remove="Resources\desktop95-sm.png" />
<None Remove="Resources\desktop95-lg.png" />
<None Remove="Resources\retrobar.ico" />
<None Remove="Resources\shader_invert.ps" />
<None Remove="Resources\start9x.png" />
Expand All @@ -43,7 +45,7 @@

<ItemGroup>
<PackageReference Include="gong-wpf-dragdrop" Version="3.1.1" />
<PackageReference Include="ManagedShell" Version="0.0.200" />
<PackageReference Include="ManagedShell" Version="0.0.202" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
</ItemGroup>

Expand All @@ -52,6 +54,8 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\desktop95-sm.png" />
<Resource Include="Resources\desktop95-lg.png" />
<Resource Include="Resources\shader_invert.ps" />
<Resource Include="Resources\retrobar.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
Expand Down
10 changes: 10 additions & 0 deletions RetroBar/Taskbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Window}" />
</DockPanel.Dock>
</controls:Toolbar>
<controls:ShowDesktopButton x:Name="ShowDesktopButtonTray"
TasksService="{Binding TasksService}"
Visibility="Collapsed">
<DockPanel.Dock>
<Binding Converter="{StaticResource dockOrientationConverter}"
ConverterParameter="trailing"
Path="Orientation"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Window}" />
</DockPanel.Dock>
</controls:ShowDesktopButton>
<GroupBox Style="{DynamicResource Tray}"
PreviewMouseRightButtonUp="NotifyArea_PreviewMouseRightButtonUp">
<DockPanel.Dock>
Expand Down
16 changes: 16 additions & 0 deletions RetroBar/Taskbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public Taskbar(WindowManager windowManager, ShellManager shellManager, StartMenu
QuickLaunchToolbar.Visibility = Visibility.Visible;
}

if (Settings.Instance.ShowDesktopButton)
{
ShowDesktopButtonTray.Visibility = Visibility.Visible;
}

// Hide the start button on secondary display(s)
if (!Screen.Primary)
{
Expand Down Expand Up @@ -162,6 +167,17 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
return;
}
}
else if (e.PropertyName == "ShowDesktopButton")
{
if (Settings.Instance.ShowDesktopButton)
{
ShowDesktopButtonTray.Visibility = Visibility.Visible;
}
else
{
ShowDesktopButtonTray.Visibility = Visibility.Collapsed;
}
}
}

private void Taskbar_OnLocationChanged(object sender, EventArgs e)
Expand Down
5 changes: 5 additions & 0 deletions RetroBar/Themes/System XP.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<BitmapImage x:Key="StartIconImage"
UriSource="../Resources/startxpclassic.png" />

<BitmapImage x:Key="ShowDesktopIconImageSmall"
UriSource="../Resources/desktopxp-sm.png" />
<BitmapImage x:Key="ShowDesktopIconImageLarge"
UriSource="../Resources/desktopxp-lg.png" />

<Style TargetType="Image"
x:Key="StartIcon"
BasedOn="{StaticResource StartIcon}">
Expand Down
Loading