forked from kc3hack/2024_H
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Core.Contracts.Services; | ||
|
||
public interface IStoryCreaterService | ||
{ | ||
public ValueTask<string> CreateStoryAsync(StoryGenre genre, string intruction, CancellationToken cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace KoeBook.Core.Models; | ||
|
||
public record class StoryGenre(string Genre, string Description); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System.Collections.Immutable; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using KoeBook.Core.Contracts.Services; | ||
using KoeBook.Core.Models; | ||
using KoeBook.Services; | ||
|
||
namespace KoeBook.ViewModels; | ||
|
||
public sealed partial class CreateStoryViewModel : ObservableObject | ||
{ | ||
private readonly IStoryCreaterService _storyCreaterService; | ||
private readonly GenerationTaskRunnerService _generationTaskRunnerService; | ||
|
||
public ImmutableArray<StoryGenre> Genres { get; } = [ | ||
new("青春小説", "学校生活、友情、恋愛など、若者の成長物語"), | ||
new("ミステリー・サスペンス", "謎解きや犯罪、真相究明などのスリリングな物語"), | ||
new("SF", "未来、科学技術、宇宙などを題材にした物語"), | ||
new("ホラー", "恐怖や怪奇現象を扱った、読者の恐怖心をくすぐる物語"), | ||
new("ロマンス", "恋愛や結婚、人間関係などを扱った、胸キュンな物語"), | ||
new("コメディ", "ユーモアやギャグ、風刺などを交えた、読者を笑わせる物語"), | ||
new("歴史小説", "過去の出来事や人物を題材にした、歴史の背景が感じられる物語"), | ||
new("ノンフィクション・エッセイ", "実際の経験や知識、考えを綴った、リアルな物語"), | ||
new("詩集", "感情や思考、風景などを言葉で表現した、韻文形式の作品集"), | ||
]; | ||
|
||
[ObservableProperty] | ||
private StoryGenre _selectedGenre; | ||
|
||
[ObservableProperty] | ||
private string _intruction = ""; | ||
|
||
[ObservableProperty] | ||
private string _storyText = """ | ||
# h1 | ||
## h2 | ||
### h3 | ||
1. aaa | ||
2. bbb | ||
3. ccc | ||
--- | ||
"""; | ||
|
||
public CreateStoryViewModel(GenerationTaskRunnerService generationTaskRunnerService) | ||
{ | ||
_selectedGenre = Genres[0]; | ||
_generationTaskRunnerService = generationTaskRunnerService; | ||
//_storyCreaterService = storyCreaterService; | ||
_storyCreaterService = null!; | ||
} | ||
|
||
public bool CanCreateStory => !string.IsNullOrWhiteSpace(Intruction); | ||
|
||
[RelayCommand(CanExecute = nameof(CanCreateStory))] | ||
private async Task OnCreateStoryAsync(CancellationToken cancellationToken) | ||
{ | ||
StoryText = await _storyCreaterService.CreateStoryAsync(SelectedGenre, Intruction, cancellationToken); | ||
} | ||
|
||
[RelayCommand] | ||
private async void OnStartGenerateTask (CancellationToken cancellationToken) | ||
{ | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Page | ||
x:Class="KoeBook.Views.CreateStoryPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:KoeBook.Views" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls" | ||
xmlns:models="using:KoeBook.Core.Models" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
|
||
<StackPanel Orientation="Horizontal"> | ||
<StackPanel Orientation="Horizontal" Spacing="12" Margin="5"> | ||
<Button | ||
Content="ストーリーを生成する"/> | ||
<Button | ||
Content="EPUBを生成する" /> | ||
</StackPanel> | ||
</StackPanel> | ||
|
||
<ScrollView | ||
Grid.Row="1" | ||
ZoomMode="Disabled" | ||
HorizontalScrollMode="Disabled"> | ||
|
||
<StackPanel Spacing="8"> | ||
<TextBlock | ||
Style="{StaticResource TitleTextBlockStyle}" | ||
Text="ストーリーの指針"/> | ||
<ComboBox | ||
Margin="{StaticResource XSmallTopMargin}" | ||
Header="ジャンル" | ||
Width="200" | ||
ItemsSource="{x:Bind ViewModel.Genres}" | ||
SelectedValue="{x:Bind ViewModel.SelectedGenre, Mode=TwoWay}"> | ||
<ComboBox.ItemTemplate> | ||
<DataTemplate x:DataType="models:StoryGenre"> | ||
<TextBlock Text="{x:Bind Genre}" ToolTipService.ToolTip="{x:Bind Description}" /> | ||
</DataTemplate> | ||
</ComboBox.ItemTemplate> | ||
</ComboBox> | ||
<TextBox | ||
Header="具体的な指示" | ||
Text="{x:Bind ViewModel.Intruction, Mode=TwoWay}" | ||
Height="256" /> | ||
<TextBlock | ||
Style="{StaticResource TitleTextBlockStyle}" | ||
Text="ストーリー" | ||
Margin="{StaticResource SmallTopMargin}" /> | ||
<controls:MarkdownTextBlock | ||
Padding="8" | ||
CornerRadius="10" | ||
Text="{x:Bind ViewModel.StoryText, Mode=OneWay}" /> | ||
</StackPanel> | ||
</ScrollView> | ||
</Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using KoeBook.ViewModels; | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace KoeBook.Views; | ||
|
||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class CreateStoryPage : Page | ||
{ | ||
public static readonly Guid Id = Guid.NewGuid(); | ||
|
||
public CreateStoryViewModel ViewModel { get; } | ||
|
||
public CreateStoryPage() | ||
{ | ||
ViewModel = App.GetService<CreateStoryViewModel>(); | ||
|
||
this.InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters