Example #1
0
        public static void Main(string[] args)
        {
            List <Step> steps    = new List <Step>();
            int         angles   = 2;
            int         widths   = 2;
            double      minWidth = 0.4;
            double      maxWidth = 0.8;

            double patchSize     = 10; //mm
            double patchDistance = 4;

            double maxStepLength = 3;

            for (int i = 0; i < angles; i++)
            {
                double angle     = i * 90.0 / angles;
                double xPosition = i * (patchSize + patchDistance);

                for (int j = 0; j < widths; j++)
                {
                    double yPosition  = j * (patchSize + patchDistance);
                    double lineHeight = minWidth + (double)j * (maxWidth - minWidth) / (double)widths;
                    steps.AddRange(CreatePatch(patchSize, xPosition, yPosition, new ColorTranslation {
                        StepAngle = angle, LineHeight = lineHeight, MaxStepLength = maxStepLength
                    }));
                }
            }

            foreach (var item in steps)
            {
                Console.WriteLine(new CsvStepWriter(item).Write());
            }

            Console.WriteLine(CsvStepWriter.WriteClosingSequence());
        }
Example #2
0
        public void WriteLineReturnsValidLine()
        {
            var           step = this.CreateStitchStep();
            CsvStepWriter w    = new CsvStepWriter(step);
            string        line = w.Write();

            Assert.IsTrue(line.Contains("STITCH"));
        }
Example #3
0
        public void WriteLineContainsFourFields()
        {
            var           step = this.CreateStitchStep();
            CsvStepWriter w    = new CsvStepWriter(step);
            string        line = w.Write();

            string[] parts = line.Split(',');
            Assert.AreEqual(4, parts.Length);
        }
Example #4
0
        public void XandYHaveFourDigits2()
        {
            var           step = this.CreateOtherStitchStep();
            CsvStepWriter w    = new CsvStepWriter(step);
            string        line = w.Write();

            string[] parts = line.Split(',');
            Assert.AreEqual("-4.5670", parts[2].Replace("\"", string.Empty));
            Assert.AreEqual("33.1000", parts[3].Replace("\"", string.Empty));
        }
Example #5
0
        public static IEnumerable <string> WriteStitches(List <ColorTranslation> colortranslations, List <Polygon> polygonList)
        {
            foreach (var poly in polygonList)
            {
                foreach (string s in WriteStitchesForOnePolygonWithTranslations(colortranslations)(poly))
                {
                    yield return(s);
                }
            }

            yield return(CsvStepWriter.WriteClosingSequence());
        }
Example #6
0
        public void WriteLineEnclosesFieldsWithQuote()
        {
            var           step = this.CreateStitchStep();
            CsvStepWriter w    = new CsvStepWriter(step);
            string        line = w.Write();

            string[] parts = line.Split(',');
            foreach (var part in parts)
            {
                Assert.AreEqual('"', part[0]);
                Assert.AreEqual('"', part[part.Length - 1]);
            }
        }