121 lines
3.6 KiB
C#
121 lines
3.6 KiB
C#
// Decompiled with JetBrains decompiler
|
|||
|
|
// Type: Raton.Windows.Preview
|
||
|
|
// 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 Raton.Classes;
|
||
|
|
using RatonBack;
|
||
|
|
using System;
|
||
|
|
using System.CodeDom.Compiler;
|
||
|
|
using System.Collections;
|
||
|
|
using System.Collections.ObjectModel;
|
||
|
|
using System.ComponentModel;
|
||
|
|
using System.Diagnostics;
|
||
|
|
using System.Runtime.InteropServices;
|
||
|
|
using System.Windows;
|
||
|
|
using System.Windows.Controls;
|
||
|
|
using System.Windows.Interop;
|
||
|
|
using System.Windows.Markup;
|
||
|
|
using System.Windows.Media;
|
||
|
|
using System.Windows.Media.Imaging;
|
||
|
|
|
||
|
|
#nullable disable
|
||
|
|
namespace Raton.Windows;
|
||
|
|
|
||
|
|
public partial class Preview : Window
|
||
|
|
{
|
||
|
|
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
|
||
|
|
private readonly ObservableCollection<PreviewEntry> _entries = new ObservableCollection<PreviewEntry>();
|
||
|
|
|
||
|
|
[DllImport("dwmapi.dll", CharSet = CharSet.Auto)]
|
||
|
|
private static extern int DwmSetWindowAttribute(
|
||
|
|
IntPtr hwnd,
|
||
|
|
int attr,
|
||
|
|
ref int attrValue,
|
||
|
|
int attrSize);
|
||
|
|
|
||
|
|
public Preview()
|
||
|
|
{
|
||
|
|
this.InitializeComponent();
|
||
|
|
this.InfoGrid.ItemsSource = (IEnumerable) this._entries;
|
||
|
|
this.Loaded += new RoutedEventHandler(this.Preview_Loaded);
|
||
|
|
}
|
||
|
|
|
||
|
|
private async void Preview_Loaded(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
this.ApplyDarkMode();
|
||
|
|
try
|
||
|
|
{
|
||
|
|
int num = await BackendClient.ValidateSessionFlags(DeviceManager.GetHWID(), DeviceManager.GetOrCreateId()) ? 1 : 0;
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
int num = (int) MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||
|
|
Environment.Exit(0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void AddPreview(string resource, string information)
|
||
|
|
{
|
||
|
|
this.Dispatcher.Invoke((Action) (() =>
|
||
|
|
{
|
||
|
|
this._entries.Add(new PreviewEntry()
|
||
|
|
{
|
||
|
|
Resource = resource,
|
||
|
|
Information = information
|
||
|
|
});
|
||
|
|
if (this._entries.Count > 0)
|
||
|
|
this.InfoGrid.ScrollIntoView((object) this._entries[this._entries.Count - 1]);
|
||
|
|
this.TbEntryCount.Text = $"{this._entries.Count.ToString()} {(this._entries.Count == 1 ? "entry" : "entries")}";
|
||
|
|
}));
|
||
|
|
}
|
||
|
|
|
||
|
|
private void MenuItemReload_Click(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
Program.form2.Command(nameof (Preview));
|
||
|
|
}
|
||
|
|
|
||
|
|
private void ApplyDarkMode()
|
||
|
|
{
|
||
|
|
bool flag = this.IsWindowsDarkMode();
|
||
|
|
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
|
||
|
|
int attrValue = flag ? 1 : 0;
|
||
|
|
Preview.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;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetPreviewImage(BitmapSource source)
|
||
|
|
{
|
||
|
|
this.Dispatcher.Invoke((Action) (() =>
|
||
|
|
{
|
||
|
|
this.PreviewImage.Source = (ImageSource) source;
|
||
|
|
this.PlaceholderPanel.Visibility = source != null ? Visibility.Collapsed : Visibility.Visible;
|
||
|
|
}));
|
||
|
|
}
|
||
|
|
|
||
|
|
public void ClearPreview()
|
||
|
|
{
|
||
|
|
this.Dispatcher.Invoke((Action) (() =>
|
||
|
|
{
|
||
|
|
this._entries.Clear();
|
||
|
|
this.TbEntryCount.Text = "0 entries";
|
||
|
|
this.PreviewImage.Source = (ImageSource) null;
|
||
|
|
this.PlaceholderPanel.Visibility = Visibility.Visible;
|
||
|
|
}));
|
||
|
|
}
|
||
|
|
}
|