Skip to content

Commit 067ec94

Browse files
authored
Merge pull request #189 from Microsoft/PerthCharern/AdjustWorkbench
Small appearance fixes in Workbench - Add missing scrollbar - Update versions to V3.0.1 and V2.0 for accuracy
2 parents ec60288 + 5f6660f commit 067ec94

File tree

2 files changed

+42
-43
lines changed

2 files changed

+42
-43
lines changed

src/Microsoft.OpenApi.Workbench/MainModel.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ public class MainModel : INotifyPropertyChanged
3030
/// <summary>
3131
/// Default format.
3232
/// </summary>
33-
private string _format = "Yaml";
33+
private OpenApiFormat _format = OpenApiFormat.Yaml;
3434

3535
/// <summary>
3636
/// Default version.
3737
/// </summary>
38-
private string _version = "V3";
38+
private OpenApiSpecVersion _version = OpenApiSpecVersion.OpenApi3_0;
3939

4040
public string Input
4141
{
4242
get => _input;
4343
set
4444
{
4545
_input = value;
46-
OnPropertyChanged("Input");
46+
OnPropertyChanged(nameof(Input));
4747
}
4848
}
4949

@@ -53,7 +53,7 @@ public string Output
5353
set
5454
{
5555
_output = value;
56-
OnPropertyChanged("Output");
56+
OnPropertyChanged(nameof(Output));
5757
}
5858
}
5959

@@ -63,7 +63,7 @@ public string Errors
6363
set
6464
{
6565
_errors = value;
66-
OnPropertyChanged("Errors");
66+
OnPropertyChanged(nameof(Errors));
6767
}
6868
}
6969

@@ -73,7 +73,7 @@ public string ParseTime
7373
set
7474
{
7575
_parseTime = value;
76-
OnPropertyChanged("ParseTime");
76+
OnPropertyChanged(nameof(ParseTime));
7777
}
7878
}
7979

@@ -83,54 +83,54 @@ public string RenderTime
8383
set
8484
{
8585
_renderTime = value;
86-
OnPropertyChanged("RenderTime");
86+
OnPropertyChanged(nameof(RenderTime));
8787
}
8888
}
8989

90-
public string Format
90+
public OpenApiFormat Format
9191
{
9292
get => _format;
9393
set
9494
{
9595
_format = value;
96-
OnPropertyChanged("IsYaml");
97-
OnPropertyChanged("IsJson");
96+
OnPropertyChanged(nameof(IsYaml));
97+
OnPropertyChanged(nameof(IsJson));
9898
}
9999
}
100100

101-
public string Version
101+
public OpenApiSpecVersion Version
102102
{
103103
get => _version;
104104
set
105105
{
106106
_version = value;
107-
OnPropertyChanged("IsV2");
108-
OnPropertyChanged("IsV3");
107+
OnPropertyChanged(nameof(IsV2_0));
108+
OnPropertyChanged(nameof(IsV3_0));
109109
}
110110
}
111111

112112
public bool IsYaml
113113
{
114-
get => Format == "Yaml";
115-
set => Format = "Yaml";
114+
get => Format == OpenApiFormat.Yaml;
115+
set => Format = OpenApiFormat.Yaml;
116116
}
117117

118118
public bool IsJson
119119
{
120-
get => Format == "JSON";
121-
set => Format = "JSON";
120+
get => Format == OpenApiFormat.Json;
121+
set => Format = OpenApiFormat.Json;
122122
}
123123

124-
public bool IsV2
124+
public bool IsV2_0
125125
{
126-
get => Version == "V2";
127-
set => Version = "V2";
126+
get => Version == OpenApiSpecVersion.OpenApi2_0;
127+
set => Version = OpenApiSpecVersion.OpenApi2_0;
128128
}
129129

130-
public bool IsV3
130+
public bool IsV3_0
131131
{
132-
get => Version == "V3";
133-
set => Version = "V3";
132+
get => Version == OpenApiSpecVersion.OpenApi3_0;
133+
set => Version = OpenApiSpecVersion.OpenApi3_0;
134134
}
135135

136136
/// <summary>
@@ -200,8 +200,8 @@ private string WriteContents(OpenApiDocument document)
200200
var outputStream = new MemoryStream();
201201
document.Serialize(
202202
outputStream,
203-
IsV3 ? OpenApiSpecVersion.OpenApi3_0 : OpenApiSpecVersion.OpenApi2_0,
204-
_format == "Yaml" ? OpenApiFormat.Yaml : OpenApiFormat.Json);
203+
Version,
204+
Format);
205205

