Exemple #1
0
        /// <summary>
        /// нарисовать на истории полоски гэпов
        /// </summary>
        private void DrawGaps(Graphics g, BrushesStorage brushes)
        {
            if (gaps.Count == 0)
            {
                return;
            }
            var widthPx = barBounds.Width - 2;

            if (widthPx == 0)
            {
                return;
            }

            var br = brushes.GetBrush(clHistOk);

            g.FillRectangle(br, barBounds.Left + 1, barBounds.Top + 1, barBounds.Width - 1, barBounds.Height - 1);

            // пересчитать модельные координаты в координаты времени,
            // заодно склеив соседние
            var      startTick   = Interval.a.Ticks;
            var      endTick     = Interval.b.Ticks;
            var      widthTics   = endTick - startTick;
            var      intervalsPx = new List <GapIntPx>();
            GapIntPx?lastPoint   = null;

            var gapsCopy = gaps.ToArray();

            foreach (var gap in gapsCopy)
            {
                var gapStartPx = (gap.start.Ticks - startTick) * widthPx / widthTics;
                var gapEndPx   = (gap.end.Ticks - startTick) * widthPx / widthTics;
                var color      = clGap[(int)gap.status];

                if (lastPoint.HasValue)
                {
                    if (lastPoint.Value.end >= gapStartPx && lastPoint.Value.color == color)
                    {
                        intervalsPx[intervalsPx.Count - 1] = new GapIntPx(lastPoint.Value.start, gapEndPx,
                                                                          color);
                        continue;
                    }
                }
                lastPoint = new GapIntPx(gapStartPx, gapEndPx == gapStartPx ? gapStartPx + 1 : gapEndPx, color);
                intervalsPx.Add(lastPoint.Value);
            }

            // отобразить
            foreach (var inter in intervalsPx)
            {
                var brushGap = brushes.GetBrush(inter.color);
                g.FillRectangle(brushGap,
                                inter.start + barLeft + 1,
                                barBounds.Top + 1,
                                (inter.end - inter.start),
                                barBounds.Height - 1);
            }
        }
        /// <summary>
        /// нарисовать на истории полоски гэпов
        /// </summary>
        private void DrawGaps(Graphics g, BrushesStorage brushes)
        {
            if (gaps.Count == 0) return;
            var widthPx = barBounds.Width - 2;
            if (widthPx == 0) return;

            var br = brushes.GetBrush(clHistOk);
            g.FillRectangle(br, barBounds.Left + 1, barBounds.Top + 1, barBounds.Width - 1, barBounds.Height - 1);

            // пересчитать модельные координаты в координаты времени,
            // заодно склеив соседние
            var startTick = Interval.a.Ticks;
            var endTick = Interval.b.Ticks;
            var widthTics = endTick - startTick;
            var intervalsPx = new List<GapIntPx>();
            GapIntPx? lastPoint = null;

            var gapsCopy = gaps.ToArray();

            foreach (var gap in gapsCopy)
            {
                var gapStartPx = (gap.start.Ticks - startTick) * widthPx / widthTics;
                var gapEndPx = (gap.end.Ticks - startTick) * widthPx / widthTics;
                var color = clGap[(int) gap.status];

                if (lastPoint.HasValue)
                    if (lastPoint.Value.end >= gapStartPx && lastPoint.Value.color == color)
                    {
                        intervalsPx[intervalsPx.Count - 1] = new GapIntPx(lastPoint.Value.start, gapEndPx,
                            color);
                        continue;
                    }
                lastPoint = new GapIntPx(gapStartPx, gapEndPx == gapStartPx ? gapStartPx + 1 : gapEndPx, color);
                intervalsPx.Add(lastPoint.Value);
            }

            // отобразить
            foreach (var inter in intervalsPx)
            {
                var brushGap = brushes.GetBrush(inter.color);
                g.FillRectangle(brushGap,
                    inter.start + barLeft + 1,
                    barBounds.Top + 1,
                    (inter.end - inter.start),
                    barBounds.Height - 1);
            }
        }