Пример #1
0
 protected void SetTarget(MarkupPoint ignore = null)
 {
     TargetPoints.Clear();
     foreach (var enter in Tool.Markup.Enters)
     {
         TargetPoints.AddRange(GetTarget(enter, ignore));
     }
 }
Пример #2
0
        private void SetEnterTarget(Enter enter, MarkupPoint ignore)
        {
            if (ignore == null || ignore.Enter != enter)
            {
                TargetPoints.AddRange(enter.Points.Cast <MarkupPoint>());
                return;
            }

            var allow     = enter.Points.Select(i => 1).ToArray();
            var ignoreIdx = ignore.Num - 1;
            var leftIdx   = ignoreIdx;
            var rightIdx  = ignoreIdx;

            foreach (var line in enter.Markup.Lines.Where(l => l.Type == MarkupLine.LineType.Stop && l.Start.Enter == enter))
            {
                var from = Math.Min(line.Start.Num, line.End.Num) - 1;
                var to   = Math.Max(line.Start.Num, line.End.Num) - 1;
                if (from < ignore.Num - 1 && ignore.Num - 1 < to)
                {
                    return;
                }
                allow[from] = 2;
                allow[to]   = 2;

                for (var i = from + 1; i <= to - 1; i += 1)
                {
                    allow[i] = 0;
                }

                if (line.ContainsPoint(ignore))
                {
                    var otherIdx = line.PointPair.GetOther(ignore).Num - 1;
                    if (otherIdx < ignoreIdx)
                    {
                        leftIdx = otherIdx;
                    }
                    else if (otherIdx > ignoreIdx)
                    {
                        rightIdx = otherIdx;
                    }
                }
            }

            SetNotAllow(allow, leftIdx == ignoreIdx ? Find(allow, ignoreIdx, -1) : leftIdx, -1);
            SetNotAllow(allow, rightIdx == ignoreIdx ? Find(allow, ignoreIdx, 1) : rightIdx, 1);
            allow[ignoreIdx] = 0;

            foreach (var point in enter.Points)
            {
                if (allow[point.Num - 1] != 0)
                {
                    TargetPoints.Add(point);
                }
            }
        }