From 5404728fdb7065c10ee4252057c0d67e9e85660c Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Sat, 1 Aug 2020 11:29:09 +0300 Subject: [PATCH] case s of '1' end MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit допускаются символы в case по строкам --- .../Graphics/Controls/cc18_SimpleCalc.pas | 26 +++++++++++---- .../WPFObjects/StartStopMoveRotation.pas | 32 +++++++++++++++++++ .../TreeConversion/syntax_tree_visitor.cs | 2 ++ bin/Lib/WPFObjects.pas | 2 ++ 4 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 InstallerSamples/Graphics/WPFObjects/StartStopMoveRotation.pas diff --git a/InstallerSamples/Graphics/Controls/cc18_SimpleCalc.pas b/InstallerSamples/Graphics/Controls/cc18_SimpleCalc.pas index e92f47dd6..f28cadba6 100644 --- a/InstallerSamples/Graphics/Controls/cc18_SimpleCalc.pas +++ b/InstallerSamples/Graphics/Controls/cc18_SimpleCalc.pas @@ -8,23 +8,37 @@ begin tb.FontSize := 30; var x := IntegerBox('X:'); var y := IntegerBox('Y:'); + x.Value := Random(0,10); + y.Value := Random(0,10); var cb := new ComboBoxWPF('Операция'); cb.AddRange('+','-','*','/'); + var count := 0; + var sb := StatusBar; + sb.Text := 'Количество вычислений: ' + count; + var b := Button('+'); b.Click := procedure -> begin - case cb.SelectedString of - string('+'): tb.Println($'{x.Value} + {y.Value} = {x.Value + y.Value}'); - string('-'): tb.Println($'{x.Value} - {y.Value} = {x.Value - y.Value}'); - string('*'): tb.Println($'{x.Value} * {y.Value} = {x.Value * y.Value}'); - string('/'): tb.Println($'{x.Value} / {y.Value} = {x.Value / y.Value}'); + case cb.SelectedText of + '+': tb.Println($'{x.Value} + {y.Value} = {x.Value + y.Value}'); + '-': tb.Println($'{x.Value} - {y.Value} = {x.Value - y.Value}'); + '*': tb.Println($'{x.Value} * {y.Value} = {x.Value * y.Value}'); + '/': tb.Println($'{x.Value} / {y.Value} = {x.Value / y.Value}'); end; x.Value := Random(0,10); y.Value := Random(0,10); + count += 1; + sb.Text := 'Количество вычислений: ' + count; + end; + + Button('Очистить').Click := () -> begin + count := 0; + sb.Text := 'Количество вычислений: ' + count; + tb.Clear; end; cb.SelectionChanged := procedure -> begin - b.Text := cb.SelectedString + b.Text := cb.SelectedText end; end. \ No newline at end of file diff --git a/InstallerSamples/Graphics/WPFObjects/StartStopMoveRotation.pas b/InstallerSamples/Graphics/WPFObjects/StartStopMoveRotation.pas new file mode 100644 index 000000000..0b0a911d6 --- /dev/null +++ b/InstallerSamples/Graphics/WPFObjects/StartStopMoveRotation.pas @@ -0,0 +1,32 @@ +// Модуль Controls - StatusBar +uses Controls,WPFObjects; + +// Управление свойствами объекта, связанными с перемещением и поворотом. +// В OnDrawFrame объект сам себя перерисовывает +begin + Window.Title := 'Модуль Controls - StatusBar'; + var l := LeftPanel(180,Colors.Orange); + + var c := new RectangleWPF(50,200,80,50,Colors.Green); + c.Direction := (1,0); + c.Velocity := 0; + c.Tag := 0; // скорость поворота + + OnDrawFrame := dt -> begin + c.MoveTime(dt); + c.RotateAngle += integer(c.Tag) * dt; + end; + + Button('Начать перемещение').Click := procedure -> begin + c.Velocity := 30; + end; + Button('Закончить перемещение').Click := procedure -> begin + c.Velocity := 0; + end; + Button('Начать поворот').Click := procedure -> begin + c.Tag := 30; + end; + Button('Закончить поворот').Click := procedure -> begin + c.Tag := 0; + end; +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index dc4ffd6fb..f5922af35 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -10583,6 +10583,8 @@ namespace PascalABCCompiler.TreeConverter foreach (SyntaxTree.expression expr in cv.conditions.expressions) { expression_node cn = convert_strong(expr); + if (cn.type == SystemLibrary.SystemLibrary.char_type) + cn = convertion_data_and_alghoritms.convert_type(cn, SystemLibrary.SystemLibrary.string_type); if (cn.type != SystemLibrary.SystemLibrary.string_type) AddError(new CanNotConvertTypes(cn, cn.type, SystemLibrary.SystemLibrary.string_type, cn.location)); string_const_node scn = convert_string_const_to_switch(cn, cn.location); diff --git a/bin/Lib/WPFObjects.pas b/bin/Lib/WPFObjects.pas index ad729e806..f8d46bbfa 100644 --- a/bin/Lib/WPFObjects.pas +++ b/bin/Lib/WPFObjects.pas @@ -404,6 +404,8 @@ type begin Result := (Left < 0) or (Top < 0) or (Right > GraphWindow.Width) or (Bottom > GraphWindow.Height); end; + /// Tag хранит любые присоединённые характеристики объекта + auto property Tag: object; end; // -----------------------------------------------------