Пример #1
0
 public static string MakeTemplate(string tpl, SongData song)
 {
     tpl = tpl.Replace("$[TITLE]", song.Title);
     tpl = tpl.Replace("$[AUTHOR]", song.Author);
     tpl = tpl.Replace("$[GROUP]", song.GroupName);
     tpl = tpl.Replace("$[REMARK]", song.Remark);
     return MakeTemplate(tpl);
 }
Пример #2
0
 public void UpdateSongByNetID(SongData song)
 {
     int index = FindNetIdIndex(song.NetID);
     if (index >= 0)
     {
         Songs[index] = song.Clone();
     }
 }
Пример #3
0
 public static int CompareTitleGroup(SongData a, SongData b)
 {
     int rt = String.Compare(a.Title, b.Title, true);
     if (rt != 0) return rt;
     int rg = String.Compare(a.GroupName, b.GroupName, true);
     if (rg != 0) return rg;
     return a.LocalID - b.LocalID;
 }
Пример #4
0
        //public static void CopySong(InetSongDb.songRow src, SongDb.songRow dst)
        //{
        //    dst.title = src.title;
        //    dst.groupname = src.groupname;
        //    dst.author = src.author;
        //    dst.songtext = src.songtext;
        //    dst.lang = src.lang;
        //    dst.remark = src.remark;
        //    //dst.netID = src.ID;
        //}
        //public static void CopySong(SongDb.songRow src, InetSongDb.songRow dst)
        //{
        //    dst.title = src.title;
        //    dst.groupname = src.groupname;
        //    dst.author = src.author;
        //    dst.songtext = src.songtext;
        //    dst.lang = src.lang;
        //    dst.remark = src.remark;
        //    //dst.ID = src.netID;
        //}


        //public static void AddSongRow(SongDb.songRow src, SongDatabase db)
        //{
        //    //SongDb.songRow dst = db.DataSet.song.NewsongRow();
        //    //CopySong(src, dst);
        //    //if (!src.IstranspNull()) dst.transp = src.transp;
        //    //db.DataSet.song.AddsongRow(dst);
        //}

        public static void CopySong(SongData src, SongData dst)
        {
            //dst.Title = src.Title;
            //dst.GroupName = src.GroupName;
            //dst.Author = src.Author;
            //dst.SongText = src.SongText;
            //dst.Lang = src.Lang;
            //dst.Remark = src.Remark;
        }
Пример #5
0
        protected override void DumpSongBegin(SongData song, TextWriter fw)
        {
            RtfTools.SetFont(fw, Fonts.TitleFont, 4);
            fw.Write(song.Title);
            fw.Write("\\par ");

            RtfTools.SetFont(fw, Fonts.AuthorFont, 5);
            fw.Write(song.Author != "" ? song.Author : song.GroupName);
            fw.Write("\\par ");
        }
Пример #6
0
 public static void ShowSong(SongData song)
 {
     if (Instance == null)
     {
         Instance = new ViewSongForm();
     }
     Instance.Song = song;
     Instance.Show();
     Instance.BringToFront();
 }
Пример #7
0
 public static void Print(SongData song, string filename)
 {
     PdfDocument doc = new PdfDocument();
     PdfPage page = doc.AddPage();
     LogPages pages = SongPrinter.FormatSongForPrinting(song, PageSizeConverter.ToSize(page.Size).Width, PdfPrintTarget.InfoContext, PageSizeConverter.ToSize(page.Size).Height, PdfPrintTarget.getmmky());
     foreach (LogPage lp in pages.Pages)
     {
         lp.DrawPage(XGraphics.FromPdfPage(page), new PointF(0, 0), null);
         if (pages.LastPage != lp) page = doc.AddPage();
     }
     doc.Save(filename);
 }
