public void DrawToBuffer() //Здесь будет происходить отрисовка кадра в буфер { int drawNum = 0; //List<DrawableObject> list = new List<DrawableObject>(); SortedList <int, DrawableObject> list = new SortedList <int, DrawableObject>(); if (System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.Z) == true) { //if (System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.Space)>0) //Отлично, для этого он просит запилить потоки и прочую чешую. Разобраться grafx.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255, 128, 0, 0)), 0, 0, view.width, view.height); } else { grafx.Graphics.FillRectangle(Brushes.Black, 0, 0, view.width, view.height); } foreach (Layer layer in game.objectManager.Layers) { DrawableObject obj = layer.getNextObject(); while (obj != null) { if ((obj.position.X + obj.width > view.x) && (obj.position.X < view.x + view.width) && (obj.position.Y + obj.height * 2 > view.y) && (obj.position.Y < view.y + view.height)) { //list.Add(obj.depth, obj); obj.Draw(grafx, (float)(obj.position.X - view.x), (float)(obj.position.Y - view.y)); drawNum++; } obj = layer.getNextObject(); } } ; /*list.Sort(delegate(DrawableObject x, DrawableObject y) * { * if (x.depth == y.depth) return 0; * else if (x.depth > y.depth) return -1; * else return 1; * });*/ for (int i = 0; i < list.Count; i++) { DrawableObject obj = list.ElementAt(i).Value; obj.Draw(grafx, (float)(obj.position.X - view.x), (float)(obj.position.Y - view.y)); } // foreach (DrawableObject obj in list) // { // obj.Draw(grafx, (float)(obj.position.X - view.x), (float)(obj.position.Y - view.y)); // } grafx.Graphics.DrawString(Convert.ToString(fps), font, Brushes.Red, new Point(0, 0)); grafx.Graphics.DrawString(Convert.ToString(drawNum), font, Brushes.Red, new Point(0, 30)); grafx.Graphics.DrawLine(new Pen(Color.White, 64.0f), new Point((int)-view.x, game.gameLogic.stageHeight - (int)view.y), new Point(game.gameLogic.stageWidth - (int)view.x, game.gameLogic.stageHeight - (int)view.y)); int l = Cursor.Position.X; int s = Cursor.Position.Y; Stats.SetStat("lives", l); Stats.SetStat("scores", s); Stats.Draw(grafx); }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; background.Draw(g, background.Rect, Color.Black); g.DrawString("Pong", new Font("Times New Roman", 25.0f), background.GetBrushColor(Color.Gray), new PointF(350f, 50f)); g.DrawString(" 1P ", new Font("Times New Roman", 25.0f), background.GetBrushColor(onePlayerColor), new PointF(350f, 100f)); g.DrawString(" 2P ", new Font("Times New Roman", 25.0f), background.GetBrushColor(twoPlayerColor), new PointF(350f, 150f)); }
private void UpdateScreen() { device.Clear(Color.White); device.Begin(); foo.Draw(scene); bar.Draw(scene); selectionCursor.Draw(scene); highlightingCursor.Draw(scene); labelPolygons.Text = device.PolygonsCount.ToString(); device.End(); }
private void canvas_Draw(object sender, CanvasDrawEventArgs e) { e.Device.Clear(Color.CornflowerBlue); e.Device.Begin(); cube.Draw(canvas.Scene); if (cursorVisible) { rotationCursor.Draw(canvas.Scene); } e.Device.End(); }
public void DrawSelections(Graphics g, Matrix transform) { //Draw drawing object if (DrawingObject != null) { DrawingObject.Draw(g, transform.Elements[3]); } //Drawing selections SelectionRectangles.Clear(); foreach (DrawableObject obj in selectedObjects) { SelectionRectangles.AddRange(obj.DrawSelection(g, selectedObjectFocusedIndex == selectedObjects.IndexOf(obj))); } if (SelectionRectangles.Count > 0) { foreach (SelectionRectangle sre in SelectionRectangles) { RectangleF rect = sre.Rectangle(transform.Elements.First()); if (sre.focus) { g.FillRectangle(Brushes.White, rect); g.DrawRectangle(new Pen(Color.Blue, 0.001f), rect.X, rect.Y, rect.Width, rect.Height); } else { g.FillRectangle(Brushes.Blue, rect); } } } if (InclusiveSelection) { Brush iselb = new SolidBrush(Color.FromArgb(20, Color.Blue)); g.FillRectangle(iselb, SelectionArea); } g.DrawRectangle(Pens.Blue, SelectionArea); //draw DrawPoint if (OnObject != null && ((Doing == MouseDoing.Resizing && OnTransition != null) || Doing == MouseDoing.Drawing || (Doing == MouseDoing.Nothing && CursorType == CursorTypes.Paint && (DrawingObjectType == DrawableObject.ObjectType.SimpleTransition || DrawingObjectType == DrawableObject.ObjectType.SuperTransition)))) { try { if (DrawingObjectType == DrawableObject.ObjectType.SimpleTransition) { if (OnObject is State || OnObject is SuperState || OnObject is Alias || OnObject is End || OnObject is Abort) { g.DrawEllipse(Pens.Red, StartDrawPoint.X - 2, StartDrawPoint.Y - 2, 4, 4); } else if (OnObject is Origin) { var origin = (Origin)OnObject; g.DrawEllipse(Pens.Red, origin.Location.X - Origin.selectionRadio, origin.Location.Y - Origin.selectionRadio, Origin.selectionRadio * 2, Origin.selectionRadio * 2); } } else if (DrawingObjectType == DrawableObject.ObjectType.SuperTransition) { if (OnObject is SuperState || OnObject is Nested) { g.DrawEllipse(Pens.Red, StartDrawPoint.X - 2, StartDrawPoint.Y - 2, 4, 4); } else if (OnObject is Origin) { var origin = (Origin)OnObject; g.DrawEllipse(Pens.Red, origin.Location.X - Origin.selectionRadio, origin.Location.Y - Origin.selectionRadio, origin.SelectionRadio * 2, Origin.selectionRadio * 2); } } else { if (OnObject is State || OnObject is SuperState || OnObject is Alias || OnObject is End || OnObject is Abort) { g.DrawEllipse(Pens.Red, StartDrawPoint.X - 2, StartDrawPoint.Y - 2, 4, 4); } else if (OnObject is Origin) { var origin = (Origin)OnObject; g.DrawEllipse(Pens.Red, origin.Location.X - Origin.selectionRadio, origin.Location.Y - Origin.selectionRadio, Origin.selectionRadio * 2, Origin.selectionRadio * 2); } } } catch (Exception e) { MessageBox.Show("Error MouseTool.DrawSelections:" + e.Message); } } }
/// <summary> /// Set bounds on drawable object and draws it on specified canvas /// </summary> public void BoundAndDraw(Canvas canvas) { DrawableObject.SetBounds(Left, Top, Right, Bottom); DrawableObject.Draw(canvas); }
/// <summary> /// Draw all graphics2d objects /// </summary> /// <param name="style">Style for drawing</param> /// <param name="draw">The drawable object to draw</param> public void Draw(DrawStyle style, DrawableObject draw) { draw.Draw(Graphics, style); }