Inheritance: Surface
Beispiel #1
0
		public static void Main(string[] args)
		{
			// call the snippets
			Snippets snip = new Snippets();
			Surface surface = new PSSurface("snippets.ps", IMAGE_WIDTH, IMAGE_WIDTH);
			Context cr = new Context(surface);
			foreach (string snippet in Snippets.snippets)
			{
				cr.Save();
				Snippets.InvokeSnippet(snip, snippet, cr, IMAGE_WIDTH, IMAGE_HEIGHT);
				cr.ShowPage();
				cr.Restore();
			}
			surface.Finish ();
		}
Beispiel #2
0
    public static void Write(string fileName)
    {
        Diagram diagram = Program.Load(fileName);
        string psName = System.IO.Path.ChangeExtension(fileName, "ps");

        if(diagram != null)
        {
            try
            {
                // It seems the page size cannot be made smaller
                // using SetSize(), only larger. Start with a
                // small surface and enlarge it after layout.
                using(PSSurface pss = new PSSurface(psName, 10, 10))
                {
                    using(Context cr = new Context(pss))
                    {
                        DiagramRenderer dr = new DiagramRenderer(cr, 0, 0, diagram);

                        cr.LineWidth = 1.0;
                        cr.Color = new Color(0.0, 0.0, 0.0);
                        dr.Render();
                        pss.SetSize(dr.width, dr.height);
                        dr.Draw();

                        cr.ShowPage();
                    }
                }

                Console.WriteLine("Wrote {0}", psName);
            }
            catch
            {
                Console.WriteLine("Error writing {0}", psName);
            }
        }
    }