Пример #8
0
 public static void AddSongRow(SongData src, InetSongDb db)
 {
     //InetSongDb.songRow dst = db.song.NewsongRow();
     //CopySong(src, dst);
     //dst.title = src.title;
     //dst.groupname = src.groupname;
     //dst.author = src.author;
     //dst.songtext = src.songtext;
     //dst.lang = src.lang;
     //dst.remark = src.remark;
     //db.song.AddsongRow(dst);
 }
Пример #9
0
        public static LogPages FormatSongForPrinting(SongData song, float pgwi, XGraphics infoContext, float pghi, float mmky)
        {
            //PrinterPrintTarget target=new PrinterPrintTarget(
            SongPrintFormatOptions opt = CfgTools.CreateSongPrintFormatOptions(pgwi, infoContext, mmky);
            SongFormatter fmt = new SongFormatter(song.SongText, opt.SongOptions);
            fmt.Run();
            PaneGrp grp = fmt.Result;
            grp.Insert(new SongHeaderPane(opt, song.Title, song.Author != "" ? song.Author : song.GroupName));

            LogPages pages = new LogPages(pghi);
            pages.AddPaneGrp(grp);
            return pages;
        }
Пример #10
0
 public void Load(XmlReader reader)
 {
     Songs.Clear();
     XmlDocument doc = new XmlDocument();
     XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
     nsmgr.AddNamespace("ns", XMLNS);
     doc.Load(reader);
     foreach (XmlElement xsong in doc.SelectNodes("/ns:InetSongDb/ns:song", nsmgr))
     {
         SongData song = new SongData();
         song.Load(xsong);
         Songs.Add(song);
         if (!String.IsNullOrEmpty(song.NetID) && Int32.Parse(song.NetID) > m_lastNetId)
         {
             m_lastNetId = Int32.Parse(song.NetID);
         }
     }
 }
Пример #11
0
        public static IEnumerable<SongData> LoadSongs(this SongDatabase db, string[] extracols, string joins, string conds)
        {
            if (extracols == null) extracols = new string[] { };
            if (conds == null) conds = "1=1";
            if (joins == null) joins = "";
            var res = new Dictionary<int, SongData>();
            string query = "select song.id,";
            foreach (string ec in extracols) query += ec + ",";
            using (var reader = db.ExecuteReader(query + String.Join(",", (from s in SONG_DATA_COLUMNS select "song." + s).ToArray()) + " from song "
                + joins.Replace("#SONGID#", "song.id") + " where " + conds.Replace("#SONGID#", "song.id")))
            {
                while (reader.Read())
                {
                    SongData song = new SongData();
                    LoadSongDataColumns(song, reader, 1 + extracols.Length);
                    if (extracols.Length > 0 && extracols[0].Contains("transp"))
                    {
                        if (!reader.IsDBNull(1)) song.Transp = reader.SafeInt(1);
                    }
                    song.LocalID = reader.SafeInt(0);
                    res[song.LocalID] = song;
                }
            }
            using (var reader = db.ExecuteReader("select songdata.song_id,songdata.datatype_id,songdata.label,songdata.textdata from songdata "
                + " inner join song on song.id = songdata.song_id "
                + joins.Replace("#SONGID#", "songdata.song_id") + " where " + conds.Replace("#SONGID#", "songdata.song_id")))
            {
                while (reader.Read())
                {
                    SongData song = res[reader.SafeInt(0)];
                    song.Items.Add(new SongDataItem
                    {
                        DataType = (SongDataType)reader.SafeInt(1),
                        Label = reader.SafeString(2),
                        TextData = reader.SafeString(3)
                    });
                }
            }
            return res.Values;

        }
