Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.3.0.2311 #32

Merged
merged 16 commits into from
Oct 30, 2023
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
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 @@
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 @@ -42,11 +44,11 @@
public static FavoritePage? FavoritePage { get; set; }
public static SettingsPage? SettingsPage { get; set; }

public static List<Favorite> Favorites { get; set; }

Check warning on line 47 in PermaTop/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Favorites' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 47 in PermaTop/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Favorites' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
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 @@

[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 @@ -193,13 +195,13 @@
{
GetWindowThreadProcessId(hWnd, out uint processId);
Process process = Process.GetProcessById((int)processId);
file = process.MainModule.FileName;

Check warning on line 198 in PermaTop/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 198 in PermaTop/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}
catch { }

if (!string.IsNullOrEmpty(windowTitle))
{
windowInfos.Add(new(windowTitle, className, IsWindowPinned(hWnd), hWnd, file));

Check warning on line 204 in PermaTop/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'processName' in 'WindowInfo.WindowInfo(string title, string className, bool pinned, IntPtr hWnd, string processName)'.

Check warning on line 204 in PermaTop/Classes/Global.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'processName' in 'WindowInfo.WindowInfo(string title, string className, bool pinned, IntPtr hWnd, string processName)'.
}
}

Expand Down Expand Up @@ -340,4 +342,17 @@
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 @@
SOFTWARE.
*/
using PermaTop.Classes;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
Expand All @@ -43,10 +45,12 @@
HelloTxt.Text = Global.GetHiSentence;
PageContent.Navigate(Global.PinWindowsPage);
CheckButton(PinPageBtn);
Global.SettingsPage.ThemeChanged += (o, e) =>

Check warning on line 48 in PermaTop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 48 in PermaTop/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
CheckButton(SettingsPageBtn);
};

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

private void CheckButton(Button btn)
Expand Down Expand Up @@ -97,4 +101,115 @@
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
Loading