Skip to content

Commit

Permalink
Temporarily replace GeckoFX with IE; Embed fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
9vult committed Apr 7, 2020
1 parent b0256ff commit 1163d79
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 148 deletions.
33 changes: 21 additions & 12 deletions MikuReader-WF/Forms/FrmBrowser.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 27 additions & 2 deletions MikuReader-WF/Forms/FrmBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,33 @@ namespace MikuReader.wf.Forms
{
public partial class FrmBrowser : Form
{
// TODO GeckoFX
// GeckoWebBrowser gfxBrowser;
WebBrowser gfxBrowser;

public FrmBrowser()
{
InitializeComponent();
Xpcom.Initialize("Firefox");
Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));

// TODO : GeckoFX
/*
gfxBrowser = new GeckoWebBrowser
{
Dock = DockStyle.Fill
};
panel1.Controls.Add(gfxBrowser);
Xpcom.Initialize("Firefox");
gfxBrowser.DocumentCompleted += Browser_DocumentCompleted;
*/
// TODO : Remove (replace with gfx)
gfxBrowser = new WebBrowser
{
Dock = DockStyle.Fill,
ScriptErrorsSuppressed = true
};
panel1.Controls.Add(gfxBrowser);
gfxBrowser.DocumentCompleted += Browser_DocumentCompleted;
}

Expand Down Expand Up @@ -54,7 +77,9 @@ private void BtnRefresh_Click(object sender, EventArgs e)
try { gfxBrowser.Refresh(); } catch (Exception) { }
}

private void Browser_DocumentCompleted(object sender, GeckoDocumentCompletedEventArgs e)
// TODO : GeckoFx
// private void Browser_DocumentCompleted(object sender, GeckoDocumentCompletedEventArgs e)
private void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (gfxBrowser.Url == null) return;

Expand Down
28 changes: 28 additions & 0 deletions MikuReader-WF/Forms/FrmLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,55 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Drawing.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MikuReader.wf.Forms
{
public partial class FrmLauncher : Form
{
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont,
IntPtr pdv, [System.Runtime.InteropServices.In] ref uint pcFonts);

private PrivateFontCollection fonts = new PrivateFontCollection();

Font bigFont;
Font smallFont;

public FrmLauncher()
{
InitializeComponent();

byte[] fontData = Properties.Resources.Franchise_Bold_hinted;
IntPtr fontPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);
System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
uint dummy = 0;
fonts.AddMemoryFont(fontPtr, Properties.Resources.Franchise_Bold_hinted.Length);
AddFontMemResourceEx(fontPtr, (uint)Properties.Resources.Franchise_Bold_hinted.Length, IntPtr.Zero, ref dummy);
System.Runtime.InteropServices.Marshal.FreeCoTaskMem(fontPtr);

bigFont = new Font(fonts.Families[0], 36.0F);
smallFont = new Font(fonts.Families[0], 20.0F);
}

private void FrmLauncher_Load(object sender, EventArgs e)
{
WFClient.logger.Log("Starting");

// Set embedded fonts
label1.Font = bigFont;
label2.Font = smallFont;


if (Properties.Settings.Default["approot"].ToString() == String.Empty)
{
Properties.Settings.Default["approot"] = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MikuReader2");
Properties.Settings.Default.Save();
}
FileHelper.APP_ROOT = FileHelper.CreateDI(Properties.Settings.Default["approot"].ToString());
Directory.CreateDirectory(FileHelper.APP_ROOT.FullName);

WFClient.logger.Log("Loading from " + FileHelper.APP_ROOT);

Expand Down
8 changes: 7 additions & 1 deletion MikuReader-WF/MikuReader-WF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -26,7 +27,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down Expand Up @@ -169,6 +169,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="Firefox\omni.ja" />
<EmbeddedResource Include="media\files\Franchise-Bold-hinted.ttf" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand Down Expand Up @@ -229,6 +230,11 @@
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Visual.C++.14.0.x86">
<Visible>False</Visible>
<ProductName>Visual C++ "14" Runtime Libraries %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Geckofx45.45.0.34\build\Geckofx45.targets" Condition="Exists('..\packages\Geckofx45.45.0.34\build\Geckofx45.targets')" />
Expand Down
10 changes: 10 additions & 0 deletions MikuReader-WF/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions MikuReader-WF/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Franchise_Bold_hinted" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\files\Franchise-Bold-hinted.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="miku" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\media\images\miku.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Binary file not shown.
Loading

0 comments on commit 1163d79

Please sign in to comment.