Ejemplo n.º 1
0
        internal static void out_bisector(Edge e)
        {
            if (triangulate && plot && !debug)
            {
                line(e.reg[0].Coord.X, e.reg[0].Coord.Y, e.reg[1].Coord.X, e.reg[1].Coord.Y);
            }
            if (!triangulate && !plot && !debug)
            {
                Console.WriteLine(String.Format("line {0} {1} {2}", e.a, e.b, e.c));
            }
            if (debug)
            {
                Console.WriteLine(String.Format("line edgeNumber: {0}, {1}x+{2}y={3}, bisecting sites # {4} {5}",
                                                e.edgeNumber, e.a, e.b, e.c, e.reg[EndPoint.Left].SiteNumber, e.reg[EndPoint.Right].SiteNumber));
            }

            LineCollection.Add(new VoronoiLine
            {
                A          = e.a,
                B          = e.b,
                C          = e.c,
                EdgeNumber = e.edgeNumber,
                Site1      = e.reg[EndPoint.Left],
                Site2      = e.reg[EndPoint.Right]
            });
        }
Ejemplo n.º 2
0
        public IfBlock(int index, LineCollection fullCode)
        {
            Else   = null;
            Header = fullCode[index];

            LineCollection ifLines   = new LineCollection();
            LineCollection elseLines = new LineCollection();

            int expected_endif = 1; // How many 'END IF' statements are expected

            index++;

            bool isElse = false; // Whether this should be added to the else block

            for (; index < fullCode.Count; index++)
            {
                Line cur = fullCode[index];
                if (cur.Name.EqualsIgnoreCase("IF"))
                {
                    expected_endif++;
                }

                if (expected_endif > 0)
                {
                    if (expected_endif == 1 && cur.Name.EqualsIgnoreCase("ELSE"))   // we are now in an else block
                    {
                        isElse = true;
                        continue; // We don't need to add the word 'ELSE'
                    }
                }

                if (cur.Text.EqualsIgnoreCase("END IF"))
                {
                    expected_endif--;
                }

                if (expected_endif == 0)
                {
                    if (elseLines.Count > 0)
                    {
                        Else = new ElseBlock(elseLines);
                    }
                    Footer = cur;
                    Body   = ifLines;
                    return;
                }

                if (isElse)
                {
                    elseLines.Add(cur);
                }
                else
                {
                    ifLines.Add(cur);
                }
            }

            throw ThrowHelper.UnterminatedBlock(Header.VisibleName);
        }
Ejemplo n.º 3
0
        internal static LineCollection ScanLines(string[] lines, out CodeBlock[] userFunctions)
        {
            LineCollection allLines = new LineCollection();
            List <uint>    funLines = new List <uint>();

            for (uint lineNumber = 0; lineNumber < lines.Length; ++lineNumber)
            {
                Line current = new Line(lineNumber + 1, lines[lineNumber]); // Tag all lines with its line number (index + 1)

                if (string.IsNullOrEmpty(current.Text) || current.Text[0] == ';')
                {
                    continue;
                }
                if (current.Name[current.Name.Length - 1] == '$' || current.Name[current.Name.Length - 1] == ']')
                {
                    current.Text = "LET " + current.Text; // add the word LET if it's an equality, but use the original name as visible name
                }
                else if (current.Name.EqualsIgnoreCase("FUNCTION"))
                {
                    funLines.Add(current.LineNumber);
                }
                else
                {
                    current.VisibleName = current.VisibleName.ToUpper();
                }

                while (current.Text[current.Text.Length - 1] == '_')   // line continuation
                {
                    lineNumber++;
                    if (lineNumber >= lines.Length)
                    {
                        throw new EndOfCodeException("line continuation character '_' cannot end script");
                    }
                    current = new Line(current.LineNumber, current.Text.Remove(current.Text.LastIndexOf('_')) + lines[lineNumber].Trim());
                }

                allLines.Add(current);
            }

            List <CodeBlock> userFuncs = new List <CodeBlock>();

            foreach (uint funcLine in funLines)
            {
                FuncBlock func = new FuncBlock(allLines.IndexOf(funcLine), allLines);
                userFuncs.Add(func);
                allLines.Remove(func.Header);
                allLines.Remove(func.Body);
                allLines.Remove(func.Footer);
            }
            userFunctions = userFuncs.ToArray();
            return(allLines);
        }
