Beispiel #1
0
        public void PlateDetermineArrowDirectionTest()
        {
            var testRange00 = new TextRange() { Id = "Range00", Length = 9, StartIndex = 7 };
            var testRange01 = new TextRange() { Id = "Range01", Length = 12, StartIndex = (testRange00.StartIndex + testRange00.Length) };
            var testRange02 = new TextRange()
            {
                Id = "Range02",
                Length = 26,
                StartIndex = (testRange01.StartIndex + testRange01.Length)
            };
            var testRange03 = new TextRange()
            {
                Id = "Range03",
                Length = 18,
                StartIndex = (testRange02.StartIndex + testRange02.Length)
            };
            var testRange04 = new TextRange()
            {
                Id = "Range04",
                Length = 20,
                StartIndex = (testRange03.StartIndex + testRange03.Length)
            };

            var testRangeList = new List<TextRange>() {testRange00, testRange01, testRange02, testRange03, testRange04};

            var testResultToRight = Arrow.DetermineArrowDirection(testRange03.Id, testRange01.Id, testRangeList);
            var testResultToLeft = Arrow.DetermineArrowDirection(testRange02.Id, testRange04.Id, testRangeList);

            Assert.AreEqual(PrintLocation.Right, testResultToRight);
            Assert.AreEqual(PrintLocation.Left, testResultToLeft);
        }
Beispiel #2
0
        public void PlateGetRangeLenBetwixt()
        {
            var testRange00 = new TextRange() {Id = "Range00", Length = 9, StartIndex = 7};
            var testRange01 = new TextRange() { Id = "Range01", Length = 12, StartIndex = (testRange00.StartIndex+testRange00.Length) };
            var testRange02 = new TextRange()
                              {
                                  Id = "Range02",
                                  Length = 26,
                                  StartIndex = (testRange01.StartIndex + testRange01.Length)
                              };
            var testRange03 = new TextRange()
                              {
                                  Id = "Range03",
                                  Length = 18,
                                  StartIndex = (testRange02.StartIndex + testRange02.Length)
                              };
            var testRange04 = new TextRange()
                              {
                                  Id = "Range04",
                                  Length = 20,
                                  StartIndex = (testRange03.StartIndex + testRange03.Length)
                              };

            var testBlockLeftId = testRange01.Id;
            var testBlockRightId = testRange04.Id;

            var testResult = Arrow.GetRangeLenBetwixt(testBlockLeftId,
                testBlockRightId,
                new List<TextRange>() {testRange00, testRange01, testRange02, testRange03, testRange04});

            System.Diagnostics.Debug.WriteLine(testResult);

            Assert.AreNotEqual(0,testResult);
        }
Beispiel #3
0
        public static TextCanvas Concat(this TextCanvas block1Tc, TextCanvas block2Tc, Rule ruler)
        {
            if(ruler == null)
                throw new NoRuleSetException();

            if (block2Tc == null)
            {
                return block1Tc;
            }

            var minIndex = block1Tc.MinIndex < block2Tc.MinIndex ? block1Tc.MinIndex : block2Tc.MinIndex;
            var maxIndex = block1Tc.MaxIndex > block2Tc.MaxIndex ? block1Tc.MaxIndex : block2Tc.MaxIndex;
            var blockBarCount = 0;

            Func<char[], bool> printBar =
                c =>
                    new String(c).EndsWith(string.Format("{0}{1}",
                        Config.GraphChars.Rail,
                        Config.GraphChars.BarRailIntersect));

            var tc = new TextCanvas() { MaxIndex = maxIndex, Ruler = ruler, MinIndex = minIndex, Id = block1Tc.Id + Config.GraphChars.IDSeparator + block2Tc.Id };
            for (var i = minIndex; i <= maxIndex; i++)
            {
                var ti1 = block1Tc.GetTextOrEmpty(i, block1Tc.Width);
                var ti2 = block2Tc.GetTextOrEmpty(i, block2Tc.Width);

                if (ti1.Index < 0 || ti2.Index < 0)
                    continue;

                var ntxt = new List<char>(ti1.Text);
                if (blockBarCount == 1 || block2Tc.MaxIndex >= i)
                    ntxt.Add(Config.GraphChars.Bar);
                else
                    ntxt.Add((char)0x20);

                if (printBar(ti1.Text.ToArray()))
                    blockBarCount += 1;

                var txtRng = new TextRange() {Id = block2Tc.Id, Length = ti2.Text.Count, StartIndex = ntxt.Count};
                ntxt.AddRange(ti2.Text);

                var nti = new TextItem() {HashMarkValue = ti1.HashMarkValue, Index = i, Text = ntxt};
                nti.Ranges.AddRange(ti1.Ranges);
                nti.Ranges.Add(txtRng);
                tc.Items.Add(nti);

                if (ntxt.Count > tc.Width)
                    tc.Width = ntxt.Count;
            }
            return tc;
        }