void DrawCurrent(Graphics graphics)
 {
     graphics.Transform = gViewer.CurrentTransform();
     graphics.FillRectangle(new SolidBrush(Draw.MsaglColorToDrawingColor(gViewer.Graph.Attr.BackgroundColor)),
                            gViewer.SrcRect);
     graphics.Clip = new Region(gViewer.SrcRect);
     Draw.DrawPrecalculatedLayoutObject(graphics, gViewer.DGraph);
 }
Esempio n. 2
0
 void DrawGraphBorder(int borderWidth, Graphics graphics)
 {
     using (var myPen = new Pen(Draw.MsaglColorToDrawingColor(drawingGraph.Attr.Color), (float)borderWidth))
         graphics.DrawRectangle(myPen,
                                (float)drawingGraph.Left,
                                (float)drawingGraph.Bottom,
                                (float)drawingGraph.Width,
                                (float)drawingGraph.Height);
 }
        void DrawAll(int w, int h, Graphics graphics)
        {
            //fill the whole image
            graphics.FillRectangle(new SolidBrush(Draw.MsaglColorToDrawingColor(gViewer.Graph.Attr.BackgroundColor)),
                                   new RectangleF(0, 0, w, h));

            //calculate the transform
            double s = ImageScale;
            Graph  g = gViewer.Graph;
            double x = 0.5 * w - s * (g.Left + 0.5 * g.Width);
            double y = 0.5 * h + s * (g.Bottom + 0.5 * g.Height);

            graphics.Transform = new Matrix((float)s, 0, 0, (float)-s, (float)x, (float)y);
            Draw.DrawPrecalculatedLayoutObject(graphics, gViewer.DGraph);
        }
        private void DrawAll(int w, int h, System.Drawing.Graphics graphics)
        {
            using (SolidBrush solidBrush = new SolidBrush(Draw.MsaglColorToDrawingColor(gViewer.Graph.Attr.BackgroundColor))) {
                //fill the whole image
                graphics.FillRectangle(solidBrush, new RectangleF(0, 0, w, h));
            }

            //calculate the transform
            double s = ImageScale;

            Microsoft.Msagl.Drawing.Graph g = gViewer.Graph;
            double x = 0.5 * w - s * (g.Left + 0.5 * g.Width);
            double y = 0.5 * h + s * (g.Bottom + 0.5 * g.Height);

            using (graphics.Transform = new System.Drawing.Drawing2D.Matrix((float)s, 0, 0, (float)-s, (float)x, (float)y)) {
                Draw.DrawPrecalculatedLayoutObject(graphics, gViewer.DGraph);
            }
        }
        /// <summary>
        /// Renders the graph inside of the rectangle
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="rect"></param>
        public void Render(System.Drawing.Graphics graphics, System.Drawing.Rectangle rect)
        {
            if (graphics != null)
            {
                if (layedOutGraph == null)
                {
                    CalculateLayout();
                }

                double s       = Math.Min(rect.Width / graph.Width, rect.Height / graph.Height);
                double xoffset = rect.Left + 0.5 * rect.Width - s * (graph.Left + 0.5 * graph.Width);
                double yoffset = rect.Top + 0.5 * rect.Height + s * (graph.Bottom + 0.5 * graph.Height);
                using (SolidBrush sb = new SolidBrush(Draw.MsaglColorToDrawingColor(graph.Attr.BackgroundColor)))
                    graphics.FillRectangle(sb, rect);

                using (System.Drawing.Drawing2D.Matrix m = new System.Drawing.Drawing2D.Matrix((float)s, 0, 0, (float)-s, (float)xoffset, (float)yoffset))
                    graphics.Transform = m;

                Draw.DrawPrecalculatedLayoutObject(graphics, layedOutGraph);
            }
        }