From 01393c9f9665fb9675cd53518014121afebe3acc Mon Sep 17 00:00:00 2001 From: dt Date: Sun, 9 Aug 2020 10:31:24 -0700 Subject: [PATCH] Trying to implement assembly resolution --- Babel/Babel.cs | 12 ++++++++++++ Babel/BabelMethods.cs | 4 +++- Babel/Disclaimer.cs | 1 + Babel/Google/GoogleAsync.cs | 6 ++++++ Babel/packages.config | 1 + 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Babel/Babel.cs b/Babel/Babel.cs index 4627ff0..a507f45 100644 --- a/Babel/Babel.cs +++ b/Babel/Babel.cs @@ -8,6 +8,7 @@ using Babel.Google; using System.Windows.Input; using System.Configuration; +//using System.Runtime.Extensions; namespace Babel { @@ -81,12 +82,23 @@ public frmBabel() InitializeComponent(); } + /*private static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) + { + Console.WriteLine("Resolving..."); + return typeof(MyType).Assembly; + }*/ + private void Viewfinder_Load(object sender, EventArgs e) { DebugLog.Log("=============================================="); DebugLog.Log("Babel starting"); LoadSettings(); + //AppDomain currentDomain = AppDomain.CurrentDomain; + + //currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolveEventHandler); + + if (Properties.Settings.Default.WaiverSigned != true) { Disclaimer dc = new Disclaimer(); diff --git a/Babel/BabelMethods.cs b/Babel/BabelMethods.cs index f061f0c..501161f 100644 --- a/Babel/BabelMethods.cs +++ b/Babel/BabelMethods.cs @@ -77,7 +77,9 @@ private string GetText(AsyncOCR OCRResult) .Select(boxenum => boxenum .Select(box => box.text) .Aggregate((l, r) => l + " " + r)); - return myTexts.Aggregate((l, r) => l + Environment.NewLine + r); + // Temporarily disabling newlines until we figure out what's going on with them + //return myTexts.Aggregate((l, r) => l + Environment.NewLine + r); + return myTexts.Aggregate((l, r) => l + " " + r); } else { diff --git a/Babel/Disclaimer.cs b/Babel/Disclaimer.cs index 9ae8780..4960fdb 100644 --- a/Babel/Disclaimer.cs +++ b/Babel/Disclaimer.cs @@ -19,6 +19,7 @@ public Disclaimer() private void button1_Click(object sender, EventArgs e) { + DebugLog.Log("User declined waiver. Exiting."); Application.Exit(); } diff --git a/Babel/Google/GoogleAsync.cs b/Babel/Google/GoogleAsync.cs index 8c849ed..e5366e3 100644 --- a/Babel/Google/GoogleAsync.cs +++ b/Babel/Google/GoogleAsync.cs @@ -139,6 +139,9 @@ private async Task DoOCR() string Identifer = Utility.RandomHex(); DebugLog.Log("Making OCR request [" + Identifer + "]"); + if (!File.Exists(Properties.Settings.Default.apiKeyPath)) + throw new FileNotFoundException("Keyfile not present at " + Properties.Settings.Default.apiKeyPath); + // Wait for rate limiter before starting the clock GoogleAsyncStatic.rate.Check(); Stopwatch sw = new Stopwatch(); @@ -268,6 +271,9 @@ private async Task DoTranslation() string Identifer = Utility.RandomHex(); DebugLog.Log("Making translation request ["+Identifer+"]: " + this.rawText); + if (!File.Exists(Properties.Settings.Default.apiKeyPath)) + throw new FileNotFoundException("Keyfile not present at " + Properties.Settings.Default.apiKeyPath); + // Wait for rate limiter before starting the clock GoogleAsyncStatic.rate.Check(); Stopwatch sw = new Stopwatch(); diff --git a/Babel/packages.config b/Babel/packages.config index b3b3cbd..fb8e6f4 100644 --- a/Babel/packages.config +++ b/Babel/packages.config @@ -20,6 +20,7 @@ + \ No newline at end of file