Skip to content

Commit 688f085

Browse files
committed
add lesson editor app; switch to json file
1 parent 79a1fc2 commit 688f085

32 files changed

+1420
-1182
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Application x:Class="LearnJsonEverything.LessonEditor.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
</Application.Resources>
7+
</Application>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace LearnJsonEverything.LessonEditor
6+
{
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<UserControl x:Class="LearnJsonEverything.LessonEditor.Controls.CodeInput"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d"
7+
d:DesignHeight="450" d:DesignWidth="800"
8+
x:Name="Self">
9+
<Grid>
10+
<Grid.RowDefinitions>
11+
<RowDefinition Height="Auto"/>
12+
<RowDefinition/>
13+
</Grid.RowDefinitions>
14+
<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"/>
17+
</Grid>
18+
</UserControl>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
4+
namespace LearnJsonEverything.LessonEditor.Controls
5+
{
6+
/// <summary>
7+
/// Interaction logic for TextInput.xaml
8+
/// </summary>
9+
public partial class CodeInput : UserControl
10+
{
11+
public CodeInput()
12+
{
13+
InitializeComponent();
14+
}
15+
16+
public string Label
17+
{
18+
get => (string)GetValue(LabelProperty);
19+
set => SetValue(LabelProperty, value);
20+
}
21+
22+
public static readonly DependencyProperty LabelProperty =
23+
DependencyProperty.Register(nameof(Label), typeof(string), typeof(CodeInput), new PropertyMetadata(string.Empty));
24+
25+
public string CodeContent
26+
{
27+
get => (string)GetValue(CodeContentProperty);
28+
set => SetValue(CodeContentProperty, value);
29+
}
30+
31+
public static readonly DependencyProperty CodeContentProperty =
32+
DependencyProperty.Register(nameof(CodeContent), typeof(string), typeof(CodeInput), new PropertyMetadata(string.Empty));
33+
}
34+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<UserControl x:Class="LearnJsonEverything.LessonEditor.Controls.Editor"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:LearnJsonEverything.LessonEditor.Controls"
7+
xmlns:services="clr-namespace:LearnJsonEverything.Services;assembly=LearnJsonEverything"
8+
mc:Ignorable="d"
9+
d:DesignHeight="450" d:DesignWidth="800"
10+
x:Name="Self">
11+
<UserControl.Resources>
12+
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
13+
<Setter Property="Margin" Value="5"/>
14+
<Setter Property="Padding" Value="10,3"/>
15+
</Style>
16+
</UserControl.Resources>
17+
<Grid>
18+
<Grid.RowDefinitions>
19+
<RowDefinition/>
20+
<RowDefinition/>
21+
<RowDefinition Height="Auto"/>
22+
</Grid.RowDefinitions>
23+
<Grid.ColumnDefinitions>
24+
<ColumnDefinition Width="Auto"/>
25+
<ColumnDefinition Width="2*"/>
26+
<ColumnDefinition Width="3*"/>
27+
</Grid.ColumnDefinitions>
28+
<Grid Margin="5,5,5,0">
29+
<Grid.RowDefinitions>
30+
<RowDefinition/>
31+
<RowDefinition Height="Auto"/>
32+
</Grid.RowDefinitions>
33+
<ListBox MinWidth="100" ItemsSource="{Binding Lessons, ElementName=Self}"
34+
SelectedItem="{Binding SelectedLesson, ElementName=Self}">
35+
<ListBox.ItemTemplate>
36+
<DataTemplate DataType="{x:Type services:LessonData}">
37+
<TextBlock Text="{Binding Title}"/>
38+
</DataTemplate>
39+
</ListBox.ItemTemplate>
40+
</ListBox>
41+
<Grid Grid.Row="1" Margin="-5,5,-5,0">
42+
<Grid.ColumnDefinitions>
43+
<ColumnDefinition Width="Auto"/>
44+
<ColumnDefinition/>
45+
<ColumnDefinition/>
46+
<ColumnDefinition Width="Auto"/>
47+
</Grid.ColumnDefinitions>
48+
<Button Content="🡅" Click="MoveLessonUp"/>
49+
<Button Content="Add" Click="AddLesson" Grid.Column="1"/>
50+
<Button Content="Delete" Click="RemoveLesson" Grid.Column="2"/>
51+
<Button Content="🡇" Click="MoveLessonDown" Grid.Column="3"/>
52+
</Grid>
53+
</Grid>
54+
<Grid Grid.Column="1" Margin="5">
55+
<Grid.RowDefinitions>
56+
<RowDefinition Height="Auto"/>
57+
<RowDefinition/>
58+
<RowDefinition Height="Auto"/>
59+
<RowDefinition/>
60+
</Grid.RowDefinitions>
61+
<local:TextInput Label="Title" TextContent="{Binding LessonTitle, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
62+
<local:TextInput Grid.Row="1" Label="Background" TextContent="{Binding LessonBackground, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
63+
<local:TextInput Grid.Row="2" Label="Docs Path (from root on docs.json-everything.net)" TextContent="{Binding DocsPath, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
64+
<local:TextInput Grid.Row="3" Label="Instructions" TextContent="{Binding Instructions, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
65+
</Grid>
66+
<Grid Grid.Column="2" Grid.RowSpan="2" Margin="5">
67+
<Grid.RowDefinitions>
68+
<RowDefinition/>
69+
<RowDefinition/>
70+
</Grid.RowDefinitions>
71+
<local:CodeInput Label="Initial Code" Margin="0,0,5,5"
72+
CodeContent="{Binding InitialCode, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
73+
<local:CodeInput Grid.Row="1" Label="Solution" Margin="0,5,5,0"
74+
CodeContent="{Binding Solution, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
75+
<Button Grid.Row="1" Content="Copy from above" Click="CopyInitialToSolution"
76+
HorizontalAlignment="Right" VerticalAlignment="Top"
77+
Padding="10,0"/>
78+
</Grid>
79+
<Grid Grid.Row="1" Margin="5,5,5,0">
80+
<Grid.RowDefinitions>
81+
<RowDefinition Height="Auto"/>
82+
<RowDefinition/>
83+
<RowDefinition Height="Auto"/>
84+
</Grid.RowDefinitions>
85+
<Label Content="Tests"/>
86+
<ListBox Grid.Row="1" ItemsSource="{Binding Tests, ElementName=Self}" SelectedItem="{Binding SelectedTest, ElementName=Self}">
87+
<ListBox.ItemTemplate>
88+
<DataTemplate DataType="{x:Type local:TestModel}">
89+
<TextBlock Text="{Binding Condensed}"/>
90+
</DataTemplate>
91+
</ListBox.ItemTemplate>
92+
</ListBox>
93+
<Grid Grid.Row="2" Margin="-5,5,-5,0">
94+
<Grid.ColumnDefinitions>
95+
<ColumnDefinition Width="Auto"/>
96+
<ColumnDefinition/>
97+
<ColumnDefinition/>
98+
<ColumnDefinition Width="Auto"/>
99+
</Grid.ColumnDefinitions>
100+
<Button Content="🡅" Click="MoveTestUp"/>
101+
<Button Content="Add" Click="AddTest" Grid.Column="1"/>
102+
<Button Content="Delete" Click="RemoveTest" Grid.Column="2"/>
103+
<Button Content="🡇" Click="MoveTestDown" Grid.Column="3"/>
104+
</Grid>
105+
</Grid>
106+
<local:CodeInput Grid.Column="1" Grid.Row="1" Label="Test Data" Margin="5"
107+
CodeContent="{Binding SelectedTest.Formatted, ElementName=Self, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
108+
<StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,5">
109+
<Button Content="Validate" Click="ValidateSolution"/>
110+
<Button Content="Save" Click="SaveChanges" IsEnabled="{Binding CanSave, ElementName=Self}"/>
111+
<Button Content="Reset" Click="ResetContent"/>
112+
</StackPanel>
113+
</Grid>
114+
</UserControl>

0 commit comments

Comments
 (0)