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
33 changes: 33 additions & 0 deletions CloseWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Input;

namespace Roundify
{
/// <summary>
/// Closes the current window.
/// </summary>
public class CloseWindowCommand : MarkupExtension, ICommand
{
public void Execute(object parameter)
{
if (Application.Current.MainWindow != null) Application.Current.MainWindow.Close();
CommandManager.InvalidateRequerySuggested();
}

public event EventHandler CanExecuteChanged;


public bool CanExecute(object parameter)
{
Window win = Application.Current.MainWindow;
return win != null;
}

public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}
Binary file added Images/Close.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 Images/icon.ico
Binary file not shown.
29 changes: 28 additions & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Roundify"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"
AllowsTransparency="True"
Expand All @@ -12,5 +14,30 @@
WindowStartupLocation="CenterScreen"
Topmost="True"
IsHitTestVisible="False"
Background="Transparent">
ShowInTaskbar="False"
Loaded="Window_Loaded"
Background="Transparent"
>

<tb:TaskbarIcon x:Name="roundifyNotificationIcon"
Visibility="Visible"
ToolTipText="Roundify"
IconSource="Images/icon.ico"
MenuActivation="LeftOrRightClick"
>
<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="Close Roundify"
Command="{local:CloseWindowCommand}"
CommandParameter="{Binding}">
<MenuItem.Icon>
<Image Width="16"
Height="16"
Source="/Images/Close.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
</tb:TaskbarIcon>

</Window>
85 changes: 81 additions & 4 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
Expand All @@ -18,15 +20,90 @@ namespace Roundify
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class MainWindow : System.Windows.Window
{
#region Window styles
[Flags]
public enum ExtendedWindowStyles
{
// ...
WS_EX_TOOLWINDOW = 0x00000080,
// ...
}

public enum GetWindowLongFields
{
// ...
GWL_EXSTYLE = (-20),
// ...
}

[DllImport("user32.dll")]
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);

private static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
{
var error = 0;
IntPtr result;
// Win32 SetWindowLong doesn't clear error on success
SetLastError(0);

if (IntPtr.Size == 4)
{
// use SetWindowLong
var tempResult = IntSetWindowLong(hWnd, nIndex, IntPtrToInt32(dwNewLong));
error = Marshal.GetLastWin32Error();
result = new IntPtr(tempResult);
}
else
{
// use SetWindowLongPtr
result = IntSetWindowLongPtr(hWnd, nIndex, dwNewLong);
error = Marshal.GetLastWin32Error();
}

if ((result == IntPtr.Zero) && (error != 0))
{
throw new System.ComponentModel.Win32Exception(error);
}

return result;
}

[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)]
private static extern IntPtr IntSetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);

[DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)]
private static extern Int32 IntSetWindowLong(IntPtr hWnd, int nIndex, Int32 dwNewLong);

private static int IntPtrToInt32(IntPtr intPtr)
{
return unchecked((int)intPtr.ToInt64());
}

[DllImport("kernel32.dll", EntryPoint = "SetLastError")]
private static extern void SetLastError(int dwErrorCode);
#endregion

public MainWindow()
{
InitializeComponent();

ImageBrush myBrush = new ImageBrush();
myBrush.ImageSource = new BitmapImage(new Uri(@"..\..\..\png.png", UriKind.Relative));
this.Background = myBrush;
var myBrush = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(@"..\..\..\scaledCorners.png", UriKind.Relative))
};
Background = myBrush;
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowInteropHelper wndHelper = new WindowInteropHelper(this);

int exStyle = (int)GetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE);

exStyle |= (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW;
SetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle);
}
}
}
7 changes: 6 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
~Description:<br/>
Note: If you are looking for a release for the version that runs in the background with a tray icon, please look at the releases tab.

The following documentation is out of date and will not be updated. You do still need to install the runtime however.


~Description:<br/>
This is a program that makes your screen's window rounded just like displaperture but for windows.

~Disclamer: <br/>
Expand Down
11 changes: 11 additions & 0 deletions Roundify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,15 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
<None Remove="Images\icon.ico" />
<Resource Include="Images\icon.ico" />
<None Remove="Images\Close.png" />
<Resource Include="Images\Close.png" />
</ItemGroup>

</Project>
Binary file added roundedCorners.psd
Binary file not shown.
Binary file added scaledCorners.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.