Skip to content

Commit 07424df

Browse files
committed
v2.0 released
1 parent b664cab commit 07424df

20 files changed

+278
-564
lines changed

RST/screenshot.png

15.8 KB
Loading

RST/screenshot2.png

91.6 KB
Loading

RoslynSyntaxTool/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public App()
3333
//ViewModels
3434
.AddSingleton<MainViewModel>()
3535
.AddSingleton<IndexPageViewModel>()
36+
.AddSingleton<SyntaxDetailViewerViewModel>()
3637
.AddSingleton<SettingPageViewModel>()
3738
.AddSingleton<ConvertToCSharpPageViewModel>()
3839
.AddSingleton<SyntaxTreeViewerViewModel>()

RoslynSyntaxTool/Control/SyntaxDetailViewer.xaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="clr-namespace:Workshop.Control"
7-
mc:Ignorable="d"
6+
xmlns:local="clr-namespace:Workshop.Control" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
7+
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
8+
mc:Ignorable="d"
89
d:DesignHeight="450" d:DesignWidth="800"
910
DataContext="{Binding Source={StaticResource Locator},Path=SyntaxDetailViewer}">
1011

@@ -17,13 +18,8 @@
1718
<TextBlock ></TextBlock>
1819
<TextBlock ></TextBlock>
1920
</StackPanel>
20-
<TreeView Grid.Row="1" ItemsSource="{Binding RootItems}">
21-
<TreeView.ItemTemplate>
22-
<HierarchicalDataTemplate
23-
ItemsSource="{Binding Items}">
24-
<TextBlock Text="{Binding Header}" ></TextBlock>
25-
</HierarchicalDataTemplate>
26-
</TreeView.ItemTemplate>
27-
</TreeView>
21+
<xctk:PropertyGrid Grid.Row="1" Background="White" BorderBrush="White" SelectedObject="{Binding CurrentItem}"></xctk:PropertyGrid>
22+
23+
2824
</Grid>
2925
</UserControl>

RoslynSyntaxTool/Control/SyntaxDetailViewer.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ namespace Workshop.Control
3030
/// <summary>
3131
/// SyntaxTreeViewer.xaml 的交互逻辑
3232
/// </summary>
33-
public partial class SyntaxTreeViewer : UserControl
33+
public partial class SyntaxDetailViewer : UserControl
3434
{
35-
public SyntaxTreeViewer()
35+
public SyntaxDetailViewer()
3636
{
3737
InitializeComponent();
3838

RoslynSyntaxTool/Control/SyntaxTreeViewer.xaml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,41 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
67
xmlns:local="clr-namespace:Workshop.Control"
78
mc:Ignorable="d"
89
d:DesignHeight="450" d:DesignWidth="800"
910
DataContext="{Binding Source={StaticResource Locator},Path=SyntaxTreeViewer}">
11+
<UserControl.Resources>
12+
<Style x:Key="TreeViewStyle" TargetType="TreeViewItem">
13+
<Setter Property="IsSelected" Value="{Binding IsExpanded, Mode=TwoWay}"/>
14+
</Style>
15+
</UserControl.Resources>
1016

1117
<Grid>
12-
<Grid.RowDefinitions>
13-
<RowDefinition Height="Auto"></RowDefinition>
14-
<RowDefinition Height="*"></RowDefinition>
15-
</Grid.RowDefinitions>
16-
<StackPanel>
17-
<TextBlock ></TextBlock>
18-
<TextBlock ></TextBlock>
19-
</StackPanel>
20-
<TreeView Grid.Row="1" ItemsSource="{Binding RootItems}">
18+
<Grid.ColumnDefinitions>
19+
<ColumnDefinition Width="2*"></ColumnDefinition>
20+
<ColumnDefinition></ColumnDefinition>
21+
</Grid.ColumnDefinitions>
22+
23+
<TreeView Grid.Column="0"
24+
SelectedItemChanged="TreeView_SelectedItemChanged"
25+
ItemsSource="{Binding RootItems}"
26+
ItemContainerStyle="{StaticResource TreeViewStyle}">
2127
<TreeView.ItemTemplate>
22-
<HierarchicalDataTemplate
28+
<HierarchicalDataTemplate
29+
2330
ItemsSource="{Binding Items}">
24-
<TextBlock Text="{Binding Header}" ></TextBlock>
31+
<TextBlock Foreground="{Binding Background}" Text="{Binding Header}" ToolTip="{Binding ToolTip}"></TextBlock>
2532
</HierarchicalDataTemplate>
2633
</TreeView.ItemTemplate>
2734
</TreeView>
35+
<StackPanel Grid.Column="1">
36+
<local:SimpleKeyValueControl KeyText="Kind"
37+
ValueText="{Binding Kind}"></local:SimpleKeyValueControl>
38+
<local:SimpleKeyValueControl KeyText="Type"
39+
ValueText="{Binding Type}"></local:SimpleKeyValueControl>
40+
41+
</StackPanel>
2842
</Grid>
2943
</UserControl>

RoslynSyntaxTool/Control/SyntaxTreeViewer.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ public SyntaxTreeViewer()
3939

4040
}
4141

42-
42+
private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
43+
{
44+
(this.DataContext as SyntaxTreeViewerViewModel).CurrentItem=e.NewValue as SyntaxTreeItemInfo;
4345

46+
}
4447
}
4548

