Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions dev/pyRevitLabs/pyRevitLabs.Common/Unmanaged.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,37 @@ public static RECT GetWindowRect(IntPtr windowHandle) {
}
}

public static class DwmApi {
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_OLD = 19;
private const int DWMWA_CAPTION_COLOR = 35;
private const int DWMWA_TEXT_COLOR = 36;

[DllImport("dwmapi.dll", PreserveSig = true)]
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, ref int pvAttribute, int cbAttribute);

private static bool TrySetAttribute(IntPtr hwnd, int attribute, int value) {
return DwmSetWindowAttribute(hwnd, attribute, ref value, sizeof(int)) == 0;
}

// Asks DWM to render a window's native title bar using the OS dark-mode
// palette (Windows 10 20H1+/Windows 11). Silently no-ops on older Windows.
public static void SetImmersiveDarkMode(IntPtr hwnd, bool enabled) {
int value = enabled ? 1 : 0;
if (!TrySetAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, value)) {
TrySetAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE_OLD, value);
}
}

// Sets the exact title bar background/text colors (Windows 11 22000+
// only; silently no-ops on Windows 10, which falls back to whatever
// SetImmersiveDarkMode picked). Colors are 0x00BBGGRR COLORREFs.
public static void SetTitleBarColors(IntPtr hwnd, int captionColorRef, int textColorRef) {
TrySetAttribute(hwnd, DWMWA_CAPTION_COLOR, captionColorRef);
TrySetAttribute(hwnd, DWMWA_TEXT_COLOR, textColorRef);
}
}

public static class Shell32 {
[DllImport("Shell32.dll")]
public static extern int SHGetKnownFolderPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
Title="{DynamicResource Window.Title}" Height="750" Width="1000" ShowInTaskbar="False" ResizeMode="CanResize"
WindowStartupLocation="CenterScreen" HorizontalContentAlignment="Center">
<Window.Resources>
<Style x:Key="ClearButton" TargetType="Button">
<Setter Property="Background" Value="White"/>
</Style>

<Canvas x:Key="filterIcon">
<Path Canvas.Top="-28" Canvas.Left="-25" Data="F1 M 45.4403,56.9637L 45.4403,55.0463L 52.8201,44.5143L 52.8201,44.4237L 46.13,44.4237L 46.13,41.4774L 57.372,41.4774L 57.372,43.5352L 50.1532,53.9265L 50.1532,54.0174L 57.4869,54.0174L 57.4869,56.9637L 45.4403,56.9637 Z M 34.8333,61.75L 34.8333,42.75L 19,20.5833L 57,20.5833L 41.1667,42.75L 41.1667,58.5833L 34.8333,61.75 Z M 25.903,52.8055L 21.4072,52.8055L 20.289,56.9855L 16.6085,56.9855L 21.4072,41.4556L 26.0661,41.4556L 30.9337,56.9855L 27.1143,56.9855L 25.903,52.8055 Z M 21.9196,50.2801L 25.3905,50.2801L 24.4122,46.9804L 23.9987,45.4806L 23.6201,43.981L 23.5736,43.981L 23.2212,45.4941L 22.8514,47.0194L 21.9196,50.2801 Z " Fill="DimGray"/>
<Path Canvas.Top="-28" Canvas.Left="-25" Data="F1 M 45.4403,56.9637L 45.4403,55.0463L 52.8201,44.5143L 52.8201,44.4237L 46.13,44.4237L 46.13,41.4774L 57.372,41.4774L 57.372,43.5352L 50.1532,53.9265L 50.1532,54.0174L 57.4869,54.0174L 57.4869,56.9637L 45.4403,56.9637 Z M 34.8333,61.75L 34.8333,42.75L 19,20.5833L 57,20.5833L 41.1667,42.75L 41.1667,58.5833L 34.8333,61.75 Z M 25.903,52.8055L 21.4072,52.8055L 20.289,56.9855L 16.6085,56.9855L 21.4072,41.4556L 26.0661,41.4556L 30.9337,56.9855L 27.1143,56.9855L 25.903,52.8055 Z M 21.9196,50.2801L 25.3905,50.2801L 24.4122,46.9804L 23.9987,45.4806L 23.6201,43.981L 23.5736,43.981L 23.2212,45.4941L 22.8514,47.0194L 21.9196,50.2801 Z " Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Window}}"/>
</Canvas>

<Style TargetType="{x:Type Hyperlink}">
Expand Down Expand Up @@ -37,11 +33,10 @@
<Button x:Name="clrsearch_b" Visibility="Collapsed" Margin="0,-25,2,0" Padding="0,-4,0,0"
Width="22px" Height="22px" HorizontalAlignment="Right"
BorderThickness="0"
Style="{StaticResource ClearButton}"
Click="clear_search">
<Button.Content>
<Canvas Width="25" Height="25" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Canvas.Top="3" Canvas.Left="1" Data="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" Fill="DimGray" />
<Path Canvas.Top="3" Canvas.Left="1" Data="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" Fill="{DynamicResource pyRevitSubtleForegroundBrush}" />
</Canvas>
</Button.Content>
</Button>
Expand Down Expand Up @@ -168,12 +163,12 @@
</StackPanel>
<ListView x:Name="extpkgs_lb" SelectionMode="Extended" SelectionChanged="update_ext_info">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Style TargetType="ListViewItem" BasedOn="{StaticResource {x:Type ListViewItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<Style TargetType="{x:Type CheckBox}" x:Key="DataGridCheckBox">
<Style TargetType="{x:Type CheckBox}" x:Key="DataGridCheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
Expand Down
Loading