Esempio n. 1
0
 public TEditor(ListBox lb, Song song, GUI owner, Translation trans)
 {
     //
     // Erforderlich für die Windows Form-Designerunterstützung
     //
     InitializeComponent();
     this.song = song;
     this.trans = trans;
     this.lb = lb;
     this.owner = owner;
     this.textBox2.Text = this.song.Number.ToString();
     this.textBox2.Enabled = false;
     TEditor.tEditor = this;
     TEditor.TEditorOpen = true;
     if (this.trans != null)
     {
         this.textBox1.Text = this.trans.Title;
         this.richTextBox1.Text = this.trans.Text;
         this.checkBox1.Checked = this.trans.Unformatted;
         this.panel1.Enabled = !this.trans.Unformatted;
     }
     else
     {
         this.textBox1.Text = "";
         this.richTextBox1.Text = "";
     }
 }
Esempio n. 2
0
 public void AddSong(Song song)
 {
     this.BeginUpdate();
     ListViewItem lvi = new ListViewItem();
     lvi.Tag = song;
     lvi.Text = song.Number.ToString();
     lvi.SubItems.Add(song.Title);
     base.Items.Add(lvi);
     this.EndUpdate();
 }
Esempio n. 3
0
 private Preview(GUI owner, Song song, Point location)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     this.owner = owner;
     this.song = song;
     this.Location = location;
     this.label1.Text = song.Number.ToString();
     this.label2.Text = song.Title;
     this.label3.Text = this.getText(song.Text);
     this.LostFocus += new EventHandler(Preview_LostFocus);
     this.Closing += new System.ComponentModel.CancelEventHandler(Preview_Closing);
     this.GotFocus += new EventHandler(Preview_GotFocus);
     this.closeBtn.GotFocus += new EventHandler(closeBtn_GotFocus);
 }
Esempio n. 4
0
 public Editor(Song song, GUI owner)
 {
     Editor.open = true;
     Editor.editor = this;
     InitializeComponent();
     this.Height = 460;
     if (song != null)
     {
         this.song = song;
         this.textBox1.Text = song.Title;
         this.textBox2.Text = song.Number.ToString();
         this.richTextBox1.Text = song.Text;
         this.button12.Enabled = true;
         if (song.Desc == "")
         {
             this.checkBox1.Checked = false;
             this.textBox3.Text = "---";
             this.textBox3.Enabled = false;
         }
         else
         {
             this.checkBox1.Checked = true;
             this.textBox3.Text = song.Desc;
             this.textBox3.Enabled = true;
         }
         if(song.BackgroundPicture != "")
         {
             this.textBox4.Text = song.BackgroundPicture;
             this.trackBar1.Value = song.Transparency;
             this.checkBox2.Checked = song.Scale;
         }
     }
     else
     {
         this.textBox1.Text = "";
         this.textBox2.Text = "";
         this.richTextBox1.Text = "";
         this.textBox2.Enabled = true;
         this.textBox3.Text = "---";
         this.checkBox1.Checked = false;
         this.textBox3.Enabled = false;
     }
     this.owner = owner;
 }
Esempio n. 5
0
        public static void ShowPreview(GUI owner, Song song, Point location)
        {
            if(_this != null)
            {
                if(_this.song == song)
                {
                    return; // do nothing
                }
                if(!_this.IsDisposed)
                {
                    _this.Close();
                }
                _this = null;
            }

            _this = new Preview(owner, song, location);
            _this.Show();
            _this.Focus();
        }
