Skip to content

Commit

Permalink
Сделал тёмную тему
Browse files Browse the repository at this point in the history
  • Loading branch information
KOTOKOPOLb committed Oct 12, 2023
1 parent e47df81 commit fe353eb
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 11 deletions.
30 changes: 25 additions & 5 deletions AP Pay/Cards.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 32 additions & 6 deletions AP Pay/Cards.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SP_tools
using static SP_tools.Main;

namespace SP_tools
{
public partial class Cards : Form
{
Expand All @@ -11,15 +13,39 @@ private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
//Main main = new Main();
File.WriteAllText("sett", textBox1.Text + "\n" + textBox2.Text);
//main.id = textBox1.Text;
//main.token = textBox2.Text;
File.WriteAllText("sett", textBox1.Text + "\n" + textBox2.Text + "\n" + checkBox1.Checked.ToString());
Close();
}
else MessageBox.Show("Введите ID и Токен!");
}

private void button2_Click(object sender, EventArgs e) => MessageBox.Show("1) Заходите на нужный сервер в Minecraft\n2) Заходите на сайт SP Worlds\n3) Нажимаете на свой аватар справо сверху и ыбираете нужный сервер\n4) Переходите в 'Кошелёк', выбираете нужную карту, нажимаете 'Поделиться'\n5) Нажимаете 'Сгенерировать новый API токен' и подтверждаете\n6) Получаете в чате Minecraft ID и токен вашей карты");
private void button2_Click(object sender, EventArgs e) => System.Diagnostics.Process.Start("explorer", "https://github.com/KOTOKOPOLb/SP-Tools/wiki/");

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
var preference = Convert.ToInt32(true);
if (checkBox1.Checked)
{
preference = Convert.ToInt32(true);
DwmSetWindowAttribute(Handle, DWMWINDOWATTRIBUTE.DARK_MODE, ref preference, sizeof(uint));
BackColor = Color.FromArgb(55, 57, 63);
label1.ForeColor = label2.ForeColor = checkBox1.ForeColor = button1.ForeColor = button2.ForeColor = textBox1.ForeColor = textBox2.ForeColor = Color.White;
button1.BackColor = button2.BackColor = Color.FromArgb(24, 25, 28);
textBox1.BackColor = textBox2.BackColor = Color.FromArgb(65, 68, 75);
button1.FlatStyle = button2.FlatStyle = FlatStyle.Popup;
textBox1.BorderStyle = textBox2.BorderStyle = BorderStyle.FixedSingle;
}
else
{
preference = Convert.ToInt32(false);
DwmSetWindowAttribute(Handle, DWMWINDOWATTRIBUTE.DARK_MODE, ref preference, sizeof(uint));
BackColor = Color.FromArgb(240, 240, 240);
label1.ForeColor = label2.ForeColor = checkBox1.ForeColor = button1.ForeColor = button2.ForeColor = textBox1.ForeColor = textBox2.ForeColor = Color.Black;
button1.BackColor = button2.BackColor = Color.FromArgb(253, 253, 253);
textBox1.BackColor = textBox2.BackColor = Color.White;
button1.FlatStyle = button2.FlatStyle = FlatStyle.Standard;
textBox1.BorderStyle = textBox2.BorderStyle = BorderStyle.Fixed3D;
}
}
}
}
4 changes: 4 additions & 0 deletions AP Pay/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions AP Pay/Main.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;

Expand All @@ -12,8 +13,14 @@ public Main()
InitializeComponent();
}

[DllImport("dwmapi.dll", CharSet = CharSet.Unicode, PreserveSig = false)]
public static extern void DwmSetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE attribute, ref int pvAttribute, uint cbAttribute);

public enum DWMWINDOWATTRIBUTE : uint { DARK_MODE = 20 }

public string id;
public string token;
public string theme;
string btoken;
private void button1_Click(object sender, EventArgs e) => pay();

Expand Down Expand Up @@ -76,11 +83,25 @@ private void Main_Load(object sender, EventArgs e)
private void button2_Click(object sender, EventArgs e)
{
Cards cards = new Cards();
if (theme == "True")
cards.checkBox1.Checked = true;
else if (theme == "False")
cards.checkBox1.Checked = false;
cards.textBox1.Text = id;
cards.textBox2.Text = token;
cards.ShowDialog();
id = cards.textBox1.Text;
token = cards.textBox2.Text;
if (cards.checkBox1.Checked)
{
SetTheme(true);
theme = "True";
}
else
{
SetTheme(false);
theme = "False";
}
balance();
}

Expand All @@ -94,8 +115,16 @@ void ReadSett()
{
id = lines[0];
token = lines[1];
theme = lines[2];
}
catch (IndexOutOfRangeException) { }
if (theme != "False" && theme != "True")
theme = "False";

if (theme == "True")
SetTheme(true);
else if (theme == "False")
SetTheme(false);
}
}

Expand All @@ -117,5 +146,33 @@ private void textBox2_TextChanged(object sender, EventArgs e)
}

private void button3_Click(object sender, EventArgs e) => balance();

public void SetTheme(bool theme)
{
var preference = Convert.ToInt32(true);
if (theme)
{
preference = Convert.ToInt32(true);
DwmSetWindowAttribute(Handle, DWMWINDOWATTRIBUTE.DARK_MODE, ref preference, sizeof(uint));
BackColor = Color.FromArgb(55, 57, 63);
label1.ForeColor = label2.ForeColor = label3.ForeColor = label4.ForeColor = textBox1.ForeColor = textBox2.ForeColor = textBox3.ForeColor = button1.ForeColor = button2.ForeColor = button3.ForeColor = statusStrip1.ForeColor = Color.White;
button1.BackColor = button2.BackColor = button3.BackColor = Color.FromArgb(24, 25, 28);
textBox1.BackColor = textBox2.BackColor = textBox3.BackColor = Color.FromArgb(65, 68, 75);
button1.FlatStyle = button2.FlatStyle = button3.FlatStyle = FlatStyle.Popup;
textBox1.BorderStyle = textBox2.BorderStyle = textBox3.BorderStyle = BorderStyle.FixedSingle;
statusStrip1.BackColor = Color.FromArgb(47, 49, 54);
}
else
{
preference = Convert.ToInt32(false);
DwmSetWindowAttribute(Handle, DWMWINDOWATTRIBUTE.DARK_MODE, ref preference, sizeof(uint));
BackColor = statusStrip1.BackColor = Color.FromArgb(240, 240, 240);
label1.ForeColor = label2.ForeColor = label3.ForeColor = label4.ForeColor = textBox1.ForeColor = textBox2.ForeColor = textBox3.ForeColor = button1.ForeColor = button2.ForeColor = button3.ForeColor = statusStrip1.ForeColor = Color.Black;
button1.BackColor = button2.BackColor = button3.BackColor = Color.FromArgb(253, 253, 253);
textBox1.BackColor = textBox2.BackColor = textBox3.BackColor = Color.White;
button1.FlatStyle = button2.FlatStyle = button3.FlatStyle = FlatStyle.Standard;
textBox1.BorderStyle = textBox2.BorderStyle = textBox3.BorderStyle = BorderStyle.Fixed3D;
}
}
}
}

0 comments on commit fe353eb

Please sign in to comment.