Example #1
0
        private void Compile()
        {
            var diagramArguments = new DiagramArguments(inputTextBox.Text, DiagramType.Sequence, (DiagramStyle)styleComboBox.SelectedItem, debugCheckBox.Checked);
            var diagramResult    = DiagramFactory.Create(diagramArguments);

            ProcessResult(diagramResult);
        }
        public ActionResult Create(string source, string type, string style = c_StyleDefault)
        {
            var diagramSource = Server.UrlDecode(source);

            DiagramType diagramType;

            if (type == null || !s_TypeMappings.TryGetValue(type, out diagramType))
            {
                return(new HttpStatusCodeResult(400, string.Format("Invalid value '{0}' for parameter 'type'.", type)));
            }

            DiagramStyle diagramStyle;

            if (style == null || !s_StyleMappings.TryGetValue(style, out diagramStyle))
            {
                return(new HttpStatusCodeResult(400, string.Format("Invalid value '{0}' for parameter 'style'.", style)));
            }

            var diagramArguments = new DiagramArguments(diagramSource, diagramType, diagramStyle);

            using (var diagramResult = DiagramFactory.Create(diagramArguments))
            {
                var id = Guid.NewGuid().ToString();

                SaveImage(diagramResult, id);

                return(CreateResult(diagramResult, id));
            }
        }
        private string GenetareImage(string source, string testCaseName, DiagramStyle diagramStyle)
        {
            var arguments = new DiagramArguments(source, DiagramType.Sequence, diagramStyle);
            var result    = DiagramFactory.Create(arguments);

            using (result)
            {
                string filename = testCaseName + ".png";
                result.Image.Save(diagramStyle + "\\" + filename, ImageFormat.Png);
                return(filename);
            }
        }
Example #4
0
        internal void Run(Options opts)
        {
            var arguments = new DiagramArguments(opts.Model, DiagramType.Class, DiagramStyle.Sketchy);
            var result    = DiagramFactory.Create(arguments);

            if (result.Errors.Count() != 0)
            {
                foreach (var de in result.Errors)
                {
                    Console.Error.WriteLine(string.Format("{0}: {1}", de.Message, de.TokenValue));
                }
                return;
            }

            using (result)
            {
                ImageFormat format;
                switch (opts.Format.ToLowerInvariant())
                {
                case "png":
                    format = ImageFormat.Png;
                    break;

                case "bmp":
                    format = ImageFormat.Bmp;
                    break;

                case "jpeg":
                    format = ImageFormat.Jpeg;
                    break;

                default:
                    throw new ArgumentException("unknown format: " + opts.Format);
                }
                result.Image.Save(opts.FileName, format);
            }
        }