Esempio n. 6
0
        private void button10_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;
            }
            if (this.toDel != null && nr == this.toDel.Number)
            {
                this.song = this.toDel;
                this.toDel = null;
                this.textBox2.Enabled = false;
                this.button12.Enabled = true;
            }
            if (this.song == null)
            {
                DialogResult add = MessageBox.Show(this, "Das neue Lied muss zuerst gespeichert werden.\n" +
                    "Soll das Lied jetzt hinzugefügt werden?", "lyra2 Hinweis", MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Warning);
                if (add == DialogResult.No)
                {
                    return;
                }
                string title = this.textBox1.Text;
                string text = this.richTextBox1.Text;
                string id = "s" + Util.toFour(nr);
                string desc = this.checkBox1.Checked ? this.textBox3.Text : "";
                this.song = new Song(nr, title, text, id, desc, true);
                if (this.toDel != null)
                {
                    this.CopyTrans(this.toDel, this.song);
                    this.toDel.Delete();
                }
                try
                {
                    this.owner.AddSong(this.song);
                }
                catch
                {
                    string msg = "Diese Liednummer wurde bereits einmal verwendet!\n";
                    msg += "Soll das Lied trotzdem hinzugefügt werden?";

                    DialogResult dr = MessageBox.Show(this, msg, "lyra2 - neues Lied hinzufügen",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (dr == DialogResult.Yes)
                    {
                        this.song.nextID();
                        this.owner.AddSong(this.song);
                    }
                    else
                    {
                        return;
                    }
                }
                this.owner.Status = "Neues Lied erfolgreich hinzugefügt...";
                this.owner.UpdateListBox();
                this.owner.ToUpdate(true);
                this.textBox2.Enabled = false;
                this.button12.Enabled = true;
            }

            if (!this.transshown)
            {
                this.Height = 568;
                this.transshown = true;
                this.button10.Text = "<< Übersetzungen";
                this.song.ShowTranslations(this.listBox1);
                if (this.listBox1.Items.Count > 0)
                {
                    this.listBox1.SelectedIndex = 0;
                }
            }
            else
            {
                this.Height = 460;
                this.transshown = false;
                this.button10.Text = "Übersetzungen >>";
            }
        }
Esempio n. 7
0
 private void addSong(IndexWriter writer, Song song)
 {
     Document songDoc = new Document();
     Field textField = new Field("text", song.Text + " " + song.Title, Field.Store.NO, Field.Index.TOKENIZED);
     Field titleField = new Field("title", song.Title, Field.Store.NO, Field.Index.TOKENIZED);
     Field nrField = new Field("nr", song.Number.ToString(), Field.Store.YES, Field.Index.TOKENIZED);
     songDoc.Add(nrField);
     songDoc.Add(titleField);
     songDoc.Add(textField);
     writer.AddDocument(songDoc);
 }
Esempio n. 8
0
        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. :-(";
            }
        }
Esempio n. 9
0
 public void AddSongToCurrent(Song song)
 {
     this.currentList.AddSong(song);
     this.update();
 }
Esempio n. 10
0
 public void AddSong(Song song)
 {
     this.Add(this.Count, song);
     this.myNode.ChildNodes[3].InnerText = this.updateList();
 }
Esempio n. 11
0
 public void copyTranslation(Song to)
 {
     to.acceptTranslation(this.Translations);
 }
Esempio n. 12
0
 public void AddSong(Song song)
 {
     this.SongList.Add(song.ID, song);
 }
Esempio n. 13
0
        private void showUnformated(Song s)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "Bitte geben Sie den Pfad für die Textdatei an!";
            sfd.Filter = "Textdatei|*.txt";
            sfd.FileName = "lyra2_" + s.Number.ToString() + ".txt";
            if(sfd.ShowDialog(this) == DialogResult.OK)
            {
                StreamWriter sw = new StreamWriter(sfd.FileName,false);
                string title = s.Number.ToString().PadRight(5,' ') + ":  " + s.Title;
                string line = "".PadRight(title.Length,'-');
                sw.WriteLine(title);
                sw.WriteLine(line);
                sw.WriteLine();
                string text = "";
                for(int i=0; i<s.Text.Length; i++)
                {
                    if(s.Text[i] == '<')
                    {
                        if(this.isFormat(s.Text.Substring(i+1)))
                        {
                            if(s.Text.Substring(i+1).StartsWith("refrain"))
                            {
                                text += "REFRAIN:" + Util.NL;
                            }
                            i = s.Text.IndexOf('>',i) + 1;
                        }
                    }
                    text += s.Text[i];
                }
                text = text.Replace("&gt;",">").Replace("&lt;","<").Replace("\n","\r\n");
                sw.WriteLine(text);
                sw.Close();

                Process.Start("file://" + sfd.FileName);
            }
        }
