Ejemplo n.º 1
0
    private void ShowLyrics(object sender, EventArgs e)
    {
        try
        {
            Button button      = (Button)sender;
            string name        = "";
            string artist      = "";
            char   separator   = " ".ToCharArray()[0];
            string buttonLabel = "";

            if (button.Name == "1")
            {
                buttonLabel = button21.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            else if (button.Name == "2")
            {
                buttonLabel = button22.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            else if (button.Name == "3")
            {
                buttonLabel = button23.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            else if (button.Name == "4")
            {
                buttonLabel = button24.Label;
                name        = buttonLabel.Split(separator)[0];
                artist      = buttonLabel.Split(separator)[2];
            }
            XDocument document = new XDocument(new XElement("Data",
                                                            new XElement("opCode", 40),
                                                            new XElement("SongName", name),
                                                            new XElement("Artist", artist)));
            SocketClient.GetSocketClient().send(document);

            document = SocketClient.GetSocketClient().Listen();
            string lyrics       = document.Root.Element("Reply").Value;
            Lyrics lyricsWindow = new Lyrics(lyrics);
            lyricsWindow.Show();
        }
        catch (Exception)
        {
            AlertWindow alertWindow = new AlertWindow("Error: No se pudo eliminar el elemento o este no existe, por favor reintentar");
        }
    }