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
19 changes: 18 additions & 1 deletion WindowsEdgeLight/ControlWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Controls"
Width="406"
Width="424"
Height="48"
AllowsTransparency="True"
Background="Transparent"
Expand All @@ -30,6 +30,23 @@
</Border.Style>

<StackPanel Orientation="Horizontal">
<Border
x:Name="DragHandle"
Width="16"
Margin="4,4,0,4"
AutomationProperties.Name="Drag toolbar"
Cursor="SizeAll"
MouseLeftButtonDown="DragHandle_MouseLeftButtonDown"
ToolTip="Drag to move">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Segoe MDL2 Assets"
FontSize="16"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="&#xE784;" />
</Border>

<Button
x:Name="BrightnessDownButton"
Width="40"
Expand Down
20 changes: 20 additions & 0 deletions WindowsEdgeLight/ControlWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows;
using System.Windows.Input;

namespace WindowsEdgeLight;

Expand Down Expand Up @@ -86,6 +87,25 @@ private void Open_Settings(object sender, RoutedEventArgs e)
ApplyButtonVisibility();
}

private void DragHandle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed)
{
return;
}

mainWindow.NotifyControlWindowManuallyMoved();

try
{
DragMove();
}
catch (System.InvalidOperationException)
{
// DragMove can throw if the mouse button is no longer pressed; ignore.
}
}

private void Close_Click(object sender, RoutedEventArgs e)
{
System.Windows.Application.Current.Shutdown();
Expand Down
16 changes: 16 additions & 0 deletions WindowsEdgeLight/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public partial class MainWindow : Window
private ControlWindow? controlWindow;
// Tracks whether the control window should be visible (controls initial visibility and toggle state)
private bool isControlWindowVisible = true;
// Session-only: once the user drags the control toolbar, stop auto-repositioning it.
private bool controlWindowManuallyMoved = false;
private ToolStripMenuItem? toggleControlsMenuItem;
private ToolStripMenuItem? excludeFromCaptureMenuItem;

Expand Down Expand Up @@ -1258,11 +1260,25 @@ private void RepositionControlWindow()
{
if (controlWindow == null) return;

// Respect a user-dragged position for the current session.
if (controlWindowManuallyMoved) return;

// Position at bottom center of main window
controlWindow.Left = this.Left + (this.Width - controlWindow.Width) / 2;
controlWindow.Top = this.Top + this.Height - controlWindow.Height - 124;
}

public void NotifyControlWindowManuallyMoved()
{
controlWindowManuallyMoved = true;
}

public void ResetControlWindowPosition()
{
controlWindowManuallyMoved = false;
RepositionControlWindow();
}

public bool HasMultipleMonitors()
{
// Refresh monitor count to handle hot-plug scenarios
Expand Down
31 changes: 31 additions & 0 deletions WindowsEdgeLight/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,37 @@
Click="ShowMonitorControls_Click" />
</StackPanel>
</Border>

<!-- Control Bar Position -->
<Border
Margin="0,0,0,12"
Padding="16"
Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="4">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock FontWeight="SemiBold" Text="📍 Control Bar Position" />
<TextBlock
Margin="0,4,0,0"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
TextWrapping="Wrap"
Text="Reset the control bar location back to its default." />
</StackPanel>
<Button
Grid.Column="1"
Margin="12,0,0,0"
VerticalAlignment="Center"
Content="Reset Position"
Click="ResetControlBarPosition_Click" />
</Grid>
</Border>
</StackPanel>
</ScrollViewer>
</Grid>
Expand Down
5 changes: 5 additions & 0 deletions WindowsEdgeLight/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ private void ShowMonitorControls_Click(object sender, RoutedEventArgs e)
UpdateOwnerControlWindow();
}

private void ResetControlBarPosition_Click(object sender, RoutedEventArgs e)
{
mainWindow.ResetControlWindowPosition();
}

private void UpdateOwnerControlWindow()
{
if (Owner is ControlWindow controlWindow)
Expand Down