Skip to content

Commit

Permalink
fix application width after dpi scaling fix and use skip_list instead…
Browse files Browse the repository at this point in the history
… of a static list.
  • Loading branch information
zefanjajobse committed Sep 22, 2024
1 parent 00ce4c1 commit 44d910e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
35 changes: 12 additions & 23 deletions PlanningCenter to OPS/Actions/LyricsToFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ namespace PlanningCenter_to_OPS.Actions
internal class LyricsToFile
{
private static readonly string[] removed_if_in_line = {
"Vers",
"Vers 1",
"Vers 2",
"Vers 3",
"Vers 4",
"Vers 5",
"Verse",
"Verse 1",
"Verse 2",
"Verse 3",
Expand Down Expand Up @@ -98,38 +100,25 @@ internal static string Lyrics(string lyrics, List<string> skip_list)
string previous_line = "";
foreach (string line in current_lyrics)
{
string mut_line = line;
foreach (var item in remove_text)
{
mut_line = Regex.Replace(mut_line, item, "");
}
// if value not in RemovedText or if added to skip_list
if (!removed_if_in_line.Any(s => line.ToLower().Contains(s.ToLower())) || skip_list.Any(s => s == line))
if (!removed_if_in_line.Any(s => mut_line.ToLower().Contains(s.ToLower())) || skip_list.Any(s => s == mut_line))
{
// replace chorus with ops eqivelant
Dictionary<string, string> translate_to_ops = new Dictionary<string, string>() {
{ "chorus", "Chorus:" },
{ "chorus 1", "Chorus 1:"},
{ "chorus 2", "Chorus 2:"},
{ "chorus 3", "Chorus 3:"},
{ "bridge", "Bridge:" },
{ "bridge 2x", "Bridge 2x:" },
{ "refrein", "Refrein:" },
{ "refrein 1", "Refrein 1:"},
{ "refrein 2", "Refrein 2:"},
{ "refrein 3", "Refrein 3:"},
};

string translated_ops;
if (translate_to_ops.TryGetValue(line.ToLower().Replace(":", ""), out translated_ops))
// Use skiplist to make it a header item when needed
if (skip_list.Contains(mut_line.Trim().ToLower().Replace(":", "") + ":"))
{
cleaned_lyrics += translated_ops + "\r\n";
cleaned_lyrics += mut_line.Trim() + ":\r\n";
}
else
{
byte[] bytes = Encoding.ASCII.GetBytes(ReplaceWordChars(line));
byte[] bytes = Encoding.ASCII.GetBytes(ReplaceWordChars(mut_line));
char[] chars = Encoding.ASCII.GetChars(bytes);
string result = new(chars);
result = result.Replace("?", "");
foreach (var item in remove_text)
{
result = Regex.Replace(result, item, "");
}

// skip the line if current and previous result are both empty
if (!(previous_line == "" && result == ""))
Expand Down
10 changes: 4 additions & 6 deletions PlanningCenter to OPS/SelectSongs.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions PlanningCenter to OPS/SelectSongs.resx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
Expand Down Expand Up @@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
Expand Down

0 comments on commit 44d910e

Please sign in to comment.