Skip to content

Commit

Permalink
Added the possibility to restore a window (#8)
Browse files Browse the repository at this point in the history
Also added icon code logic
  • Loading branch information
lpeyr committed Aug 2, 2023
1 parent ebf7e1c commit e2039ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions PermaTop/UserControls/WindowPropertyItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ private void InitUI()

Favorite item = new(WindowInfo.ClassName, WindowInfo.Title, WindowInfo.ProcessName);
FavBtn.Content = Global.Favorites.Contains(item) ? "\uF71B" : "\uF710";

MaxRestoreBtn.Content = Global.IsWindowMaximized(WindowInfo.Hwnd) ? "\uF670" : "\uFA41";
MaxRestoreBtn.FontSize = Global.IsWindowMaximized(WindowInfo.Hwnd) ? 18 : 14;
}

private void PinBtn_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -83,6 +84,7 @@ private void FavBtn_Click(object sender, RoutedEventArgs e)
private const int WM_SYSCOMMAND = 0x0112;
private const int SC_CLOSE = 0xF060;
private const int SC_MAXIMIZE = 0xF030;
private const int SC_RESTORE = 0xF120;


[DllImport("user32.dll")]
Expand All @@ -102,8 +104,12 @@ private void MaxRestoreBtn_Click(object sender, RoutedEventArgs e)
if (!Global.IsWindowMaximized(WindowInfo.Hwnd))
{
SendMessage(WindowInfo.Hwnd, WM_SYSCOMMAND, (IntPtr)SC_MAXIMIZE, IntPtr.Zero);

MaxRestoreBtn.Content = "\uF670";
MaxRestoreBtn.FontSize = 18;
return;
}
SendMessage(WindowInfo.Hwnd, WM_SYSCOMMAND, (IntPtr)SC_RESTORE, IntPtr.Zero);
MaxRestoreBtn.Content = "\uFA41";
MaxRestoreBtn.FontSize = 14;
}
}

0 comments on commit e2039ab

Please sign in to comment.