Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	ChehueWPF/ChehueWPF.csproj
#	ChehueWPF/MainWindow.xaml
#	ChehueWPF/MainWindow.xaml.cs
#	UpgradeLog2.htm
#	作夥直排/Chehue.csproj
  • Loading branch information
SODAISpod committed Apr 13, 2023
2 parents 0555c91 + 8045443 commit 500eeb4
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 25 deletions.
17 changes: 17 additions & 0 deletions ChehueWPF/ChehueWPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,23 @@
<HintPath>..\packages\ModernWpfUI.0.9.4\lib\net462\ModernWpf.Controls.dll</HintPath>
</Reference>
<Reference Include="netstandard" />
<<<<<<< HEAD
<Reference Include="NLog">
<HintPath>..\..\..\Downloads\Release (2)\Release\NLog.dll</HintPath>
=======
<Reference Include="NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.5.1.1\lib\net46\NLog.dll</HintPath>
>>>>>>> dev
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<<<<<<< HEAD
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
=======
<Reference Include="System.IO.Compression" />
>>>>>>> dev
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -124,7 +134,14 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<<<<<<< HEAD
<None Include="Resources\Replacement_Image.bmp" />
=======
<ProjectReference Include="..\作夥直排\Chehue.csproj">
<Project>{16268030-1DF7-48FD-BA3D-D0CE9DBF5F15}</Project>
<Name>Chehue</Name>
</ProjectReference>
>>>>>>> dev
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
24 changes: 23 additions & 1 deletion ChehueWPF/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ChoHoe"
mc:Ignorable="d"
<<<<<<< HEAD
Title="MainWindow" Height="680" Width="800"
xmlns:ui="http://schemas.modernwpf.com/2019"
ui:WindowHelper.UseModernWindowStyle="True">
Expand Down Expand Up @@ -46,14 +47,35 @@
<ui:ToggleSwitch Margin="10,351,0,0" VerticalAlignment="Top"/>
<Button Content="開啟" Margin="10,422,0,0" VerticalAlignment="Top" Width="69"/>
<Button Content="轉檔" Margin="84,422,0,0" VerticalAlignment="Top" Width="69"/>
=======
Title="MainWindow" Height="543.667" Width="800">
<StackPanel Orientation="Horizontal" Margin="8,0,0,0">
<Border BorderBrush="Black" BorderThickness="1" Width="541" Height="513" CornerRadius="15,15,15,15">
<DataGrid ItemsSource="{Binding Source=tests}" Margin="0,-1,0,0" Padding="0,17,0,0">
<DataGrid.Columns>
<DataGridTextColumn Header="書名" Binding="{Binding ff}" />
</DataGrid.Columns>
</DataGrid>
</Border>
<Border BorderBrush="Black" BorderThickness="1" Width="233" Height="514" Margin="7,0,0,0" CornerRadius="15,15,15,15"/>
</StackPanel>

<!--xmlns:ui="http://schemas.modernwpf.com/2019"
ui:WindowHelper.UseModernWindowStyle="True"-->

</Grid>

>>>>>>> dev


<<<<<<< HEAD
</ScrollViewer>
</Border>

<ui:VisualStateGroupListener HorizontalAlignment="Left" Height="116" Margin="-254,182,0,0" VerticalAlignment="Top" Width="1204"/>

</Grid>

=======

>>>>>>> dev
</Window>
22 changes: 21 additions & 1 deletion ChehueWPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ChoHoeBV;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -21,17 +22,36 @@ namespace ChoHoe
/// </summary>
public partial class MainWindow : Window
{
<<<<<<< HEAD


public MainWindow()
{
InitializeComponent();

=======
Book theBook = new Book();
List<Book> books = new List<Book>();
List<test> tests= new List<test>();

public MainWindow()
{
InitializeComponent();
test fd= new test();
tests.Add(fd);
test qw2= new test();
tests.Add(qw2);
>>>>>>> dev
}

private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

}
class test
{
string ff = "11";
string ff2 = "22";
}
}
}
1 change: 1 addition & 0 deletions ChehueWPF/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<package id="Ionic.Zip" version="1.9.1.8" targetFramework="net48" />
<package id="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" targetFramework="net48" />
<package id="ModernWpfUI" version="0.9.4" targetFramework="net48" />
<package id="NLog" version="5.1.1" targetFramework="net48" />
<package id="System.Runtime.WindowsRuntime" version="4.6.0" targetFramework="net48" />
<package id="System.Runtime.WindowsRuntime.UI.Xaml" version="4.6.0" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
Expand Down
4 changes: 2 additions & 2 deletions 作夥直排/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ChoHoe.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="ChoHoe.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
<section name="作夥直排.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<userSettings>
<ChoHoe.Properties.Settings>
Expand Down
77 changes: 69 additions & 8 deletions 作夥直排/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ private LoadResult LoadAsEpub(string _path)
Uncompressing(_path, _uncompressedPath);
Mimetype();
Container(_containerXML);
if (OpfReader() == OpfReadResult.epunNeedPandocFor2to3)
OpfReadResult result = OpfReader();
if (result == OpfReadResult.pandocConvertError)
{
Logger.logger.Fatal($"Pandoc filed to process: {_originalFilePath}");
}
if (result == OpfReadResult.epunNeedPandocFor2to3 || result == OpfReadResult.pandocConvertError )
{
return LoadResult.fail;
}
Expand Down Expand Up @@ -437,12 +442,19 @@ private OpfReadResult OpfReader()