206206
outputStream.Position = 0;
207207

src/Microsoft.OpenApi.Workbench/MainWindow.xaml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,31 @@
1111
<ColumnDefinition/>
1212
<ColumnDefinition />
1313
</Grid.ColumnDefinitions>
14-
<TextBox x:Name="txtInput" Text="{Binding Input}" Margin="10" TextWrapping="Wrap" AcceptsReturn="True" FontFamily="Consolas" />
14+
<TextBox x:Name="txtInput" Text="{Binding Input}" VerticalScrollBarVisibility="Auto" Margin="10" TextWrapping="Wrap" AcceptsReturn="True" FontFamily="Consolas" />
1515
<DockPanel Grid.Column="1" Margin="0,10" >
16-
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
17-
<Button Content="Convert" VerticalAlignment="Center" HorizontalAlignment="Left" Height="20" Margin="10" Width="131" Click="Button_Click" Grid.Column="1"/>
18-
<StackPanel Orientation="Vertical" DockPanel.Dock="Top">
19-
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
20-
<Label>Format:</Label>
21-
<RadioButton GroupName="Format" Content="Yaml" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsYaml }" />
22-
<RadioButton GroupName="Format" Content="JSON" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsJson }" />
23-
</StackPanel>
24-
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
25-
<Label>Version:</Label>
26-
<RadioButton GroupName="Format" Content="V3" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsV3 }" />
27-
<RadioButton GroupName="Format" Content="V2" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsV2 }" />
28-
</StackPanel>
29-
</StackPanel>
30-
</StackPanel>
31-
16+
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
17+
<Button Content="Convert" VerticalAlignment="Center" HorizontalAlignment="Left" Height="20" Margin="10" Width="131" Click="Button_Click" Grid.Column="1"/>
18+
<StackPanel Orientation="Vertical" DockPanel.Dock="Top">
19+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
20+
<Label>Format:</Label>
21+
<RadioButton GroupName="Format" Content="YAML" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsYaml}" />
22+
<RadioButton GroupName="Format" Content="JSON" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsJson}" />
23+
</StackPanel>
24+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
25+
<Label>Version:</Label>
26+
<RadioButton GroupName="Format" Content="V3.0.1" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsV3_0}" />
27+
<RadioButton GroupName="Format" Content="V2.0" Padding="5" Height="24" VerticalAlignment="Top" IsChecked="{Binding IsV2_0}" />
28+
</StackPanel>
29+
</StackPanel>
30+
</StackPanel>
3231
<TextBox x:Name="txtErrors" Margin="10,10,10,10" TextWrapping="Wrap" Text="{Binding Errors}" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" DockPanel.Dock="Top" MaxHeight="100" ScrollViewer.VerticalScrollBarVisibility="Auto" IsReadOnlyCaretVisible="True" IsManipulationEnabled="True" />
3332
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
3433
<Label>Parsing: </Label>
3534
<TextBlock x:Name="txtParseTime" Text="{Binding ParseTime}" Width="100" VerticalAlignment="Center"/>
3635
<Label>Rendering:</Label>
3736
<TextBlock x:Name="txtRenderTime" Text="{Binding RenderTime}" VerticalAlignment="Center"/>
3837
</StackPanel>
39-
<TextBox x:Name="txtOutput" Text="{Binding Output}" VerticalScrollBarVisibility="Auto" Margin="10,10,10,10" VerticalAlignment="Stretch" TextWrapping="Wrap" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" FontFamily="Consolas" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Stretch" IsManipulationEnabled="True" HorizontalScrollBarVisibility="Auto" DockPanel.Dock="Top" />
38+
<TextBox x:Name="txtOutput" Text="{Binding Output}" VerticalScrollBarVisibility="Auto" Margin="10,10,10,0" VerticalAlignment="Stretch" TextWrapping="Wrap" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" FontFamily="Consolas" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Stretch" IsManipulationEnabled="True" HorizontalScrollBarVisibility="Auto" DockPanel.Dock="Top" />
4039

4140
</DockPanel>
4241
</Grid>

0 commit comments

Comments
 (0)