Skip to content
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,6 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

*.MD
2 changes: 0 additions & 2 deletions Splitter/DropShadow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public class DropShadow

#region Fields

private bool _isAeroEnabled = false;
private bool _isDraggingEnabled = false;
private const int WM_NCHITTEST = 0x84;
private const int WS_MINIMIZEBOX = 0x20000;
private const int HTCLIENT = 0x1;
Expand Down
117 changes: 116 additions & 1 deletion Splitter/FormSplitter.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,128 @@
namespace Splitter
namespace Splitter
{
public partial class FormSplitter : Form
{
private TaskbarPosition _taskbarPosition;

public FormSplitter()
{
InitializeComponent();

// Detect taskbar position
_taskbarPosition = TaskbarHelper.GetTaskbarPosition();
System.Diagnostics.Debug.WriteLine($">>> Detected Taskbar Position: {_taskbarPosition}");
System.Diagnostics.Debug.WriteLine($">>> Is Vertical Taskbar: {TaskbarHelper.IsVerticalTaskbar()}");

// Apply appropriate icon and dimensions based on taskbar position
ConfigureForTaskbarPosition();

// Apply drop shadow
(new Core.DropShadow()).ApplyShadows(this);
}

/// <summary>
/// Configures form icon, size and position based on taskbar location
/// </summary>
private void ConfigureForTaskbarPosition()
{
System.Diagnostics.Debug.WriteLine(">>> ConfigureForTaskbarPosition called");

if (TaskbarHelper.IsVerticalTaskbar())
{
System.Diagnostics.Debug.WriteLine(">>> Configuring for VERTICAL taskbar (Left/Right)");

// Use horizontal icon for vertical taskbar
LoadHorizontalIcon();

// Adjust form dimensions for vertical taskbar
// Width should be smaller, height should be larger

//this.Width = 8; // Thin horizontal separator
//this.Height = 100; // Longer bar

System.Diagnostics.Debug.WriteLine($">>> Form dimensions set to: Width={this.Width}, Height={this.Height}");
}
else
{
System.Diagnostics.Debug.WriteLine(">>> Configuring for HORIZONTAL taskbar (Top/Bottom)");

// Use vertical icon for horizontal taskbar (default)
LoadVerticalIcon();

// Keep existing dimensions for horizontal taskbar
this.Width = 100;
this.Height = 8;

System.Diagnostics.Debug.WriteLine($">>> Form dimensions set to: Width={this.Width}, Height={this.Height}");
}
}

/// <summary>
/// Loads the horizontal separator icon (for vertical taskbar)
/// </summary>
private void LoadHorizontalIcon()
{
try
{
string iconPath = System.IO.Path.Combine(
Application.StartupPath,
"icons",
"separator_horizontal.ico"
);

System.Diagnostics.Debug.WriteLine($">>> Loading horizontal icon from: {iconPath}");
System.Diagnostics.Debug.WriteLine($">>> File exists: {System.IO.File.Exists(iconPath)}");

if (System.IO.File.Exists(iconPath))
{
this.Icon = new Icon(iconPath);
System.Diagnostics.Debug.WriteLine(">>> Horizontal icon loaded successfully ✓");
}
else
{
System.Diagnostics.Debug.WriteLine(">>> ERROR: Horizontal icon file not found!");
}
}
catch (Exception ex)
{
// Log error but don't crash the application
System.Diagnostics.Debug.WriteLine($">>> ERROR loading horizontal icon: {ex.Message}");
}
}

/// <summary>
/// Loads the vertical separator icon (for horizontal taskbar)
/// </summary>
private void LoadVerticalIcon()
{
try
{
string iconPath = System.IO.Path.Combine(
Application.StartupPath,
"icons",
"separator.ico"
);

System.Diagnostics.Debug.WriteLine($">>> Loading vertical icon from: {iconPath}");
System.Diagnostics.Debug.WriteLine($">>> File exists: {System.IO.File.Exists(iconPath)}");

if (System.IO.File.Exists(iconPath))
{
this.Icon = new Icon(iconPath);
System.Diagnostics.Debug.WriteLine(">>> Vertical icon loaded successfully ✓");
}
else
{
System.Diagnostics.Debug.WriteLine(">>> ERROR: Vertical icon file not found!");
}
}
catch (Exception ex)
{
// Log error but don't crash the application
System.Diagnostics.Debug.WriteLine($">>> ERROR loading vertical icon: {ex.Message}");
}
}

private void btnClose_Click(object sender, EventArgs e)
{
Application.Exit();
Expand Down
7 changes: 6 additions & 1 deletion Splitter/Splitter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
</PropertyGroup>

<ItemGroup>
<Content Include="icons\separator.ico" />
<Content Include="icons\separator.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="icons\separator_horizontal.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
117 changes: 117 additions & 0 deletions Splitter/TaskbarHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using System;
using System.Runtime.InteropServices;

namespace Splitter
{
/// <summary>
/// Represents the position of the Windows taskbar on the screen
/// </summary>
public enum TaskbarPosition
{
/// <summary>
/// Taskbar is positioned on the left side of the screen
/// </summary>
Left = 0,

/// <summary>
/// Taskbar is positioned at the top of the screen
/// </summary>
Top = 1,

/// <summary>
/// Taskbar is positioned on the right side of the screen
/// </summary>
Right = 2,

/// <summary>
/// Taskbar is positioned at the bottom of the screen (default)
/// </summary>
Bottom = 3,

/// <summary>
/// Taskbar position could not be determined
/// </summary>
Unknown = -1
}

/// <summary>
/// Helper class to detect Windows taskbar position and properties
/// </summary>
public static class TaskbarHelper
{
[StructLayout(LayoutKind.Sequential)]
private struct APPBARDATA
{
public uint cbSize;
public IntPtr hWnd;
public uint uCallbackMessage;
public uint uEdge;
public RECT rc;
public int lParam;
}

[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}

[DllImport("shell32.dll", SetLastError = true)]
private static extern IntPtr SHAppBarMessage(uint dwMessage, ref APPBARDATA pData);

private const uint ABM_GETTASKBARPOS = 5;

/// <summary>
/// Gets the current position of the Windows taskbar
/// </summary>
/// <returns>TaskbarPosition enum indicating where the taskbar is located</returns>
public static TaskbarPosition GetTaskbarPosition()
{
try
{
APPBARDATA data = new APPBARDATA
{
cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA))
};

IntPtr result = SHAppBarMessage(ABM_GETTASKBARPOS, ref data);

if (result == IntPtr.Zero)
{
// If API fails, return Bottom as default
return TaskbarPosition.Bottom;
}

return (TaskbarPosition)data.uEdge;
}
catch
{
// In case of error, return Bottom as default
return TaskbarPosition.Bottom;
}
}

/// <summary>
/// Checks if the taskbar is in vertical position (Left or Right)
/// </summary>
/// <returns>True if taskbar is on left or right side</returns>
public static bool IsVerticalTaskbar()
{
var position = GetTaskbarPosition();
return position == TaskbarPosition.Left || position == TaskbarPosition.Right;
}

/// <summary>
/// Checks if the taskbar is in horizontal position (Top or Bottom)
/// </summary>
/// <returns>True if taskbar is on top or bottom</returns>
public static bool IsHorizontalTaskbar()
{
var position = GetTaskbarPosition();
return position == TaskbarPosition.Top || position == TaskbarPosition.Bottom;
}
}
}
Binary file added Splitter/icons/separator_horizontal.ico
Binary file not shown.
Loading