Ejemplo n.º 1
0
        public void DrawFixedPointsInContext(CGContext context, bool isDebuggingEnabled, bool usePreciseLocation, bool commitAll = false)
        {
            var allPoints  = new List <LinePoint> (Points);
            var committing = new List <LinePoint> ();

            if (commitAll)
            {
                committing = allPoints;
                Points.Clear();
            }
            else
            {
                for (int i = 0; i < allPoints.Count; i++)
                {
                    var point = allPoints[i];
                    if ((point.PointType.Has(PointType.NeedsUpdate) ||
                         point.PointType.Has(PointType.Predicted)) && i > (allPoints.Count - 2))
                    {
                        committing.Add(Points.First());
                        break;
                    }

                    if (i <= 0)
                    {
                        continue;
                    }

                    var removed = Points.First();
                    Points.Remove(removed);
                    committing.Add(removed);
                }
            }

            if (committing.Count <= 1)
            {
                return;
            }

            var committedLine = new Line {
                Points = committing
            };

            committedLine.DrawInContext(context, isDebuggingEnabled, usePreciseLocation);

            if (CommittedPoints.Count > 0)
            {
                CommittedPoints.Remove(CommittedPoints.Last());
            }

            // Store the points being committed for redrawing later in a different style if needed.
            CommittedPoints.AddRange(committing);
        }
Ejemplo n.º 2
0
        public void DrawFixedPointsInContext(CGContext context, bool isDebuggingEnabled, bool usePreciseLocation, bool commitAll = false)
        {
            var allPoints  = new List <LinePoint> (Points);
            var committing = new List <LinePoint> ();

            if (commitAll)
            {
                committing.AddRange(allPoints);
                Points.Clear();
            }
            else
            {
                for (int i = 0; i < allPoints.Count; i++)
                {
                    var point = allPoints[i];
                    if (!point.PointType.HasFlag(PointType.NeedsUpdate | PointType.Predicted) || i >= (allPoints.Count - 2))
                    {
                        committing.Add(Points.First());
                        break;
                    }

                    if (i > 0)
                    {
                        committing.Add(Points [0]);
                        Points.RemoveAt(0);
                    }
                }
            }

            if (committing.Count <= 1)
            {
                return;
            }

            var committedLine = new Line();

            committedLine.Points.AddRange(committing);

            committedLine.DrawInContext(context, isDebuggingEnabled, usePreciseLocation);

            var last = CommittedPoints.Count - 1;

            if (last >= 0)
            {
                CommittedPoints.RemoveAt(last);
            }

            // Store the points being committed for redrawing later in a different style if needed.
            CommittedPoints.AddRange(committing);
        }