Skip to content

Commit

Permalink
#36 AiStoryの属性を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
miyaji255 committed Apr 29, 2024
1 parent 935632c commit e31a665
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
3 changes: 1 addition & 2 deletions Epub/KoeBook.Epub/Services/AiStoryAnalyzerService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using KoeBook.Core.Utilities;
using KoeBook.Epub.Contracts.Services;
using KoeBook.Epub.Contracts.Services;
using KoeBook.Epub.Models;
using KoeBook.Models;

Expand Down
30 changes: 19 additions & 11 deletions KoeBook.Core/Models/AiStory.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
using System.Xml.Serialization;
using KoeBook.Core.Utilities;

namespace KoeBook.Models;

[XmlRoot("Book", IsNullable = false)]
[XmlRoot("Book")]
public record AiStory(
[XmlElement("Title", typeof(string), IsNullable = false)] string Title,
[XmlArray("Content", IsNullable = false), XmlArrayItem("Section", IsNullable = false)] AiStory.Section[] Sections)
[property: XmlElement("Title", typeof(string), IsNullable = false)] string Title,
[property: XmlArray("Content", IsNullable = false), XmlArrayItem("Section", IsNullable = false)] AiStory.Section[] Sections)
{
private AiStory() : this("", []) { }

public record Section(
[XmlElement("Paragraph", IsNullable = false)] Paragraph[] Paragraphs);
[property: XmlArrayItem("Paragraph", IsNullable = false)] Paragraph[] Paragraphs)
{
private Section() : this([]) { }
}


public record Paragraph(
[XmlElement("Text", typeof(TextElement), IsNullable = false), XmlElement("Ruby", typeof(Ruby), IsNullable = false)] InlineElement[] Inlines)
[property: XmlElement("Text", typeof(TextElement), IsNullable = false), XmlElement("Ruby", typeof(Ruby), IsNullable = false)] InlineElement[] Inlines)
{
private Paragraph() : this([]) { }

public string GetText() => string.Concat(Inlines.Select(e => e.Text));

public string GetScript() => string.Concat(Inlines.Select(e => e.Script));
Expand All @@ -26,19 +32,21 @@ public abstract record class InlineElement
public abstract string Script { get; }
}

public record TextElement([XmlText] string InnerText) : InlineElement
public record TextElement([property: XmlText] string InnerText) : InlineElement
{
private TextElement() : this("") { }

public override string Text => InnerText;
public override string Script => InnerText;
}


public record Ruby(
[XmlElement("Rb", IsNullable = false)] string Rb,
[XmlElement("Rt", IsNullable = false)] string Rt) : InlineElement
[property: XmlElement("Rb", IsNullable = false)] string Rb,
[property: XmlElement("Rt", IsNullable = false)] string Rt) : InlineElement
{
private Ruby() : this("", "") { }

public override string Text => Rb;
public override string Script => Rt;
}

}
4 changes: 2 additions & 2 deletions KoeBook.Core/Models/BookProperties.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics;
using KoeBook.Models;
using KoeBook.Models;

namespace KoeBook.Core.Models;

Expand All @@ -21,6 +20,7 @@ public BookProperties(Guid id, AiStory aiStory)
{
Id = id;
Source = aiStory;
SourceType = SourceType.AiStory;
}

public Guid Id { get; }
Expand Down
6 changes: 3 additions & 3 deletions KoeBook/Models/GenerationTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public BookProperties ToBookProperties()

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(StateText))]
[NotifyPropertyChangedFor(nameof(SkipEditChangable))]
[NotifyPropertyChangedFor(nameof(SkipEditChangeable))]
[NotifyPropertyChangedFor(nameof(Editable))]
private GenerationState _state;

Expand All @@ -79,7 +79,7 @@ public bool SkipEdit
get => _skipEdit;
set
{
if (_skipEdit != value && SkipEditChangable)
if (_skipEdit != value && SkipEditChangeable)
{
OnPropertyChanging(nameof(SkipEdit));
_skipEdit = value;
Expand All @@ -89,7 +89,7 @@ public bool SkipEdit
}
private bool _skipEdit;

public bool SkipEditChangable => State < GenerationState.Editting;
public bool SkipEditChangeable => State < GenerationState.Editting;

public bool Editable => State == GenerationState.Editting;

Expand Down
2 changes: 1 addition & 1 deletion KoeBook/Views/EditDetailsTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
Margin="{StaticResource XXSmallLeftTopRightBottomMargin}"
OffContent="編集する"
OnContent="編集しない"
IsEnabled="{x:Bind ViewModel.Task.SkipEditChangable, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.Task.SkipEditChangeable, Mode=OneWay}"
IsOn="{x:Bind ViewModel.Task.SkipEdit, Mode=TwoWay}"/>

<TextBlock
Expand Down

0 comments on commit e31a665

Please sign in to comment.