Ejemplo n.º 4
0
            public static int ParseBlock(int index, LineCollection all, out CaseBlock caseBlock)
            {
                LineCollection blockLines = new LineCollection();

                bool isBlock = false;

                for (; index < all.Count; index++)
                {
                    if (isBlock)
                    {
                        if (all[index].Name.EqualsIgnoreCase("CASE") ||
                            all[index].Name.EqualsIgnoreCase("DEFAULT"))
                        {
                            break;
                        }
                        else
                        {
                            blockLines.Add(all[index]);
                        }
                    }
                    else if (all[index].Name.EqualsIgnoreCase("CASE") ||
                             all[index].Name.EqualsIgnoreCase("DEFAULT"))
                    {
                        isBlock = true;
                        blockLines.Add(all[index]);
                    }
                }
                if (blockLines.Count > 0)
                {
                    caseBlock = new CaseBlock(blockLines);
                }
                else
                {
                    caseBlock = null;
                }
                return(index);
            }
        public LineCollection GenerateLineCollection(int lines)
        {
            var result = new LineCollection(Pool.Legs.Length);

            if (lines <= 0)
            {
                return(result);
            }

            while (result.Count < lines)
            {
                var line = GenerateNewLine();
                result.Add(line);
            }

            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Run the verification
        /// </summary>
        /// <param name="sender">Button object details</param>
        /// <param name="e">Event Arguments</param>
        /// <returns>Bind LOC count to view</returns>
        /// 2019/07/13, Vinoth N,  Initial Version
        private async void Counter_Click(object sender, RoutedEventArgs e)
        {
            Clear();
            DisableControls();
            try
            {
                results = new GetFileDetail();
                string location = t_Location.Text;
                string tag      = t_POTag.Text;
                int    i        = 1;
                var    count    = 0;
                if (StartingFlag())
                {
                    if (Directory.Exists(location))
                    {
                        Loadgif.Visibility       = Visibility.Visible;
                        b_Download.IsEnabled     = true;
                        counterStatus.Content    = "Processing..";
                        counterStatus.Foreground = Brushes.Green;
                        await Task.Run(() => results = ViewModel.StartCounter(location, tag));

                        if (results.JavaFunctionDetails != null)
                        {
                            foreach (var counter in results.JavaFunctionDetails)
                            {
                                Dispatcher.Invoke(() =>
                                {
                                    LineCollection.Add(new CounterModel
                                    {
                                        Total        = results.JavaFunctionDetails.IndexOf(counter) + 1,
                                        FileName     = counter.FileName,
                                        FunctionName = counter.FunctionName,
                                        Description  = counter.Description,
                                        AllCount     = counter.AllCount,
                                        AddCount     = counter.AddCount,
                                        ModCount     = counter.ModCount,
                                        NewCount     = counter.NewCount,
                                        DelCount     = counter.DelCount,
                                        Error        = counter.Error,
                                        IsGUI        = counter.IsGUI
                                    });
                                });
                                Dispatcher.Invoke(() => DetailCollection.Add("<<<" + counter.FunctionName + ">>>"));
                                if (counter.FullFunctionLine != null)
                                {
                                    foreach (var line in counter.FullFunctionLine)
                                    {
                                        Dispatcher.Invoke(() => DetailCollection.Add(line));
                                    }
                                }
                                count += counter.AllCount;
                            }
                        }
                        var counterValue = $"{count}";
                        tbk_counter.Text = counterValue;
                        errorCount       = LineCollection.Where(p => p.Error == true).Count();
                        FinishVerification(true);
                    }
                    else
                    {
                        b_Download.IsEnabled = false;
                        MessageBox.Show("Location Not Found !");
                    }
                }
            }
            catch (Exception ex)
            {
                LogModel.Log(ex.Message);
                LogModel.Log(ex.StackTrace);
            }
        }