Skip to content

Commit

Permalink
Merge pull request #6 from sabdelmalik/BibleTaggingUtil_5.2.0
Browse files Browse the repository at this point in the history
Bible tagging util 5.2.0
  • Loading branch information
sabdelmalik authored Jan 23, 2024
2 parents ce9dc62 + c219218 commit e6a2557
Show file tree
Hide file tree
Showing 35 changed files with 2,994 additions and 179 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Bibles/
BibleModuleDev/
!.gitignore
src/BibleTaggingUtil/ReferenceBibles/NIV/01.NIV11-NT-Strong.txt
src/BibleTaggingUtil/ReferenceBibles/NASB2020/1.osis.xml
src/BibleTaggingUtil/ReferenceBibles/NIV/1.NIV11-NT-Strong.txt
4 changes: 3 additions & 1 deletion src/BibleTaggingUtil/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ private void OpenBrowser(string link)
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}

}
Expand Down
3 changes: 3 additions & 0 deletions src/BibleTaggingUtil/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<setting name="PeriodicSaveTime" serializeAs="String">
<value>0</value>
</setting>
<setting name="Osis" serializeAs="String">
<value>False</value>
</setting>
</BibleTaggingUtil.Properties.Settings>
<BibleTagging.Properties.Settings>
<setting name="ReferenceBibleFileName" serializeAs="String">
Expand Down
155 changes: 118 additions & 37 deletions src/BibleTaggingUtil/BibleTaggingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

using BibleTaggingUtil.Editor;
using SM.Bible.Formats.USFM;
using SM.Bible.Formats.OSIS;
using SM.Bible.Formats.USFM2OSIS;
using System.Reflection;

using BibleTaggingUtil.BibleVersions;
Expand All @@ -35,12 +35,14 @@ public partial class BibleTaggingForm : Form
private ProgressForm progressForm;

private TargetVersion target;
private ReferenceVersionKJV referenceKJV;
private TargetOsisVersion osisTarget;
private ReferenceTopVersion referenceTopVersion;
private ReferenceVersionTOTHT referenceTOTHT;
private ReferenceVersionTAGNT referenceTAGNT;

private string execFolder = string.Empty;
private string kjvPath = string.Empty;
private string refFolder = string.Empty;
private string topReferencePath = string.Empty;
private string tagntPath = string.Empty;
private string tothtPath = string.Empty;
private string crosswirePath = string.Empty;
Expand Down Expand Up @@ -78,7 +80,8 @@ public BibleTaggingForm()
#endif

target = new TargetVersion(this);
referenceKJV = new ReferenceVersionKJV(this);
osisTarget = new TargetOsisVersion(this);
referenceTopVersion = new ReferenceTopVersion(this);
referenceTOTHT = new ReferenceVersionTOTHT(this);
referenceTAGNT = new ReferenceVersionTAGNT(this);
}
Expand Down Expand Up @@ -160,15 +163,13 @@ private void BibleTaggingForm_Load(object sender, EventArgs e)
Tracing.InitialiseTrace(execFolder);

crosswirePath = Path.Combine(execFolder, "Crosswire");
string refFolder = Path.Combine(execFolder, "ReferenceBibles");
if(workingOnNIV)
kjvPath = Path.Combine(refFolder, "NIV");
else
kjvPath = Path.Combine(refFolder, "KJV");
refFolder = Path.Combine(execFolder, "ReferenceBibles");

tagntPath = Path.Combine(refFolder, "TAGNT");
tothtPath = Path.Combine(refFolder, "TOTHT");

editorPanel.TargetVersion = target;
editorPanel.TargetOsisVersion = osisTarget;

new Thread(() => { LoadBibles(); }).Start();
}
Expand Down Expand Up @@ -222,7 +223,9 @@ private void BibleTaggingForm_Closing(object sender, System.ComponentModel.Cance
}
catch(Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}

Expand Down Expand Up @@ -269,12 +272,7 @@ private void LoadBibles()
}
}

editorPanel.TargetBibleName(Path.GetFileName(biblesFolder));
target.BibleName = Path.GetFileName(biblesFolder);
referenceKJV.BibleName = "KJV";
referenceTAGNT.BibleName = "TAGNT";
referenceTOTHT.BibleName = "TOTHT";

