Skip to content

Commit

Permalink
#29 テキストボックスの配置を変更
Browse files Browse the repository at this point in the history
  • Loading branch information
miyaji255 committed Apr 29, 2024
1 parent d37bb44 commit 56c0ab6
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 51 deletions.
28 changes: 14 additions & 14 deletions KoeBook/ViewModels/CreateStoryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ public sealed partial class CreateStoryViewModel : ObservableObject

public ImmutableArray<StoryGenre> Genres { get; } = [
new("青春小説", "学校生活、友情、恋愛など、若者の成長物語"),
new("ミステリー・サスペンス", "謎解きや犯罪、真相究明などのスリリングな物語"),
new("SF", "未来、科学技術、宇宙などを題材にした物語"),
new("ホラー", "恐怖や怪奇現象を扱った、読者の恐怖心をくすぐる物語"),
new("ロマンス", "恋愛や結婚、人間関係などを扱った、胸キュンな物語"),
new("コメディ", "ユーモアやギャグ、風刺などを交えた、読者を笑わせる物語"),
new("歴史小説", "過去の出来事や人物を題材にした、歴史の背景が感じられる物語"),
new("ノンフィクション・エッセイ", "実際の経験や知識、考えを綴った、リアルな物語"),
new("詩集", "感情や思考、風景などを言葉で表現した、韻文形式の作品集"),
];
new("ミステリー・サスペンス", "謎解きや犯罪、真相究明などのスリリングな物語"),
new("SF", "未来、科学技術、宇宙などを題材にした物語"),
new("ホラー", "恐怖や怪奇現象を扱った、読者の恐怖心をくすぐる物語"),
new("ロマンス", "恋愛や結婚、人間関係などを扱った、胸キュンな物語"),
new("コメディ", "ユーモアやギャグ、風刺などを交えた、読者を笑わせる物語"),
new("歴史小説", "過去の出来事や人物を題材にした、歴史の背景が感じられる物語"),
new("ノンフィクション・エッセイ", "実際の経験や知識、考えを綴った、リアルな物語"),
new("詩集", "感情や思考、風景などを言葉で表現した、韻文形式の作品集"),
];

[ObservableProperty]
private StoryGenre _selectedGenre;

[ObservableProperty]
private string _intruction = "";
private string _instruction = "";

[ObservableProperty]
private string _storyText = """
Expand All @@ -51,17 +51,17 @@ public CreateStoryViewModel(GenerationTaskRunnerService generationTaskRunnerServ
_storyCreaterService = null!;
}

public bool CanCreateStory => !string.IsNullOrWhiteSpace(Intruction);
public bool CanCreateStory => !string.IsNullOrWhiteSpace(Instruction);

[RelayCommand(CanExecute = nameof(CanCreateStory))]
private async Task OnCreateStoryAsync(CancellationToken cancellationToken)
{
StoryText = await _storyCreaterService.CreateStoryAsync(SelectedGenre, Intruction, cancellationToken);
StoryText = await _storyCreaterService.CreateStoryAsync(SelectedGenre, Instruction, cancellationToken);
}

[RelayCommand]
private async void OnStartGenerateTask (CancellationToken cancellationToken)
{
private async void OnStartGenerateTask(CancellationToken cancellationToken)

Check warning on line 63 in KoeBook/ViewModels/CreateStoryViewModel.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 63 in KoeBook/ViewModels/CreateStoryViewModel.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 63 in KoeBook/ViewModels/CreateStoryViewModel.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 63 in KoeBook/ViewModels/CreateStoryViewModel.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
}
}

100 changes: 63 additions & 37 deletions KoeBook/Views/CreateStoryPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,80 @@
xmlns:models="using:KoeBook.Core.Models"
mc:Ignorable="d">

<Grid>
<Grid RowSpacing="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="240" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition MinHeight="220" />
<RowDefinition />
</Grid.RowDefinitions>

<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal" Spacing="12" Margin="5">
<Button
Content="ストーリーを生成する"/>
<Button
Content="EPUBを生成する" />
</StackPanel>
<TextBlock
Grid.ColumnSpan="2"
Style="{StaticResource TitleTextBlockStyle}"
Text="物語をAIで生成する"/>

<StackPanel
Grid.Row="1"
Margin="5">
<TextBlock
Style="{StaticResource SubtitleTextBlockStyle}"
Text="ジャンル"/>
<ComboBox
Margin="{StaticResource SmallTopMargin}"
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>

<TextBlock
Style="{StaticResource SubtitleTextBlockStyle}"
Margin="{StaticResource MediumTopMargin}"
Text="生成"/>
<Button
Margin="{StaticResource SmallTopMargin}"
Content="物語を生成する"
Width="160"/>
<Button
Margin="{StaticResource SmallTopMargin}"
Content="EPUBを生成する"
Width="160" />
</StackPanel>

<StackPanel
Grid.Column="1"
Grid.Row="1">
<TextBlock
Style="{StaticResource SubtitleTextBlockStyle}"
Text="物語の概要" />
<TextBox
FontSize="16"
AcceptsReturn="True"
TextWrapping="Wrap"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Margin="{StaticResource SmallTopMargin}"
Text="{x:Bind ViewModel.Instruction, Mode=TwoWay}"
Height="256" />
</StackPanel>

<ScrollView
Grid.Row="1"
ZoomMode="Disabled"
HorizontalScrollMode="Disabled">
Grid.Row="2"
Grid.ColumnSpan="2">
<StackPanel>

<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="ストーリー"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="出力された物語"
Margin="{StaticResource SmallTopMargin}" />
<controls:MarkdownTextBlock
Padding="8"
CornerRadius="10"
Text="{x:Bind ViewModel.StoryText, Mode=OneWay}" />

</StackPanel>
</ScrollView>
</Grid>
Expand Down

0 comments on commit 56c0ab6

Please sign in to comment.