Skip to content

Commit

Permalink
Merge pull request #15 from Leo-Corporation/vNext
Browse files Browse the repository at this point in the history
Version 1.1.0.2308
  • Loading branch information
lpeyr authored Aug 3, 2023
2 parents 753a480 + 99b3a3d commit 6716739
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 11 deletions.
57 changes: 55 additions & 2 deletions PermaTop/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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.0.0.2307";
public static string Version => "1.1.0.2308";
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 @@ -88,7 +88,60 @@ public static string GetHiSentence
internal const int GWL_STYLE = -16;
internal const int WS_VISIBLE = 0x10000000;

public static SolidColorBrush GetSolidColor(string resource) => (SolidColorBrush)Application.Current.Resources[resource];
internal const int SW_SHOWNORMAL = 1;
internal const int SW_SHOWMINIMIZED = 2;
internal const int SW_SHOWMAXIMIZED = 3;

internal enum WindowPlacementFlags : int
{
WPF_SETMINPOSITION = 0x0001,
WPF_RESTORETOMAXIMIZED = 0x0002,
WPF_ASYNCWINDOWPLACEMENT = 0x0004
}

[StructLayout(LayoutKind.Sequential)]
internal struct WINDOWPLACEMENT
{
public int length;
public int flags;
public int showCmd;
public System.Drawing.Point ptMinPosition;
public System.Drawing.Point ptMaxPosition;
public System.Drawing.Rectangle rcNormalPosition;
}

[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}

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

internal static Rect GetWindowPosition(IntPtr windowHandle)
{
GetWindowRect(windowHandle, out RECT windowRect);
return new Rect(windowRect.Left, windowRect.Top, windowRect.Right - windowRect.Left, windowRect.Bottom - windowRect.Top);
}

[DllImport("user32.dll")]
internal static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);

internal static bool IsWindowMaximized(IntPtr windowHandle)
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
GetWindowPlacement(windowHandle, ref placement);

return placement.showCmd == SW_SHOWMAXIMIZED;
}

internal static SolidColorBrush GetSolidColor(string resource) => (SolidColorBrush)Application.Current.Resources[resource];

// Import the SetWindowPos function from user32.dll
[DllImport("user32.dll")]
Expand Down
2 changes: 1 addition & 1 deletion PermaTop/Pages/PinWindowsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal void InitUI()
var openedWindows = Global.GetWindows();
for (int i = 0; i < openedWindows.Count; i++)
{
WindowDisplayer.Children.Add(new WindowPropertyItem(openedWindows[i]));
WindowDisplayer.Children.Add(new WindowPropertyItem(openedWindows[i], WindowDisplayer));
}
}

Expand Down
8 changes: 4 additions & 4 deletions PermaTop/PermaTop.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand All @@ -9,7 +9,7 @@
<ApplicationIcon>PermaTop.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Title>PermaTop</Title>
<Version>1.0.0.2307</Version>
<Version>1.1.0.2308</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 Down Expand Up @@ -37,8 +37,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="PeyrSharp.Core" Version="1.7.0.2307" />
<PackageReference Include="PeyrSharp.Env" Version="1.7.0.2307" />
<PackageReference Include="PeyrSharp.Core" Version="1.8.0.2308" />
<PackageReference Include="PeyrSharp.Env" Version="1.8.0.2308" />
</ItemGroup>

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