// Load configuration
config = new ConfigurationHolder();
string confResult = config.ReadBiblesConfig(biblesFolder);
if (!string.IsNullOrEmpty(confResult))
Expand Down Expand Up @@ -319,18 +317,63 @@ private void LoadBibles()
break;
}
}
if (string.IsNullOrEmpty(config.TopReferenceVersion))
{
topReferencePath = Path.Combine(refFolder, "KJV");
}
else
{
topReferencePath = Path.Combine(refFolder, config.TopReferenceVersion);
if (!Directory.Exists(topReferencePath))
{
topReferencePath = Path.Combine(refFolder, "KJV");
}
}



editorPanel.TargetBibleName(Path.GetFileName(biblesFolder));
target.BibleName = Path.GetFileName(biblesFolder);
osisTarget.BibleName = Path.GetFileName(biblesFolder);
string refBibleName = Path.GetFileName(topReferencePath);
referenceTopVersion.BibleName = refBibleName;
editorPanel.TopReferenceBibleName(refBibleName);

referenceTAGNT.BibleName = "TAGNT";
referenceTOTHT.BibleName = "TOTHT";


}
catch(Exception ex)
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}

WaitCursorControl(true);

string[] files = Directory.GetFiles(taggedFolder);
if (files.Length > 0)
{
target.LoadBibleFile(files[0], true, false);
string ext = Path.GetExtension(files[0]);
Properties.Settings.Default.Osis = false;
// if (Properties.Settings.Default.Osis)
if (ext.ToLower() == ".xml")
{
Properties.Settings.Default.Osis = true;

generateOSISToolStripMenuItem.Visible = false;
usfmToolStripMenuItem.Visible = false;
oSISToolStripMenuItem.Visible = true;
generateSWORDFilesToolStripMenuItem.Visible = false;
saveHebrewToolStripMenuItem.Visible = false;
saveKJVPlainToolStripMenuItem.Visible = false;

osisTarget.LoadBibleFile(files[0], true, false);
}
else
target.LoadBibleFile(files[0], true, false);
VerseSelectionPanel.SetBookCount(target.BookCount);
}
else
Expand Down Expand Up @@ -360,19 +403,19 @@ private void LoadBibles()
this.Closing -= BibleTaggingForm_Closing;
this.Closing += BibleTaggingForm_Closing;

if (!LoadReferenceFiles(kjvPath, referenceKJV)) { CloseForm(); return; }
if (!LoadReferenceFiles(topReferencePath, referenceTopVersion)) { CloseForm(); return; }
if (!LoadReferenceFiles(tothtPath, referenceTOTHT)) { CloseForm(); return; }
if (!LoadReferenceFiles(tagntPath, referenceTAGNT)) { CloseForm(); return; }


