示例#1
0
文件: Entry.cs 项目: nofuture-git/31g
        protected internal void AssignStartEndValueByString(string printYears)
        {
            var dfRuleValues = GetRulerStartEndValues();
            var parsedValues =
                TimelineExtensions.ParseYearsRange(printYears, dfRuleValues.Item1, dfRuleValues.Item2).ToList();

            if (parsedValues.Any())
            {
                StartValue = parsedValues[0].Item1.GetValueOrDefault(0D);
                EndValue   = parsedValues[0].Item2.GetValueOrDefault(0D);
            }
        }
示例#2
0
        public TextCanvas ToTextCanvas()
        {
            var tc = Ruler.ToTextCanvas();

            _rulerWidth = tc.Width;
            tc          = _blocks.Aggregate(tc, (current, block) => TimelineExtensions.Concat(current, block.PrintEntriesOnCanvas(), Ruler));

            foreach (var ti in tc.Items)
            {
                ti.Text.Add(Config.GraphChars.Bar);
                if (ti.Text.Count > _width)
                {
                    _width = ti.Text.Count;
                }
            }
            _width = _width - _rulerWidth;
            return(tc);
        }
示例#3
0
文件: Entry.cs 项目: nofuture-git/31g
        }//end CalcHeight

        protected internal string PrintStartEndValue()
        {
            //if no range given print empty
            if (StartValue == 0 && EndValue == 0)
            {
                return(string.Empty);
            }

            //convert to nullables
            var entrySv = StartValue == 0 ? null : new double?(StartValue);
            var entryEv = EndValue == 0 ? null : new double?(EndValue);

            //short-circuit out with when just StartValue
            if (entrySv.HasValue && entryEv.HasValue && entrySv == entryEv)
            {
                return(((int)Math.Round(entrySv.Value)).ToString());
            }

            var dfRuleValues = GetRulerStartEndValues();

            return(TimelineExtensions.PrintYearsRange(new[] { new Tuple <double?, double?>(entrySv, entryEv) }, dfRuleValues.Item1,
                                                      dfRuleValues.Item2));
        }
示例#4
0
 protected internal virtual IEnumerable <Tuple <double?, double?> > ParseYearsRange(string printyears)
 {
     return(TimelineExtensions.ParseYearsRange(printyears, StartValue, EndValue));
 }
示例#5
0
        }//end ToTextCanvas

        protected internal virtual string PrintYearsRange(IEnumerable <Tuple <double?, double?> > years)
        {
            return(TimelineExtensions.PrintYearsRange(years, StartValue, EndValue));
        }