AutoInsertCode - малые исправления

WPFObjects - малые дополнения
This commit is contained in:
Mikhalkovich Stanislav 2019-08-07 15:24:12 +03:00
parent bd52663612
commit 49334c73ff
5 changed files with 25 additions and 19 deletions

View file

@ -1,4 +1,4 @@
uses
uses
GraphABC,
ABCObjects,
System.Reflection;

View file

@ -1,4 +1,4 @@
// Клонирование графических объектов
// Клонирование графических объектов
uses ABCObjects,GraphABC;
var bt: TextABC;

View file

@ -2630,7 +2630,8 @@ namespace PascalABCCompiler.TreeConverter
if (convertion_data_and_alghoritms.function_eq_params_and_result(meth, fn))
{
//Нашли нужную функцию
if (meth == fn || fn is common_method_node && (fn as common_method_node).overrided_method == null) sil = null;
if (meth == fn || fn is common_method_node && (fn as common_method_node).overrided_method == null)
sil = null;
break;
}
}
@ -2860,10 +2861,12 @@ namespace PascalABCCompiler.TreeConverter
while (tn != null)
{
common_type_node cint = tn as common_type_node;
if (cint != null)
{
if (_ctn.IsAbstract) return;
if (_ctn.IsStatic) return;
foreach (common_method_node meth in cint.methods)
{
if (meth.polymorphic_state == SemanticTree.polymorphic_state.ps_virtual_abstract)

View file

@ -97,12 +97,18 @@ namespace VisualPascalABC
return false;
var caret = editor.ActiveTextAreaControl.Caret;
int start = TextUtilities.FindPrevWordStart(editor.Document, caret.Offset);
// Нужно, чтобы в Text было последнее слово в строке !!! Исключение - когда в следующей надо сделать просто сдвиг
var Text = editor.Document.GetText(start, caret.Offset - start).TrimEnd();
//var curStrEnd = TextUtilities.GetLineAsString(editor.Document, caret.Line).Substring(caret.Column);
if (Text.ToLower() == "begin")
{
string cur, next, prev;
GetCurNextLines(out cur, out next, out prev);
// Ничего не надо делать если begin - не последнее слово в строке
var curStrEnd = cur.Substring(caret.Column);
if (!string.IsNullOrWhiteSpace(curStrEnd))
return false;
// анализ предыдущей
var icur = Indent(cur);
if (cur.Trim().ToLower() == "begin" && (next == null || Indent(next) < icur || Indent(next) == icur && !next.TrimStart().ToLower().StartsWith("end"))) // значит, это единственное слово begin в строке
@ -144,6 +150,8 @@ namespace VisualPascalABC
{
string cur, next, prev;
GetCurNextLines(out cur, out next, out prev);
if (!string.IsNullOrWhiteSpace(cur.Substring(caret.Column)))
return false;
var icur = Indent(cur);
ta.InsertString("\n" + Spaces(icur + 2));
if (next == null || Indent(next) < icur || Indent(next) == icur && !next.TrimStart().ToLower().StartsWith("until"))
@ -160,6 +168,8 @@ namespace VisualPascalABC
{
string cur, next, prev;
GetCurNextLines(out cur, out next, out prev);
if (!string.IsNullOrWhiteSpace(cur.Substring(caret.Column)))
return false;
var icur = Indent(cur);
ta.InsertString("\n" + Spaces(icur + 2));
if (cur.TrimStart().ToLower().StartsWith("case") && next == null || Indent(next) < icur || Indent(next) == icur && !next.TrimStart().ToLower().StartsWith("end"))
@ -188,7 +198,7 @@ namespace VisualPascalABC
//if (curline.Contains(":=") && !curline.TrimStart().ToLower().StartsWith("for")) // Это наиболее спорно. Надо проверять, что до присваивания - одно имя
if (Regex.IsMatch(curline, @"^\s*\w+\s*:=", RegexOptions.IgnoreCase))
{
var curlinenew = Regex.Replace(curline, @"(\s*)(\S+)(\s*):=(\s*)([^ ;]+)(\s*)(;?)", @"$1$2 := $5;",RegexOptions.IgnoreCase);
var curlinenew = Regex.Replace(curline, @"(\s*)(\S+)(\s*):=(\s*)([^;]+)(\s*)(;?)$", @"$1$2 := $5;",RegexOptions.IgnoreCase);
while (curlinenew.EndsWith(";;"))
curlinenew = curlinenew.Remove(curlinenew.Length - 1);
doc.Replace(seg.Offset, curline.Length, curlinenew);

View file

@ -290,10 +290,6 @@ type
transl.BeginAnimation(TranslateTransform.XProperty, ax, HandoffBehavior.Compose);
transl.BeginAnimation(TranslateTransform.YProperty, ay, HandoffBehavior.Compose);
end;
public
/// Анимирует перемещение графического объекта к точке (x,y) в течение sec секунд
procedure AnimMoveTo(x,y: real; sec: real := 1) := Invoke(AnimMoveToP,x,y,sec);
private
procedure AnimMoveEndP;
begin
var animation := new DoubleAnimation();
@ -301,19 +297,11 @@ type
transl.BeginAnimation(TranslateTransform.XProperty, animation);
transl.BeginAnimation(TranslateTransform.YProperty, animation);
end;
public
/// Завершает анимацию перемещения
procedure AnimMoveEnd := Invoke(AnimMoveEndP);
private
procedure AnimRotateP(a,sec: real);
begin
var an := new DoubleAnimation(a, System.TimeSpan.FromSeconds(sec));
rot.BeginAnimation(RotateTransform.AngleProperty, an, HandoffBehavior.Compose);
end;
public
/// Анимирует вращение графического объекта на угол a в течение sec секунд
procedure AnimRotate(a: real; sec: real := 1) := Invoke(AnimRotateP,a,sec);
private
procedure AnimScaleP(a,sec: real);
begin
var an := new DoubleAnimation(a, System.TimeSpan.FromSeconds(sec));
@ -321,9 +309,14 @@ type
sca.BeginAnimation(ScaleTransform.ScaleYProperty, an, HandoffBehavior.Compose);
end;
public
/// Анимирует перемещение графического объекта к точке (x,y) в течение sec секунд
procedure AnimMoveTo(x,y: real; sec: real := 1) := Invoke(AnimMoveToP,x,y,sec);
/// Завершает анимацию перемещения
procedure AnimMoveEnd := Invoke(AnimMoveEndP);
/// Анимирует вращение графического объекта на угол a в течение sec секунд
procedure AnimRotate(a: real; sec: real := 1) := Invoke(AnimRotateP,a,sec);
/// Анимирует масштабирование графического объекта на величину a в течение sec секунд
procedure AnimScale(a: real; sec: real := 1) := Invoke(AnimScaleP,a,sec);
/// Добавляет к графическому объекту дочерний
procedure AddChild(ch: ObjectWPF; al: Alignment := Alignment.LeftTop);
/// Удаляет из графического объекта дочерний
@ -439,8 +432,8 @@ type
function SetText(txt: string; size: real := 16; fontname: string := 'Arial'; c: GColor := Colors.Black): EllipseWPF
:= inherited SetText(txt,size,fontname,c) as EllipseWPF;
/// Декоратор поворота объекта
function SetRotate(da: real): EllipseWPF
:= inherited SetRotate(da) as EllipseWPF;
function SetRotate(da: real): EllipseWPF := inherited SetRotate(da) as EllipseWPF;
///
end;
// -----------------------------------------------------