Пример #1
0
        public static void ProcessStage2(Syntax.Block document, CommonMarkSettings settings = null)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            if (document.Tag != Syntax.BlockTag.Document)
            {
                throw new ArgumentException("The block element passed to this method must represent a top level document.", "document");
            }

            if (settings == null)
            {
                settings = CommonMarkSettings.Default;
            }

            try
            {
                BlockMethods.ProcessInlines(document, document.ReferenceMap, settings);
            }
            catch (CommonMarkException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CommonMarkException("An error occurred during inline parsing.", ex);
            }
        }
Пример #2
0
        public static void ProcessStage2(Syntax.Block document, PandocMarkSettings settings = null)
        {
            if (document is null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            if (document.Tag != Syntax.BlockTag.Document)
            {
                throw new ArgumentException("The block element passed to this method must represent a top level document.", nameof(document));
            }

            if (settings is null)
            {
                settings = PandocMarkSettings.Default;
            }

            try
            {
                BlockMethods.ProcessInlines(document, document.Document, settings);
            }
            catch (PandocMarkException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new PandocMarkException("An error occurred during inline parsing.", ex);
            }
        }
Пример #3
0
        public static void ProcessStage2(Syntax.Block document, CommonMarkSettings settings = null)
        {
            if (document == null)
            {
                throw new ArgumentNullException(document.ToString());
            }

            if (document.Tag != Syntax.BlockTag.Document)
            {
                throw new ArgumentException("Блочный элемент, предоставляемый методу, должен быть высокоуровневым документом.", document.ToString());
            }

            if (settings == null)
            {
                settings = CommonMarkSettings.Default;
            }

            try
            {
                BlockMethods.ProcessInlines(document, document.ReferenceMap, settings);
            }
            catch (CommonMarkException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CommonMarkException("Ошибка при инлайн-парсинге.", ex);
            }
        }
Пример #4
0
        public static Syntax.Block ProcessStage1(TextReader source, CommonMarkSettings settings = null)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (settings == null)
            {
                settings = CommonMarkSettings.Default;
            }

            var cur  = Syntax.Block.CreateDocument();
            var doc  = cur;
            var line = new LineInfo(settings.TrackSourcePosition);

            try
            {
                var reader = new TabTextReader(source);
                reader.ReadLine(line);
                while (line.Line != null)
                {
                    BlockMethods.IncorporateLine(line, ref cur);
                    reader.ReadLine(line);
                }
            }
            catch (IOException)
            {
                throw;
            }
            catch (CommonMarkException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CommonMarkException("An error occurred while parsing line " + line.ToString(), cur, ex);
            }

            try
            {
                do
                {
                    BlockMethods.Finalize(cur, line);
                    cur = cur.Parent;
                } while (cur != null);
            }
            catch (CommonMarkException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CommonMarkException("An error occurred while finalizing open containers.", cur, ex);
            }

            return(doc);
        }
Пример #5
0
        public static Syntax.Block ProcessStage1(TextReader source, CommonMarkSettings settings = null)
        {
            if (source == null)
            {
                throw new ArgumentNullException(source.ToString());
            }

            if (settings == null)
            {
                settings = CommonMarkSettings.Default;
            }

            var cur  = Syntax.Block.CreateDocument();
            var doc  = cur;
            var line = new LineInfo(settings.TrackSourcePosition);

            try
            {
                var reader = new TabTextReader(source);
                reader.ReadLine(line);
                while (line.Line != null)
                {
                    BlockMethods.IncorporateLine(line, ref cur);
                    reader.ReadLine(line);
                }
            }
            catch (IOException)
            {
                throw;
            }
            catch (CommonMarkException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CommonMarkException("Ошибка при разборе строки " + line.ToString(), cur, ex);
            }

            try
            {
                do
                {
                    BlockMethods.Finalize(cur, line);
                    cur = cur.Parent;
                } while (cur != null);
            }
            catch (CommonMarkException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CommonMarkException("Ошибка при финализации открытых контейнеров.", cur, ex);
            }

            return(doc);
        }
        private void cmdStart_Click(object sender, EventArgs e)
        {
            if (Directory.Exists(txtDir.Text) && txtName.Text != "")
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "Images (*.png, *.jpg, *.jpeg, *.bmp) | *.png; *.jpg; *.jpeg; *.bmp";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Bitmap    image = new Bitmap(dialog.FileName);
                    Blueprint bp    = new Blueprint(txtDir.Text, txtName.Text);

                    float sampleRate = (float)numSampling.Value;

                    for (float y = 0; y < image.Height; y += sampleRate)
                    {
                        for (float x = 0; x < image.Width; x += sampleRate)
                        {
                            Color pixel = image.GetPixel((int)x, (int)y);
                            int   posX  = (int)(x / sampleRate);
                            int   posY  = (int)(y / sampleRate) * -1;
                            bp.addBlock((Block)cmbMaterial.SelectedIndex, posX, 0, posY, BlockMethods.ColorToString(pixel));
                        }
                    }

                    bp.closeFile();
                }
            }
        }