Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Epubのクラス定義 #18

Merged
merged 12 commits into from
Feb 21, 2024
21 changes: 21 additions & 0 deletions Epub/KoeBook.Epub/Audio.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using NAudio.Wave;

namespace KoeBook.Epub;

public sealed class Audio
{
public TimeSpan TotalTime { get; }
private byte[] _mp3Data = [];

public Audio(byte[] mp3Data)
{
_mp3Data = mp3Data;
using var ms = new MemoryStream();
ms.Write(_mp3Data.AsSpan());
ms.Flush();
ms.Position = 0;
using var reader = new Mp3FileReader(ms);
TotalTime = reader.TotalTime;
}
}
7 changes: 7 additions & 0 deletions Epub/KoeBook.Epub/Chapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace KoeBook.Epub;

public class Chapter
{
public List<string> Sections = [];
public string? Title { get; set; }
}
7 changes: 7 additions & 0 deletions Epub/KoeBook.Epub/CssStyle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace KoeBook.Epub;

public class CssStyle
aiueo-1234 marked this conversation as resolved.
Show resolved Hide resolved
{
public string? Name { get; set; }
public string? Text { get; set; }
}
6 changes: 6 additions & 0 deletions Epub/KoeBook.Epub/Element.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace KoeBook.Epub;

public abstract class Element
{
public string? StyleName { get; set; }
aiueo-1234 marked this conversation as resolved.
Show resolved Hide resolved
}
6 changes: 0 additions & 6 deletions Epub/KoeBook.Epub/Epub.cs

This file was deleted.

15 changes: 15 additions & 0 deletions Epub/KoeBook.Epub/EpubDocument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Globalization;
using System.Xml;

namespace KoeBook.Epub;

public class EpubDocument(string title, string author)
{
public string Title { get; set; } = title;
public string Author { get; set; } = author;

public string CoverFilePath { get; set; } = "";

public List<CssStyle>? CssStyles { get; set; }
public List<Chapter>? Chapters { get; set; }
}
4 changes: 2 additions & 2 deletions Epub/KoeBook.Epub/KoeBook.Epub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastEnum" Version="1.8.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
</ItemGroup>

</Project>
7 changes: 7 additions & 0 deletions Epub/KoeBook.Epub/Paragraph.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace KoeBook.Epub;

public sealed class Paragraph : Element
{
public Audio? Audio { get; set; }
public string? Text { get; set; }
}
6 changes: 6 additions & 0 deletions Epub/KoeBook.Epub/Picture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace KoeBook.Epub;

public class Picture(string path) : Element
{
public string PictureFilePath { get; set; } = path;
}
14 changes: 14 additions & 0 deletions Epub/KoeBook.Epub/Section.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace KoeBook.Epub;

public sealed class Section
{
public string Id { get; }
public string Title { get; set; } = "";
aiueo-1234 marked this conversation as resolved.
Show resolved Hide resolved
public List<Element> Elements { get; set; } = [];

internal Section(string title)
{
Title = title;
Id = Guid.NewGuid().ToString();
}
}
Loading