Skip to content

Commit

Permalink
Merge pull request #32 from Leo-Corporation/vNext
Browse files Browse the repository at this point in the history
Version 1.3.0.2311
  • Loading branch information
lpeyr authored Oct 30, 2023
2 parents 9a2caca + 33e76ec commit a75dbef
Show file tree
Hide file tree
Showing 12 changed files with 2,095 additions and 1,113 deletions.
2,113 changes: 1,304 additions & 809 deletions PermaTop/App.xaml

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions PermaTop/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace PermaTop.Classes;
public static class Global
Expand All @@ -46,7 +48,7 @@ public static class Global
internal static string SettingsPath => $@"{FileSys.AppDataPath}\Léo Corporation\PermaTop\Settings.xml";
public static Settings Settings { get; set; } = XmlSerializerManager.LoadFromXml<Settings>(SettingsPath) ?? new();

public static string Version => "1.2.0.2309";
public static string Version => "1.3.0.2311";
public static string LastVersionLink => "https://raw.githubusercontent.com/Leo-Corporation/LeoCorp-Docs/master/Liens/Update%20System/PermaTop/Version.txt";

public static string GetHiSentence
Expand Down Expand Up @@ -121,7 +123,7 @@ public struct RECT

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
internal static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);

internal static Rect GetWindowPosition(IntPtr windowHandle)
{
Expand Down Expand Up @@ -340,4 +342,17 @@ public static void ChangeLanguage()
break;
}
}

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

[DllImport("user32.dll", SetLastError = true)]
internal static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);


[DllImport("user32.dll")]
internal static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll")]
internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
}
Binary file added PermaTop/Images/PermaTop.ico
Binary file not shown.
725 changes: 481 additions & 244 deletions PermaTop/MainWindow.xaml

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions PermaTop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
using PermaTop.Classes;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
Expand All @@ -47,6 +49,8 @@ private void InitUI()
{
CheckButton(SettingsPageBtn);
};

WindowsMenu.Loaded += (o, e) => { GenerateMenu(); };
}

private void CheckButton(Button btn)
Expand Down Expand Up @@ -97,4 +101,115 @@ private void SettingsPageBtn_Click(object sender, RoutedEventArgs e)
UnCheckAllButton();
CheckButton(SettingsPageBtn);
}

bool isHidden = false;
private void HideMenu_Click(object sender, RoutedEventArgs e)
{

isHidden = !isHidden;
if (isHidden)
{
Hide();
HideMenu.Header = Properties.Resources.Show;

return;
}
Show();
HideMenu.Header = Properties.Resources.Hide;
}

private void QuitMenu_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}

