Esempio n. 1
0
 private static bool TryFindLineWithValueSettingToVariable(int realLineWithStartValueIndex, int lineWithStartValueIndex, Variable variable)
 {
     for (int j = lineWithStartValueIndex + 1; j < variable.Lines.Count; j++)
     {
         if (Line.IsSettingValueToVariable(variable.Lines[j], variable))
         {
             if (FirstTask.IsLineInBlock(variable.Lines[lineWithStartValueIndex], out CodeBlock block))
             {
                 List <CodeBlock> connectedBlocks = FirstTask.Get_IF_ConnectedBlocks(block);
                 if (IsLineIn_IF_ConnectedBlock(connectedBlocks, variable.Lines[j]))
                 {
                     return(TryFindLineWithValueSettingToVariable(realLineWithStartValueIndex, j, variable));
                 }
             }
             string clarification;
             if (variable.IsParameter)
             {
                 clarification = "Начальное значение изменяется в строке " + (variable.Lines[j] + 1).ToString() + ".";
             }
             else
             {
                 clarification = "Начальное значение задается в строке " + (variable.Lines[realLineWithStartValueIndex] + 1).ToString() + ", изменяется в строке " + (variable.Lines[j] + 1).ToString() + ".";
             }
             variable.SetGroup(Group.M, clarification, true);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 2
0
        public Grid GetGrid(int number, bool needsBottomBorder, double fontSize, Brush background)
        {
            Grid grid = new Grid();

            MarkupGrid(ref grid, needsBottomBorder);

            string lines;

            if (Operator == Data.IF.Text)
            {
                List <CodeBlock> list = FirstTask.Get_IF_ConnectedBlocks(this);
                if (list.Count > 0)
                {
                    CodeBlock last = list.Last();
                    lines = (StartLine + 1).ToString() + " ... " + (last.EndLine + 1).ToString();
                }
                else
                {
                    lines = (StartLine + 1).ToString() + " ... " + (EndLine + 1).ToString();
                }
            }
            else
            {
                lines = (StartLine + 1).ToString() + " ... " + (EndLine + 1).ToString();
            }
            string @operator = Operator;

            if (Operator == Data.DO.Text)
            {
                @operator += " " + Data.WHILE.Text;
            }
            if (Operator == Data.QUESTION_MARK)
            {
                @operator = "Тернарный";
            }

            TextBox numberTextBox = new TextBox()
            {
                Text = number.ToString(), Background = background, BorderThickness = Data.NullThickness, TextWrapping = TextWrapping.Wrap, FontSize = fontSize, IsReadOnly = true, Cursor = Cursors.Arrow
            };
            TextBox operatorTextBox = new TextBox()
            {
                Text = @operator, Background = background, BorderThickness = Data.NullThickness, TextWrapping = TextWrapping.Wrap, FontSize = fontSize, IsReadOnly = true, Cursor = Cursors.Arrow, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };
            TextBox linesTextBox = new TextBox()
            {
                Text = lines, Background = background, BorderThickness = Data.NullThickness, TextWrapping = TextWrapping.Wrap, FontSize = fontSize, IsReadOnly = true, Cursor = Cursors.Arrow, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };
            TextBox nestingLevelTextBox = new TextBox()
            {
                Text = NestingLevel.ToString(), Background = background, BorderThickness = Data.NullThickness, TextWrapping = TextWrapping.Wrap, FontSize = fontSize, IsReadOnly = true, Cursor = Cursors.Arrow, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };

            if (Operator == Data.SWITCH.Text)
            {
                string     caption     = "Уровни вложенности ветвей оператора";
                List <int> indexes     = FirstTask.CASE_And_DEFAULT_LinesIndexesOf_SWITCH_Block(this);
                Grid       toolTipGrid = new Grid();
                toolTipGrid.ColumnDefinitions.Add(new ColumnDefinition());
                int toolTipGridRowCounter = 0;
                foreach (int index in indexes)
                {
                    CodeBlock block = FirstTask.GetBlockByStartLine(index);
                    toolTipGrid.RowDefinitions.Add(new RowDefinition());
                    if (index == indexes.Last())
                    {
                        WPF_Methods.AddToGrid(ref toolTipGrid, (block.GetGrid(toolTipGridRowCounter + 1, true, Data.UsualTextFontSize, Data.ToolTipTextBackground), 0, toolTipGridRowCounter++));
                    }
                    else
                    {
                        WPF_Methods.AddToGrid(ref toolTipGrid, (block.GetGrid(toolTipGridRowCounter + 1, false, Data.UsualTextFontSize, Data.ToolTipTextBackground), 0, toolTipGridRowCounter++));
                    }
                }
                WPF_Methods.SetToolTip(ref operatorTextBox, WPF_Methods.CreateToolTipWithGrid(caption, toolTipGrid));
            }

            WPF_Methods.AddToGrid(ref grid, (numberTextBox, 1, 1), (operatorTextBox, 3, 1), (linesTextBox, 5, 1), (nestingLevelTextBox, 7, 1));
            MakeBordersInGrid(ref grid, needsBottomBorder);
            return(grid);
        }