Pandetthe
Pandetthe
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
There can be also readonly methods
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
Okay I am back and I found this for anyone else interested in it
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
I haven't thought that it's possible because it sounds funny
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
I need to get more deeper into it
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
Thanks
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
For example winapi union struct with uint value, first bit is working as Boolean. In my getter I am extracting this one bit and comparin to 0 to get boolean
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
It only suggests on getter where I modify fields value
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
But it's building normally on .net 8.0
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
I thought that too
18 replies
CC#
Created by Pandetthe on 7/30/2024 in #help
Read-only question
Now I am not at home, I will send later
18 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
I was just randomly checking difference between screen boundries and restoreboundries of the window after show method. I was amazed that my -720 top was converted to -480. I thought it is impossible and just googled it and this came up as a first research. Spoiler, every previous search did not show this
80 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
15h of research RIP, and I am still not satisfied
80 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
For next person looking
80 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
public class DpiAwareWindow : Window
{
public new static readonly DependencyProperty LeftProperty =
DependencyProperty.RegisterAttached(nameof(Left), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Left
{
get => (double)GetValue(LeftProperty);
set => SetValue(LeftProperty, value);
}

public new static readonly DependencyProperty TopProperty =
DependencyProperty.RegisterAttached(nameof(Top), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Top
{
get => (double)GetValue(TopProperty);
set => SetValue(TopProperty, value);
}

public new static readonly DependencyProperty WidthProperty =
DependencyProperty.RegisterAttached(nameof(Width), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Width
{
get => (double)GetValue(WidthProperty);
set => SetValue(WidthProperty, value);
}

public new static readonly DependencyProperty HeightProperty =
DependencyProperty.RegisterAttached(nameof(Height), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Height
{
get => (double)GetValue(HeightProperty);
set => SetValue(HeightProperty, value);
}

private static void OnPlacementChange(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
if (obj is not DpiAwareWindow window) return;
IntPtr hwnd = new WindowInteropHelper(window).EnsureHandle();
if (!NativeMethods.GetWindowPlacement(hwnd, out WINDOWPLACEMENT placement))
return;
placement.normalPosition = RECT.FromXYWH((int)window.Left, (int)window.Top, (int)window.Width, (int)window.Height);
NativeMethods.SetWindowPlacement(hwnd, ref placement);
}
public class DpiAwareWindow : Window
{
public new static readonly DependencyProperty LeftProperty =
DependencyProperty.RegisterAttached(nameof(Left), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Left
{
get => (double)GetValue(LeftProperty);
set => SetValue(LeftProperty, value);
}

public new static readonly DependencyProperty TopProperty =
DependencyProperty.RegisterAttached(nameof(Top), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Top
{
get => (double)GetValue(TopProperty);
set => SetValue(TopProperty, value);
}

public new static readonly DependencyProperty WidthProperty =
DependencyProperty.RegisterAttached(nameof(Width), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Width
{
get => (double)GetValue(WidthProperty);
set => SetValue(WidthProperty, value);
}

public new static readonly DependencyProperty HeightProperty =
DependencyProperty.RegisterAttached(nameof(Height), typeof(double), typeof(DpiAwareWindow),
new PropertyMetadata(OnPlacementChange));

public new double Height
{
get => (double)GetValue(HeightProperty);
set => SetValue(HeightProperty, value);
}

private static void OnPlacementChange(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
if (obj is not DpiAwareWindow window) return;
IntPtr hwnd = new WindowInteropHelper(window).EnsureHandle();
if (!NativeMethods.GetWindowPlacement(hwnd, out WINDOWPLACEMENT placement))
return;
placement.normalPosition = RECT.FromXYWH((int)window.Left, (int)window.Top, (int)window.Width, (int)window.Height);
NativeMethods.SetWindowPlacement(hwnd, ref placement);
}
80 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
This is my solution
80 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
80 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
Oh my problem is related to wpf issue
80 replies
CC#
Created by Pandetthe on 7/27/2024 in #help
Positioning window in per monitor aware v2
Oh it's interesting, when I set window top to -720, after a second, wpf translate to -480
80 replies