/* bool result = false;
files = Directory.GetFiles(kjvPath);
files = Directory.GetFiles(topReferencePath);
for (int i = 0; i < files.Length; i++)
{
result = referenceKJV.LoadBibleFile(files[i], i == 0, i != (files.Length - 1));
result = referenceTopVersion.LoadBibleFile(files[i], i == 0, i != (files.Length - 1));
}
// referenceKJV.LoadBibleFile(config.KJV, true, false);
// referenceTopVersion.LoadBibleFile(config.KJV, true, false);
StartGui();
Expand Down Expand Up @@ -560,7 +603,8 @@ private DialogResult ShowMessageBox(string text, string caption, MessageBoxButto
public EditorPanel EditorPanel { get { return editorPanel; } }
public VerseSelectionPanel VerseSelectionPanel { get { return verseSelectionPanel; } }
public TargetVersion Target { get { return target; } }
public ReferenceVersionKJV KJV { get {return referenceKJV; } }
public TargetOsisVersion OsisTarget { get { return osisTarget; } }
public ReferenceTopVersion TopVersion { get {return referenceTopVersion; } }
public ReferenceVersionTOTHT TOTHT { get { return referenceTOTHT; } }
public ReferenceVersionTAGNT TAGNT { get { return referenceTAGNT; } }

Expand Down Expand Up @@ -780,24 +824,28 @@ private void saveKJVPlainToolStripMenuItem_Click(object sender, EventArgs e)
for (int verse = 1; verse <= lastVerse; verse++)
{
string verseRef = string.Format("{0:s} {1:d}:{2:d}", bookName, chapter + 1, verse);
if (referenceKJV.Bible.ContainsKey(verseRef))
if (referenceTopVersion.Bible.ContainsKey(verseRef))
{
string line = string.Format("{0:s} {1:s}", verseRef, Utils.GetVerseText(referenceKJV.Bible[verseRef], false));
string line = string.Format("{0:s} {1:s}", verseRef, Utils.GetVerseText(referenceTopVersion.Bible[verseRef], false));
outputFile.WriteLine(line);
}
}
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}
}
}
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}

Expand Down Expand Up @@ -887,7 +935,9 @@ private string[] GetHebrewLine(Verse verseWords)
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
return lines;
}
Expand Down Expand Up @@ -943,7 +993,9 @@ private void saveHebrewToolStripMenuItem_Click(object sender, EventArgs e)
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}
}
Expand All @@ -953,7 +1005,9 @@ private void saveHebrewToolStripMenuItem_Click(object sender, EventArgs e)
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}

Expand Down Expand Up @@ -981,7 +1035,9 @@ public void FindVerse (string tag)
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}

if ((string.IsNullOrEmpty(tag) || tag.ToLower() == "<blank>"))
Expand All @@ -1002,7 +1058,9 @@ public void FindVerse (string tag)
}
catch(Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}

Expand Down Expand Up @@ -1043,13 +1101,17 @@ public void FindRepetitive()
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
}

Expand Down Expand Up @@ -1084,6 +1146,16 @@ private void generateOSISToolStripMenuItem_Click(object sender, EventArgs e)
private void generateSWORDFilesOsisToolStripMenuItem_Click(object sender, EventArgs e)
{
target.SaveUpdates();

if (Properties.Settings.Default.Osis)
{
// copy last changes to the output xml
string taggedFolder = Path.Combine(Properties.Settings.Default.BiblesFolder, "tagged");
string LastChanged = Directory.GetFiles(taggedFolder)[0];
string outputXml = Path.Combine(Properties.Settings.Default.BiblesFolder, config.OSIS[OsisConstants.output_file]);
System.IO.File.Copy(LastChanged, outputXml, true);
}

new Thread(
() =>
{
Expand Down Expand Up @@ -1190,7 +1262,9 @@ private void RunOsis2mod(string sourceFileName, string targetFolderName)
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name, ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}


Expand Down Expand Up @@ -1256,7 +1330,9 @@ private void RunOsis2mod(string sourceFileName, string targetFolderName)
}
catch (Exception ex)
{
Tracing.TraceException(MethodBase.GetCurrentMethod().Name + ": Executing osis2mod", ex.Message);
var cm = System.Reflection.MethodBase.GetCurrentMethod();
var name = cm.DeclaringType.FullName + "." + cm.Name;
Tracing.TraceException(name, ex.Message);
}
finally
{
Expand Down Expand Up @@ -1297,5 +1373,10 @@ private void reloadTargetToolStripMenuItem_Click(object sender, EventArgs e)

}
}

internal void EnableSaveButton(bool v)
{
editorPanel.EnableSaveButton(v);
}
}
}
6 changes: 5 additions & 1 deletion src/BibleTaggingUtil/BibleTaggingUtil.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Copyright>Copyright © 2023 by Sami Abdel Malik</Copyright>
<RepositoryUrl>https://github.com/sabdelmalik/BibleTagging</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>4.4.0.0</Version>
<Version>5.2.0.0</Version>
<Title>Bible Text Tagging with Strong's Numbers</Title>
<BaseOutputPath></BaseOutputPath>
</PropertyGroup>
Expand All @@ -26,6 +26,10 @@
<Optimize>True</Optimize>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Editor\OsisTargetGridView.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1370.28" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/BibleTaggingUtil/BibleTaggingUtil.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Compile Update="Editor\HebrewGreekGrid.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="Editor\KJVGridView.cs">
<Compile Update="Editor\TopVersionGridView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="Editor\TargetGridView.cs">
Expand Down
Loading

0 comments on commit e6a2557

Please sign in to comment.