Skip to content

Commit

Permalink
開啟書本時的副檔名,新增同時讀取epub以及txt的選項
Browse files Browse the repository at this point in the history
  • Loading branch information
SODAISpod committed Apr 13, 2023
1 parent d441622 commit 8045443
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 46 deletions.
2 changes: 1 addition & 1 deletion ChehueWPF/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using System.Windows.Forms;
using System.Diagnostics;

namespace ChoHoeBV
namespace ChoHoe
{
public class Book
{
Expand Down
12 changes: 12 additions & 0 deletions ChehueWPF/ChehueWPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@
<HintPath>..\packages\ModernWpfUI.0.9.4\lib\net462\ModernWpf.Controls.dll</HintPath>
</Reference>
<Reference Include="netstandard" />
<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>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -72,6 +77,7 @@
<AdditionalFiles Include="Book.cs" />
<Compile Include="BookEnum.cs" />
<Compile Include="CssStyle.cs" />
<Compile Include="Logger.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -104,5 +110,11 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\作夥直排\Chehue.csproj">
<Project>{16268030-1DF7-48FD-BA3D-D0CE9DBF5F15}</Project>
<Name>Chehue</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
19 changes: 19 additions & 0 deletions ChehueWPF/Logger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLog;
namespace ChoHoe
{
static class Logger
{
public static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
static Logger()
{


}

}
}
48 changes: 13 additions & 35 deletions ChehueWPF/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ChehueWPF"
mc:Ignorable="d"
Title="MainWindow" Height="543.667" Width="800"
xmlns:ui="http://schemas.modernwpf.com/2019"
ui:WindowHelper.UseModernWindowStyle="True">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="145*"/>
<ColumnDefinition Width="53*"/>
</Grid.ColumnDefinitions>
<ui:SimpleStackPanel Margin="12" Spacing="24" Grid.ColumnSpan="2">
<TextBlock Text="書名:無職轉生" Style="{StaticResource HeaderTextBlockStyle}" />

<DataGrid Margin="0,-19,215,-303" SelectionChanged="DataGrid_SelectionChanged">
<DataGrid.Resources>
<c:Book x:Key="books"/>
</DataGrid.Resources>
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"-->

<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalAlignment="Right" Width="196" Height="396" VerticalAlignment="Top" Margin="0,-43,0,0" >
<Grid Width="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListBox}},Path=ActualWidth}" Height="396">

<Label Content="中文轉換" Height="396" VerticalAlignment="Bottom"/>
<ui:ToggleSwitch Margin="10,24,0,340"></ui:ToggleSwitch>
<ToggleButton Content="轉換成正體中文" Margin="60,56,10,309" HorizontalAlignment="Stretch"/>
<Label Content="翻頁方向" Margin="0,92,0,278"/>
<ui:ToggleSwitch Margin="10,118,0,246"/>
<ToggleButton Content="由右往左翻" Margin="60,150,10,215" HorizontalAlignment="Stretch"/>
<Label Content="匯出.mobi檔" Margin="0,186,0,184"/>
<ui:ToggleSwitch Margin="10,217,0,147"/>
<Label Content="替換插圖" Margin="0,255,0,115"/>
<ui:ToggleSwitch Margin="10,286,0,78"/>
<Label Content="移除CSS" Margin="0,323,0,47"/>
<ui:ToggleSwitch Margin="10,349,0,15"/>

</Grid>

</ScrollViewer>

</ui:SimpleStackPanel>
</Grid>
</Window>
16 changes: 15 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 @@ -20,14 +21,27 @@ namespace ChehueWPF
/// </summary>
public partial class MainWindow : Window
{
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);
}

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 @@ -2,6 +2,7 @@
<packages>
<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
Binary file added UpgradeLog2.htm
Binary file not shown.
45 changes: 41 additions & 4 deletions 作夥直排/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,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 @@ -720,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 @@ -748,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 @@ -918,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
1 change: 1 addition & 0 deletions 作夥直排/Chehue.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
</Reference>
<Reference Include="Ionic.Zip">
<HintPath>J:\development\DotNetZipLib-DevKit-v1.9.zip\Ionic.Zip.dll</HintPath>
<Private>True</Private>
</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
6 changes: 3 additions & 3 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 @@ -144,7 +144,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 @@ -238,7 +238,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
4 changes: 2 additions & 2 deletions 作夥直排/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 8045443

Please sign in to comment.