// ok private void button1_Click(object sender, System.EventArgs e) { int nr = 0; try { nr = Int32.Parse(this.textBox2.Text); } catch (Exception ex) { Util.MBoxError("Überprüfen Sie die Liednummer!", ex); this.textBox2.Focus(); this.textBox2.SelectAll(); return; } string title = this.textBox1.Text; string text = this.richTextBox1.Text; string desc = this.textBox3.Text == "---" ? "" : this.textBox3.Text; if (this.toDel != null && nr == this.toDel.Number) // number hasn't changed! { this.song = this.toDel; } if (this.song != null) { this.song.Title = title; this.song.Text = text; this.song.Desc = desc; this.song.BackgroundPicture = this.textBox4.Text; this.song.Transparency = this.trackBar1.Value; this.song.Scale = this.checkBox2.Checked; this.owner.Status = "Liedtext editiert..."; } else { string id = "s" + Util.toFour(nr); Song newSong = new Song(nr, title, text, id, desc, true); newSong.BackgroundPicture = this.textBox4.Text; newSong.Transparency = this.trackBar1.Value; newSong.Scale = this.checkBox2.Checked; if (this.toDel != null) { this.CopyTrans(this.toDel, newSong); this.toDel.Delete(); } try { this.owner.AddSong(newSong); } catch { string msg = "Diese Liednummer wurde bereits einmal verwendet!\n"; msg += "Soll das Lied trotzdem hinzugefügt werden?\n"; msg += "(evtl. haben Sie das Lied bereits einer anderen Nummer zugewiesen,\n"; msg += "in diesem Fall einfach \"Ja\" klicken!)"; DialogResult dr = MessageBox.Show(this, msg, "lyra2 - neues Lied hinzufügen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { newSong.nextID(); this.owner.AddSong(newSong); } else { return; } } this.owner.Status = "Neues Lied erfolgreich hinzugefügt..."; } this.owner.UpdateListBox(); this.owner.ToUpdate(true); this.Close(); }
private void ImportLTX(string url, bool append) { if (!append) { this.storage.Clear(); Util.DELALL = true; } StreamReader reader = new StreamReader(url); try { string line, text, title; line = text = title = ""; int nr = 0; bool intext = false; while ((line = reader.ReadLine()) != null) { if (intext) { if (line.EndsWith("#END")) { text += line.Substring(0, line.Length - 4); Song song = new Song(nr, title, text, "s" + Util.toFour(nr), "", true); text = title = ""; intext = false; try { this.storage.AddSong(song); } catch (ArgumentException) { string msg = "Wollen Sie Lied Nr." + nr.ToString() + " ersetzen?\n"; msg += "(drücken Sie \"abbrechen\", wenn Sie das Lied überspringen wollen.)"; DialogResult dr = MessageBox.Show(this, msg, "lyra2 import", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { this.storage.RemoveSong(song.ID); this.storage.AddSong(song); } else if (dr == DialogResult.No) { song.nextID(); this.storage.AddSong(song); } else { // cancel <-> ignore song } continue; } } else { text += line + "\n"; } } // first line of song else if (line != "") { string[] words = line.Split(' '); title = line.Substring(words[0].Length + 1); nr = Int32.Parse(words[0]); intext = true; } } this.storage.displaySongs(this.listBox1); this.ToUpdate(true); this.Status = "LTX-Import erfolgreich! :-)"; } catch (Exception ie) { Util.MBoxError("Fehler beim Importieren.\n" + ie.Message, ie); this.Status = "Beim LTX-Import ging leider etwas schief. :-("; } }