Exemple #1
0
    // What to do when the user wants to export a TeX file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream         stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter           = "SVG files|*.svg|TeX files|(*.tex)";
        saveFileDialog.RestoreDirectory = true;

        if (saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if ((stream = saveFileDialog.OpenFile()) != null)
            {
                // Insert code here that generates the string of LaTeX
                //   commands to draw the shapes

                SVG graphics = new SVG();
                foreach (Shape shape in shapes)
                {
                    shape.Draw(graphics);
                }
                graphics.Export();

                //System.IO.File.WriteAllLines(saveFileDialog.FileName, graphics.Document);

                using (StreamWriter writer = new StreamWriter(stream))
                {
                    // Write strings to the file here using:
                    foreach (string regel in graphics.Document)
                    {
                        writer.WriteLine(regel);
                    }
                }
            }
        }
    }