using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace QSMUnlockTool
{
public class MainForm : Form
{
// Layout
Panel panelTop, panelSidebar, panelCenter, panelRight, panelAction, panelBottom;
FlowLayoutPanel flowBrands;
TabControl tabFeatures;
TabPage tabADB, tabRepair, tabScreen, tabMTP, tabDL, tabFlash;
RichTextBox richLog;
Button btnSelectAll, btnClear, btnStop, btnDoJob;
Label lblTop, lblLog;
// State
readonly Dictionary<string, List<CheckBox>> _tabChecks = new(StringComparer.OrdinalIgnoreCase);
readonly List<CheckBox> _bottomChecks = new();
string _currentBrand = "";
// Data
readonly string[] _brandList = {
"SAMSUNG","XIAOMI","HUAWEI","QUALCOMM","MEDIATEK",
"USB MTP-FRP","SPREADTRUM","FRP-ALL","LOG","LOGIN"
};
readonly string[] _tabNames = { "ADB", "Repair", "Screen Lock", "MTP", "Download Mode", "Flashing" };
readonly Dictionary<string, Dictionary<string, List<string>>> Catalog =
new(StringComparer.OrdinalIgnoreCase)
{
["SAMSUNG"] = new(StringComparer.OrdinalIgnoreCase)
{
["ADB"] = new(){ "Read Info","Reset FRP ADB","Enable ADB","KG Remove New Security OS 13 2023","Samsung KG Method OS 12/13 OLD Patch",
"Remove Samsung account","Reboot To Normal Mode","Reboot to Download Mode","Reboot To Recovery Mode" },
["Repair"] = new() { "Active diag (No Root)", "Enable All languages (Root)", "Reset lock (Halab devices)" },
["Screen Lock"] = new() { "Remove screen lock (ADB)", "Reset screen lock (Root)" },
["MTP"] = new() { "Enable Mobile Data Icon (No Root)", "Remove security notice (No Root)", "Delete security notice (Root)" },
["Download Mode"] = new() { "Reboot to Download", "Odin flash (placeholder)" },
["Flashing"] = new() { "Run service (Root)", "ServiceMode (HW)" },
["_bottom"] = new() { "Fix Logo after bootloader unlock (Root)", "Disable Samsung update" }
},
["XIAOMI"] = new(StringComparer.OrdinalIgnoreCase)
{
["ADB"] = new() { "Read Info", "Reset FRP (ADB)", "Remove Mi Account (ADB)" },
["Recovery"] = new() { "Anti-Relock (ADB)", "Enable Camera2 API" },
["FastBoot Mode"] = new() { "Remove screen lock (ADB)" },
["MTP"] = new() { "Disable OTA update" },
["EDL/Brom"] = new() { "Reboot to EDL (Fastboot)", "Reboot to Recovery", "Reboot to System" },
}
};
// Common dark colors
readonly Color Dark0 = Color.FromArgb(36, 36, 36);
readonly Color Dark1 = Color.FromArgb(44, 44, 44);
readonly Color Dark2 = Color.FromArgb(48, 48, 48);
readonly Color Dark3 = Color.FromArgb(54, 54, 54);
public MainForm()
{
// Reduce flicker / paint artifacts
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.OptimizedDoubleBuffer, true);
this.UpdateStyles();
BuildUi();
BuildBrandButtons();
LoadBrand("SAMSUNG"); // preview
}
// ====== UI ======
void BuildUi()
{
Text = "QSM Unlock Tool";
ClientSize = new Size(1200, 720);
MinimumSize = new Size(900, 600);
StartPosition = FormStartPosition.CenterScreen;
Font = new Font("Segoe UI", 10F);
SuspendLayout();
// Center (add FIRST to fix Dock order: Fill docks LAST)
panelCenter = new Panel { Dock = DockStyle.Fill, BackColor = Dark3, Padding = new Padding(0, 0, 0, 0) };
tabFeatures = new TabControl { Dock = DockStyle.Fill, Font = new Font("Segoe UI", 10F) };
// Dark tab pages
tabADB = new TabPage("ADB") { BackColor = Dark3, UseVisualStyleBackColor = false };
tabRepair = new TabPage("Repair") { BackColor = Dark3, UseVisualStyleBackColor = false };
tabScreen = new TabPage("Screen Lock") { BackColor = Dark3, UseVisualStyleBackColor = false };
tabMTP = new TabPage("MTP") { BackColor = Dark3, UseVisualStyleBackColor = false };
tabDL = new TabPage("Download Mode") { BackColor = Dark3, UseVisualStyleBackColor = false };
tabFlash = new TabPage("Flashing") { BackColor = Dark3, UseVisualStyleBackColor = false };
tabFeatures.TabPages.AddRange(new[] { tabADB, tabRepair, tabScreen, tabMTP, tabDL, tabFlash });
panelCenter.Controls.Add(tabFeatures);
Controls.Add(panelCenter);
// Right Log
panelRight = new Panel { Dock = DockStyle.Right, Width = 360, BackColor = Dark2 };
lblLog = new Label
{
Text = "LOG",
Dock = DockStyle.Top,
Height = 32,
ForeColor = Color.White,
Font = new Font("Segoe UI", 10F, FontStyle.Bold),
TextAlign = ContentAlignment.MiddleLeft,
Padding = new Padding(12, 0, 0, 0)
};
richLog = new RichTextBox
{
Dock = DockStyle.Fill,
ReadOnly = true,
BackColor = Color.FromArgb(32, 32, 32),
ForeColor = Color.Lime,
BorderStyle = BorderStyle.None,
Font = new Font("Consolas", 10F)
};
panelRight.Controls.Add(richLog);
panelRight.Controls.Add(lblLog);
Controls.Add(panelRight);
// Left Sidebar
panelSidebar = new Panel { Dock = DockStyle.Left, Width = 190, BackColor = Dark1 };
flowBrands = new FlowLayoutPanel
{
Dock = DockStyle.Fill,
FlowDirection = FlowDirection.TopDown,
AutoScroll = true,
WrapContents = false,
Padding = new Padding(0, 8, 0, 8)
};
panelSidebar.Controls.Add(flowBrands);
Controls.Add(panelSidebar);
// Top bar
panelTop = new Panel { Dock = DockStyle.Top, Height = 36, BackColor = Dark0 };
lblTop = new Label
{
Text = "QSM Unlock Tool — USER: demo@local • Credits: 0",
Dock = DockStyle.Fill,
ForeColor = Color.White,
Font = new Font("Segoe UI", 11F, FontStyle.Bold),
TextAlign = ContentAlignment.MiddleLeft,
Padding = new Padding(16, 0, 0, 0)
};
panelTop.Controls.Add(lblTop);
Controls.Add(panelTop);
// Bottom options
panelBottom = new Panel { Dock = DockStyle.Bottom, Height = 42, BackColor = Dark1, Padding = new Padding(12, 0, 12, 0) };
Controls.Add(panelBottom);
// Action bar
panelAction = new Panel { Dock = DockStyle.Bottom, Height = 48, BackColor = Dark0, Padding = new Padding(12, 0, 12, 0) };
btnSelectAll = MakeButton("Select All", 110, 32, 0, 8, Color.FromArgb(60, 60, 60), onClick: btnSelectAll_Click);
btnClear = MakeButton("Clear", 110, 32, 120, 8, Color.FromArgb(60, 60, 60), onClick: btnClear_Click);
btnDoJob = MakeButton("DO JOB", 120, 36, 0, 6, Color.FromArgb(0, 120, 215), anchorRight: true, onClick: btnDoJob_Click);
btnStop = MakeButton("STOP", 100, 36, 0, 6, Color.FromArgb(200, 40, 40), anchorRight: true, onClick: btnStop_Click);
panelAction.Controls.AddRange(new Control[] { btnSelectAll, btnClear, btnStop, btnDoJob });
panelAction.Resize += (s, e) =>
{
btnDoJob.Left = panelAction.Width - btnDoJob.Width - 12;
btnStop.Left = btnDoJob.Left - btnStop.Width - 12;
};
Controls.Add(panelAction);
ResumeLayout();
}
Button MakeButton(string text, int w, int h, int left, int top, Color bg, bool anchorRight = false, EventHandler? onClick = null)
{
var b = new Button
{
Text = text,
Width = w,
Height = h,
Left = left,
Top = top,
BackColor = bg,
ForeColor = Color.White,
FlatStyle = FlatStyle.Flat
};
b.FlatAppearance.BorderSize = 0;
if (anchorRight) b.Anchor = AnchorStyles.Right;
if (onClick != null) b.Click += onClick;
return b;
}
// ====== Brands ======
void BuildBrandButtons()
{
flowBrands.Controls.Clear();
foreach (var brand in _brandList)
{
var btn = new Button
{
Text = brand,
Width = 170,
Height = 36,
Margin = new Padding(8, 4, 8, 4),
BackColor = Color.FromArgb(60, 60, 60),
ForeColor = Color.White,
FlatStyle = FlatStyle.Flat
};
btn.FlatAppearance.BorderSize = 0;
btn.Click += (s, e) => LoadBrand(brand);
flowBrands.Controls.Add(btn);
}
}
// ====== Load brand & render tabs ======
void LoadBrand(string brand)
{
_currentBrand = brand;
_tabChecks.Clear();
_bottomChecks.Clear();
var TabBg = Dark3;
for (int i = 0; i < _tabNames.Length; i++)
{
var tab = tabFeatures.TabPages[i];
tab.Controls.Clear();
if (Catalog.TryGetValue(brand, out var brandDict) && brandDict.TryGetValue(_tabNames[i], out var actions))
{
var scroll = new Panel { Dock = DockStyle.Fill, AutoScroll = true, BackColor = TabBg };
var table = new TableLayoutPanel
{
Dock = DockStyle.Top,
AutoSize = true,
ColumnCount = 2,
Padding = new Padding(16, 12, 16, 12),
BackColor = TabBg
};
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50f));
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50f));
var checks = new List<CheckBox>();
for (int j = 0; j < actions.Count; j++)
{
var cb = new CheckBox
{
Text = actions[j],
AutoSize = true,
Margin = new Padding(4),
ForeColor = Color.White,
BackColor = TabBg
};
checks.Add(cb);
table.Controls.Add(cb, j % 2, j / 2);
}
_tabChecks[_tabNames[i]] = checks;
scroll.Controls.Add(table);
tab.Controls.Add(scroll);
}
else
{
tab.Controls.Add(new Label
{
Text = $"{brand} — {_tabNames[i]}\nComing Soon...",
Dock = DockStyle.Fill,
TextAlign = ContentAlignment.MiddleCenter,
ForeColor = Color.White,
BackColor = TabBg,
Font = new Font("Segoe UI", 13F, FontStyle.Bold)
});
_tabChecks[_tabNames[i]] = new List<CheckBox>();
}
}
// Bottom options
panelBottom.Controls.Clear();
if (Catalog.TryGetValue(brand, out var bdict) && bdict.TryGetValue("_bottom", out var bottomList))
{
var flow = new FlowLayoutPanel
{
Dock = DockStyle.Fill,
FlowDirection = FlowDirection.LeftToRight,
WrapContents = false,
Padding = new Padding(0, 8, 0, 0),
BackColor = Color.Transparent
};
foreach (var opt in bottomList)
{
var cb = new CheckBox
{
Text = opt,
AutoSize = true,
Margin = new Padding(12, 0, 0, 0),
ForeColor = Color.White,
BackColor = Color.Transparent
};
_bottomChecks.Add(cb);
flow.Controls.Add(cb);
}
panelBottom.Controls.Add(flow);
}
Log($"[UI] Selected brand: {brand}");
}
// ====== Actions ======
void btnSelectAll_Click(object? sender, EventArgs e)
{
foreach (var list in _tabChecks.Values) foreach (var cb in list) cb.Checked = true;
foreach (var cb in _bottomChecks) cb.Checked = true;
}
void btnClear_Click(object? sender, EventArgs e)
{
foreach (var list in _tabChecks.Values) foreach (var cb in list) cb.Checked = false;
foreach (var cb in _bottomChecks) cb.Checked = false;
}
void btnStop_Click(object? sender, EventArgs e) => Log("[JOB] STOP requested.");
void btnDoJob_Click(object? sender, EventArgs e)
{
var selected = new List<string>();
foreach (var tab in _tabNames)
if (_tabChecks.TryGetValue(tab, out var list))
selected.AddRange(list.Where(cb => cb.Checked).Select(cb => $"{tab}: {cb.Text}"));
selected.AddRange(_bottomChecks.Where(cb => cb.Checked).Select(cb => $"Option: {cb.Text}"));
if (selected.Count == 0)
{
MessageBox.Show("Please select at least one action.", "No Action Selected",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
Log($"[JOB] {_currentBrand} -> {selected.Count} action(s)");
foreach (var s in selected) Log(" " + s);
}
// ====== Logger ======
void Log(string text)
{
if (richLog.InvokeRequired) { richLog.Invoke(new Action(() => Log(text))); return; }
if (richLog.TextLength > 0) richLog.AppendText(Environment.NewLine);
richLog.AppendText($"[{DateTime.Now:HH:mm:ss}] {text}");
richLog.ScrollToCaret();
}
}
}
0 Comments