提交 092cc298 编写于 作者: H Huajiang Wei

improve the visual code editor and add more functions

上级 403751b1
using System;
namespace FontAwesome.WPF
{
/// <summary>
/// Represents the category of a fontawesome icon.
/// </summary>
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
public class IconCategoryAttribute
: Attribute
{
/// <summary>
/// Gets or sets the category of the icon.
/// </summary>
public string Category { get; set; }
/// <summary>
/// Initializes a new instance of the FontAwesome.WPF.IconCategoryAttribute class.
/// </summary>
/// <param name="category">The icon category.</param>
public IconCategoryAttribute(string category)
{
Category = category;
}
}
/// <summary>
/// Represents the field is an alias of another icon.
/// </summary>
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = false)]
public class IconAliasAttribute
: Attribute
{ }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace FontAwesome.WPF
{
/// <summary>
/// Control extensions
/// </summary>
public static class ControlExtensions
{
/// <summary>
/// The key used for storing the spinner Storyboard.
/// </summary>
private static readonly string SpinnerStoryBoardName = String.Format("{0}Spinner", typeof(FontAwesome).Name);
/// <summary>
/// Start the spinning animation
/// </summary>
/// <typeparam name="T">FrameworkElement and ISpinable</typeparam>
/// <param name="control">Control to apply the rotation </param>
public static void BeginSpin<T>(this T control)
where T : FrameworkElement, ISpinable
{
if (!(control.RenderTransform is TransformGroup
&& ((TransformGroup)control.RenderTransform).Children.OfType<RotateTransform>().Any()))
{
var transformGroup = new TransformGroup();
transformGroup.Children.Add(new RotateTransform(0.0));
control.RenderTransform = transformGroup;
control.RenderTransformOrigin = new Point(0.5, 0.5);
}
var storyboard = new Storyboard();
var animation = new DoubleAnimation
{
From = 0,
To = 360,
AutoReverse = false,
RepeatBehavior = RepeatBehavior.Forever,
Duration = new Duration(TimeSpan.FromSeconds(1))
};
storyboard.Children.Add(animation);
Storyboard.SetTarget(animation, control);
Storyboard.SetTargetProperty(animation,
new PropertyPath("(0).(1)[0].(2)", UIElement.RenderTransformProperty,
TransformGroup.ChildrenProperty, RotateTransform.AngleProperty));
storyboard.Begin();
control.Resources.Add(SpinnerStoryBoardName, storyboard);
}
/// <summary>
/// Stop the spinning animation
/// </summary>
/// <typeparam name="T">FrameworkElement and ISpinable</typeparam>
/// <param name="control">Control to stop the rotation.</param>
public static void StopSpin<T>(this T control)
where T : FrameworkElement, ISpinable
{
var storyboard = control.Resources[SpinnerStoryBoardName] as Storyboard;
if (storyboard == null) return;
storyboard.Stop();
control.Resources.Remove(SpinnerStoryBoardName);
}
}
}
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace FontAwesome.WPF
{
/// <summary>
/// Provides a lightweight control for displaying a FontAwesome icon as text.
/// </summary>
public class FontAwesome
: TextBlock, ISpinable
{
/// <summary>
/// FontAwesome FontFamily.
/// </summary>
private static readonly FontFamily FontAwesomeFontFamily = new FontFamily(new Uri("pack://application:,,,/FontAwesome.WPF;component/"), "./#FontAwesome");
/// <summary>
/// The key used for storing the spinner Storyboard.
/// </summary>
private static readonly string StoryBoardName = String.Format("{0}-storyboard-spinner", typeof(FontAwesome).Name);
/// <summary>
/// Identifies the FontAwesome.WPF.FontAwesome.Icon dependency property.
/// </summary>
public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(FontAwesomeIcon), typeof(FontAwesome), new PropertyMetadata(FontAwesomeIcon.None, OnIconPropertyChanged));
/// <summary>
/// Identifies the FontAwesome.WPF.FontAwesome.Spin dependency property.
/// </summary>
public static readonly DependencyProperty SpinProperty =
DependencyProperty.Register("Spin", typeof(bool), typeof(FontAwesome), new PropertyMetadata(false, OnSpinPropertyChanged));
/// <summary>
/// Gets or sets the FontAwesome icon. Changing this property will cause the icon to be redrawn.
/// </summary>
public FontAwesomeIcon Icon
{
get { return (FontAwesomeIcon)GetValue(IconProperty); }
set { SetValue(IconProperty, value); }
}
/// <summary>
/// Gets or sets the current spin (angle) animation of the icon.
/// </summary>
public bool Spin
{
get { return (bool)GetValue(SpinProperty); }
set { SetValue(SpinProperty, value); }
}
private static void OnIconPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.SetValue(FontFamilyProperty, FontAwesomeFontFamily);
d.SetValue(TextAlignmentProperty, TextAlignment.Center);
d.SetValue(TextProperty, char.ConvertFromUtf32((int)e.NewValue));
}
private static void OnSpinPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var fontAwesome = d as FontAwesome;
if (fontAwesome == null) return;
if((bool)e.NewValue)
fontAwesome.BeginSpin();
else
fontAwesome.StopSpin();
}
}
}
此差异已折叠。
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
namespace FontAwesome.WPF
{
/// <summary>
/// Represents a control that draws an FontAwesome icon as an image.
/// </summary>
public class ImageAwesome
: Image, ISpinable
{
/// <summary>
/// FontAwesome FontFamily.
/// </summary>
private static readonly FontFamily FontAwesomeFontFamily = new FontFamily(new Uri("pack://application:,,,/FontAwesome.WPF;component/"), "./#FontAwesome");
/// <summary>
/// Typeface used to generate FontAwesome icon.
/// </summary>
private static readonly Typeface FontAwesomeTypeface = new Typeface(FontAwesomeFontFamily, FontStyles.Normal,
FontWeights.Normal, FontStretches.Normal);
/// <summary>
/// Identifies the FontAwesome.WPF.ImageAwesome.Foreground dependency property.
/// </summary>
public static readonly DependencyProperty ForegroundProperty =
DependencyProperty.Register("Foreground", typeof(Brush), typeof(ImageAwesome), new PropertyMetadata(Brushes.Black, OnIconPropertyChanged));
/// <summary>
/// Identifies the FontAwesome.WPF.ImageAwesome.Icon dependency property.
/// </summary>
public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(FontAwesomeIcon), typeof(ImageAwesome), new PropertyMetadata(FontAwesomeIcon.None, OnIconPropertyChanged));
/// <summary>
/// Identifies the FontAwesome.WPF.ImageAwesome.Spin dependency property.
/// </summary>
public static readonly DependencyProperty SpinProperty =
DependencyProperty.Register("Spin", typeof(bool), typeof(ImageAwesome), new PropertyMetadata(false, OnSpinPropertyChanged));
/// <summary>
/// Gets or sets the foreground brush of the icon. Changing this property will cause the icon to be redrawn.
/// </summary>
public Brush Foreground
{
get { return (Brush)GetValue(ForegroundProperty); }
set { SetValue(ForegroundProperty, value); }
}
/// <summary>
/// Gets or sets the FontAwesome icon. Changing this property will cause the icon to be redrawn.
/// </summary>
public FontAwesomeIcon Icon
{
get { return (FontAwesomeIcon)GetValue(IconProperty); }
set { SetValue(IconProperty, value); }
}
/// <summary>
/// Gets or sets the current spin (angle) animation of the icon.
/// </summary>
public bool Spin
{
get { return (bool)GetValue(SpinProperty); }
set { SetValue(SpinProperty, value); }
}
private static void OnSpinPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var imageAwesome = d as ImageAwesome;
if (imageAwesome == null) return;
if((bool)e.NewValue)
imageAwesome.BeginSpin();
else
imageAwesome.StopSpin();
}
private static void OnIconPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var imageAwesome = d as ImageAwesome;
if (imageAwesome == null) return;
d.SetValue(SourceProperty, CreateImageSource(imageAwesome.Icon, imageAwesome.Foreground));
}
/// <summary>
/// Creates a new System.Windows.Media.ImageSource of a specified FontAwesomeIcon and foreground System.Windows.Media.Brush.
/// </summary>
/// <param name="icon">The FontAwesome icon to be drawn.</param>
/// <param name="foregroundBrush">The System.Windows.Media.Brush to be used as the foreground.</param>
/// <returns>A new System.Windows.Media.ImageSource</returns>
public static ImageSource CreateImageSource(FontAwesomeIcon icon, Brush foregroundBrush)
{
var charIcon = char.ConvertFromUtf32((int)icon);
var visual = new DrawingVisual();
using (var drawingContext = visual.RenderOpen())
{
drawingContext.DrawText(
new FormattedText(charIcon, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
FontAwesomeTypeface, 100, foregroundBrush) { TextAlignment = TextAlignment.Center }, new Point(0, 0));
}
return new DrawingImage(visual.Drawing);
}
}
}
......@@ -2,7 +2,7 @@
This is a visual programming editor like google blocky and scratch, but implemented by WPF and dotnet. Compared with existing tools, the visual script is more like real code, and it has more programming feature. With this tool, you can simply enable your application with a visual code editor and run your visual code.
In the demo, we write a visual code editor, and scratch like editor. If you use it inot other situation, please tell us.
In the demo, we write a visual code editor, and scratch like editor. If you use it in other application, please tell us.
## Features
......@@ -16,6 +16,11 @@ Now following feature was achieved
- loop flow control, including break, continue and return
- try catch finally, exception handling
- array
- support string operation
- support stack, queue, dictionary, list and binary tree
- support sound synthesis
- support translation
- support drawing canvas liking python turtle
Besides the programming feature, this tool has following feature
......@@ -81,9 +86,6 @@ If your execution function, you must return the right completion type, return ex
## Future Plan
- support EV3 control
- support string operation
- support stack, queue, dictionary, list and binary tree
- support sound synthesis
- support file handling
- support switch statement
- static key word for variable and function.
......@@ -94,4 +96,5 @@ If your execution function, you must return the right completion type, return ex
## Screenshot
![ScreenShot](PrintScreen3.png)
![ScreenShot](canvas.png)
![ScreenShot](PrintScreen.PNG)

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScratchNet", "demo\ScratchNet\ScratchNet.csproj", "{79F40D09-D4EE-469F-883D-0D471E22AE20}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptEngine", "src\ScriptEngine\ScriptEngine.csproj", "{9EFE2134-8015-4957-A9E1-F7D2FBB4CDA7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FontAwesome.WPF", "FontAwesome.WPF\FontAwesome.WPF.csproj", "{7006AC9F-D218-4D7B-98EB-5D2D91F69C57}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScratchControl", "src\ScratchControl\ScratchControl.csproj", "{E1C33987-94F5-472F-B191-8CBEDDEE5D99}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptEditor", "src\ScratchEditor\ScriptEditor.csproj", "{801CFD14-89D2-4B1E-9332-B22EC959BABA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{574786AA-DCD3-435B-8411-3C0850428F93}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{98B9AB53-DABC-4E87-B63B-BFFB0B7BAB81}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "improve", "improve", "{CE3FE9EE-1EC5-4CAB-990F-27F21F2586FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoScriptEditor", "demo\DemoScriptEditor\DemoScriptEditor.csproj", "{692B38FD-DD40-4DAE-858C-5966C50E7D3D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{86E202C1-9FAE-4FB1-8259-03A9D423A717}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject", "test\UnitTestProject\UnitTestProject.csproj", "{584AAAFE-1EAE-4F99-9E9B-C375098B7A9E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{79F40D09-D4EE-469F-883D-0D471E22AE20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{79F40D09-D4EE-469F-883D-0D471E22AE20}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79F40D09-D4EE-469F-883D-0D471E22AE20}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79F40D09-D4EE-469F-883D-0D471E22AE20}.Release|Any CPU.Build.0 = Release|Any CPU
{9EFE2134-8015-4957-A9E1-F7D2FBB4CDA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EFE2134-8015-4957-A9E1-F7D2FBB4CDA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EFE2134-8015-4957-A9E1-F7D2FBB4CDA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EFE2134-8015-4957-A9E1-F7D2FBB4CDA7}.Release|Any CPU.Build.0 = Release|Any CPU
{7006AC9F-D218-4D7B-98EB-5D2D91F69C57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7006AC9F-D218-4D7B-98EB-5D2D91F69C57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7006AC9F-D218-4D7B-98EB-5D2D91F69C57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7006AC9F-D218-4D7B-98EB-5D2D91F69C57}.Release|Any CPU.Build.0 = Release|Any CPU
{E1C33987-94F5-472F-B191-8CBEDDEE5D99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1C33987-94F5-472F-B191-8CBEDDEE5D99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1C33987-94F5-472F-B191-8CBEDDEE5D99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1C33987-94F5-472F-B191-8CBEDDEE5D99}.Release|Any CPU.Build.0 = Release|Any CPU
{801CFD14-89D2-4B1E-9332-B22EC959BABA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{801CFD14-89D2-4B1E-9332-B22EC959BABA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{801CFD14-89D2-4B1E-9332-B22EC959BABA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{801CFD14-89D2-4B1E-9332-B22EC959BABA}.Release|Any CPU.Build.0 = Release|Any CPU
{692B38FD-DD40-4DAE-858C-5966C50E7D3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{692B38FD-DD40-4DAE-858C-5966C50E7D3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692B38FD-DD40-4DAE-858C-5966C50E7D3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692B38FD-DD40-4DAE-858C-5966C50E7D3D}.Release|Any CPU.Build.0 = Release|Any CPU
{584AAAFE-1EAE-4F99-9E9B-C375098B7A9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{584AAAFE-1EAE-4F99-9E9B-C375098B7A9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{584AAAFE-1EAE-4F99-9E9B-C375098B7A9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{584AAAFE-1EAE-4F99-9E9B-C375098B7A9E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{79F40D09-D4EE-469F-883D-0D471E22AE20} = {98B9AB53-DABC-4E87-B63B-BFFB0B7BAB81}
{9EFE2134-8015-4957-A9E1-F7D2FBB4CDA7} = {574786AA-DCD3-435B-8411-3C0850428F93}
{7006AC9F-D218-4D7B-98EB-5D2D91F69C57} = {574786AA-DCD3-435B-8411-3C0850428F93}
{E1C33987-94F5-472F-B191-8CBEDDEE5D99} = {CE3FE9EE-1EC5-4CAB-990F-27F21F2586FD}
{801CFD14-89D2-4B1E-9332-B22EC959BABA} = {574786AA-DCD3-435B-8411-3C0850428F93}
{692B38FD-DD40-4DAE-858C-5966C50E7D3D} = {98B9AB53-DABC-4E87-B63B-BFFB0B7BAB81}
{584AAAFE-1EAE-4F99-9E9B-C375098B7A9E} = {86E202C1-9FAE-4FB1-8259-03A9D423A717}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0BD434C9-8675-4D9D-B905-6C481145EB9A}
EndGlobalSection
EndGlobal
此差异已折叠。
<Application x:Class="DemoScriptEditor.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DemoScriptEditor"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="{x:Type Window}">
<Setter Property="FontSize" Value="13"/>
</Style>
</Application.Resources>
</Application>
<Window xmlns:ScratchNet="clr-namespace:ScratchNet;assembly=DemoScriptEditor" x:Class="DemoScriptEditor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DemoScriptEditor"
xmlns:editor="clr-namespace:ScratchNet;assembly=ScriptEditor"
mc:Ignorable="d" WindowState="Maximized"
xmlns:fa="http://schemas.fontawesome.io/icons/"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="5"/>
<RowDefinition Height="150"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Button Margin="5" Grid.Column="2" Click="OnNew" Name="ButtonNew" ToolTip="Create New" Focusable="True">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome Name="StartIcon" FontSize="25" Foreground="Green" Icon="NewspaperOutlined"/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="StartIcon" Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Margin="5" Grid.Column="2" Click="OnOpen" Name="ButtonOpen" IsEnabled="True" ToolTip="Open a File">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome Name="StartIcon" FontSize="25" Foreground="Green" Icon="FolderOpenOutlined"/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="StartIcon" Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Margin="5" Grid.Column="2" Click="OnSave" Name="ButtonSave" IsEnabled="False" ToolTip="Save">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome Name="StartIcon" FontSize="25" Foreground="Green" Icon="Save"/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="StartIcon" Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Margin="5" Grid.Column="2" Click="OnStartRun" Name="ButtonStart" IsEnabled="False" ToolTip="Run">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome Name="StartIcon" FontSize="25" Foreground="Green" Icon="Play"/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="StartIcon" Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Margin="5" Grid.Column="3" Click="OnStopRun" Name="ButtonStop" IsEnabled="False" Visibility="Visible" ToolTip="Stop">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome Name="StartIcon" FontSize="25" Foreground="DarkRed" Icon="Stop"/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="StartIcon" Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Margin="5" Grid.Column="3" Click="OnClearError" Name="ButtonClearError" IsEnabled="true" Visibility="Visible" ToolTip="Clear Error">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome Name="StartIcon" FontSize="25" Foreground="Blue" Icon="Remove"/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="StartIcon" Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<editor:GraphicScriptEditor Grid.Row="1" Name="Editor"/>
<GridSplitter Background="White" Grid.Row="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
ResizeBehavior="PreviousAndNext" ResizeDirection="Rows" ShowsPreview="True"/>
<TabControl Grid.Row="3">
<TabItem Header="Console">
<DataGrid Grid.Row="3" IsReadOnly="True" Name="ConsoleList" AutoGenerateColumns="False" GridLinesVisibility="None">
<DataGrid.Columns>
<DataGridTextColumn Header="Time" Binding="{Binding Path=Time}" Width="150"/>
<DataGridTextColumn Header="Text" Binding="{Binding Path=Text}" Width="*"/>
</DataGrid.Columns>
</DataGrid>
</TabItem>
<TabItem Header="Error">
</TabItem>
</TabControl>
</Grid>
</Window>
using Microsoft.Win32;
using ScratchEditor;
using ScratchNet;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DemoScriptEditor
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
[DllImport("kernel32.dll")]
public static extern Boolean AllocConsole();
[DllImport("kernel32.dll")]
public static extern Boolean FreeConsole();
ObservableCollection<ConsoleItem> consoles = new ObservableCollection<ConsoleItem>();
public MainWindow()
{
AllocConsole();
InitializeComponent();
ConifgFileName =Environment.CurrentDirectory+"\\ "+"config.ini";
Editor.IsEnabled = false;
List<ScriptStepGroup> toolbar = new List<ScriptStepGroup>();
toolbar.Add(new ScriptStepGroup()
{
Name = "Logic",
Types = new List<object>(){
new CompareExpression(),
new LogicExpression(),
new NotExpression()
}
});
toolbar.Add(new ScriptStepGroup()
{
Name = "Number",
Types = new List<object>(){
new BinaryExpression(),
new ConditionalExpression(),
new RandomExpression()
}
});
toolbar.Add(new ScriptStepGroup()
{
Name = "Flow",
Types = new List<object>(){
new IfStatement(),
new IfStatement(){Alternate=new BlockStatement()},
new ForStatement(),
new LoopStatement(),
new WhileStatement(),
new BreakStatement(),
new ContinueStatement(),
new ReturnStatement(),
new TryStatement()
}
});
toolbar.Add(new ScriptStepGroup()
{
Name = "Others",
Types = new List<object>(){
new LogStatement(),
new WaitStatement(),
new ExpressionStatement()
}
});
/*
toolbar.Add(new ScriptStepGroup()
{
Name = "Event",
Types = new List<object>(){
//new StartEventHandler(),
}
});*/
toolbar.Add(new ScriptStepGroup()
{
Name = "Variable",
Types = new List<object>(){
"CreateVariable",
new AssignmentStatement(),
}
});
toolbar.Add(new ScriptStepGroup()
{
Name = "Function",
Types = new List<object>(){
"CreateFunction"
}
});
Editor.SetToolBar(toolbar);
LogStatement.WriteLine = WriteLineFunc;
ConsoleList.ItemsSource = consoles;
new Thread(() =>
{
Thread.Sleep(300);
if (!string.IsNullOrEmpty(File) && System.IO.File.Exists(File))
{
Dispatcher.InvokeAsync(() =>
{
Editor.Script = null;
Editor.IsEnabled = false;
Script script = Serialization.Load(File);
Editor.Script = script;
Editor.IsEnabled = true;
ButtonStart.IsEnabled = true;
ButtonOpen.IsEnabled = true;
ButtonSave.IsEnabled = true;
});
}
}).Start();
}
void WriteLineFunc(object obj, params object[] param)
{
Dispatcher.InvokeAsync(() =>
{
string text = string.Format(obj + "", param);
consoles.Insert(0, new ConsoleItem() { Time = DateTime.Now, Text = text });
});
}
//ExecutionEngine engine;
private void OnStartRun(object sender, RoutedEventArgs e)
{
consoles.Clear();
ExecutionEnvironment engine = new ExecutionEnvironment();
ButtonStart.IsEnabled = false;
ButtonStop.IsEnabled = true;
Editor.IsEnabled = false;
engine.ExecutionCompleted += Engine_ExecutionCompleted;
engine.ExecutionAborted += Engine_ExecutionAborted;
engine.ExecuteAsync(Editor.Script);
Console.WriteLine("Start run");
return;
}
private void Engine_ExecutionCompleted(object engine, object arg)
{
Dispatcher.InvokeAsync(() =>
{
Editor.IsEnabled = true;
ButtonStart.IsEnabled = true;
ButtonStop.IsEnabled = false;
});
}
IErrorHighlight lastErrorEditor;
private void Engine_ExecutionAborted(object engine, Completion arg)
{
if (arg != null)
{
Console.WriteLine(arg.ReturnValue);
Console.WriteLine(arg.Location);
Dispatcher.InvokeAsync(() =>
{
var editor = Editor.FindEditorFor(arg.Location);
if (editor != null)
{
Console.WriteLine("last " + editor);
lastErrorEditor = (editor as IErrorHighlight);
lastErrorEditor?.HighlightError();
}
//var p = Editor.FindParent(arg.Location);
// var pe = Editor.FindEditorFor(p);
});
}
Dispatcher.InvokeAsync(() =>
{
Editor.IsEnabled = true;
ButtonStart.IsEnabled = true;
ButtonStop.IsEnabled = false;
});
}
private void OnStopRun(object sender, RoutedEventArgs e)
{
/*
if (engine != null)
{
engine.ExecutionCompleted -= Engine_ExecutionCompleted;
engine.Stop();
engine = null;
}
*/
}
protected override void OnClosing(CancelEventArgs e)
{
OnStopRun(this, null);
base.OnClosing(e);
}
string _currentFile;
public string File
{
get
{
if(string.IsNullOrEmpty(_currentFile))
_currentFile = ReadValue("Editor", "LastOpen");
return _currentFile;
}
set
{
_currentFile = value;
WriteValue("Editor", "LastOpen", value);
}
}
private void OnOpen(object sender, RoutedEventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.DefaultExt = ".xml";
dlg.Filter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
dlg.Multiselect = false;
dlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
ButtonOpen.IsEnabled = false;
ButtonSave.IsEnabled = false;
ButtonStart.IsEnabled = false;
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
Editor.Script = null;
Editor.IsEnabled = false;
File = dlg.FileName;
Script script = Serialization.Load(File);
Editor.Script = script;
Editor.IsEnabled = true;
ButtonStart.IsEnabled = true;
}
ButtonOpen.IsEnabled = true;
ButtonSave.IsEnabled = true;
}
private void OnSave(object sender, RoutedEventArgs e)
{
ButtonOpen.IsEnabled = false;
ButtonSave.IsEnabled = false;
if (string.IsNullOrEmpty(File))
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.DefaultExt = ".xml";
dlg.Filter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*";
//dlg.Multiselect = false;
dlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
Nullable<bool> result = dlg.ShowDialog();
if (result != true)
{
ButtonOpen.IsEnabled = true;
ButtonSave.IsEnabled = true;
return;
}
File = dlg.FileName;
}
Serialization.Save((Script)Editor.Script, File);
ButtonOpen.IsEnabled = true;
ButtonSave.IsEnabled = true;
}
private void OnNew(object sender, RoutedEventArgs e)
{
File = null;
Editor.Script = new Script();
Editor.IsEnabled = true;
ButtonOpen.IsEnabled = true;
ButtonSave.IsEnabled = true;
ButtonStart.IsEnabled = true;
}
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,
string key, string def, StringBuilder retVal,
int size, string filePath);
[DllImport("kernel32.dll")]
private static extern int GetPrivateProfileSection(string lpAppName, byte[] lpszReturnBuffer, int nSize, string lpFileName);
public void WriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, ConifgFileName);
}
public string ReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp,
255, ConifgFileName);
if (i <= 0)
return null;
String Value = temp.ToString();
return Value;
}
/// <summary>
/// Ini configuration file name
/// </summary>
string ConifgFileName = "config.ini";
private void OnClearError(object sender, RoutedEventArgs e)
{
lastErrorEditor?.ClearHighlightError();
}
/// <summary>
/// constructor
/// </summary>
/// <param name="file">Ini configuration file name</param>
}
}
......@@ -33,13 +33,11 @@
<Button Margin="5" Click="OnLoadFile">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="FolderOpenOutlined"/>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="FolderOpen"/>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<local:ScriptPlayer x:Name="ScriptPlayer"
Grid.Row="1" Margin="5,0,0,0"/>
<StackPanel Margin="5,0,0,0" Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2">
<TextBlock Width="25" HorizontalAlignment="Right">X:</TextBlock>
<TextBlock Name="PositionX" Width="25" HorizontalAlignment="Right"></TextBlock>
......@@ -61,5 +59,7 @@
<local:ResourceList x:Name="ResourceEditor"/>
</TabItem>
</TabControl>
<local:ScriptPlayer x:Name="ScriptPlayer"
Grid.Row="1" Margin="5,0,0,0"/>
</Grid>
</Window>
......@@ -34,6 +34,18 @@ namespace ScratchNet
this.SpriteList.SpriteListView.SelectionChanged += SpriteListView_SelectionChanged;
//this.SpriteList.BackgroundContainer.Checked += BackgroundContainer_Checked;
this.ScriptPlayer.PlayScreen.PreviewMouseMove += PlayScreen_PreviewMouseMove;
ScriptEditor.Register(((Color)ColorConverter.ConvertFromString("#4C97FF")), typeof(MoveStatement),
typeof(RotationStatement), typeof(ReflectionStatement), typeof(SetRotationModeStatement), typeof(SetDegreeStatement),
typeof(SetPositionStatement), typeof(SetPositionXStatement), typeof(SetPositionYStatement), typeof(TimedMoveStatement),
typeof(XPositionExpression), typeof(YPositionExpression), typeof(DegreeExpression));
ScriptEditor.Register(((Color)ColorConverter.ConvertFromString("#9966FF")), typeof(ResizeStatement),
typeof(SetImageStatement), typeof(SetNextImageStatement), typeof(ShowStatement), typeof(HideStatement), typeof(SizeExpression));
ScriptEditor.Register(((Color)ColorConverter.ConvertFromString("#FFBF00")), typeof(StartEventHandler),
typeof(ClickEventHandler), typeof(MessageEvetHandler));
List<ScriptStepGroup> toolbar = new List<ScriptStepGroup>();
toolbar.Add(new ScriptStepGroup()
{
......@@ -71,8 +83,8 @@ namespace ScratchNet
{
Name = Localize.GetString("xc_Logic"),
Types = new List<object>(){
new CompareExpression(),
new LogicExpression(),
new BinaryExpression(){ ValueType="boolean", Operator= Operator.Equal },//compare operator
new BinaryExpression(){ValueType="boolean", Operator= Operator.And },//logical operator
new NotExpression()
}
});
......@@ -115,7 +127,7 @@ namespace ScratchNet
Name = Localize.GetString("xc_Variable"),
Types = new List<object>(){
"CreateVariable",
new AssignmentStatement(),
new ExpressionStatement(){ Expression= new AssignmentExpression() }
}
});
toolbar.Add(new ScriptStepGroup()
......
//------------------------------------------------------------------------------
// <auto-generated>
// このコードはツールによって生成されました。
// ランタイム バージョン:4.0.30319.42000
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
// コードが再生成されるときに損失したりします。
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
......@@ -13,12 +13,12 @@ namespace ScratchNet.Properties {
/// <summary>
/// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// このクラスは StronglyTypedResourceBuilder クラスが ResGen
// または Visual Studio のようなツールを使用して自動生成されました。
// メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
// ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
......@@ -33,7 +33,7 @@ namespace ScratchNet.Properties {
}
/// <summary>
/// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
......@@ -47,8 +47,8 @@ namespace ScratchNet.Properties {
}
/// <summary>
/// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします
/// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
......
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18408
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
......@@ -12,7 +12,7 @@ namespace ScratchNet.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
......
......@@ -29,14 +29,14 @@
<Button Margin="5" Click="OnImportImage">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="CloudUpload"/>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="FolderOpen"/>
</ControlTemplate>
</Button.Template>
</Button>
<Button Margin="5" >
<Button.Template>
<ControlTemplate>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="TimesCircleOutlined"/>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="FileOutline"/>
</ControlTemplate>
</Button.Template>
</Button>
......@@ -120,14 +120,14 @@
<Button Margin="5" >
<Button.Template>
<ControlTemplate>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="PlayCircleOutlined"/>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="PlayCircle"/>
</ControlTemplate>
</Button.Template>
</Button>
<Button Margin="5" >
<Button.Template>
<ControlTemplate>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="TimesCircleOutlined"/>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="TimesCircleOutline"/>
</ControlTemplate>
</Button.Template>
</Button>
......
......@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ScratchNet</RootNamespace>
<AssemblyName>ScratchNet</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
......@@ -37,6 +37,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
<HintPath>..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework.Aero" />
<Reference Include="System" />
<Reference Include="System.Data" />
......@@ -177,6 +180,7 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......@@ -184,9 +188,9 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\FontAwesome.WPF\FontAwesome.WPF.csproj">
<Project>{7006ac9f-d218-4d7b-98eb-5d2d91f69c57}</Project>
<Name>FontAwesome.WPF</Name>
<ProjectReference Include="..\..\src\Math\Math.csproj">
<Project>{a0ff7df5-1936-4cc7-9e49-e2af197ec70f}</Project>
<Name>Math</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\ScratchEditor\ScriptEditor.csproj">
<Project>{801cfd14-89d2-4b1e-9332-b22ec959baba}</Project>
......@@ -196,6 +200,10 @@
<Project>{9efe2134-8015-4957-a9e1-f7d2fbb4cda7}</Project>
<Name>ScriptEngine</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Thread\Thread.csproj">
<Project>{6e2ff20a-0a70-42eb-9d7f-232825741aff}</Project>
<Name>Thread</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="function\" />
......
......@@ -24,7 +24,7 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Button Margin="5" Grid.Column="0">
<Button Margin="5" Grid.Column="0" Click="OnChangeSizeClicked">
<Button.Template>
<ControlTemplate>
<fa:FontAwesome FontSize="25" Foreground="DarkBlue" Icon="ArrowsAlt"/>
......@@ -57,10 +57,10 @@
</Button>
</Grid>
</Border>
<Canvas Name="PlayScreen" ClipToBounds="True" SizeChanged="PlayScreen_SizeChanged" Background="White"
<Canvas Name="PlayScreen" ClipToBounds="True" SizeChanged="PlayScreen_SizeChanged" Background="White" Focusable="True"
Height="{Binding ElementName=PlayerContainer, Path=ActualWidth, Converter={StaticResource ActualWidth43Converter}}"
Grid.Row="1" MouseLeftButtonDown="OnMouseLeftDown" MouseLeftButtonUp="OnMouseLeftUp"
MouseMove="OnMouseMove" MouseLeave="PlayScreen_MouseLeave"
MouseMove="OnMouseMove" MouseLeave="PlayScreen_MouseLeave" KeyDown="OnPalyerKeyDown" KeyUp="OnPlayerKeyUp"
>
</Canvas>
......
......@@ -264,5 +264,19 @@ namespace ScratchNet
DrawScript();
}
private void OnPalyerKeyDown(object sender, KeyEventArgs e)
{
e.Handled = true;
}
private void OnPlayerKeyUp(object sender, KeyEventArgs e)
{
e.Handled = true;
}
public bool IsFullSize = false;
private void OnChangeSizeClicked(object sender, RoutedEventArgs e)
{
IsFullSize = !IsFullSize;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
......@@ -7,11 +7,11 @@ namespace ScratchNet
{
public class HideStatement : Statement
{
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
Sprite sp = enviroment.GetValue("$$INSTANCE$$") as Sprite;
if (sp.Visible)
......@@ -25,7 +25,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -34,7 +34,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -43,13 +43,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -13,11 +13,11 @@ namespace ScratchNet
Message = new Literal() { Raw = "Log Text" };
}
public Expression Message { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (Message == null)
return Completion.Void;
......@@ -31,7 +31,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -42,7 +42,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -51,13 +51,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -12,11 +12,11 @@ namespace ScratchNet
Size = new Literal() { Raw = "90" };
}
public Expression Size { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (Size == null)
return Completion.Void;
......@@ -40,7 +40,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -50,7 +50,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -59,13 +59,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -11,11 +11,11 @@ namespace ScratchNet
{
}
public Expression ImageIndex { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (ImageIndex == null)
return Completion.Void;
......@@ -58,7 +58,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -69,7 +69,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -78,13 +78,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -7,11 +7,11 @@ namespace ScratchNet
{
public class SetNextImageStatement : Statement
{
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
Sprite sp = enviroment.GetValue("$$INSTANCE$$") as Sprite;
int current = sp.CurrentImage;
......@@ -26,7 +26,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -35,7 +35,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -44,13 +44,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -7,11 +7,11 @@ namespace ScratchNet
{
public class ShowStatement : Statement
{
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
Sprite sp = enviroment.GetValue("$$INSTANCE$$") as Sprite;
if (!sp.Visible)
......@@ -25,7 +25,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -34,7 +34,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -43,13 +43,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -7,18 +7,18 @@ namespace ScratchNet
{
public class SizeExpression : Expression
{
public string ReturnType
public override string ReturnType
{
get { return "number"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
Sprite sp = enviroment.GetValue("$$INSTANCE$$") as Sprite;
return new Completion(sp.Size);
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -28,7 +28,7 @@ namespace ScratchNet
}
}
public string Type
public override string Type
{
get { return "XPositionExpression"; }
}
......
......@@ -7,18 +7,18 @@ namespace ScratchNet
{
public class DegreeExpression: Expression
{
public string ReturnType
public override string ReturnType
{
get { return "number"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
Sprite sp = enviroment.GetValue("$$INSTANCE$$") as Sprite;
return new Completion(sp.Direction);
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -28,7 +28,7 @@ namespace ScratchNet
}
}
public string Type
public override string Type
{
get { return "DegreeExpression"; }
}
......
......@@ -12,11 +12,11 @@ namespace ScratchNet
Step = new Literal() { Raw = "5" };
}
public Expression Step { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (Step == null)
return Completion.Void;
......@@ -72,7 +72,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -83,7 +83,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -92,13 +92,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -11,17 +11,21 @@ namespace ScratchNet
public ReflectionStatement()
{
}
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if(enviroment.HasValue("$$ReflectionOnTouchSide&&"))
enviroment.SetValue("$$ReflectionOnTouchSide&&", true);
else
enviroment.RegisterValue("$$ReflectionOnTouchSide&&", true);
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -30,7 +34,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -39,13 +43,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -9,11 +9,11 @@ namespace ScratchNet
{
public Expression Degree { get; set; }
public RotationDirection Direction { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (Degree == null)
return Completion.Void;
......@@ -42,7 +42,7 @@ namespace ScratchNet
return new Completion(result);
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -59,7 +59,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -68,13 +68,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -12,11 +12,11 @@ namespace ScratchNet
Degree = new Literal() { Raw = "0" };
}
public Expression Degree { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (Degree == null)
return Completion.Void;
......@@ -45,7 +45,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -56,7 +56,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -65,13 +65,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -15,11 +15,11 @@ namespace ScratchNet
}
public Expression X { get; set; }
public Expression Y { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (X == null)
return Completion.Void;
......@@ -60,7 +60,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -72,7 +72,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -81,13 +81,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -13,11 +13,11 @@ namespace ScratchNet
X = new Literal() { Raw = "5" };
}
public Expression X { get; set; }
public string ReturnType
public override string ReturnType
{
get { return "void"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
if (X == null)
return Completion.Void;
......@@ -43,7 +43,7 @@ namespace ScratchNet
return Completion.Void;
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -53,7 +53,7 @@ namespace ScratchNet
return desc;
}
}
public string Type
public override string Type
{
get
{
......@@ -62,13 +62,13 @@ namespace ScratchNet
}
public BlockDescriptor BlockDescriptor
public override BlockDescriptor BlockDescriptor
{
get { return null; }
}
public bool IsClosing
public override bool IsClosing
{
get { return false; }
}
......
......@@ -7,18 +7,18 @@ namespace ScratchNet
{
public class XPositionExpression : Expression
{
public string ReturnType
public override string ReturnType
{
get { return "number"; }
}
public Completion Execute(ExecutionEnvironment enviroment)
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
{
double result = (enviroment.GetValue("$$INSTANCE$$") as Sprite).X;
return new Completion(result);
}
public Descriptor Descriptor
public override Descriptor Descriptor
{
get
{
......@@ -28,7 +28,7 @@ namespace ScratchNet
}
}
public string Type
public override string Type
{
get { return "XPositionExpression"; }
}
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net451" />
</packages>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册