Skip to content

Commit

Permalink
Add DWM.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkwpsv committed Mar 28, 2021
1 parent db5b79a commit d9e2dde
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions WindowDebugger/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<views:WindowStylesExTab Header="StyleExes"/>
<views:ClassStylesTab Header="ClassStyles"/>
<views:OperationsTab Header="Operations"/>
<views:DWMTab Header="DWM"/>
<views:OthersTab Header="Others"/>
</TabControl>
<Button Grid.Row="1" Content="Refresh Current" MaxWidth="200"
Expand Down
8 changes: 8 additions & 0 deletions WindowDebugger/ViewModels/ViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Lsj.Util.Text;
using Lsj.Util.Win32;
using Lsj.Util.Win32.Extensions;
using Lsj.Util.WPF;
using System;
Expand All @@ -25,6 +26,9 @@ public ObservableCollection<WindowItem> Windows

public void RefreshWindowList()
{
Dwmapi.DwmIsCompositionEnabled(out var isEnabled);
SetField(ref _dwmIsCompositionEnabled, isEnabled, propertyName: nameof(DwmIsCompositionEnabled));

var windows = WindowExtensions.GetAllWindowHandle();
Windows.Clear();
foreach (var handle in windows)
Expand Down Expand Up @@ -68,5 +72,9 @@ public void RefreshWindowList()

private WindowItem _currentWindow;
public WindowItem SelectedWindow { get => _currentWindow; set => SetField(ref _currentWindow, value, extraAction: () => { value?.RefreshItem(); value?.RefreshScreenShot(); }); }

private bool _dwmIsCompositionEnabled;

public bool DwmIsCompositionEnabled { get => _dwmIsCompositionEnabled; }
}
}
59 changes: 59 additions & 0 deletions WindowDebugger/Views/DWMTab.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<TabItem x:Class="WindowDebugger.Views.DWMTab"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WindowDebugger.Views"
xmlns:win32Enums="clr-namespace:Lsj.Util.Win32.Enums;assembly=Lsj.Util.Win32"
xmlns:converters="clr-namespace:WindowDebugger.Converters"
xmlns:utilconverters="clr-namespace:Lsj.Util.WPF.Converters;assembly=Lsj.Util.WPF"
xmlns:markupExtensions="clr-namespace:Lsj.Util.WPF.MarkupExtensions;assembly=Lsj.Util.WPF"
xmlns:viewmodels="clr-namespace:WindowDebugger.ViewModels"
mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="500" d:DataContext="{d:DesignInstance Type=viewmodels:WindowItem}" Header="{Binding Content, RelativeSource={RelativeSource Self}, Mode=OneWay}">
<Border Padding="10,10,10,0">
<Grid>
<Grid.Resources>
<Style TargetType="TextBlock">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style.Setters>
</Style>
<Style TargetType="TextBox">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Height" Value="20"/>
</Style.Setters>
</Style>
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Height" Value="20"/>
<Setter Property="Margin" Value="10,0,0,0"/>
<Setter Property="Padding" Value="8 0" />
</Style.Setters>
</Style>
<Style TargetType="ComboBox">
<Style.Setters>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Height" Value="22"/>
</Style.Setters>
</Style>
<Style TargetType="CheckBox">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<CheckBox Grid.Row="0" Grid.Column="0" Content="DwmIsCompositionEnabled" IsChecked="{Binding DwmIsCompositionEnabled, Source={x:Static viewmodels:ViewModel.Instance}, Mode=OneWay}" IsEnabled="False"/>
<Grid Grid.Row="1" IsEnabled="{Binding DwmIsCompositionEnabled, Source={x:Static viewmodels:ViewModel.Instance}, Mode=OneWay}">
<GroupBox Header="">

</GroupBox>
</Grid>
</Grid>
</Border>
</TabItem>
30 changes: 30 additions & 0 deletions WindowDebugger/Views/DWMTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Lsj.Util.Win32.Extensions;
using Lsj.Util.WPF;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WindowDebugger.ViewModels;

namespace WindowDebugger.Views
{
/// <summary>
/// DWMTab.xaml 的交互逻辑
/// </summary>
public partial class DWMTab : TabItem
{
public DWMTab()
{
InitializeComponent();
}
}
}

0 comments on commit d9e2dde

Please sign in to comment.