private const int WM_SYSCOMMAND = 0x0112;
private const int SC_CLOSE = 0xF060;
private const int SC_MAXIMIZE = 0xF030;
private const int SC_RESTORE = 0xF120;
private const int SC_MINIMIZE = 0xF020;
private const int GCL_HICON = -14;
private const int ICON_SMALL = 0;
private const int ICON_BIG = 1;
private const uint WM_GETICON = 0x007F;
private const uint SWP_NOSIZE = 0x0001;
private const uint SWP_NOZORDER = 0x0004;
private void GenerateMenu()
{
WindowsMenu.Items.Clear();
var windows = Global.GetWindows();
foreach (var window in windows)
{
var menu = new MenuItem() { Header = window.Title, Style = (Style)Application.Current.Resources["MenuStyle"] };

var closeMenu = new MenuItem() { Header = Properties.Resources.Close, Style = (Style)Application.Current.Resources["MenuStyle"] };
closeMenu.Click += (o, e) =>
{
MessageBox.Show(window.Title);
try
{
Global.SendMessage(window.Hwnd, WM_SYSCOMMAND, (IntPtr)SC_CLOSE, IntPtr.Zero);
}
catch { }
};

var maxMenu = new MenuItem() { Header = Properties.Resources.Maximize, Style = (Style)Application.Current.Resources["MenuStyle"] };
maxMenu.Click += (o, e) =>
{
try
{
Global.SendMessage(window.Hwnd, WM_SYSCOMMAND, (IntPtr)SC_MAXIMIZE, IntPtr.Zero);
}
catch { }
};

var restoreMenu = new MenuItem() { Header = Properties.Resources.Restore, Style = (Style)Application.Current.Resources["MenuStyle"] };
restoreMenu.Click += (o, e) =>
{
try
{
Global.SendMessage(window.Hwnd, WM_SYSCOMMAND, (IntPtr)SC_RESTORE, IntPtr.Zero);
}
catch { }
};

var minMenu = new MenuItem() { Header = Properties.Resources.Minimize, Style = (Style)Application.Current.Resources["MenuStyle"] };
minMenu.Click += (o, e) =>
{
try
{
Global.SendMessage(window.Hwnd, WM_SYSCOMMAND, (IntPtr)SC_MINIMIZE, IntPtr.Zero);
}
catch { }
};

var pinMenu = new MenuItem() { Header = Properties.Resources.Pin, Style = (Style)Application.Current.Resources["MenuStyle"] };
pinMenu.Click += (o, e) =>
{
try
{
Global.SetWindowTopMost(window.Hwnd, true);
}
catch { }
};

var unpinMenu = new MenuItem() { Header = Properties.Resources.UnPin, Style = (Style)Application.Current.Resources["MenuStyle"] };
unpinMenu.Click += (o, e) =>
{
try
{
Global.SetWindowTopMost(window.Hwnd, false);
}
catch { }
};

menu.Items.Add(closeMenu);
menu.Items.Add(maxMenu);
menu.Items.Add(restoreMenu);
menu.Items.Add(minMenu);
menu.Items.Add(pinMenu);
menu.Items.Add(unpinMenu);
WindowsMenu.Items.Add(menu);
}
}
}
11 changes: 8 additions & 3 deletions PermaTop/PermaTop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ApplicationIcon>PermaTop.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Title>PermaTop</Title>
<Version>1.2.0.2309</Version>
<Version>1.3.0.2311</Version>
<Authors>Léo Corporation</Authors>
<Company>Léo Corporation</Company>
<Description>A simple utility to keep your windows in sight and in control.</Description>
Expand All @@ -27,18 +27,23 @@
<None Remove="Images\DarkTheme.png" />
<None Remove="Images\Light.png" />
<None Remove="Images\LightTheme.png" />
<None Remove="Images\PermaTop.ico" />
<None Remove="Images\SystemTheme.png" />
</ItemGroup>

<ItemGroup>
<Resource Include="Images\PermaTop.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Content Include="PermaTop.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Core" Version="1.9.0.2309" />
<PackageReference Include="PeyrSharp.Env" Version="1.9.0.2309" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
<PackageReference Include="PeyrSharp.Core" Version="1.10.0.2310" />
<PackageReference Include="PeyrSharp.Env" Version="1.10.0.2310" />
</ItemGroup>

<ItemGroup>
Expand Down
63 changes: 63 additions & 0 deletions PermaTop/Properties/Resources.Designer.cs

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

21 changes: 21 additions & 0 deletions PermaTop/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,25 @@
<data name="Move" xml:space="preserve">
<value>Move</value>
</data>
<data name="Quit" xml:space="preserve">
<value>Quit</value>
</data>
<data name="Hide" xml:space="preserve">
<value>Hide</value>
</data>
<data name="Show" xml:space="preserve">
<value>Show</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Restore</value>
</data>
<data name="Maximize" xml:space="preserve">
<value>Maximize</value>
</data>
<data name="ManageWindows" xml:space="preserve">
<value>Manage windows</value>
</data>
<data name="UnPin" xml:space="preserve">
<value>Unpin</value>
</data>
</root>
21 changes: 21 additions & 0 deletions PermaTop/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,25 @@
<data name="Move" xml:space="preserve">
<value>Déplacer</value>
</data>
<data name="Quit" xml:space="preserve">
<value>Quitter</value>
</data>
<data name="Hide" xml:space="preserve">
<value>Cacher</value>
</data>
<data name="Show" xml:space="preserve">
<value>Montrer</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Restorer</value>
</data>
<data name="Maximize" xml:space="preserve">
<value>Maximiser</value>
</data>
<data name="ManageWindows" xml:space="preserve">
<value>Gérer les fenêtres</value>
</data>
<data name="UnPin" xml:space="preserve">
<value>Désépingler</value>
</data>
</root>
Loading

0 comments on commit a75dbef

Please sign in to comment.