mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-01 17:34:10 +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.Handling;
|
||||||
using TweetDick.Core.Other;
|
using TweetDick.Core.Other;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using TweetDick.Resources;
|
||||||
|
|
||||||
namespace TweetDick.Core{
|
namespace TweetDick.Core{
|
||||||
partial class FormBrowser : Form{
|
partial class FormBrowser : Form{
|
||||||
@ -82,13 +83,7 @@ private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEvent
|
|||||||
|
|
||||||
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||||
if (e.Frame.IsMain){
|
if (e.Frame.IsMain){
|
||||||
string js = null;
|
string js = ScriptLoader.LoadResource("code.js");
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (js != null){
|
if (js != null){
|
||||||
browser.ExecuteScriptAsync(js);
|
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>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Resources\ScriptLoader.cs" />
|
||||||
<None Include="Configuration\app.config" />
|
<None Include="Configuration\app.config" />
|
||||||
<None Include="Configuration\packages.config" />
|
<None Include="Configuration\packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user