Skip to content

Commit

Permalink
Fix UpdateOwnerWindow IsEnabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkwpsv committed Nov 16, 2021
1 parent 17bc562 commit 25b5d68
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Globalization;
using System.Windows.Data;
using static Lsj.Util.Win32.User32;

namespace WindowDebugger.Converters
{
public class ParentWindowHandleToCanUpdateOwnerConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> value is IntPtr parentWindowHandle && parentWindowHandle == GetDesktopWindow();

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
}
4 changes: 3 additions & 1 deletion WindowDebugger/Views/WindowInfoTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Grid>
<Grid.Resources>
<utilconverters:IntPtrToHexConverter x:Key="IntPtrToHexConverter"/>
<converters:ParentWindowHandleToCanUpdateOwnerConverter x:Key="ParentWindowHandleToCanUpdateOwnerConverter"/>
<Style TargetType="TextBlock">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Center"/>
Expand Down Expand Up @@ -110,7 +111,8 @@
<Button Grid.Row="8" Grid.Column="2" Click="UpdateParentWindowHandle" Content="Update"/>
<TextBlock Grid.Row="9" Grid.Column="0" Text="Owner Window"/>
<TextBox Grid.Row="9" Grid.Column="1" x:Name="TextBoxOwnerWindowHandle" Text="{Binding OwnerWindowHandle, Converter={StaticResource IntPtrToHexConverter}, UpdateSourceTrigger=Explicit}"/>
<Button Grid.Row="9" Grid.Column="2" Click="UpdateOwnerWindowHandle" Content="Update" IsEnabled="{Binding CanUpdateOwner}"/>
<Button Grid.Row="9" Grid.Column="2" Click="UpdateOwnerWindowHandle" Content="Update"
IsEnabled="{Binding ParentWindowHandle,Converter={StaticResource ParentWindowHandleToCanUpdateOwnerConverter}}"/>
<Border Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="3" BorderThickness="2" BorderBrush="{StaticResource Brush.Theme}"
HorizontalAlignment="Center" VerticalAlignment="Center">
<Image Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="3" Source="{Binding Screenshot}" RenderOptions.BitmapScalingMode="Fant"/>
Expand Down

0 comments on commit 25b5d68

Please sign in to comment.