private void AddOptionLevel(OptionData opt, bool isMedian)
        {
            var color = isMedian ? Color.Green : opt.Type == OptionType.PUT ? colorPut : colorGet;

            var linePart = new SpanWithText
                               {
                                   Price = opt.OptionLevelClose,
                                   LineColor = color,
                                   Name = string.Format("{0} {1:f4} OI:{2}", opt.Type, opt.OptionLevelClose, opt.OpenInterest)
                               };
            var indexStart = owner.StockSeries.GetIndexByCandleOpen(opt.DatePublished);
            var indexEnd = owner.StockSeries.GetIndexByCandleOpen(opt.DatePublished.AddHours(LengthHours));

            // проверить расстояние до рынка в пп
            // как мин. расстояние до уровня
            if (MaxPointsDistanceToShow > 0)
            {
                var candles = owner.StockSeries.Data.Candles;
                var distanceAbs = float.MaxValue;
                for (var i = indexStart < 0 ? 0 : indexStart; i < indexEnd; i++)
                {
                    if (i >= candles.Count) break;
                    var dist = Math.Min(
                        Math.Abs(candles[i].high - opt.OptionLevelClose),
                        Math.Abs(candles[i].low - opt.OptionLevelClose));
                    if (dist < distanceAbs) distanceAbs = dist;
                }
                var distPoints = DalSpot.Instance.GetPointsValue(owner.Symbol, distanceAbs);
                if (distPoints > MaxPointsDistanceToShow) return;
            }

            linePart.StartIndex = indexStart;
            linePart.EndIndex = indexEnd;
            var daysLeft = (opt.DateExpiration - opt.DatePublished).TotalDays;
            if (daysLeft <= daysToHighlight) linePart.LineWidth = 2;
            // показать метки
            if (LabelLeft != LevelLabel.Нет) AddOptionLabel(linePart, LabelLeft, true, opt);
            if (LabelRight != LevelLabel.Нет) AddOptionLabel(linePart, LabelRight, false, opt);
            seriesSpan.data.Add(linePart);
            // подсказка по уровню
            lineHints.Add(linePart, string.Format("{0:f4}{1} {2} (strike:{3:f4} close:{4:f4} OI:{5} volm:{6})",
                                                  opt.OptionLevelClose,
                                                  opt.Type,
                                                  opt.Style == OptionStyle.American ? "AM" : "EU",
                                                  opt.StrikePrice,
                                                  opt.ContractClose,
                                                  opt.OpenInterest,
                                                  opt.Volume));
        }
        private bool IsInLine(SpanWithText line, int x, int y, int tolerance)
        {
            // чувствительность, пикс
            if (seriesSpan.Owner == null) return false;

            // расстояние до прямой в экранных коорд.
            var ptA = Conversion.WorldToScreen(new PointD(line.StartIndex, (double)line.Price),
                                                      seriesSpan.Owner.WorldRect, seriesSpan.Owner.CanvasRect);
            var ptB = Conversion.WorldToScreen(new PointD(line.EndIndex, (double)line.Price),
                                                      seriesSpan.Owner.WorldRect, seriesSpan.Owner.CanvasRect);
            //screenPointA = seriesSpan.Owner.CanvasPointToClientPoint(screenPointA);
            //screenPointB = seriesSpan.Owner.CanvasPointToClientPoint(screenPointB);

            var distX = x < ptA.X ? (ptA.X - x) : x > ptB.X ? (ptB.X - x) : 0;
            var distY = Math.Abs(y - ptA.Y);
            return distX < tolerance && distY < tolerance;
        }
        private static void AddOptionLabel(SpanWithText span, LevelLabel label, bool isLeft, OptionData opt)
        {
            string text = label == LevelLabel.Объем
                              ? opt.Volume.ToString()
                              : label == LevelLabel.ОткрИнтерес
                                    ? opt.OpenInterest.ToString()
                                    : string.Format("{0:MMMyy}", opt.DateExpiration);

            if (isLeft) span.TextLeft = text;
            else span.TextRight = text;
        }