Beispiel #1
0
        public Interval(List <IntervalJson> intervals, string dir, bool withText, int row = 0)
        {
            Row = row;
            if (intervals == null)
            {
                return;
            }
            int i = 1;

            Info = intervals[0];
            //TODO: Добавить чтение текста по надобности
            if (withText)
            {
                try {
                    var Lines = File.ReadLines(dir + '/' + Info.id.pname);
                    for (int j = Info.id.nline - 1; j < Info.id.nline_end; ++j)
                    {
                        Text += Lines.ElementAt(j) + '\n';
                    }
                    HasText = true;
                } catch (Exception e)
                {
                    Text = e.Message;
                }
            }
            while (i < intervals.Count)
            {
                if (intervals[i].id.nlev == Info.id.nlev + 1)
                {
                    int j = i + 1;
                    while (j < intervals.Count && intervals[j].id.nlev > intervals[i].id.nlev)
                    {
                        ++j;
                    }
                    Intervals.Add(new Interval(intervals.GetRange(i, j - i), dir, withText, row + 1));
                    row += j - i - 1;
                    i    = j - 1;
                }
                ++row;
                ++i;
            }
        }
        private CAGradientLayer MakeGradLayer(IntervalJson inter, bool isVertical = true)
        {
            var            gradientLayer = new CAGradientLayer();
            List <CGColor> colors        = new List <CGColor>();

            if (inter.times.comm >= 0.15 * maxTimeLost)
            {
                colors.Add(OxyColors.GreenYellow.ToCGColor());
            }
            if (inter.times.idle >= 0.15 * maxTimeLost)
            {
                colors.Add(OxyColors.LightSkyBlue.ToCGColor());
            }
            if (inter.times.insuf_user >= 0.15 * maxTimeLost)
            {
                colors.Add(OxyColors.Orchid.ToCGColor());
            }
            if (inter.times.insuf_sys >= 0.15 * maxTimeLost)
            {
                colors.Add(OxyColors.Pink.ToCGColor());
            }
            if (isVertical)
            {
                if (colors.Count == 1)
                {
                    colors.Add(colors[0]);
                }
                gradientLayer.StartPoint = new CGPoint(.0, 1.0);
                gradientLayer.EndPoint   = new CGPoint(.0, .0);
            }
            else
            {
                colors.Insert(0, OxyColors.Transparent.ToCGColor());
                gradientLayer.StartPoint = new CGPoint(.0, .0);
                gradientLayer.EndPoint   = new CGPoint(1.0, .0);
            }
            gradientLayer.Colors = colors.ToArray();
            return(gradientLayer);
        }