Files
2026-08-27 11:23:13 -06:00

133 lines
5.0 KiB
C#

// Decompiled with JetBrains decompiler
// Type: WpfApp1.FavoritePicker
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
#nullable disable
namespace WpfApp1;
public class FavoritePicker : Window
{
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(
IntPtr hwnd,
int attr,
ref int attrValue,
int attrSize);
public string SelectedHeader { get; private set; }
public FavoritePicker(List<string> items, string action)
{
this.Title = action;
this.Width = 340.0;
this.Height = 460.0;
this.Background = (Brush) new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte) 36, (byte) 36, (byte) 36));
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
this.ResizeMode = ResizeMode.NoResize;
Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition()
{
Height = GridLength.Auto
});
ListBox listBox = new ListBox();
listBox.Background = (Brush) Brushes.Transparent;
listBox.Foreground = (Brush) Brushes.White;
listBox.BorderThickness = new Thickness(0.0);
listBox.Margin = new Thickness(10.0);
listBox.FontSize = 13.0;
ListBox lb = listBox;
lb.ItemContainerStyle = this.BuildListItemStyle();
items.ForEach((Action<string>) (i => lb.Items.Add((object) i)));
Grid.SetRow((UIElement) lb, 0);
Button button = new Button();
button.Content = (object) action;
button.Margin = new Thickness(10.0, 4.0, 10.0, 10.0);
button.Padding = new Thickness(0.0, 8.0, 0.0, 8.0);
button.Background = (Brush) new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte) 51, (byte) 51, (byte) 51));
button.Foreground = (Brush) Brushes.White;
button.BorderThickness = new Thickness(0.0);
button.FontSize = 13.0;
button.Cursor = Cursors.Hand;
Button element = button;
Grid.SetRow((UIElement) element, 1);
element.Click += (RoutedEventHandler) ((s, e) =>
{
if (!(lb.SelectedItem is string selectedItem2))
return;
this.SelectedHeader = selectedItem2;
this.DialogResult = new bool?(true);
});
lb.MouseDoubleClick += (MouseButtonEventHandler) ((s, e) =>
{
if (!(lb.SelectedItem is string selectedItem4))
return;
this.SelectedHeader = selectedItem4;
this.DialogResult = new bool?(true);
});
grid.Children.Add((UIElement) lb);
grid.Children.Add((UIElement) element);
this.Content = (object) grid;
this.Loaded += (RoutedEventHandler) ((s, e) => this.ApplyDarkMode());
}
private void ApplyDarkMode()
{
bool flag = this.IsWindowsDarkMode();
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
int attrValue = flag ? 1 : 0;
FavoritePicker.DwmSetWindowAttribute(handle, 20, ref attrValue, Marshal.SizeOf(typeof (int)));
}
private bool IsWindowsDarkMode()
{
using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"))
{
if (registryKey != null)
{
if (registryKey.GetValue("AppsUseLightTheme") is int num)
return num == 0;
}
}
return false;
}
private Style BuildListItemStyle()
{
Style style = new Style(typeof (ListBoxItem));
style.Setters.Add((SetterBase) new Setter(Control.BackgroundProperty, (object) Brushes.Transparent));
style.Setters.Add((SetterBase) new Setter(Control.ForegroundProperty, (object) Brushes.White));
style.Setters.Add((SetterBase) new Setter(Control.PaddingProperty, (object) new Thickness(8.0, 6.0, 8.0, 6.0)));
style.Setters.Add((SetterBase) new Setter(Control.BorderThicknessProperty, (object) new Thickness(0.0)));
Trigger trigger1 = new Trigger()
{
Property = UIElement.IsMouseOverProperty,
Value = (object) true
};
trigger1.Setters.Add((SetterBase) new Setter(Control.BackgroundProperty, (object) new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte) 51, (byte) 51, (byte) 51))));
Trigger trigger2 = new Trigger()
{
Property = ListBoxItem.IsSelectedProperty,
Value = (object) true
};
trigger2.Setters.Add((SetterBase) new Setter(Control.BackgroundProperty, (object) new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte) 58, (byte) 58, (byte) 58))));
style.Triggers.Add((TriggerBase) trigger1);
style.Triggers.Add((TriggerBase) trigger2);
return style;
}
}