276 lines
15 KiB
Plaintext
276 lines
15 KiB
Plaintext
|
|
<controls:MaterialWindow x:Class="Szmedi.AIScriptRunner.RvScript.RoslynEditor"
|
||
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||
|
|
xmlns:avalonDock="https://github.com/Dirkster99/AvalonDock"
|
||
|
|
xmlns:codeActions="clr-namespace:Microsoft.CodeAnalysis.CodeActions;assembly=Microsoft.CodeAnalysis.Workspaces"
|
||
|
|
xmlns:codeFixes="clr-namespace:RoslynPad.Roslyn.CodeFixes;assembly=RoslynPad.Roslyn"
|
||
|
|
xmlns:controls="clr-namespace:Szmedi.AIScriptRunner.Controls"
|
||
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||
|
|
xmlns:editor="clr-namespace:RoslynPad.Editor;assembly=RoslynPad.Editor.Windows"
|
||
|
|
xmlns:local="clr-namespace:Szmedi.AIScriptRunner.RvScript"
|
||
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||
|
|
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||
|
|
Width="800"
|
||
|
|
Height="500"
|
||
|
|
Background="{DynamicResource MaterialDesign.Brush.Background}"
|
||
|
|
mc:Ignorable="d"
|
||
|
|
Closing="Window_Closing"
|
||
|
|
d:DataContext="{d:DesignInstance local:RoslynEditorViewModel}"
|
||
|
|
ResizeMode="CanResize"
|
||
|
|
SizeToContent="Manual"
|
||
|
|
Style="{DynamicResource SZMEDIWindowStyle}"
|
||
|
|
Title="C#脚本执行">
|
||
|
|
<Window.Resources>
|
||
|
|
<ResourceDictionary>
|
||
|
|
<ResourceDictionary.MergedDictionaries>
|
||
|
|
<ResourceDictionary Source="pack://application:,,,/Szmedi.AIScriptRunner;component/Icons.xaml" />
|
||
|
|
<ResourceDictionary Source="pack://application:,,,/Szmedi.AIScriptRunner;component/WPFUI.xaml" />
|
||
|
|
</ResourceDictionary.MergedDictionaries>
|
||
|
|
<HierarchicalDataTemplate DataType="{x:Type codeFixes:CodeFixCollection}" ItemsSource="{Binding Fixes, Mode=OneTime}">
|
||
|
|
<TextBlock Text="{Binding Provider, Mode=OneTime}" />
|
||
|
|
</HierarchicalDataTemplate>
|
||
|
|
<HierarchicalDataTemplate DataType="{x:Type codeFixes:CodeFix}" ItemsSource="{Binding Action,
|
||
|
|
Mode=OneTime,
|
||
|
|
Converter={local:CodeActionsConverter}}">
|
||
|
|
<ContentPresenter Content="{Binding Action, Mode=OneTime}" />
|
||
|
|
</HierarchicalDataTemplate>
|
||
|
|
<DataTemplate DataType="{x:Type codeActions:CodeAction}">
|
||
|
|
<TextBlock Text="{Binding Title, Mode=OneTime}" />
|
||
|
|
</DataTemplate>
|
||
|
|
</ResourceDictionary>
|
||
|
|
</Window.Resources>
|
||
|
|
<Window.InputBindings>
|
||
|
|
<KeyBinding Key="F5" Command="{Binding ActiveDocument.RunCommand}" />
|
||
|
|
<KeyBinding Command="{Binding ActiveDocument.SaveCommand}" Gesture="Ctrl+S" />
|
||
|
|
<KeyBinding Command="{Binding ActiveDocument.FormatCommand}" Gesture="Ctrl+F8" />
|
||
|
|
</Window.InputBindings>
|
||
|
|
<Grid>
|
||
|
|
<Grid.ColumnDefinitions>
|
||
|
|
<ColumnDefinition Width="*" MinWidth="30" />
|
||
|
|
<ColumnDefinition Width="2" />
|
||
|
|
<ColumnDefinition Width="0.6*" MinWidth="20" />
|
||
|
|
</Grid.ColumnDefinitions>
|
||
|
|
<Grid.RowDefinitions>
|
||
|
|
<RowDefinition Height="Auto" />
|
||
|
|
<RowDefinition Height="Auto" />
|
||
|
|
<RowDefinition Height="Auto" />
|
||
|
|
<RowDefinition Height="*" MinHeight="20" />
|
||
|
|
<RowDefinition Height="2" />
|
||
|
|
<RowDefinition Height="60" MinHeight="60" />
|
||
|
|
</Grid.RowDefinitions>
|
||
|
|
<!-- <StackPanel HorizontalAlignment="Left" Grid.Column="0">
|
||
|
|
<Button Name="ScriptRunner" Click="ScriptRunner_Click">Run Script</Button>
|
||
|
|
</StackPanel> -->
|
||
|
|
<DockPanel Grid.Row="0" Grid.Column="0">
|
||
|
|
<Menu DockPanel.Dock="Top">
|
||
|
|
<MenuItem Header="文件">
|
||
|
|
<MenuItem Command="{Binding NewCommand}" Header="新建脚本">
|
||
|
|
<MenuItem.Icon>
|
||
|
|
<md:PackIcon Kind="File" />
|
||
|
|
</MenuItem.Icon>
|
||
|
|
</MenuItem>
|
||
|
|
<MenuItem Command="{Binding OpenCommand}" Header="打开脚本">
|
||
|
|
<MenuItem.Icon>
|
||
|
|
<md:PackIcon Kind="OpenInNew" />
|
||
|
|
</MenuItem.Icon>
|
||
|
|
</MenuItem>
|
||
|
|
<MenuItem Command="{Binding ActiveDocument.SaveCommand}" Header="保存">
|
||
|
|
<MenuItem.Icon>
|
||
|
|
<md:PackIcon Kind="ContentSave" />
|
||
|
|
</MenuItem.Icon>
|
||
|
|
</MenuItem>
|
||
|
|
<MenuItem Command="{Binding ActiveDocument.SaveAsCommand}" Header="另存为">
|
||
|
|
<MenuItem.Icon>
|
||
|
|
<md:PackIcon Kind="ContentSaveAdd" />
|
||
|
|
</MenuItem.Icon>
|
||
|
|
</MenuItem>
|
||
|
|
<!-- <MenuItem Header="退出">
|
||
|
|
<MenuItem.Icon>
|
||
|
|
<md:PackIcon Kind="ExitRun" />
|
||
|
|
</MenuItem.Icon>
|
||
|
|
</MenuItem> -->
|
||
|
|
</MenuItem>
|
||
|
|
<MenuItem Header="运行">
|
||
|
|
<MenuItem Command="{Binding ActiveDocument.RunCommand}" Header="执行脚本">
|
||
|
|
<MenuItem.Icon>
|
||
|
|
<md:PackIcon Kind="Play" />
|
||
|
|
</MenuItem.Icon>
|
||
|
|
</MenuItem>
|
||
|
|
</MenuItem>
|
||
|
|
<MenuItem Header="帮助">
|
||
|
|
<MenuItem Command="{Binding AboutCommand}" Header="关于">
|
||
|
|
<MenuItem.Icon>
|
||
|
|
<md:PackIcon Kind="Information" />
|
||
|
|
</MenuItem.Icon>
|
||
|
|
</MenuItem>
|
||
|
|
</MenuItem>
|
||
|
|
</Menu>
|
||
|
|
</DockPanel>
|
||
|
|
<ToolBar Grid.Row="1">
|
||
|
|
<Button x:Name="New"
|
||
|
|
Command="{Binding NewCommand}"
|
||
|
|
ToolTip="新建脚本">
|
||
|
|
<md:PackIcon Kind="File" />
|
||
|
|
<!-- <ContentControl Template="{StaticResource ResourceKey=NewFile}" ToolTip="新建脚本" /> -->
|
||
|
|
</Button>
|
||
|
|
<Button x:Name="Open_Script"
|
||
|
|
Command="{Binding OpenCommand}"
|
||
|
|
ToolTip="打开脚本">
|
||
|
|
<!-- <md:PackIcon Kind="OpenInApp" /> -->
|
||
|
|
<Image Width="16"
|
||
|
|
Height="16"
|
||
|
|
Source="{StaticResource OpenSciptFile}" />
|
||
|
|
<!-- <ContentControl Template="{StaticResource ResourceKey=OpenFile}" ToolTip="打开脚本" /> -->
|
||
|
|
</Button>
|
||
|
|
<Separator />
|
||
|
|
<Button x:Name="Save"
|
||
|
|
Command="{Binding ActiveDocument.SaveCommand}"
|
||
|
|
ToolTip="保存脚本">
|
||
|
|
<md:PackIcon Kind="ContentSave" />
|
||
|
|
<!-- <ContentControl Template="{StaticResource ResourceKey=SaveFile}" ToolTip="保存脚本" /> -->
|
||
|
|
</Button>
|
||
|
|
<Button x:Name="Save_As"
|
||
|
|
Command="{Binding ActiveDocument.SaveAsCommand}"
|
||
|
|
ToolTip="另存为脚本">
|
||
|
|
<md:PackIcon Kind="ContentSaveAdd" />
|
||
|
|
<!-- <ContentControl Template="{StaticResource ResourceKey=SaveAsFile}" ToolTip="另存为脚本" /> -->
|
||
|
|
</Button>
|
||
|
|
<Button Command="Undo" ToolTip="撤销">
|
||
|
|
<md:PackIcon Kind="Undo" />
|
||
|
|
</Button>
|
||
|
|
<Button Command="Redo" ToolTip="重做">
|
||
|
|
<md:PackIcon Kind="Redo" />
|
||
|
|
</Button>
|
||
|
|
<Button Command="{Binding ActiveDocument.CommentCommand}"
|
||
|
|
CommandParameter="{Binding ElementName=dockManager}"
|
||
|
|
Name="CommentBtn"
|
||
|
|
ToolTip="注释">
|
||
|
|
<Image Width="22"
|
||
|
|
Height="22"
|
||
|
|
Source="{StaticResource Comments}" />
|
||
|
|
<!-- <md:PackIcon Kind="CommentOutline" /> -->
|
||
|
|
</Button>
|
||
|
|
<Button Command="{Binding ActiveDocument.UnCommentCommand}"
|
||
|
|
CommandParameter="{Binding ElementName=dockManager}"
|
||
|
|
Name="UnCommentBtn"
|
||
|
|
ToolTip="取消注释">
|
||
|
|
<!-- <md:PackIcon Kind="CommentOffOutline" /> -->
|
||
|
|
<Image Width="22"
|
||
|
|
Height="22"
|
||
|
|
Source="{StaticResource UnComments}" />
|
||
|
|
</Button>
|
||
|
|
<Button Command="{Binding ActiveDocument.FormatCommand}"
|
||
|
|
Name="formatBtn"
|
||
|
|
ToolTip="格式化脚本">
|
||
|
|
<!-- <md:PackIcon Kind="FormatText" /> -->
|
||
|
|
<Image Width="22"
|
||
|
|
Height="22"
|
||
|
|
Source="{StaticResource FormatCode}" />
|
||
|
|
</Button>
|
||
|
|
<!-- <Button x:Name="CloseScript" Command="{Binding ActiveDocument.CloseCommand}" Content="关闭脚本" /> -->
|
||
|
|
<Separator />
|
||
|
|
<Button x:Name="Run"
|
||
|
|
Command="{Binding ActiveDocument.RunCommand}"
|
||
|
|
ToolTip="运行脚本">
|
||
|
|
<md:PackIcon Kind="Play" />
|
||
|
|
</Button>
|
||
|
|
</ToolBar>
|
||
|
|
<ProgressBar Grid.Row="2"
|
||
|
|
Height="5"
|
||
|
|
IsIndeterminate="True"
|
||
|
|
Visibility="{Binding IsRunning}" />
|
||
|
|
<avalonDock:DockingManager x:Name="dockManager"
|
||
|
|
Grid.Row="3"
|
||
|
|
ActiveContent="{Binding ActiveDocument, Mode=TwoWay}"
|
||
|
|
Background="{DynamicResource MaterialDesign.Brush.Background}"
|
||
|
|
DocumentClosing="dockManager_DocumentClosing"
|
||
|
|
DocumentsSource="{Binding Documents}"
|
||
|
|
TextElement.Foreground="{DynamicResource MaterialDesign.Brush.Foreground}">
|
||
|
|
<avalonDock:DockingManager.Resources>
|
||
|
|
<ResourceDictionary>
|
||
|
|
<ResourceDictionary.MergedDictionaries>
|
||
|
|
<ResourceDictionary Source="pack://application:,,,/Szmedi.AIScriptRunner;component/RvScript/Generic.xaml" />
|
||
|
|
<ResourceDictionary Source="pack://application:,,,/AvalonDock.Themes.VS2013;component/DarkTheme.xaml" />
|
||
|
|
</ResourceDictionary.MergedDictionaries>
|
||
|
|
</ResourceDictionary>
|
||
|
|
</avalonDock:DockingManager.Resources>
|
||
|
|
<avalonDock:DockingManager.DocumentHeaderTemplate>
|
||
|
|
<DataTemplate>
|
||
|
|
<StackPanel Orientation="Horizontal">
|
||
|
|
<TextBlock VerticalAlignment="Center"
|
||
|
|
Text="{Binding Content.FileName, Mode=OneWay}"
|
||
|
|
TextTrimming="CharacterEllipsis" />
|
||
|
|
</StackPanel>
|
||
|
|
</DataTemplate>
|
||
|
|
</avalonDock:DockingManager.DocumentHeaderTemplate>
|
||
|
|
<avalonDock:DockingManager.LayoutItemTemplateSelector>
|
||
|
|
<local:DocumentTemplateSelector>
|
||
|
|
<local:DocumentTemplateSelector.DocumentViewTemplate>
|
||
|
|
<DataTemplate>
|
||
|
|
<editor:RoslynCodeEditor x:Name="CodeEditor"
|
||
|
|
IsModified="{Binding IsDirty,
|
||
|
|
Mode=TwoWay,
|
||
|
|
UpdateSourceTrigger=PropertyChanged}"
|
||
|
|
IsReadOnly="{Binding IsReadOnly}"
|
||
|
|
Loaded="CodeEditor_Loaded" />
|
||
|
|
<!-- <ed:TextEditor
|
||
|
|
x:Name="CodeEditor"
|
||
|
|
IsModified="{Binding IsDirty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||
|
|
IsReadOnly="{Binding IsReadOnly}"
|
||
|
|
Loaded="CodeEditor_Loaded" /> -->
|
||
|
|
</DataTemplate>
|
||
|
|
</local:DocumentTemplateSelector.DocumentViewTemplate>
|
||
|
|
</local:DocumentTemplateSelector>
|
||
|
|
</avalonDock:DockingManager.LayoutItemTemplateSelector>
|
||
|
|
<avalonDock:LayoutRoot>
|
||
|
|
<avalonDock:LayoutPanel Orientation="Vertical">
|
||
|
|
<avalonDock:LayoutDocumentPane />
|
||
|
|
</avalonDock:LayoutPanel>
|
||
|
|
</avalonDock:LayoutRoot>
|
||
|
|
</avalonDock:DockingManager>
|
||
|
|
<!-- <editor:RoslynCodeEditor x:Name="CodeEditor" SyntaxHighlighting="C#" Grid.Column="0" Grid.Row="1" ShowLineNumbers="False" Margin="5" Loaded="CodeEditor_Loaded"></editor:RoslynCodeEditor> -->
|
||
|
|
<GridSplitter Grid.Row="0"
|
||
|
|
Grid.RowSpan="4"
|
||
|
|
Grid.Column="1"
|
||
|
|
Width="2"
|
||
|
|
HorizontalAlignment="Stretch"
|
||
|
|
VerticalAlignment="Stretch"
|
||
|
|
ResizeDirection="Columns" />
|
||
|
|
<local:ChatDialogue Grid.Row="0"
|
||
|
|
Grid.RowSpan="6"
|
||
|
|
Grid.Column="2"
|
||
|
|
MinWidth="300"
|
||
|
|
HorizontalAlignment="Stretch"
|
||
|
|
VerticalAlignment="Stretch" />
|
||
|
|
<GridSplitter Grid.Row="4"
|
||
|
|
Height="2"
|
||
|
|
HorizontalAlignment="Stretch"
|
||
|
|
VerticalAlignment="Stretch" />
|
||
|
|
<ScrollViewer Grid.Row="5"
|
||
|
|
Grid.Column="0"
|
||
|
|
VerticalScrollBarVisibility="Auto">
|
||
|
|
<TextBox IsReadOnly="True"
|
||
|
|
Text="{Binding Result}"
|
||
|
|
TextAlignment="Left" />
|
||
|
|
</ScrollViewer>
|
||
|
|
<StackPanel Grid.Row="5"
|
||
|
|
Grid.Column="2"
|
||
|
|
HorizontalAlignment="Left"
|
||
|
|
VerticalAlignment="Bottom"
|
||
|
|
Orientation="Horizontal">
|
||
|
|
<Button Margin="5"
|
||
|
|
HorizontalAlignment="Left"
|
||
|
|
VerticalAlignment="Bottom"
|
||
|
|
Command="{Binding RunCodeCommand}"
|
||
|
|
ToolTip="直接执行对话中的代码">
|
||
|
|
<md:PackIcon Kind="Code" />
|
||
|
|
</Button>
|
||
|
|
<Button Margin="5"
|
||
|
|
Command="{Binding CopyCodeCommand}"
|
||
|
|
ToolTip="复制对话中的代码">
|
||
|
|
<md:PackIcon Kind="ContentCopy" />
|
||
|
|
</Button>
|
||
|
|
</StackPanel>
|
||
|
|
</Grid>
|
||
|
|
|
||
|
|
</controls:MaterialWindow>
|