public static void drawGraphics(List <double> xs, List <double> ys, double w_height, System.Windows.Forms.Panel panel) { double maxX = xs.Max(); double maxY = ys.Max(); double width = maxX - xs.Min(); double maxheight = maxY - ys.Min(); double xscale = panel.Width / width; double yscale = panel.Height / maxheight; System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Tan, 3); System.Drawing.SolidBrush waterFill = new System.Drawing.SolidBrush(System.Drawing.Color.AliceBlue); System.Drawing.Graphics crossSection = panel.CreateGraphics(); crossSection.ScaleTransform((float)xscale, (float)yscale); System.Drawing.PointF[] points = new System.Drawing.PointF[xs.Count]; for (int i = 0; i < xs.Count - 1; i++) { double y = maxY - ys[i]; double y2 = maxY - ys[i + 1]; double x = xs[i]; points[i] = new System.Drawing.PointF((float)x, (float)y); } byte[] types = { (byte)points[0].X, (byte)System.Drawing.Drawing2D.PathPointType.Line, (byte)System.Drawing.Drawing2D.PathPointType.DashMode }; System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(points, types, System.Drawing.Drawing2D.FillMode.Alternate); crossSection.DrawPath(pen, path); crossSection.FillPath(waterFill, path); }
// draw the 16x16 abstraction public void drawAbstraction(System.Windows.Forms.Panel panel) { int AbstractedFrameWidth = panel.Width; int AbstractedFrameHeight = panel.Height; Graphics gr = panel.CreateGraphics(); gr.Clear(Color.White); int line, col, i, j; int resolutionX = AbstractedFrameWidth / ABSTRACTION_FRAME_WIDTH; int resolutionY = AbstractedFrameHeight / ABSTRACTION_FRAME_HEIGHT; for (line = 0; line < ABSTRACTION_FRAME_HEIGHT; line++) { for (i = 0; i < resolutionY; i++) { for (col = 0; col < ABSTRACTION_FRAME_WIDTH; col++) { for (j = 0; j < resolutionX; j++) { System.Drawing.Pen pen = new Pen(Color.FromArgb(RawAbstraction[(line * ABSTRACTION_FRAME_WIDTH + col) * 3], RawAbstraction[(line * ABSTRACTION_FRAME_WIDTH + col) * 3 + 1], RawAbstraction[(line * ABSTRACTION_FRAME_WIDTH + col) * 3 + 2] ) ); int y = line * resolutionY + i; int x = col * resolutionX + j; gr.DrawLine(pen, x, y, x + 1, y + 1); } } } } flagAbstractionReady = false; }
public void GraphGraphicsEquals() { System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel(); System.Drawing.Graphics graphics = panel.CreateGraphics(); Graph graph = new Graph(graphics); Assert.AreEqual(graphics, graph.GetGraphics()); }
public void GraphDrawEmpty() { System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel(); System.Drawing.Graphics graphics = panel.CreateGraphics(); Graph graph = new Graph(graphics); graph.Draw(); }
public void draw() { //if (parent == null) // return; System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush((type == CircleType.RED)?System.Drawing.Color.Red : System.Drawing.Color.Yellow); System.Drawing.Graphics formGraphics = parent.CreateGraphics(); formGraphics.FillEllipse(myBrush, new System.Drawing.Rectangle(x, y, width, height)); myBrush.Dispose(); formGraphics.Dispose(); }
public static void drawCrossSection(List <double> xs, List <double> ys, double w_height, System.Windows.Forms.Panel panel) { double maxX = xs.Max(); double maxY = ys.Max(); double width = maxX - xs.Min(); double maxheight = maxY - ys.Min(); double xscale = panel.Width / width; double yscale = panel.Height / maxheight; System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Tan, 3); System.Drawing.SolidBrush waterFill = new System.Drawing.SolidBrush(System.Drawing.Color.AliceBlue); System.Drawing.Pen waterFillPen = new System.Drawing.Pen(System.Drawing.Color.AliceBlue); System.Drawing.Graphics crossSection = panel.CreateGraphics(); crossSection.ScaleTransform((float)xscale, (float)yscale); System.Drawing.PointF[] crosspoints = new System.Drawing.PointF[xs.Count]; for (int i = 0; i < xs.Count - 1; i++) { double y = maxY - ys[i]; double y2 = maxY - ys[i + 1]; double x = xs[i]; double curwidth = xs[i + 1] - xs[i]; double highpoint = Math.Max(y, y2); //crossSection.DrawRectangle(waterFillPen, (float)x, -(float)highpoint, (float)curwidth, -(float)(w_height - highpoint)); //crosspoints[i] = new System.Drawing.PointF((float)x, (float)highpoint); // crosspoints[i + 1] = new System.Drawing.PointF((float)xs[i + 1], (float)highpoint); crossSection.DrawLine(pen, (float)xs[i], (float)y, (float)xs[i + 1], (float)y2); if (w_height > highpoint) { System.Drawing.RectangleF currec = new System.Drawing.RectangleF(); currec.Height = (float)(maxY - (w_height - highpoint)); currec.Location = new System.Drawing.PointF((float)x, (float)(maxY - (w_height))); currec.Width = (float)(xs[i + 1] - x); crossSection.FillRectangle(waterFill, currec); //crossSection.FillRectangle(waterFill, (float)x, (float)(panel.Height - ys[i]), (float)curwidth, -(float)(maxheight - (w_height - highpoint))); } } //crossSection.FillClosedCurve(waterFill, points); //crossSection.FillPolygon(waterFill, points); }
public override void Draw(Pen lul, System.Windows.Forms.Panel kek) { Graphics g = kek.CreateGraphics(); g.DrawRectangle(lul, x, y, a, b); Point one = new Point((int)x, (int)y); Point d = new Point((int)(x + a), (int)(y + b)); Point two = new Point((int)x, (int)(y + b / 2)); Point d2 = new Point((int)(x + a / 2), (int)(y + b)); Point three = new Point((int)(x + b / 2), (int)(y)); Point d3 = new Point((int)(x + a), (int)(y + b / 2)); g.DrawLine(lul, one, d); g.DrawLine(lul, two, d2); g.DrawLine(lul, three, d3); }
public override void Draw(Pen lul, System.Windows.Forms.Panel kek) { //рисуем первый квадрат Graphics g = kek.CreateGraphics(); g.DrawRectangle(lul, x, y, a, a); //находим все его точки Point one = new Point((int)x, (int)y); Point one2 = new Point((int)(x + a), (int)y); //* * //* * Point two = new Point((int)x, (int)(y + a)); Point two2 = new Point((int)(x + a), (int)(y + a)); //рисуем переехавший квадрат g.DrawRectangle(lul, x+a/2, y+a/2, a, a); //находим все его точки Point three = new Point((int)(x + a / 2), (int)(y + a / 2)); Point three2 = new Point((int)(a+ x + a / 2), (int)(y + a / 2)); //* * //* * Point four = new Point((int)(x + a / 2), (int)(a +y + a / 2)); Point four2 = new Point((int)(a + x + a / 2), (int)(a + y + a / 2)); //коннектим линиями первый ряд точек со вторым g.DrawLine(lul, one, three); g.DrawLine(lul, one2, three2); g.DrawLine(lul, two, four); g.DrawLine(lul, two2, four2); //g.DrawLine(lul, one, two2); // Point one = new Point() // g.DrawRectangle(lul, x, y, a, b); }
public override void Draw(Pen lul, System.Windows.Forms.Panel kek) { //рисуем первый квадрат Graphics g = kek.CreateGraphics(); //находим все его точки Point one = new Point((int)x, (int)y); Point one2 = new Point((int)(x + a), (int)y); //* * //* * Point two = new Point((int)x, (int)(y + b)); Point two2 = new Point((int)(x + a), (int)(y + b)); //рисуем переехавший квадрат g.DrawRectangle(lul, x + h, y + h, a, b); //находим все его точки Point three = new Point((int)(x + h), (int)(y + h)); Point three2 = new Point((int)(a + x + h), (int)(y + h)); //* * //* * Point four = new Point((int)(x + h), (int)(b + y + h)); Point four2 = new Point((int)(a + x + h), (int)(b + y + h)); //коннектим линиями первый ряд точек со вторым g.DrawLine(lul, one, three); g.DrawLine(lul, one2, three2); g.DrawLine(lul, two, four); lul.DashCap = System.Drawing.Drawing2D.DashCap.Round; lul.DashPattern = new float[] { 4.0F, 2.0F, 1.0F, 3.0F }; g.DrawLine(lul, two2, four2); g.DrawRectangle(lul, x, y, a, b); }
public override void Draw(Pen lul, System.Windows.Forms.Panel kek) { //рисуем первый квадрат Graphics g = kek.CreateGraphics(); // g.DrawRectangle(lul, x, y, a, b); //находим все его точки Point one = new Point((int)x, (int)y); Point two = new Point((int)(x + a), (int)(y)); Point three = new Point((int)(x + a + a / 2), (int)(y + Math.Sqrt(2) * a) / 2); Point four = new Point((int)(x + a / 2), (int)(y + Math.Sqrt(2) * a) / 2); Point r = new Point((int)((x + a + a / 2) - x), (int)(y - h)); // Point r2 = new Point((int)(((x + (x + a + a / 2)) / 2) + h), ((int)(((x + (x + a + a / 2)) / 2) - h))); //A,B,C,D g.DrawLine(lul, four, three); g.DrawLine(lul, one, four); //H //g.DrawLine(lul, r, r2); //AH,BH,CH,DH g.DrawLine(lul, one, r); g.DrawLine(lul, three, r); g.DrawLine(lul, four, r); lul.DashCap = System.Drawing.Drawing2D.DashCap.Round; lul.DashPattern = new float[] { 4.0F, 2.0F, 1.0F, 3.0F }; g.DrawLine(lul, one, two); g.DrawLine(lul, three, two); g.DrawLine(lul, two, r); }
public static void drawCrossSection2(List <double> xs, List <double> ys, double w_height, System.Windows.Forms.Panel panel) { double maxX = xs.Max(); double maxY = ys.Max(); double width = maxX - xs.Min(); double maxheight = maxY - ys.Min(); double xscale = panel.Width / width; double yscale = panel.Height / maxheight; System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Tan, 3); System.Drawing.SolidBrush waterFill = new System.Drawing.SolidBrush(System.Drawing.Color.AliceBlue); System.Drawing.Graphics crossSection = panel.CreateGraphics(); crossSection.ScaleTransform((float)xscale, (float)yscale); System.Drawing.PointF[] points = new System.Drawing.PointF[xs.Count]; for (int i = 0; i < xs.Count - 1; i++) { double y = maxY - ys[i]; double y2 = maxY - ys[i + 1]; double x = xs[i]; if (x == maxX) { points[i] = new System.Drawing.PointF((float)x, (float)maxY); } else { points[i] = new System.Drawing.PointF((float)x, (float)y); } if (xs[i + 1] == maxX) { points[i + 1] = new System.Drawing.PointF((float)x, (float)maxY); } } crossSection.DrawLines(pen, points); }
public override void Draw(Pen lul, System.Windows.Forms.Panel kek) { Graphics g = kek.CreateGraphics(); g.DrawRectangle(lul, x, y, a, b); }
public Adapter(System.Windows.Forms.Panel panel) { g = panel.CreateGraphics(); shapeList = new List <Shape>(); }
//Liefert zeichenflaeche zurueck public Graphics ZeichneFlaeche(System.Windows.Forms.Panel panel, Graphics zeichenflaeche) { zeichenflaeche = panel.CreateGraphics(); return(zeichenflaeche); }