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

206 lines
6.0 KiB
C#

// Decompiled with JetBrains decompiler
// Type: Raton.Windows.Tools
// 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 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.Linq;
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 Tools : Window
{
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
private List<ToolFileItem> _allFiles = new List<ToolFileItem>();
private ObservableCollection<ToolFileItem> _filtered = new ObservableCollection<ToolFileItem>();
[DllImport("dwmapi.dll", CharSet = CharSet.Auto)]
private static extern int DwmSetWindowAttribute(
IntPtr hwnd,
int attr,
ref int attrValue,
int attrSize);
public Tools() => this.InitializeComponent();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.ApplyDarkTitle();
this.LoadFiles();
}
private void ApplyDarkTitle()
{
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
int attrValue = 1;
Tools.DwmSetWindowAttribute(handle, 20, ref attrValue, Marshal.SizeOf(typeof (int)));
}
private void LoadFiles()
{
this._allFiles.Clear();
string toolsFolder = MainWindow.ToolsFolder;
this.TbFolderPath.Text = string.IsNullOrWhiteSpace(toolsFolder) ? nameof (Tools) : toolsFolder;
if (!string.IsNullOrWhiteSpace(toolsFolder))
{
if (Directory.Exists(toolsFolder))
{
try
{
foreach (string file in Directory.GetFiles(toolsFolder, "*.exe"))
{
FileInfo fileInfo = new FileInfo(file);
this._allFiles.Add(new ToolFileItem()
{
FileName = fileInfo.Name,
FullPath = file,
Extension = "EXE",
Size = Tools.FormatSize(fileInfo.Length),
LastModified = fileInfo.LastWriteTime.ToString("dd/MM/yyyy HH:mm"),
IconGlyph = Tools.GetIconGlyph(fileInfo.Extension)
});
}
this.ApplyFilter(this.TbSearch.Text);
return;
}
catch (Exception ex)
{
this.TbStatus.Text = "Error: " + ex.Message;
return;
}
}
}
this.TbStatus.Text = "Folder not found";
this.FilesGrid.ItemsSource = (IEnumerable) this._filtered;
}
private void TbSearch_TextChanged(object sender, TextChangedEventArgs e)
{
this.TbSearchPlaceholder.Visibility = string.IsNullOrEmpty(this.TbSearch.Text) ? Visibility.Visible : Visibility.Collapsed;
this.ApplyFilter(this.TbSearch.Text);
}
private void ApplyFilter(string query)
{
this._filtered.Clear();
foreach (ToolFileItem toolFileItem in !string.IsNullOrWhiteSpace(query) ? this._allFiles.Where<ToolFileItem>((Func<ToolFileItem, bool>) (f => f.FileName != null && f.FileName.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)) : (IEnumerable<ToolFileItem>) this._allFiles)
this._filtered.Add(toolFileItem);
this.FilesGrid.ItemsSource = (IEnumerable) this._filtered;
this.TbStatus.Text = this._filtered.Count == 1 ? "1 file" : this._filtered.Count.ToString() + " files";
}
private void FilesGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (!(this.FilesGrid.SelectedItem is ToolFileItem selectedItem))
return;
try
{
Process.Start(new ProcessStartInfo()
{
FileName = selectedItem.FullPath,
UseShellExecute = true
});
}
catch (Win32Exception ex)
{
if (ex.NativeErrorCode != 1223)
return;
Tools.OpenContainingFolder(selectedItem.FullPath);
}
catch (UnauthorizedAccessException ex)
{
Tools.OpenContainingFolder(selectedItem.FullPath);
}
catch
{
Tools.OpenContainingFolder(selectedItem.FullPath);
}
}
private static void OpenContainingFolder(string filePath)
{
try
{
string directoryName = Path.GetDirectoryName(filePath);
if (string.IsNullOrEmpty(directoryName) || !Directory.Exists(directoryName))
return;
Process.Start(new ProcessStartInfo()
{
FileName = "explorer.exe",
Arguments = $"\"{directoryName}\"",
UseShellExecute = true
});
}
catch
{
}
}
private static string FormatSize(long bytes)
{
if (bytes < 1024L /*0x0400*/)
return bytes.ToString() + " B";
if (bytes < 1048576L /*0x100000*/)
return ((double) bytes / 1024.0).ToString("F1") + " KB";
return bytes < 1073741824L /*0x40000000*/ ? ((double) bytes / 1048576.0).ToString("F1") + " MB" : ((double) bytes / 1073741824.0).ToString("F1") + " GB";
}
private static string GetIconGlyph(string ext)
{
if (string.IsNullOrEmpty(ext))
return "\uE7C3";
ext = ext.ToLowerInvariant();
switch (ext)
{
case ".exe":
case ".msi":
return "\uE756";
case ".bat":
case ".cmd":
case ".ps1":
return "\uE756";
case ".zip":
case ".rar":
case ".7z":
return "\uF012";
case ".txt":
case ".log":
return "\uE8A5";
case ".pdf":
return "\uEA90";
case ".lnk":
return "\uE71B";
case ".xml":
case ".json":
return "\uE943";
case ".ini":
case ".cfg":
return "\uE713";
case ".png":
case ".jpg":
case ".bmp":
case ".ico":
case ".gif":
return "\uEB9F";
default:
return "\uE7C3";
}
}
}