string[] argu = { $@"-o ""temp/{namer}.epub"" -t epub3 ""{ _originalFilePath }""", namer };

if (ExtensionProcess(ExtensionMethod.pandocWithReload, argu)==ExtensionResult.fail)

ExtensionResult result = ExtensionProcess(ExtensionMethod.pandocWithReload, argu);

if (result==ExtensionResult.fail)
{
return OpfReadResult.epunNeedPandocFor2to3;
}
else if (result==ExtensionResult.failWithPandocErrors)
{
return OpfReadResult.pandocConvertError;
}

return OpfReadResult.finishDueToEpub3LoadingTakeover;
return OpfReadResult.finishDueToEpub3LoadingTookover;

}
catch (Exception e)
Expand Down Expand Up @@ -656,7 +668,7 @@ private void HtmlEdit(string path, bool DoTransfer, bool ToTraidional)
{
foreach (HtmlNode body_child_Node in bodynode.ChildNodes)
{
RecursivelyReplaceText(body_child_Node, ToTraidional, DoTransfer);
RecursivelyReplaceText(body_child_Node, ToTraidional, DoTransfer,false);
if (isRemoveCss)
{
RemoveHtmlStyle(body_child_Node);
Expand Down Expand Up @@ -708,8 +720,18 @@ private void RemoveHtmlStyle(HtmlNode subBodyNode)
}
}
}
private void RecursivelyReplaceText(HtmlNode innernode, bool toTraditional, bool doTransfer)
/// <summary>
/// toTradition: 翻成繁體, replacePunctuation: 取代橫式標點符號成直式
///
/// </summary>
/// <param name="innernode"></param>
/// <param name="toTraditional">翻成繁體</param>
/// <param name="doTransfer">是否要進行轉檔,其他選項必須先滿足轉檔為是</param>
/// <param name="replacePunctuation">取代橫式標點符號成直式</param>
private void RecursivelyReplaceText(HtmlNode innernode, bool toTraditional, bool doTransfer,bool replacePunctuation)
{


foreach (HtmlNode childinnenode in innernode.ChildNodes)
{

Expand All @@ -736,11 +758,38 @@ private void RecursivelyReplaceText(HtmlNode innernode, bool toTraditional, bool
}
else
{
RecursivelyReplaceText(childinnenode, toTraditional, doTransfer);
RecursivelyReplaceText(childinnenode, toTraditional, doTransfer,replacePunctuation);
}
}

}
/// <summary>
/// 取代字串中的符號至直排符號
/// </summary>
/// <param name="rawString"></param>
/// <returns></returns>
//private string PunctuationReplacement(string rawString)
//{

// StringBuilder sb=new StringBuilder(rawString);
// sb.Replace("「","﹁");
// sb.Replace("“", "﹁"); //中式左括號
// sb.Replace("”", "﹁"); //中式右括號
// sb.Replace("『", "﹃");
// sb.Replace("‘", "﹃"); //中式左括號
// sb.Replace("’", "﹄"); //中式右括號
// sb.Replace("』", "﹄");
// sb.Replace("」", "﹂");
// sb.Replace("(", "﹂");
// sb.Replace(")", "﹂");
// sb.Replace(")", "﹂");





//}

