Example #1
0
 protected internal virtual string DrawHeader()
 {
     var label = Util.Etc.PrintInCenter(Width, Title);
     var bar = DrawBar();
     var strBuilder = new StringBuilder();
     for (var i = 0; i < Width; i++)
     {
         var headerChar = label[i] == (char)0x20 ? bar[i] : label[i];
         strBuilder.Append(headerChar);
     }
     strBuilder.AppendLine();
     return strBuilder.ToStringUnixNewline();
 }
Example #2
0
        public override string ToString()
        {
            if (string.IsNullOrEmpty(Text))
                return string.Empty;
            if (Width == 0)
                _width = Config.Numerics.DefaultWidth;
            if (_height == 0)
                _height = CalcHeight();

            Func<int, string> sfOpL = i => "{0,-" + i + "}";
            Func<int, string> sfOpR = i => "{0," + i + "}";

            var strBuilder = new StringBuilder();
            switch (Location)
            {
                case PrintLocation.Center:
                    strBuilder.AppendLine(Util.Etc.PrintInCenter(Width, Text));
                    break;
                case PrintLocation.Left:
                    strBuilder.AppendLine(string.Format(sfOpL(Width), Text));
                    break;
                case PrintLocation.Right:
                    strBuilder.AppendLine(string.Format(sfOpR(Width), Text.Trim()));
                    break;
            }

            if (_height <= 1)
                return strBuilder.ToStringUnixNewline();

            for (var i = 0; i < _height - 1; i++)
            {
                switch (Location)
                {
                    case PrintLocation.Center:
                        strBuilder.AppendLine(Util.Etc.PrintInCenter(Width, Config.GraphChars.LifeLine.ToString()));
                        break;
                    case PrintLocation.Left:
                        strBuilder.AppendLine(string.Format(sfOpL(Width), Config.GraphChars.LifeLine));
                        break;
                    case PrintLocation.Right:
                        strBuilder.AppendLine(string.Format(sfOpR(Width), Config.GraphChars.LifeLine));
                        break;
                }
            }
            switch (Location)
            {
                case PrintLocation.Center:
                    strBuilder.AppendLine(Util.Etc.PrintInCenter(Width, new string(Config.GraphChars.Rail,3)));
                    break;
                case PrintLocation.Left:
                    strBuilder.AppendLine(string.Format(sfOpL(Width), new string(Config.GraphChars.Rail, 3)));
                    break;
                case PrintLocation.Right:
                    strBuilder.AppendLine(string.Format(sfOpR(Width), new string(Config.GraphChars.Rail, 3)));
                    break;
            }
            return strBuilder.ToStringUnixNewline();
        }
Example #3
0
        public override string ToString()
        {
            if (Ruler == null)
                throw new NoRuleSetException();

            var strBuilder = new StringBuilder();

            if (EmptyChar == '\0')
                EmptyChar = (char)0x20;

            var entryIndex = Ruler.CalcEntryIndex(this);
            strBuilder.Append(DrawHeader());
            for (var i = entryIndex.Item1 + 1; i <= entryIndex.Item2 - 1; i++)
            {
                strBuilder.AppendLine(new string(EmptyChar, Width));
            }
            strBuilder.Append(DrawBar());
            return strBuilder.ToStringUnixNewline();
        }
Example #4
0
        protected internal virtual string DrawBar()
        {
            var strBuilder = new StringBuilder();
            strBuilder.Append(Config.GraphChars.BarRailIntersect);
            for (var i = 1; i < Width - 1; i++)
            {
                strBuilder.Append(Config.GraphChars.Rail);
            }
            strBuilder.Append(Config.GraphChars.BarRailIntersect);
            strBuilder.AppendLine();

            return strBuilder.ToStringUnixNewline();
        }
Example #5
0
        public override string ToString()
        {
            var str = new StringBuilder();
            foreach (var item in Items)
                str.AppendLine(new string(item.Text.ToArray()));

            return str.ToStringUnixNewline();
        }
Example #6
0
        public override string ToString()
        {
            //determine if required vals are assigned
            if (StartValue == EndValue)
                throw new ArgumentException("The start at value must be greater-than or less-than the end at value.");

            //default these if not assigned
            if (RuleLineSpacing == 0)
                RuleLineSpacing = Config.Numerics.DefaultRuleLnSp;
            double increment = CountIncrement.Value;

            //construct a the ruler as a printable string
            var strBuilder = new StringBuilder();
            double loopCounter = StartValue;

            Func<double, double, double, bool> loopOp = (a, z, i) => a > z ? i >= z : i <= z;

            while (loopOp(StartValue, EndValue, loopCounter))
            {
                strBuilder.AppendLine(string.Format("{0,-6}", loopCounter));
                for (var i = 0; i < RuleLineSpacing - 1; i++)
                {
                    strBuilder.AppendLine(string.Format("{0,-6}", " "));
                }
                loopCounter += increment;
            }

            return strBuilder.ToStringUnixNewline();
        }
Example #7
0
        protected internal string DrawHeader()
        {
            if (_width - 2 <= 0)
                return Name;

            var title = Etc.PrintInCenter((_width - 2), Name);
            var strBuilder = new StringBuilder();
            if (_rulerWidth > 0)
                strBuilder.Append(new string((char) 0x20, _rulerWidth));
            strBuilder.Append(Config.GraphChars.Bar);
            strBuilder.Append(title);
            strBuilder.Append(Config.GraphChars.Bar);
            return strBuilder.ToStringUnixNewline();
        }
Example #8
0
        protected internal string DrawBar()
        {
            if (_width <= 0)
                return string.Empty;
            var strBuilder = new StringBuilder();
            if (_rulerWidth > 0)
                strBuilder.Append(new string((char)0x20, _rulerWidth));
            strBuilder.Append(Config.GraphChars.BarRailIntersect);
            strBuilder.Append(new string(Config.GraphChars.Rail, _width - 2));
            strBuilder.Append(Config.GraphChars.BarRailIntersect);

            return strBuilder.ToStringUnixNewline();
        }
Example #9
0
        public override string ToString()
        {
            var tc = ToTextCanvas();
            var strBuilder = new StringBuilder();
            if (!string.IsNullOrWhiteSpace(Name))
            {
                strBuilder.AppendLine(DrawBar());
                strBuilder.AppendLine(DrawHeader());
            }
            foreach (var arrow in _arrows)
            {
                tc = arrow.ComposeArrow(Ruler, tc);
            }
            strBuilder.AppendLine(tc.ToString());

            foreach (var note in Notes)
                strBuilder.AppendLine(note);

            return strBuilder.ToStringUnixNewline();
        }