Anonymous Anonymous - 27 days ago
109 0

No description

C#

Rendering

public static void renderPartGraphics(Part tempPart, string fileName){     
            try{         
                Matrix translateMatrix = new Matrix();
                tempPart.generateGraphicsPath();

                float xOffset = -tempPart.getGraphicsPath().GetBounds().X;
                float yOffset = -tempPart.getGraphicsPath().GetBounds().Y;
                
                translateMatrix.Translate(xOffset, yOffset);
                tempPart.getGraphicsPath().Transform(translateMatrix);
                int tempWidth = (int)tempPart.getGraphicsPath().GetBounds().Width;
                int tempHeight = (int)tempPart.getGraphicsPath().GetBounds().Height+5;
                Bitmap graphicsBitmap = new Bitmap(tempWidth, tempHeight);

                Graphics outputGraphics = Graphics.FromImage(graphicsBitmap);
                
                outputGraphics.Clear(Color.Transparent);
                LinearGradientBrush linGrBrush = new LinearGradientBrush(
                    new Point(0, 10),
                    new Point(3000, 10),
                    Color.FromArgb(255, 75, 75, 75),
                    Color.FromArgb(255, 100, 100, 100));

                outputGraphics.SmoothingMode = SmoothingMode.AntiAlias;
                outputGraphics.FillPath(linGrBrush, tempPart.getGraphicsPath());
                outputGraphics.DrawPath(new Pen(Color.Red), tempPart.getGraphicsPath());
   
                graphicsBitmap.Save(@String.Format("images/Part_" +fileName+ "_" +tempPart.getPartName() + ".png" ));
            }
            catch(Exception e){
                Console.WriteLine("Part Rendering Not Possible");
                Console.WriteLine(e.ToString());
            }
        }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download