private string EscapeCharacterReplacement(string replacement)
{
//if (fuck.Substring(fuck.IndexOf("&") - 1, 1)!= "\\")
Expand Down Expand Up @@ -906,7 +955,7 @@ private void ZipUp(bool convertMobi)
else
{//todo compress option -c2 -donotaddsource
string outputfilename = Path.GetFileNameWithoutExtension(outputPath);
string[] argu = { $@"""{ outputPath}"" -o ""{ outputfilename }.mobi"" " };
string[] argu = { $@"""{ outputPath}"" -o ""{ outputfilename }.mobi"" -c1 -dont_append_source" };
ExtensionProcess(ExtensionMethod.kindleGen, argu);

}
Expand Down Expand Up @@ -993,6 +1042,10 @@ private ExtensionResult ExtensionProcess(ExtensionMethod method, string[] argum)
{
return ExtensionResult.success;
}
else
{
return ExtensionResult.failWithPandocErrors;
}

//3 PandocFailOnWarningError
//4 PandocAppError
Expand All @@ -1019,7 +1072,15 @@ private ExtensionResult ExtensionProcess(ExtensionMethod method, string[] argum)
//99 PandocResourceNotFound
break;
case ExtensionMethod.pandocWithReload:
Load($@"temp\{argum[1]}.epub");
if (result != 0)
{
return ExtensionResult.failWithPandocErrors;
}
else
{

Load($@"temp\{argum[1]}.epub");
}
break;

}
Expand Down
8 changes: 5 additions & 3 deletions 作夥直排/BookEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ enum OpfReadResult
{
success,
fail,
finishDueToEpub3LoadingTakeover,
epunNeedPandocFor2to3
finishDueToEpub3LoadingTookover,
epunNeedPandocFor2to3,
pandocConvertError
}
public enum LoadResult
{
Expand All @@ -31,7 +32,8 @@ enum ExtensionResult
{
success,
fail,
finish
finish,
failWithPandocErrors

}

Expand Down
7 changes: 6 additions & 1 deletion 作夥直排/Chehue.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChoHoe</RootNamespace>
<AssemblyName>做伙直排</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
Expand Down Expand Up @@ -147,7 +147,12 @@
<HintPath>..\packages\HtmlAgilityPack.1.11.7\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip">
<<<<<<< HEAD
<HintPath>..\..\..\Downloads\Release (2)\Release\Ionic.Zip.dll</HintPath>
=======
<HintPath>J:\development\DotNetZipLib-DevKit-v1.9.zip\Ionic.Zip.dll</HintPath>
<Private>True</Private>
>>>>>>> dev
</Reference>
<Reference Include="MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
<HintPath>..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll</HintPath>
Expand Down
8 changes: 4 additions & 4 deletions 作夥直排/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace ChoHoeBV
{

public partial class Form1 : MetroFramework.Forms.MetroForm
{
private readonly BackgroundWorker bw = new BackgroundWorker();
Expand Down Expand Up @@ -155,7 +155,7 @@ private void btnLoad_Click(object sender, EventArgs e)
using (OpenFileDialog Import_File = new OpenFileDialog())
{

Import_File.Filter = "EPUB檔案|*.epub|TXT檔案|*.txt"; ;
Import_File.Filter = "EPUB、TXT檔案|*.epub;*.txt"; ;
Import_File.Title = "請選擇一個電子書檔案";
if (Import_File.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Expand Down Expand Up @@ -249,7 +249,7 @@ private void btnLoadBatch_Click(object sender, EventArgs e)
using (OpenFileDialog Import_File = new OpenFileDialog())
{

Import_File.Filter = "EPUB檔案|*.epub|TXT檔案|*.txt";
Import_File.Filter = "EPUB、TXT 檔案|*.epub;*.txt|EPUB 檔案|*.epub|TXT 檔案|*.txt";
Import_File.Title = "請選擇一個電子書檔案";
Import_File.Multiselect = true;

Expand Down Expand Up @@ -392,7 +392,7 @@ private void Load_Batch_Backgroundworker_DoWork(object sender, DoWorkEventArgs e
foreach (string name in paths.FileNames)
{
Book abooks = new Book();
if (abooks.Load(name) != LoadResult.fail)
if (abooks.Load(name) == LoadResult.success)
{
string[] row1 = new string[] { abooks.GetTitle(), abooks.GetAuthor() };

Expand Down
6 changes: 3 additions & 3 deletions 作夥直排/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("做伙直排")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// 您可以指定所有的值,也可以依照以下的方式,使用 '*' 將組建和修訂編號
// 指定為預設值:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.1.0")]
[assembly: AssemblyFileVersion("0.11.1.0")]
[assembly: AssemblyVersion("0.11.2.0")]
[assembly: AssemblyFileVersion("0.11.2.0")]
2 changes: 1 addition & 1 deletion 作夥直排/Properties/Resources.Designer.cs

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

Loading

0 comments on commit 500eeb4

Please sign in to comment.