예제 #1
0
        private void btnGenerateData_Click(object sender, EventArgs e)
        {
            var selectedItemText = cmbPattern.SelectedItem.ToString();
            var codeDataGenerator = new CodeDataGenerator(GetPlatformSpecificPath(tbSourceCodeFilesFolder.Text));
            switch (selectedItemText)
            {
                case "Asciimation_1_3.cs":
                    List<CompressedFrame> compressedFrames;
                    var asciimationGenerator13 = new AsciimationDataGenerator(File.ReadAllText(Path.Combine(tbPatternsFolder.Text, "Asciimation.txt")));
                    tbInput.Text = codeDataGenerator.SubstituteData(tbInput.Text, new List<CodeDataGeneratorParam>()
                    {
                        new CodeDataGeneratorParam {
                            KeyBegin = "/*%Data_1_3*/",
                            KeyEnd = "/*Data_1_3%*/",
                            Value = '"' + asciimationGenerator13.Compress_v_1_3(out compressedFrames) + '"'
                        }
                    });
                    break;

                case "QuineClock.cs":
                    var quineClock3Generator = new QuineClockDataGenerator(File.ReadAllText(Path.Combine(tbPatternsFolder.Text, "QuineClockDigits.txt")));
                    tbInput.Text = codeDataGenerator.SubstituteData(tbInput.Text, new List<CodeDataGeneratorParam>()
                        {
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*%Digits*/",
                                KeyEnd = "/*Digits%*/",
                                Value = '"' + string.Join("\",\"", quineClock3Generator.GetDigits().Select(s => s.Replace("\\", "\\\\"))) + '"'
                            }
                        });
                    break;

                case "QuineSnake.cs":
                    var quineSnakeGenerator = new QuineSnakeGenerator();
                    tbInput.Text = codeDataGenerator.SubstituteData(tbInput.Text, new List<CodeDataGeneratorParam>()
                        {
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$FieldWidth*/",
                                KeyEnd = "/*FieldWidth$*/",
                                Value = QuineSnakeGenerator.FieldWidth.ToString(),
                                SaveKey = false
                            },
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$FieldHeight*/",
                                KeyEnd = "/*FieldHeight$*/",
                                Value = QuineSnakeGenerator.FieldHeight.ToString(),
                                SaveKey = false
                            },
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$HeadRow*/",
                                KeyEnd = "/*HeadRow$*/",
                                Value = QuineSnakeGenerator.HeadRow.ToString(),
                            },
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$HeadColumn*/",
                                KeyEnd = "/*HeadColumn$*/",
                                Value = QuineSnakeGenerator.HeadColumn.ToString(),
                            },
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$FoodRow*/",
                                KeyEnd = "/*FoodRow$*/",
                                Value = QuineSnakeGenerator.FoodRow.ToString(),
                            },
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$FoodColumn*/",
                                KeyEnd = "/*FoodColumn$*/",
                                Value = QuineSnakeGenerator.FoodColumn.ToString(),
                            },
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$NewDir*/",
                                KeyEnd = "/*NewDir$*/",
                                Value = QuineSnakeGenerator.NewDirString.ToString()
                            },
                            new CodeDataGeneratorParam
                            {
                                KeyBegin = "/*$Dirs*/",
                                KeyEnd = "/*Dirs$*/",
                                Value = QuineSnakeGenerator.DirsString
                            }
                        });
                    break;
            }
        }
예제 #2
0
 private void btnGenerateCode_Click(object sender, EventArgs e)
 {
     var codeDataGenerator = new CodeDataGenerator(GetPlatformSpecificPath(tbSourceCodeFilesFolder.Text));
     tbInput.Text = codeDataGenerator.SubstituteCode(tbInput.Text);
 }