Exemplo n.º 1
0
        private void btn_Edit_Key_Click(object sender, EventArgs e)
        {
            cB_enableRadio_Version.Checked = false;
            InputAuthKey inputAuthKey = new InputAuthKey();

            inputAuthKey.ShowDialog();
            inputAuthKey.VisibleChanged += InputAuthKey_VisibleChanged;
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //defaulting to Banana
            setStrings(isPotato);
            DialogResult r;

VMInit:

            while (true)
            {
                try
                {
                    vm = new VmClient();
                    Thread.Sleep(100);
                    if (!vm.Poll())
                    {
                        throw new Exception();
                    }
                    break;
                }
                catch (Exception ex)
                {
                    r = MessageBox.Show("Couldn't connect to VoiceMeeter!\nIs it running?", "Error", MessageBoxButtons.RetryCancel);
                    if (r == DialogResult.Cancel)
                    {
                        start = StartResult.VM;
                        this.Close();
                        return;
                    }
                }
            }


            while (true)
            {
                try
                {
                    ti = new TelnetConnection("localhost", 25639);
                    //hardcoding for now

                    string fileName = String.Format(@"{0}\TS_API_key", Application.StartupPath);
                    if (!File.Exists(fileName) || new FileInfo(fileName).Length == 0)
                    {
                        //this.Hide();
                        InputAuthKey inputAuthKey = new InputAuthKey();
                        inputAuthKey.ShowDialog();
                        inputAuthKey.VisibleChanged += InputAuthKey_VisibleChanged;
                    }

                    if (File.Exists(fileName))
                    {
                        TS_API_KEY = File.ReadAllText(fileName);
                    }
                    else
                    {
                        TS_API_KEY = "ERROR";
                    }


                    //TS_API_KEY = "TJP8-5MKV-B1DG-HWM2-3X6Z-Q99B";
                    ti.WriteLine("auth apikey=" + TS_API_KEY);
                    //Console.WriteLine(ti.Read());
                    break;
                }
                catch (Exception ex)
                {
                    r = MessageBox.Show("Couldn't connect to TeamSpeak!\nIs it running?", "Error", MessageBoxButtons.RetryCancel);
                    if (r == DialogResult.Cancel)
                    {
                        start = StartResult.TS;
                        this.Close();
                        return;
                    }
                }
            }



            if (!(ti.Read().Contains("error id=0 msg=ok")))
            {
                r = MessageBox.Show("Couldn't connect to TeamSpeak!\nThe API key was not accepted. Do you want to reenter it?", "Error", MessageBoxButtons.OKCancel);
                if (r == DialogResult.Cancel)
                {
                    start = StartResult.Success;
                    this.Close();
                    return;
                }
                else
                {
                    InputAuthKey inputAuthKey = new InputAuthKey();
                    inputAuthKey.ShowDialog();
                    inputAuthKey.VisibleChanged += InputAuthKey_VisibleChanged;
                }
            }
            else
            {
                Console.WriteLine("Successfully connected to TeamSpeak!");
            }

            //Get all active TeamSpeak sessions. We'll only be using the first two, but we'll query anyway in case the user has closed tabs before.

            while (true)
            {
                try
                {
                    ti.WriteLine("serverconnectionhandlerlist");
                    string     serverconnectionhandler_result = ti.Read();
                    List <int> conn = new List <int>();
                    foreach (char c in serverconnectionhandler_result)
                    {
                        if (Char.GetNumericValue(c) > 0.0)
                        {
                            conn.Add((int)Char.GetNumericValue(c));
                        }
                    }
                    TSConnection1 = conn[0];
                    TSConnection2 = conn[1];
                    break;
                }
                catch
                {
                    r = MessageBox.Show("Please confirm that you have two open TeamSpeak tabs.", "Error", MessageBoxButtons.RetryCancel);
                    if (r == DialogResult.Cancel)
                    {
                        start = StartResult.Success;
                        this.Close();
                        return;
                    }
                }
            }


            //conn.ForEach(Console.WriteLine);


            getDefaultVoiceMeeter();
        }