9 changes: 9 additions & 0 deletions PermaTop/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,13 @@
<data name="Launch" xml:space="preserve">
<value>Launch</value>
</data>
<data name="X" xml:space="preserve">
<value>X</value>
</data>
<data name="Y" xml:space="preserve">
<value>Y</value>
</data>
<data name="Position" xml:space="preserve">
<value>Position</value>
</data>
</root>
9 changes: 9 additions & 0 deletions PermaTop/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,13 @@
<data name="Launch" xml:space="preserve">
<value>Lancer</value>
</data>
<data name="X" xml:space="preserve">
<value>X</value>
</data>
<data name="Y" xml:space="preserve">
<value>Y</value>
</data>
<data name="Position" xml:space="preserve">
<value>Position</value>
</data>
</root>
9 changes: 9 additions & 0 deletions PermaTop/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,13 @@
<data name="Launch" xml:space="preserve">
<value>Launch</value>
</data>
<data name="X" xml:space="preserve">
<value>X</value>
</data>
<data name="Y" xml:space="preserve">
<value>Y</value>
</data>
<data name="Position" xml:space="preserve">
<value>Position</value>
</data>
</root>
54 changes: 51 additions & 3 deletions PermaTop/UserControls/WindowPropertyItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:PermaTop.UserControls"
xmlns:lang="clr-namespace:PermaTop.Properties"
mc:Ignorable="d" FontFamily="..\Fonts\#Hauora"
Height="50" d:DesignWidth="800" Foreground="{DynamicResource Foreground1}">
<Border CornerRadius="10" Padding="5" Margin="5" Background="{DynamicResource CardBackground}">
Expand All @@ -13,18 +14,65 @@

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TitleTxt" FontWeight="ExtraBold" d:Text="WindowTItle" FontSize="14" VerticalAlignment="Center">
<Image x:Name="IconImg" Grid.Column="0" Margin="5 0" MaxWidth="15" MaxHeight="15"/>
<TextBlock x:Name="TitleTxt" FontWeight="ExtraBold" d:Text="WindowTItle" FontSize="14" VerticalAlignment="Center" Grid.Column="1">
<TextBlock.ToolTip>
<ToolTip x:Name="TitleToolTip" Foreground="{DynamicResource Foreground1}" Background="{DynamicResource Background1}" />
</TextBlock.ToolTip>
</TextBlock>
<Button Foreground="{DynamicResource Foreground1}" x:Name="FavBtn" Click="FavBtn_Click" Width="30" Grid.Column="2" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF710;" FontSize="14" Margin="0 0 5 0"/>
<Button Foreground="{DynamicResource Foreground1}" x:Name="PinBtn" Click="PinBtn_Click" Width="30" Grid.Column="3" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF602;" FontSize="14"/>
<Button Foreground="{DynamicResource Foreground1}" x:Name="MoreBtn" Click="MoreBtn_Click" Width="30" Grid.Column="3" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xFC2E;" FontSize="14" Margin="0 0 5 0"/>
<Button Foreground="{DynamicResource Foreground1}" x:Name="FavBtn" Click="FavBtn_Click" Width="30" Grid.Column="4" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF710;" FontSize="14" Margin="0 0 5 0"/>
<Button Foreground="{DynamicResource Foreground1}" x:Name="PinBtn" Click="PinBtn_Click" Width="30" Grid.Column="5" Style="{DynamicResource DefaultButton}" Background="{DynamicResource Background2}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF602;" FontSize="14" Margin="0 0 5 0"/>
<Button Foreground="{DynamicResource Foreground1}" x:Name="MinBtn" Click="MinBtn_Click" Width="30" Grid.Column="6" Style="{DynamicResource DefaultButton}" Background="{DynamicResource CardBackground}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF4E0;" FontSize="14" Margin="0 0 5 0"/>
<Button Foreground="{DynamicResource Foreground1}" x:Name="MaxRestoreBtn" Click="MaxRestoreBtn_Click" Width="30" Grid.Column="7" Style="{DynamicResource DefaultButton}" Background="{DynamicResource CardBackground}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xFA41;" FontSize="14" Margin="0 0 5 0"/>
<Button Foreground="{DynamicResource Foreground1}" x:Name="CloseBtn" Click="CloseBtn_Click" Width="30" Grid.Column="8" Style="{DynamicResource DefaultButton}" Background="{DynamicResource CardBackground}" FontFamily="..\Fonts\#FluentSystemIcons-Regular" Content="&#xF36A;" FontSize="14"/>

<Popup StaysOpen="False" x:Name="MorePopup" Placement="Bottom" PlacementTarget="{Binding ElementName=MoreBtn}" AllowsTransparency="True">
<Border Background="{DynamicResource Background1}" Padding="10" CornerRadius="10" Margin="10">
<Border.Effect>
<DropShadowEffect BlurRadius="10" Color="#1F1F1F" Direction="270" Opacity="0.1" ShadowDepth="0"/>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<TextBlock Text="{x:Static lang:Resources.Position}" FontWeight="Bold"/>
<TextBlock Text="{x:Static lang:Resources.X}" Grid.Row="1" VerticalAlignment="Center" Margin="10" FontWeight="Bold"/>
<TextBlock Text="{x:Static lang:Resources.Y}" Grid.Row="2" VerticalAlignment="Center" Margin="10" FontWeight="Bold"/>
<Border Grid.Row="1" Background="{DynamicResource CardBackground}" Width="50" CornerRadius="5" HorizontalAlignment="Center" Grid.Column="1" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect Color="{DynamicResource LightAccentColor}" BlurRadius="15" Opacity="0.2" ShadowDepth="0"/>
</Border.Effect>
<TextBox x:Name="XTxt" Padding="3" Margin="3" BorderThickness="0" FontWeight="Bold" Foreground="{DynamicResource DarkGray}" d:Text="123" Background="Transparent" TextAlignment="Center"/>
</Border>
<Border Grid.Row="2" Background="{DynamicResource CardBackground}" Width="50" CornerRadius="5" HorizontalAlignment="Center" Grid.Column="1" VerticalAlignment="Center">
<Border.Effect>
<DropShadowEffect Color="{DynamicResource LightAccentColor}" BlurRadius="15" Opacity="0.2" ShadowDepth="0"/>
</Border.Effect>
<TextBox x:Name="YTxt" Padding="3" Margin="3" BorderThickness="0" FontWeight="Bold" Foreground="{DynamicResource DarkGray}" d:Text="123" Background="Transparent" TextAlignment="Center"/>
</Border>
<Button Content="{x:Static lang:Resources.Apply}" x:Name="ApplyBtn" Style="{DynamicResource PrimaryButton}" Click="ApplyBtn_Click" Grid.ColumnSpan="2" Grid.Row="3" HorizontalAlignment="Center" Margin="5" Padding="5" Background="{DynamicResource Accent}" FontWeight="Bold" Foreground="{DynamicResource WindowButtonsHoverForeground1}"/>
</Grid>
</Border>
</Popup>
</Grid>
</Border>
</UserControl>
Loading

0 comments on commit 6716739

Please sign in to comment.