Visual Basic for Applications to C#
Needs some help from the coders.
I'm currently using this code in Visual Basic for Applications to copy/paste the selected reference:
Sub CopyBibleVerses()
Dim launcher As LogosLauncher
Dim app As LogosApplication
Dim cbv As LogosCopyBibleVerses
Dim req As LogosCopyBibleVersesRequest
Dim LogosRef As String
LogosRef = Selection.Text
Set launcher = New LogosLauncher
Set app = launcher.Application
Set cbv = app.CopyBibleVerses
Set req = cbv.CreateRequest
req.Reference = app.DataTypes.GetDataType("bible").ParseReference(LogosRef)
Selection.TypeText Text:=cbv.GetText(req)
End Sub
I need help converting that into C#
Can anyone help with that?
This works to launch:
using Logos4Lib;
LogosLauncher launcher = new LogosLauncher();
launcher.LaunchApplication();
LogosApplication app = launcher.Application;
But I have no idea to enable fetching the bible verse in C# using DataType etc.
Comments
-
Weekly bump for attention 9
Orthodox Bishop Alfeyev: "To be a theologian means to have experience of a personal encounter with God through prayer and worship."; Orthodox proverb: "We know where the Church is, we do not know where it is not."
0 -
Here's one solution that can be used as a template. Code is attached to a form button.
using Logos4Lib;
using System;
using System.Windows.Forms;
namespace CopyBibleVerse
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{ }
private void button1_Click(object sender, EventArgs e)
{
LogosLauncher launcher = new LogosLauncher();
LogosApplication app = launcher.Application;
LogosCopyBibleVerses cbv = app.CopyBibleVerses;
LogosCopyBibleVersesRequest req = cbv.CreateRequest();
var CopiedReference = Clipboard.GetText();
req.Reference = app.DataTypes.GetDataType("bible").ParseReference(CopiedReference);
String message = cbv.GetText(req);
//var result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (message != null) Clipboard.SetText(message);
//var text = Clipboard.GetText(TextDataFormat.Html);
}
}
}Code can be improved, but here are the basics: highlight a Bible Reference in any application. Click on the C# form button that has the code, and then paste the Bible verse into the document.
0