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.4.0.2401 #42

Merged
merged 18 commits into from
Jan 6, 2024
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
3 changes: 2 additions & 1 deletion PermaTop/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ private void Application_Startup(object sender, StartupEventArgs e)

if (!Global.Settings.IsFirstRun)
{
new MainWindow().Show();
var mw = new MainWindow();
if (Global.Settings.LaunchAtStart == false) mw.Show();
}
else
{
Expand Down
14 changes: 13 additions & 1 deletion PermaTop/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,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.
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.3.0.2311";
public static string Version => "1.4.0.2401";
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 @@ -195,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 @@ -343,6 +343,18 @@
}
}

public static void SetLaunchAtStart(bool launchAtStart)
{
var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (launchAtStart)
{
key?.SetValue("PermaTop", Environment.ProcessPath ?? $@"{AppContext.BaseDirectory}\PermaTop.exe");
return;
}

key?.DeleteValue("PermaTop", false);
}

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

Expand Down
2 changes: 2 additions & 0 deletions PermaTop/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public class Settings
public Languages Language { get; set; }
public bool IsFirstRun { get; set; }
public bool CheckUpdateOnStart { get; set; }
public bool? LaunchAtStart { get; set; }
public Settings()
{
Theme = Themes.System;
Language = Languages.Default;
IsFirstRun = true;
CheckUpdateOnStart = true;
LaunchAtStart = false;
}
}
12 changes: 10 additions & 2 deletions PermaTop/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
{
InitializeComponent();
InitUI();
if (Global.Settings.LaunchAtStart ?? false)
{
HideMenu_Click(this, null);

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

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

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

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
}
}

private void InitUI()
Expand All @@ -45,12 +49,12 @@
HelloTxt.Text = Global.GetHiSentence;
PageContent.Navigate(Global.PinWindowsPage);
CheckButton(PinPageBtn);
Global.SettingsPage.ThemeChanged += (o, e) =>

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

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 52 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(); };
WindowsMenu.Loaded += (o, e) => { GenerateMenu(); };
}

private void CheckButton(Button btn)
Expand All @@ -73,6 +77,11 @@

private void CloseBtn_Click(object sender, RoutedEventArgs e)
{
if (Global.Settings.LaunchAtStart ?? false)
{
HideMenu_Click(sender, e);
return;
}
Application.Current.Shutdown();
}

Expand Down Expand Up @@ -105,7 +114,6 @@
bool isHidden = false;
private void HideMenu_Click(object sender, RoutedEventArgs e)
{

isHidden = !isHidden;
if (isHidden)
{
Expand Down
617 changes: 457 additions & 160 deletions PermaTop/Pages/SettingsPage.xaml

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions PermaTop/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
public delegate void ThemeChangedEvent(object sender, EventArgs e);
public event ThemeChangedEvent ThemeChanged;
readonly System.Windows.Forms.NotifyIcon notifyIcon = new();
public SettingsPage()

Check warning on line 47 in PermaTop/Pages/SettingsPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 47 in PermaTop/Pages/SettingsPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 47 in PermaTop/Pages/SettingsPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build

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

Check warning on line 47 in PermaTop/Pages/SettingsPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable field 'ThemeSelectedBorder' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
InitializeComponent();
InitUI();
Expand All @@ -52,6 +52,9 @@

private async void InitUI()
{
// Upgrade settings
Global.Settings.LaunchAtStart ??= false;

// About section
VersionTxt.Text = Global.Version; // Update the current version label

Expand All @@ -70,10 +73,11 @@
Themes.Light => LightBorder,
Themes.Dark => DarkBorder,
_ => SystemBorder
}, null);

Check warning on line 76 in PermaTop/Pages/SettingsPage.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

// Checkboxes
UpdateOnStartChk.IsChecked = Global.Settings.CheckUpdateOnStart;
LaunchOnStartChk.IsChecked = Global.Settings.LaunchAtStart ?? false;

if (!Global.Settings.CheckUpdateOnStart) return;
try
Expand Down Expand Up @@ -123,8 +127,8 @@
{
MessageBox.Show($"{Properties.Resources.Licenses}\n\n" +
"Fluent System Icons - MIT License - © 2020 Microsoft Corporation\n" +
"PeyrSharp - MIT License - © 2022-2023 Léo Corporation\n" +
"PermaTop - MIT License - © 2023 Léo Corporation", $"{Properties.Resources.PermaTop} - {Properties.Resources.Licenses}", MessageBoxButton.OK, MessageBoxImage.Information);
"PeyrSharp - MIT License - © 2022-2024 Devyus\n" +
"PermaTop - MIT License - © 2023-2024 Léo Corporation", $"{Properties.Resources.PermaTop} - {Properties.Resources.Licenses}", MessageBoxButton.OK, MessageBoxImage.Information);
}

Border ThemeSelectedBorder;
Expand Down Expand Up @@ -263,5 +267,13 @@
Global.Settings.CheckUpdateOnStart = UpdateOnStartChk.IsChecked ?? true;
XmlSerializerManager.SaveToXml(Global.Settings, Global.SettingsPath);
}
}

