<commit_before>﻿using Sakuno.SystemInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Interop;

namespace Sakuno.UserInterface
{
    public static class WindowUtil
    {
        public static bool? ShowDialog(Window rpDialog)
        {
            rpDialog.Owner = GetTopWindow();
            rpDialog.ShowInTaskbar = false;
            return rpDialog.ShowDialog();
        }
        static Window GetTopWindow()
        {
            var rHandle = NativeMethods.User32.GetForegroundWindow();
            if (rHandle == IntPtr.Zero)
                return null;

            return HwndSource.FromHwnd(rHandle)?.RootVisual as Window;
        }

        public static IEnumerable<Window> GetWindowsOrderedByZOrder(IEnumerable<Window> rpWindows)
        {
            var rWindows = rpWindows.Select(r => new { Window = r, Handle = new WindowInteropHelper(r).Handle }).ToDictionary(r => r.Handle, r => r.Window);

            var rResult = new List<Window>();

            var rHandle = NativeMethods.User32.GetTopWindow(IntPtr.Zero);
            while (rHandle != IntPtr.Zero)
            {
                Window rWindow;
                if (rWindows.TryGetValue(rHandle, out rWindow))
                    rResult.Add(rWindow);
                rHandle = NativeMethods.User32.GetWindow(rHandle, NativeConstants.GetWindow.GW_HWNDNEXT);
            }
<commit_msg>Little modification<commit_after>﻿using Sakuno.SystemInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Interop;

namespace Sakuno.UserInterface
{
    public static class WindowUtil
    {
        public static bool? ShowDialog(Window rpDialog)
        {
            rpDialog.Owner = GetTopWindow();
            rpDialog.ShowInTaskbar = false;
            return rpDialog.ShowDialog();
        }

        public static Window GetTopWindow()
        {
            var rHandle = NativeMethods.User32.GetForegroundWindow();
            if (rHandle == IntPtr.Zero)
                return null;

            return HwndSource.FromHwnd(rHandle)?.RootVisual as Window;
        }

        public static IEnumerable<Window> GetWindowsOrderedByZOrder(IEnumerable<Window> rpWindows)
        {
            var rWindows = rpWindows.Select(r => new { Window = r, Handle = new WindowInteropHelper(r).Handle }).ToDictionary(r => r.Handle, r => r.Window);

            var rResult = new List<Window>();

            var rHandle = NativeMethods.User32.GetTopWindow(IntPtr.Zero);
            while (rHandle != IntPtr.Zero)
            {
                Window rWindow;
                if (rWindows.TryGetValue(rHandle, out rWindow))
                    rResult.Add(rWindow);
                rHandle = NativeMethods.User32.GetWindow(rHandle, NativeConstants.GetWindow.GW_HWNDNEXT);
            }

{'fraction_non_alphanumeric': 0.09122562674094707, 'fraction_numerical': 0.004178272980501393, 'mean_word_length': 2.2353603603603602, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '800200', 'n_tokens_mistral': 801, 'n_tokens_neox': 770, 'n_words': 166}