Skip to content

Commit

Permalink
Merge pull request #42 from Leo-Corporation/vNext
Browse files Browse the repository at this point in the history
Version 1.4.0.2401
  • Loading branch information
lpeyr authored Jan 6, 2024
2 parents 9630432 + 1bdcf18 commit a2b5c6d
Show file tree
Hide file tree
Showing 13 changed files with 545 additions and 174 deletions.
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 @@ -48,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.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 @@ -343,6 +343,18 @@ public static void ChangeLanguage()
}
}

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 @@ public MainWindow()
{
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 @@ -50,7 +54,7 @@ private void InitUI()
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 MinimizeBtn_Click(object sender, RoutedEventArgs e)

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 @@ private void SettingsPageBtn_Click(object sender, RoutedEventArgs e)
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 @@ -52,6 +52,9 @@ public SettingsPage()

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

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

Expand All @@ -74,6 +77,7 @@ private async void InitUI()

// 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 @@ private void SeeLicensesBtn_Click(object sender, RoutedEventArgs e)
{
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 @@ private void UpdateOnStartChk_Checked(object sender, RoutedEventArgs e)
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>
<Copyright2023</Copyright>
<Copyright2024</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 Down Expand Up @@ -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

0 comments on commit a2b5c6d

Please sign in to comment.