private void LaunchOnStartChk_Checked(object sender, RoutedEventArgs e)
{
Global.Settings.LaunchAtStart = LaunchOnStartChk.IsChecked;
XmlSerializerManager.SaveToXml(Global.Settings, Global.SettingsPath);

Global.SetLaunchAtStart(Global.Settings.LaunchAtStart ?? false);
}
}
}
8 changes: 4 additions & 4 deletions PermaTop/PermaTop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<ApplicationIcon>PermaTop.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Title>PermaTop</Title>
<Version>1.3.0.2311</Version>
<Version>1.4.0.2401</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>
<Copyright>© 2023</Copyright>
<Copyright>© 2024</Copyright>
<RepositoryUrl>https://github.com/Leo-Corporation/PermaTop</RepositoryUrl>
<PackageProjectUrl>https://github.com/Leo-Corporation/PermaTop</PackageProjectUrl>
</PropertyGroup>
Expand Down Expand Up @@ -42,8 +42,8 @@

<ItemGroup>
<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" />
<PackageReference Include="PeyrSharp.Core" Version="2.1.0.2312" />
<PackageReference Include="PeyrSharp.Env" Version="2.1.0.2312" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 18 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.

6 changes: 6 additions & 0 deletions PermaTop/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,10 @@
<data name="UnPin" xml:space="preserve">
<value>Unpin</value>
</data>
<data name="LaunchOnStart" xml:space="preserve">
<value>Launch PermaTop at Windows startup</value>
</data>
<data name="PermaTopOnStartInfo" xml:space="preserve">
<value>PermaTop will start minimized in the system tray if you enable this option.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions PermaTop/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,10 @@
<data name="UnPin" xml:space="preserve">
<value>Désépingler</value>
</data>
<data name="LaunchOnStart" xml:space="preserve">
<value>Lancer PermaTop lors du démarrage de Windows</value>
</data>
<data name="PermaTopOnStartInfo" xml:space="preserve">
<value>PermaTop démarrera minimisé dans la barre d'état système si vous activez cette option.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions PermaTop/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,10 @@
<data name="UnPin" xml:space="preserve">
<value>Unpin</value>
</data>
<data name="LaunchOnStart" xml:space="preserve">
<value>Launch PermaTop at Windows startup</value>
</data>
<data name="PermaTopOnStartInfo" xml:space="preserve">
<value>PermaTop will start minimized in the system tray if you enable this option.</value>
</data>
</root>
7 changes: 5 additions & 2 deletions PermaTop/UserControls/WindowPropertyItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
Grid.Row="3"
Grid.ColumnSpan="2"
Margin="5"
Padding="5"
Padding="2"
HorizontalAlignment="Center"
Background="{DynamicResource Accent}"
Click="ApplyBtn_Click"
Expand All @@ -243,7 +243,7 @@
</Popup>
<Popup
x:Name="ContextMenu"
AllowsTransparency="True"

Check warning on line 246 in PermaTop/UserControls/WindowPropertyItem.xaml

View workflow job for this annotation

GitHub Actions / build

'WindowPropertyItem.ContextMenu' hides inherited member 'FrameworkElement.ContextMenu'. Use the new keyword if hiding was intended.

Check warning on line 246 in PermaTop/UserControls/WindowPropertyItem.xaml

View workflow job for this annotation

GitHub Actions / build

'WindowPropertyItem.ContextMenu' hides inherited member 'FrameworkElement.ContextMenu'. Use the new keyword if hiding was intended.
Placement="Bottom"
PlacementTarget="{Binding ElementName=MoreBtn}"
StaysOpen="False">
Expand All @@ -270,6 +270,7 @@
Click="SetPosBtn_Click"
Content="{x:Static lang:Resources.SetPosition}"
FontWeight="Bold"
Foreground="{DynamicResource Foreground1}"
Style="{DynamicResource PrimaryButton}" />
<Button
x:Name="SetScreenBtn"
Expand All @@ -279,6 +280,7 @@
Click="SetScreenBtn_Click"
Content="{x:Static lang:Resources.MoveToScreen}"
FontWeight="Bold"
Foreground="{DynamicResource Foreground1}"
Style="{DynamicResource PrimaryButton}" />
</StackPanel>
</Border>
Expand Down Expand Up @@ -313,10 +315,11 @@
x:Name="MoveBtn"
Padding="2"
HorizontalAlignment="Center"
Background="Transparent"
Background="{DynamicResource Accent}"
Click="MoveBtn_Click"
Content="{x:Static lang:Resources.SetPosition}"
FontWeight="Bold"
Foreground="{DynamicResource Foreground1}"
Style="{DynamicResource PrimaryButton}" />
</StackPanel>
</Border>
Expand Down
2 changes: 1 addition & 1 deletion SETUP_LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Léo Corporation
Copyright (c) 2023-2024 Léo Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
Loading