Skip to content

Commit 2806789

Browse files
committed
updated editor to include skipped lessons; added some lessons
1 parent e88ea4a commit 2806789

File tree

7 files changed

+177
-8
lines changed

7 files changed

+177
-8
lines changed

LearnJsonEverything.LessonEditor/Controls/CodeInput.xaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<RowDefinition/>
1313
</Grid.RowDefinitions>
1414
<Label Content="{Binding Label, ElementName=Self}"/>
15-
<TextBox Grid.Row="1" Text="{Binding CodeContent, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
16-
FontFamily="Consolas" AcceptsReturn="True" AcceptsTab="True"/>
15+
<TextBox Grid.Row="1" FontFamily="Consolas" AcceptsReturn="True" AcceptsTab="True"
16+
Text="{Binding CodeContent, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
17+
IsReadOnly="{Binding IsReadOnly, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
1718
</Grid>
1819
</UserControl>

LearnJsonEverything.LessonEditor/Controls/CodeInput.xaml.cs

+9
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,14 @@ public string CodeContent
3030

3131
public static readonly DependencyProperty CodeContentProperty =
3232
DependencyProperty.Register(nameof(CodeContent), typeof(string), typeof(CodeInput), new PropertyMetadata(string.Empty));
33+
34+
public bool IsReadOnly
35+
{
36+
get => (bool)GetValue(IsReadOnlyProperty);
37+
set => SetValue(IsReadOnlyProperty, value);
38+
}
39+
40+
public static readonly DependencyProperty IsReadOnlyProperty =
41+
DependencyProperty.Register(nameof(IsReadOnly), typeof(bool), typeof(CodeInput), new PropertyMetadata(false));
3342
}
3443
}

LearnJsonEverything.LessonEditor/Controls/Editor.xaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959
<RowDefinition Height="Auto"/>
6060
<RowDefinition/>
6161
</Grid.RowDefinitions>
62-
<local:TextInput Label="Title
63-
" TextContent="{Binding SelectedLesson.Title, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
62+
<local:TextInput Label="Title"
63+
TextContent="{Binding SelectedLesson.Title, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
64+
<CheckBox Content="Skip" HorizontalAlignment="Right" Margin="0,6,0,0"
65+
IsChecked="{Binding SelectedLesson.Skip, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
6466
<local:TextInput Grid.Row="1" Label="Background"
6567
TextContent="{Binding SelectedLesson.Background, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
6668
<local:TextInput Grid.Row="2" Label="Docs Path (from root on docs.json-everything.net)"
@@ -78,7 +80,7 @@
7880
CodeContent="{Binding SelectedLesson.InitialCode, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
7981
<local:CodeInput Grid.Row="1" Label="Solution" Margin="0,5,5,5"
8082
CodeContent="{Binding SelectedLesson.Solution, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
81-
<local:CodeInput Grid.Row="2" Label="Output" Margin="0,5,5,0" IsEnabled="False"
83+
<local:CodeInput Grid.Row="2" Label="Output" Margin="0,5,5,0" IsReadOnly="False"
8284
CodeContent="{Binding ValidationOutput, ElementName=Self}"/>
8385
<Button Grid.Row="1" Content="Copy from above" Click="CopyInitialToSolution"
8486
HorizontalAlignment="Right" VerticalAlignment="Top"

LearnJsonEverything.LessonEditor/Controls/LessonModel.cs

+11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public string Title
1818
public static readonly DependencyProperty TitleProperty =
1919
DependencyProperty.Register(nameof(Title), typeof(string), typeof(LessonModel), new PropertyMetadata(null));
2020

21+
public bool Skip
22+
{
23+
get => (bool)GetValue(SkipProperty);
24+
set => SetValue(SkipProperty, value);
25+
}
26+
27+
public static readonly DependencyProperty SkipProperty =
28+
DependencyProperty.Register(nameof(Skip), typeof(bool), typeof(LessonModel), new PropertyMetadata(false));
29+
2130
public string Background
2231
{
2332
get => (string)GetValue(BackgroundProperty);
@@ -94,6 +103,7 @@ public LessonModel(LessonData data)
94103
public void Reset()
95104
{
96105
Title = Lesson.Title;
106+
Skip = Lesson.Skip;
97107
Background = Lesson.Background;
98108
DocsPath = Lesson.Docs;
99109
Instructions = Lesson.Instructions;
@@ -106,6 +116,7 @@ public void Reset()
106116
public void Save()
107117
{
108118
Lesson.Title = Title;
119+
Lesson.Skip = Skip;
109120
Lesson.Background = Background;
110121
Lesson.Docs = DocsPath;
111122
Lesson.Instructions = Instructions;

LearnJsonEverything.LessonEditor/MainWindow.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
xmlns:controls="clr-namespace:LearnJsonEverything.LessonEditor.Controls"
77
xmlns:hosts="clr-namespace:LearnJsonEverything.Services.Hosts;assembly=LearnJsonEverything"
88
mc:Ignorable="d"
9-
Title="MainWindow" Height="800" Width="1200"
9+
Title="Learn json-everything - Lesson Editor"
10+
WindowState="Maximized"
1011
SnapsToDevicePixels="True"
1112
UseLayoutRounding="True"
1213
TextElement.FontSize="14"

LearnJsonEverything/Services/LessonPlan.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class LessonPlanJsonConverter : JsonConverter<LessonPlan>
5151
var lessonData = JsonSerializer.Deserialize<LessonData[]>(ref reader, options)!;
5252
#pragma warning restore IL2026 // Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code
5353

54-
return new LessonPlan(lessonData.Where(x => !x.Skip).ToArray());
54+
return new LessonPlan(lessonData.ToArray());
5555
}
5656

5757
public override void Write(Utf8JsonWriter writer, LessonPlan value, JsonSerializerOptions options)

0 commit comments

Comments
 (0)