220 lines
7.8 KiB
C#
220 lines
7.8 KiB
C#
// Decompiled with JetBrains decompiler
|
|||
|
|
// Type: Raton.Windows.Settings
|
||
|
|
// 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 DarkModeForms;
|
||
|
|
using Microsoft.CSharp.RuntimeBinder;
|
||
|
|
using Newtonsoft.Json;
|
||
|
|
using System;
|
||
|
|
using System.CodeDom.Compiler;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.ComponentModel;
|
||
|
|
using System.Diagnostics;
|
||
|
|
using System.Drawing;
|
||
|
|
using System.Drawing.Imaging;
|
||
|
|
using System.IO;
|
||
|
|
using System.Linq.Expressions;
|
||
|
|
using System.Runtime.CompilerServices;
|
||
|
|
using System.Runtime.InteropServices;
|
||
|
|
using System.Windows;
|
||
|
|
using System.Windows.Controls;
|
||
|
|
using System.Windows.Forms;
|
||
|
|
using System.Windows.Interop;
|
||
|
|
using System.Windows.Markup;
|
||
|
|
using Newtonsoft.Json.Linq;
|
||
|
|
using WpfApp1;
|
||
|
|
|
||
|
|
#nullable disable
|
||
|
|
namespace Raton.Windows;
|
||
|
|
|
||
|
|
public partial class Settings : Window
|
||
|
|
{
|
||
|
|
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
|
||
|
|
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
|
||
|
|
|
||
|
|
[DllImport("dwmapi.dll")]
|
||
|
|
private static extern int DwmSetWindowAttribute(
|
||
|
|
IntPtr hwnd,
|
||
|
|
int attr,
|
||
|
|
ref int attrValue,
|
||
|
|
int attrSize);
|
||
|
|
|
||
|
|
public Settings()
|
||
|
|
{
|
||
|
|
this.InitializeComponent();
|
||
|
|
this.SourceInitialized += new EventHandler(this.Settings_SourceInitialized);
|
||
|
|
this.Loaded += new RoutedEventHandler(this.Settings_Loaded);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void Settings_SourceInitialized(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
|
||
|
|
int attrValue = 1;
|
||
|
|
Settings.DwmSetWindowAttribute(handle, 20, ref attrValue, 4);
|
||
|
|
Settings.DwmSetWindowAttribute(handle, 19, ref attrValue, 4);
|
||
|
|
}
|
||
|
|
|
||
|
|
private void Settings_Loaded(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
string path1 = Path.Combine(MainWindow.appData, "userData.json");
|
||
|
|
if (File.Exists(path1))
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
JObject json = JObject.Parse(File.ReadAllText(path1));
|
||
|
|
bool flag = json["Webhook"]?.ToString() == "true";
|
||
|
|
this.ChkWebhook.IsChecked = flag;
|
||
|
|
this.TbWebhookUrl.IsEnabled = flag;
|
||
|
|
this.TbWebhookUrl.Text = json["URL"]?.ToString() ?? "";
|
||
|
|
}
|
||
|
|
catch { }
|
||
|
|
}
|
||
|
|
string path2 = Path.Combine(MainWindow.appData, "telegram.json");
|
||
|
|
if (File.Exists(path2))
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
JObject json = JObject.Parse(File.ReadAllText(path2));
|
||
|
|
bool flag1 = json["Enabled"]?.Value<bool>() ?? false;
|
||
|
|
this.ChkBot.IsChecked = flag1;
|
||
|
|
this.TbBotToken.IsEnabled = flag1;
|
||
|
|
this.TbChatId.IsEnabled = flag1;
|
||
|
|
this.TbBotToken.Text = json["Token"]?.ToString() ?? "";
|
||
|
|
this.TbChatId.Text = json["ChatId"]?.ToString() ?? "";
|
||
|
|
}
|
||
|
|
catch { }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void ChkWebhook_Changed(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
System.Windows.Controls.TextBox tbWebhookUrl = this.TbWebhookUrl;
|
||
|
|
bool? isChecked = this.ChkWebhook.IsChecked;
|
||
|
|
bool flag = true;
|
||
|
|
int num = isChecked.GetValueOrDefault() == flag & isChecked.HasValue ? 1 : 0;
|
||
|
|
tbWebhookUrl.IsEnabled = num != 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void ChkBot_Changed(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
bool? isChecked = this.ChkBot.IsChecked;
|
||
|
|
bool flag1 = true;
|
||
|
|
bool flag2 = isChecked.GetValueOrDefault() == flag1 & isChecked.HasValue;
|
||
|
|
this.TbBotToken.IsEnabled = flag2;
|
||
|
|
this.TbChatId.IsEnabled = flag2;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void BtnSave_Click(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
Directory.CreateDirectory(MainWindow.appData);
|
||
|
|
bool? isChecked1 = this.ChkWebhook.IsChecked;
|
||
|
|
bool flag1 = true;
|
||
|
|
if (isChecked1.GetValueOrDefault() == flag1 & isChecked1.HasValue && !this.TbWebhookUrl.Text.Trim().StartsWith("https://discord.com/api/webhooks/"))
|
||
|
|
{
|
||
|
|
int num1 = (int) Messenger.MessageBox("The URL is not a webhook", "Error", icon: MessageBoxImage.Hand);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
string path1 = Path.Combine(MainWindow.appData, "userData.json");
|
||
|
|
bool? isChecked2 = this.ChkWebhook.IsChecked;
|
||
|
|
bool flag2 = true;
|
||
|
|
string str1 = isChecked2.GetValueOrDefault() == flag2 & isChecked2.HasValue ? "true" : "false";
|
||
|
|
bool? isChecked3 = this.ChkWebhook.IsChecked;
|
||
|
|
bool flag3 = true;
|
||
|
|
string str2 = isChecked3.GetValueOrDefault() == flag3 & isChecked3.HasValue ? this.TbWebhookUrl.Text.Trim() : "null";
|
||
|
|
var data1 = new{ Webhook = str1, URL = str2 };
|
||
|
|
File.WriteAllText(path1, JsonConvert.SerializeObject((object) data1, Formatting.Indented));
|
||
|
|
string path2 = Path.Combine(MainWindow.appData, "telegram.json");
|
||
|
|
isChecked3 = this.ChkBot.IsChecked;
|
||
|
|
bool flag4 = true;
|
||
|
|
int num2 = isChecked3.GetValueOrDefault() == flag4 & isChecked3.HasValue ? 1 : 0;
|
||
|
|
isChecked3 = this.ChkBot.IsChecked;
|
||
|
|
bool flag5 = true;
|
||
|
|
string str3 = isChecked3.GetValueOrDefault() == flag5 & isChecked3.HasValue ? this.TbBotToken.Text.Trim() : "";
|
||
|
|
isChecked3 = this.ChkBot.IsChecked;
|
||
|
|
bool flag6 = true;
|
||
|
|
string str4 = isChecked3.GetValueOrDefault() == flag6 & isChecked3.HasValue ? this.TbChatId.Text.Trim() : "";
|
||
|
|
var data2 = new
|
||
|
|
{
|
||
|
|
Enabled = num2 != 0,
|
||
|
|
Token = str3,
|
||
|
|
ChatId = str4
|
||
|
|
};
|
||
|
|
File.WriteAllText(path2, JsonConvert.SerializeObject((object) data2, Formatting.Indented));
|
||
|
|
Process.Start(System.Windows.Forms.Application.ExecutablePath);
|
||
|
|
Environment.Exit(0);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
int num = (int) Messenger.MessageBox(ex.Message);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void BtnPfp_Click(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||
|
|
{
|
||
|
|
openFileDialog.Filter = "Images|*.png;*.jpg;*.jpeg;*.bmp;*.gif";
|
||
|
|
if (openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
|
||
|
|
return;
|
||
|
|
this.SaveImage(openFileDialog.FileName, "pfp");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void BtnWallpaper_Click(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||
|
|
{
|
||
|
|
openFileDialog.Filter = "Images|*.png;*.jpg;*.jpeg;*.bmp;*.gif";
|
||
|
|
if (openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
|
||
|
|
return;
|
||
|
|
this.SaveImage(openFileDialog.FileName, "wallpaper");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void BtnRemoveWall_Click(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
foreach (string file in Directory.GetFiles(MainWindow.appData))
|
||
|
|
{
|
||
|
|
if (Path.GetFileNameWithoutExtension(file).Equals("wallpaper", StringComparison.OrdinalIgnoreCase))
|
||
|
|
File.Delete(file);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private void BtnDisableRpc_Click(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
if (MainWindow.form2 == null || MainWindow.form2.dclient == null || MainWindow.form2.dclient.IsDisposed)
|
||
|
|
return;
|
||
|
|
MainWindow.form2.dclient.ClearPresence();
|
||
|
|
MainWindow.form2.dclient.Dispose();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void SaveImage(string sourcePath, string baseName)
|
||
|
|
{
|
||
|
|
foreach (string file in Directory.GetFiles(MainWindow.appData, baseName + ".*"))
|
||
|
|
File.Delete(file);
|
||
|
|
using (FileStream fileStream = new FileStream(sourcePath, FileMode.Open, FileAccess.Read))
|
||
|
|
{
|
||
|
|
using (System.Drawing.Image original = System.Drawing.Image.FromStream((Stream) fileStream))
|
||
|
|
{
|
||
|
|
using (Bitmap bitmap = new Bitmap(original))
|
||
|
|
{
|
||
|
|
string str = ".png";
|
||
|
|
if (ImageFormat.Jpeg.Equals((object) bitmap.RawFormat))
|
||
|
|
str = ".jpg";
|
||
|
|
else if (ImageFormat.Bmp.Equals((object) bitmap.RawFormat))
|
||
|
|
str = ".bmp";
|
||
|
|
else if (ImageFormat.Gif.Equals((object) bitmap.RawFormat))
|
||
|
|
str = ".gif";
|
||
|
|
bitmap.Save(Path.Combine(MainWindow.appData, baseName + str));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|