4649
}

RoslynSyntaxTool/MainWindow.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
99
mc:Ignorable="d"
1010
WindowState="Maximized"
11-
Title="Roslyn Syntax Tool 版本1.1" Height="720" Width="1080">
11+
Title="Roslyn Syntax Tool 版本2.0" Height="720" Width="1080">
1212
<mah:MetroWindow.RightWindowCommands>
1313
<mah:WindowCommands>
1414
<Button Content="关于" Click="ButtonBase_OnClick"></Button>
@@ -112,9 +112,9 @@
112112
<!-- Items -->
113113
<mah:HamburgerMenu.ItemsSource>
114114
<mah:HamburgerMenuItemCollection>
115-
<mah:HamburgerMenuIconItem Label="C# 转 Syntax" Tag="./View/IndexPage.xaml">
115+
<mah:HamburgerMenuIconItem Label="C# To SyntaxTree" Tag="./View/IndexPage.xaml">
116116
</mah:HamburgerMenuIconItem>
117-
<mah:HamburgerMenuIconItem Label="Syntax 转 C#" Tag="./View/ConvertToCSharpPage.xaml">
117+
<mah:HamburgerMenuIconItem Label="SyntaxTree To C#" Tag="./View/ConvertToCSharpPage.xaml">
118118
</mah:HamburgerMenuIconItem>
119119
<mah:HamburgerMenuIconItem Label="设置" Tag="./View/SettingPage.xaml">
120120
</mah:HamburgerMenuIconItem>
Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using System;
23
using System.Collections.Generic;
34
using System.Collections.ObjectModel;
45
using System.Linq;
@@ -8,22 +9,43 @@
89

910
namespace Workshop.Model
1011
{
11-
public class SyntaxTreeItemInfo
12+
public class SyntaxTreeItemInfo : ObservableObject
1213
{
14+
1315
public SyntaxTreeItemInfo()
1416
{
1517
this.Items=new ObservableCollection<SyntaxTreeItemInfo>();
18+
this.PropertyChanged+=SyntaxTreeItemInfo_PropertyChanged;
19+
}
20+
21+
private void SyntaxTreeItemInfo_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
22+
{
23+
if (e.PropertyName == nameof(IsExpanded))
24+
{
25+
this.Expanded?.Invoke(this);
26+
}
1627
}
1728

1829
public SyntaxTag Tag { get; set; }
1930

20-
public bool IsExpanded { get; set; }
31+
private bool _isExpanded;
32+
33+
public bool IsExpanded
34+
{
35+
get { return _isExpanded; }
36+
set
37+
{
38+
_isExpanded = value;
39+
OnPropertyChanged();
40+
}
41+
}
42+
2143

2244
public string Background { get; set; }
2345
public string ToolTip { get; internal set; }
24-
public Action<object, object> Expanded { get; internal set; }
46+
public Action<SyntaxTreeItemInfo> Expanded { get; internal set; }
2547
public string Header { get; internal set; }
2648
public IList<SyntaxTreeItemInfo> Items { get; internal set; }
27-
public Action<object, object> Selected { get; internal set; }
49+
public Action<SyntaxTreeItemInfo> Selected { get; internal set; }
2850
}
2951
}

RoslynSyntaxTool/RoslynSyntaxTool.csproj

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<ItemGroup>
2626
<PackageReference Include="AvalonEdit" Version="6.1.3.50" />
2727
<PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
28+
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.3.0" />
2829
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
2930
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.1.0" />
3031
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.1.0" />
@@ -76,6 +77,12 @@
7677
</Compile>
7778
</ItemGroup>
7879

80+
<ItemGroup>
81+
<None Update="default.txt">
82+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
83+
</None>
84+
</ItemGroup>
85+
7986
<ItemGroup>
8087
<Page Update="Control\ProgressWindow.xaml">
8188
<SubType>Designer</SubType>
@@ -87,10 +94,6 @@
8794
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
8895
<SubType>Designer</SubType>
8996
</Page>
90-
<Page Update="MainWindow.xaml">
91-
<SubType>Designer</SubType>
92-
<Generator>MSBuild:Compile</Generator>
93-
</Page>
9497
<Page Update="Style\ConvertersDictionary.xaml">
9598
<SubType>Designer</SubType>
9699
</Page>

0 commit comments

Comments
 (0)