Files

264 lines
13 KiB
C#
Raw Permalink Normal View History

2026-08-27 11:23:13 -06:00
// Decompiled with JetBrains decompiler
// Type: Raton.Windows.PluginTutorial
// 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.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
#nullable disable
namespace Raton.Windows;
public partial class PluginTutorial : Window
{
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
[DllImport("dwmapi.dll", CharSet = CharSet.Auto)]
private static extern int DwmSetWindowAttribute(
IntPtr hwnd,
int attr,
ref int attrValue,
int attrSize);
public PluginTutorial()
{
this.InitializeComponent();
this.Loaded += new RoutedEventHandler(this.PluginTutorial_Loaded);
}
private void PluginTutorial_Loaded(object sender, RoutedEventArgs e)
{
this.AnimateIn();
this.ApplyDarkMode();
}
private void ApplyDarkMode()
{
bool flag = this.IsWindowsDarkMode();
IntPtr handle = new WindowInteropHelper((Window) this).Handle;
int attrValue = flag ? 1 : 0;
PluginTutorial.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 AnimateIn()
{
this.ContentPanel.Opacity = 0.0;
this.ContentPanel.RenderTransform = (Transform) new TranslateTransform(0.0, 18.0);
DoubleAnimation doubleAnimation1 = new DoubleAnimation(0.0, 1.0, (Duration) TimeSpan.FromMilliseconds(380.0));
CubicEase cubicEase1 = new CubicEase();
cubicEase1.EasingMode = EasingMode.EaseOut;
doubleAnimation1.EasingFunction = (IEasingFunction) cubicEase1;
DoubleAnimation animation1 = doubleAnimation1;
DoubleAnimation doubleAnimation2 = new DoubleAnimation(18.0, 0.0, (Duration) TimeSpan.FromMilliseconds(380.0));
CubicEase cubicEase2 = new CubicEase();
cubicEase2.EasingMode = EasingMode.EaseOut;
doubleAnimation2.EasingFunction = (IEasingFunction) cubicEase2;
DoubleAnimation animation2 = doubleAnimation2;
this.ContentPanel.BeginAnimation(UIElement.OpacityProperty, (AnimationTimeline) animation1);
this.ContentPanel.RenderTransform.BeginAnimation(TranslateTransform.YProperty, (AnimationTimeline) animation2);
}
private void AnimateScroll(double toOffset)
{
double from = this.MainScroll.VerticalOffset;
double to = Math.Max(0.0, toOffset);
double elapsed = 0.0;
double dur = 320.0;
DispatcherTimer timer = new DispatcherTimer()
{
Interval = TimeSpan.FromMilliseconds(16.0)
};
timer.Tick += (EventHandler) ((s, e) =>
{
elapsed += 16.0;
double num = Math.Min(elapsed / dur, 1.0);
this.MainScroll.ScrollToVerticalOffset(from + (to - from) * (1.0 - Math.Pow(1.0 - num, 3.0)));
if (num < 1.0)
return;
timer.Stop();
});
timer.Start();
}
private void ScrollToSection(FrameworkElement section)
{
this.AnimateScroll(section.TranslatePoint(new Point(0.0, 0.0), (UIElement) this.ContentPanel).Y - 16.0);
this.AnimateSectionHighlight(section);
}
private void AnimateSectionHighlight(FrameworkElement section)
{
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
animation.KeyFrames.Add((DoubleKeyFrame) new EasingDoubleKeyFrame(0.35, KeyTime.FromTimeSpan(TimeSpan.Zero)));
DoubleKeyFrameCollection keyFrames = animation.KeyFrames;
EasingDoubleKeyFrame keyFrame = new EasingDoubleKeyFrame(1.0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(300.0)));
CubicEase cubicEase = new CubicEase();
cubicEase.EasingMode = EasingMode.EaseOut;
keyFrame.EasingFunction = (IEasingFunction) cubicEase;
keyFrames.Add((DoubleKeyFrame) keyFrame);
section.BeginAnimation(UIElement.OpacityProperty, (AnimationTimeline) animation);
}
private void Nav_Welcome(object sender, MouseButtonEventArgs e) => this.AnimateScroll(0.0);
private void Nav_Structure(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_Structure);
}
private void Nav_PluginInfo(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_PluginInfo);
}
private void Nav_EntryPoint(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_EntryPoint);
}
private void Nav_Pack(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_Pack);
}
private void Nav_Args(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_Args);
}
private void Nav_PackRef(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_PackRef);
}
private void Nav_Example(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_Example);
}
private void Nav_Tips(object sender, MouseButtonEventArgs e)
{
this.ScrollToSection((FrameworkElement) this.Sec_Tips);
}
private void CopyToClipboard(string text, Border btn)
{
try
{
Clipboard.SetText(text);
this.FlashCopyButton(btn, "Copied!");
}
catch
{
this.FlashCopyButton(btn, "Failed");
}
}
private void FlashCopyButton(Border btn, string message)
{
if (btn == null)
return;
TextBlock tb = PluginTutorial.FindChild<TextBlock>((DependencyObject) btn);
if (tb == null)
return;
string original = tb.Text;
tb.Text = message;
tb.Foreground = (Brush) new SolidColorBrush(message == "Copied!" ? System.Windows.Media.Color.FromRgb((byte) 76, (byte) 175, (byte) 80 /*0x50*/) : System.Windows.Media.Color.FromRgb((byte) 239, (byte) 83, (byte) 80 /*0x50*/));
if (!(btn.RenderTransform is ScaleTransform))
{
btn.RenderTransformOrigin = new Point(0.5, 0.5);
btn.RenderTransform = (Transform) new ScaleTransform(1.0, 1.0);
}
DoubleAnimation doubleAnimation = new DoubleAnimation(1.0, 1.14, (Duration) TimeSpan.FromMilliseconds(100.0));
doubleAnimation.AutoReverse = true;
CubicEase cubicEase = new CubicEase();
cubicEase.EasingMode = EasingMode.EaseOut;
doubleAnimation.EasingFunction = (IEasingFunction) cubicEase;
DoubleAnimation animation = doubleAnimation;
btn.RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, (AnimationTimeline) animation);
DispatcherTimer timer = new DispatcherTimer()
{
Interval = TimeSpan.FromMilliseconds(1400.0)
};
timer.Tick += (EventHandler) ((s, e) =>
{
tb.Text = original;
tb.Foreground = (Brush) new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte) 76, (byte) 175, (byte) 80 /*0x50*/));
timer.Stop();
});
timer.Start();
}
private static T FindChild<T>(DependencyObject parent) where T : DependencyObject
{
if (parent == null)
return default (T);
for (int childIndex = 0; childIndex < VisualTreeHelper.GetChildrenCount(parent); ++childIndex)
{
DependencyObject child1 = VisualTreeHelper.GetChild(parent, childIndex);
if (child1 is T child2)
return child2;
T child3 = PluginTutorial.FindChild<T>(child1);
if ((object) child3 != null)
return child3;
}
return default (T);
}
private void CopyCode_PluginInfoAttr(object sender, MouseButtonEventArgs e)
{
this.CopyToClipboard("using System;\r\n[AttributeUsage(AttributeTargets.Class)]\r\npublic class PluginInfoAttribute : Attribute\r\n{\r\n public string Description { get; }\r\n public string Provider { get; }\r\n\r\n public PluginInfoAttribute(string description)\r\n {\r\n Provider = \"Raton\";\r\n Description = description;\r\n }\r\n}", sender as Border);
}
private void CopyCode_PluginInfoUsage(object sender, MouseButtonEventArgs e)
{
this.CopyToClipboard("[PluginInfo(\"Example plugin for testing\")]\r\nclass Program\r\n{\r\n}", sender as Border);
}
private void CopyCode_Main(object sender, MouseButtonEventArgs e)
{
this.CopyToClipboard("public static Action<byte[]> _send;\r\n\r\nstatic void Main(Action<byte[]> send, string[] args)\r\n{\r\n _send = send;\r\n if (args == null || args.Length == 0)\r\n {\r\n ExecuteArg(\"default\", \"\");\r\n return;\r\n }\r\n ParseArgs(args);\r\n}", sender as Border);
}
private void CopyCode_Pack(object sender, MouseButtonEventArgs e)
{
this.CopyToClipboard("Pack pack = new Pack();\r\npack.SetString(\"Packet\", \"UserMessage\");\r\npack.SetString(\"Message\", \"Hello from my plugin!\");\r\npack.SetString(\"Status\", \"Success\");\r\n_send(pack.Pacc());", sender as Border);
}
private void CopyCode_ParseArgs(object sender, MouseButtonEventArgs e)
{
this.CopyToClipboard("static void ParseArgs(string[] args)\r\n{\r\n string currentArg = null;\r\n StringBuilder valueBuilder = new StringBuilder();\r\n for (int i = 0; i < args.Length; i++)\r\n {\r\n string arg = args[i];\r\n if (arg.StartsWith(\"-\"))\r\n {\r\n if (currentArg != null)\r\n ExecuteArg(currentArg, valueBuilder.ToString());\r\n currentArg = arg.ToLower();\r\n valueBuilder.Clear();\r\n }\r\n else\r\n {\r\n if (valueBuilder.Length > 0) valueBuilder.Append(\" \");\r\n valueBuilder.Append(arg);\r\n }\r\n }\r\n if (currentArg != null)\r\n ExecuteArg(currentArg, valueBuilder.ToString());\r\n}", sender as Border);
}
private void CopyCode_Full(object sender, MouseButtonEventArgs e)
{
this.CopyToClipboard("using Stuff;\r\nusing System;\r\nusing System.Text;\r\n\r\nnamespace TestPlugin\r\n{\r\n [PluginInfo(\"Example plugin for testing\")]\r\n class Program\r\n {\r\n public static Action<byte[]> _send;\r\n\r\n static void Main(Action<byte[]> send, string[] args)\r\n {\r\n _send = send;\r\n if (args == null || args.Length == 0)\r\n {\r\n ExecuteArg(\"default\", \"\");\r\n return;\r\n }\r\n ParseArgs(args);\r\n }\r\n\r\n static void ParseArgs(string[] args)\r\n {\r\n string currentArg = null;\r\n StringBuilder valueBuilder = new StringBuilder();\r\n for (int i = 0; i < args.Length; i++)\r\n {\r\n string arg = args[i];\r\n if (arg.StartsWith(\"-\"))\r\n {\r\n if (currentArg != null)\r\n ExecuteArg(currentArg, valueBuilder.ToString());\r\n currentArg = arg.ToLower();\r\n valueBuilder.Clear();\r\n }\r\n else\r\n {\r\n if (valueBuilder.Length > 0) valueBuilder.Append(\" \");\r\n valueBuilder.Append(arg);\r\n }\r\n }\r\n if (currentArg != null)\r\n ExecuteArg(currentArg, valueBuilder.ToString());\r\n }\r\n\r\n static void ExecuteArg(string arg, string value)\r\n {\r\n switch (arg)\r\n {\r\n case \"-msg\":\r\n Pack pack = new Pack();\r\n pack.SetString(\"Packet\", \"UserMessage\");\r\n pack.SetString(\"Message\", \"Your message was: \" + value);\r\n pack.SetString(\"Status\", \"Success\");\r\n _send(pack.Pacc());\r\n break;\r\n default:\r\n Pack pack2 = new Pack();\r\n pack2.SetString(\"Packet\", \"UserMessage\");\r\n pack2.SetString(\"Message\", \"Try: -msg <text>\");\r\n pack2.SetString(\"Status\", \"Warning\");\r\n _send(pack2.Pacc());\r\n break;\r\n }\r\n }\r\n }\r\n}", sender as Border);
}
}