Пример #12
0
 public EditSongForm(SongDatabase db, SongData song)
 {
     InitializeComponent();
     m_db = db;
     m_song = song;
     tbtitle.Text = m_song.Title;
     tbauthor.Text = m_song.Author;
     tbgroup.Text = m_song.GroupName;
     tbtext.Text = (m_song.SongText ?? "").Replace("\r", "").Replace("\n", "\r\n");
     tbremark.Text = m_song.Remark;
     //tblink_1.Text = m_song.Link_1;
     //tblink_2.Text = m_song.Link_2;
     songView1.SongText = m_song.OrigText;
     lbxLinks.Items.Clear();
     foreach (var data in m_song.GetData(SongDataType.Link))
     {
         lbxLinks.Items.Add(data.TextData);
     }
     cbxServer.Database = m_db;
     object o = m_db.ExecuteScalar("select server_id from song where id=@id", "id", m_song.LocalID);
     if (o == DBNull.Value) cbxServer.ServerID = null;
     else cbxServer.ServerID = Int32.Parse(o.ToString());
 }
Пример #13
0
 public void SaveSong(SongData song, int ?serverid)
 {
     if (song.LocalID == 0)
     {
         InsertSong(song, serverid, true);
     }
     else
     {
         UpdateSong(song, serverid);
     }
 }
Пример #14
0
 private void SetSong(SongData song)
 {
     m_song = song;
     SetText(song != null ? song.OrigText : null);
     //button1.Enabled = song != null ? song.Link_1 != "" : false;
     //button2.Enabled = song != null ? song.Link_2 != "" : false;
 }
Пример #15
0
        public PaneGrp FormatSong(SongData song)
        {
            if (m_formatted.ContainsKey(song.LocalID)) return m_formatted[song.LocalID];

            SongFormatter fmt = new SongFormatter(song.SongText, SongFormatOptions);
            fmt.Run();
            PaneGrp grp = fmt.Result;
            grp.Insert(new SongHeaderPane(BookFormatOptions, song.Title, song.Author));
            grp.Add(new SongSeparatorPane(BookFormatOptions));
            m_formatted[song.LocalID] = grp;

            return m_formatted[song.LocalID];
        }
Пример #16
0
 public void AddSongWithNewNetID(SongData song)
 {
     m_lastNetId += 1;
     song.NetID = m_lastNetId.ToString();
     Songs.Add(song.Clone());
 }
Пример #17
0
 protected virtual void DumpSongEnd(SongData song, TextWriter fw) { }
Пример #18
0
 protected override void DumpSongBegin(SongData song, TextWriter fw)
 {
     fw.Write(MakeTemplate(m_songHeader, song));
 }
Пример #19
0
 private static string MakeTemplate(string tpl, SongData song)
 {
     return Templates.MakeTemplate(tpl, song);
 }
 private string MakeTemplate(string tpl, SongData song, DirectorySongHolder dsh)
 {
     tpl = tpl.Replace("$[SONGINDEX]", dsh.SongIndexes[song].ToString());
     tpl = Templates.MakeTemplate(tpl, song);
     tpl = MakeTemplate(tpl, dsh.SongGroups[song]);
     return tpl;
 }
Пример #21
0
 protected override void DumpSongEnd(SongData song, TextWriter fw)
 {
     fw.Write(MakeTemplate(m_songFooter, song));
 }
Пример #22
0
 public SongPrinter(SongData song, PrinterSettings settings)
 {
     m_song = song;
     m_settings = settings;
     m_target = new PrinterPrintTarget(m_settings);
 }
Пример #23
0
 private static void AnalyseSongHeaderLines(List<string> songlines, SongData song)
 {
     if (songlines.Count == 0) return;
     string line0 = songlines[0];
     if (line0.IndexOf(" - ") >= 0)
     {
         int i = line0.IndexOf(" - ");
         song.Title = line0.Substring(0, i).Trim();
         song.Author = line0.Substring(i + 3).Trim();
         songlines.RemoveAt(0);
     }
     else if (line0.IndexOf("    ") >= 0)
     {
         int i = line0.IndexOf("    ");
         song.Title = line0.Substring(0, i).Trim();
         song.Author = line0.Substring(i + 4).Trim();
         songlines.RemoveAt(0);
     }
     else
     {
         song.Title = line0.Trim();
         songlines.RemoveAt(0);
         if (songlines.Count == 0) return;
         line0 = songlines[0];
         if (line0 == "")
         {
             songlines.RemoveAt(0);
             return;
         }
         if (LooksLikeTextLine(line0)) return;
         song.Author = line0.Trim();
         songlines.RemoveAt(0);
     }
 }