Esempio n. 14
0
 private void CopyTrans(Song from, Song to)
 {
     from.copyTranslation(to);
 }
Esempio n. 15
0
        private string createSongTable(Song song)
        {
            string table = "<ul><table cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"#aaaaaa\" width=\"800\">\n\t\t" +
                "<tr>\n\t\t\t<td width=\"50\" bgcolor=\"dddddd\">\n\t\t\t\t<b>" + song.Number.ToString() +
                "</b>\n\t\t\t</td>\n\t\t\t<td width=\"710\" bgcolor=\"#dddddd\">" + this.cleanText(song.Title, false) +
                "</td>\n\t\t\t<td width=\"20\" bgcolor=\"#dddddd\"><a class=\"top\" href=\"" + this.getBack(this.box, song) +
                "\" target=\"content\">back</a></td>\n\t\t\t" +
                "<td width=\"20\" bgcolor=\"#dddddd\"><a class=\"top\" href=\"" + this.getNext(this.box, song) +
                "\" target=\"content\">next</a></td>\n\t\t</tr>\n\t\t<tr>" +
                "\n\t\t\t<td width=\"800\" style=\"padding:10px;\" colspan=\"4\" bgcolor=\"#f4f4f4\">" +
                this.cleanText(song.Text, this.checkBox1.Checked) + "</td>\n\t\t</tr>\n\t" +
                this.createTransTable(song.GetTransEnum()) + "</table></ul><br />\n\n\t";

            return table;
        }
Esempio n. 16
0
 public TEditor(ListBox lb, Song song, GUI owner)
     : this(lb, song, owner, null)
 {
 }
Esempio n. 17
0
 private static void addSongToHistory(Song song)
 {
     if(songHistory.Contains(song))
     {
         songHistory.Remove(song);
     }
     songHistory.Add(song);
     if(HistoryChanged != null)
     {
         HistoryChanged(null, EventArgs.Empty);
     }
 }
Esempio n. 18
0
 public void refresh(Song song)
 {
     if (this.song != null) this.song.uncheck();
     this.refresh(song, null);
 }
Esempio n. 19
0
 public void refresh(Song song, Translation trans)
 {
     this.song = song;
     this.trans = trans;
     this.refresh();
 }
Esempio n. 20
0
 public static void ShowSong(Song song, GUI owner, ListBox navigate)
 {
     Preview.ClosePreview();
     View.ShowSong(song, null, owner, navigate);
     _this.menuItem1.Visible = true;
 }
Esempio n. 21
0
 public static void ShowSong(Song song, Translation trans, GUI owner, ListBox navigate)
 {
     if(_this == null)
     {
         _this = new View();
     }
     _this.menuItem1.Visible = false;
     _this.owner = owner;
     _this.navigate = navigate;
     _this.menuItem6.Checked = Util.SHOWRIGHT;
     _this.richTextBox1.Font = Util.FONT;
     _this.richTextBox2.Font = Util.FONT;
     if (trans != null)
     {
         _this.refresh(song, trans);
     }
     else
     {
         _this.refresh(song);
     }
     _this.richTextBox1.Focus();
     _this.pos = navigate.Items.IndexOf(_this.song);
     _this.Show();
 }
Esempio n. 22
0
 // next
 private string getNext(ListBox box, Song song)
 {
     int i = (box.Items.IndexOf(song) + 1)%box.Items.Count;
     return ((Song) box.Items[i]).ID + ".html";
 }
Esempio n. 23
0
 private void button12_Click(object sender, System.EventArgs e)
 {
     if (this.transshown)
     {
         this.button10_Click(sender, e);
     }
     this.button12.Enabled = false;
     this.textBox2.Enabled = true;
     this.toDel = this.song;
     this.song = null;
 }
Esempio n. 24
0
        // 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();
        }
Esempio n. 25
0
 /// <summary>
 /// Util
 /// </summary>
 public void AddSong(Song song)
 {
     this.storage.AddSong(song);
 }