mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-23 12:15:48 +02:00
Move code.js loading to ScriptLoader
This commit is contained in:
parent
69dcfe17a7
commit
cf58ac5665
@ -9,6 +9,7 @@
|
||||
using TweetDick.Core.Handling;
|
||||
using TweetDick.Core.Other;
|
||||
using System.Drawing;
|
||||
using TweetDick.Resources;
|
||||
|
||||
namespace TweetDick.Core{
|
||||
partial class FormBrowser : Form{
|
||||
@ -82,13 +83,7 @@ private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEvent
|
||||
|
||||
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
if (e.Frame.IsMain){
|
||||
string js = null;
|
||||
|
||||
try{
|
||||
js = File.ReadAllText("code.js",Encoding.UTF8);
|
||||
}catch(Exception ex){
|
||||
MessageBox.Show("Unfortunately, TweetDick could not load the code.js file. The program will continue running with limited functionality.\r\n\r\n"+ex.Message,"TweetDick Has Failed :(",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||
}
|
||||
string js = ScriptLoader.LoadResource("code.js");
|
||||
|
||||
if (js != null){
|
||||
browser.ExecuteScriptAsync(js);
|
||||
|
17
Resources/ScriptLoader.cs
Normal file
17
Resources/ScriptLoader.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDick.Resources{
|
||||
static class ScriptLoader{
|
||||
public static string LoadResource(string name){
|
||||
try{
|
||||
return File.ReadAllText(name,Encoding.UTF8);
|
||||
}catch(Exception ex){
|
||||
MessageBox.Show("Unfortunately, TweetDick could not load the "+name+" file. The program will continue running with limited functionality.\r\n\r\n"+ex.Message,"TweetDick Has Failed :(",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -145,6 +145,7 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Resources\ScriptLoader.cs" />
|
||||
<None Include="Configuration\app.config" />
|
||||
<None Include="Configuration\packages.config" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user