Пример #24
0
 private void InsertSong(SongData song, int? serverid, bool localmodified)
 {
     InsertSong(null, song, serverid, localmodified);
 }
Пример #25
0
 private void UpdateSong(SongData song, int ?serverid)
 {
     ExecuteNonQuery("delete from songdata where song_id=@id", "id", song.LocalID);
     foreach (var item in song.Items)
     {
         InsertSongItem(song.LocalID, item);
     }
     ExecuteNonQuery(@"update song set title=@title, groupname=@groupname, author=@author, lang=@lang, 
                     server_id=@server, netID=@netid, transp=@transp, remark=@remark, published=@published, localmodified=1
                     where id=@id",
                     "title", song.Title, "groupname", song.GroupName, "author", song.Author, "lang", song.Lang,
                     "server", serverid, "netid", song.NetID, "transp", song.Transp, "remark", song.Remark, 
                     "published", song.Published, "id", song.LocalID);
 }
Пример #26
0
 private static void LoadSongDataColumns(SongData song, DbDataReader reader, int ofs)
 {
     song.Title = reader.SafeString(ofs + 0);
     song.GroupName = reader.SafeString(ofs + 1);
     song.Author = reader.SafeString(ofs + 2);
     song.Lang = reader.SafeString(ofs + 3);
     song.NetID = reader.SafeString(ofs + 4);
     song.Transp = reader.SafeInt(ofs + 5);
     song.Remark = reader.SafeString(ofs + 6);
 }
Пример #27
0
 private void InsertSong(SQLiteTransaction tran, SongData song, int? serverid, bool localmodified)
 {
     ExecuteNonQuery(tran, @"insert into song (title, groupname, author, lang, server_id, netID, transp, remark, published, localmodified)
                      values
                      (@title, @groupname, @author, @lang, @server, @netid, @transp, @remark, @published, @localmodified)",
                     "title", song.Title, "groupname", song.GroupName, "author", song.Author, "lang", song.Lang,
                     "server", serverid, "netid", song.NetID, "transp", song.Transp, "remark", song.Remark,
                     "published", song.Published, "localmodified", localmodified);
     song.LocalID = LastInsertId();
     foreach (var item in song.Items)
     {
         InsertSongItem(tran, song.LocalID, item);
     }
 }
Пример #28
0
 public static bool Run(SongDatabase db, SongData song)
 {
     EditSongForm win = new EditSongForm(db, song);
     return win.ShowDialog() == DialogResult.OK;
 }
Пример #29
0
 private void ProcessPublishSong(SQLiteTransaction tran, InetSongDb xmldb, SongData song, IWaitDialog dlg)
 {
     if (song.NetID != null)
     {
         xmldb.UpdateSongByNetID(song);
         ExecuteNonQuery("update song set published=@published, localmodified=0 where id=@id",
             "published", DateTime.UtcNow, "id", song.LocalID);
     }
     else
     {
         xmldb.AddSongWithNewNetID(song);
         ExecuteNonQuery("update song set published=@published, localmodified=0, netID=@netid where id=@id",
             "published", DateTime.UtcNow, "id", song.LocalID, "netid", song.NetID);
     }
     dlg.Message(String.Format("Publikuji píseò {0}, netID={1}", song.Title, song.NetID));
 }
Пример #30
0
 protected override void DumpSongBegin(SongData song, TextWriter fw)
 {
     fw.WriteLine(song.Title);
     fw.WriteLine(song.Author != "" ? song.Author : song.GroupName);
 }