public void DrawArc(QRectangle Rectangle, float StartAngle, float SweepAngle, QPen Pen) { #if WPF #else DrawingTarget.DrawArc(Pen.Pen, Rectangle.X, Rectangle.Y, Rectangle.Width, Rectangle.Height, StartAngle, SweepAngle); #endif }
public void Shoot(ref ObservableCollection <Target> Targets, double commonTime, int countThreadsMine, bool message) { timer.Tick += new EventHandler(dispatcherTimerWork_Tick); timer.Interval = TimeSpan.FromSeconds(1); timer.Start(); currentTime = 0; while (currentTime < commonTime - 2) { Thread.Sleep(Random.Next(85, 160)); int TargetIndex = Random.Next(Targets.Count); int damage = Random.Next(35, 45); if ((Targets[TargetIndex].GetType() == typeof(Target))) { Targets[TargetIndex].HealthPoints -= damage; CountHit++; } else { Targets[TargetIndex].HealthPoints -= damage; CountHit++; } DrawingTarget.Invoke(this); } if (currentTime == commonTime - 2) { timer.Tick -= new EventHandler(dispatcherTimerWork_Tick); timer.Stop(); if (message) { Enabled.Invoke(this); } return; } }
public void DrawString(string Text, QPoint Location, QPen Pen, QFont Font) { #if WPF PendingText.Add(new Tuple <string, QPoint, QPen, QFont, bool>(Text, Location, Pen, Font, false)); #else DrawingTarget.DrawString(Text, Font.Font, Pen.Brush, Location.X, Location.Y); #endif }
public void DrawStringCentered(string Text, QPoint Location, QPen Pen, QFont Font) { #if WPF PendingText.Add(new Tuple <string, QPoint, QPen, QFont, bool>(Text, Location, Pen, Font, true)); #else var size = MeasureText(Text, Font); DrawingTarget.DrawString(Text, Font.Font, Pen.Brush, Location.X - size.Width / 2, Location.Y - size.Height / 2); #endif }
public void RenderShape(Shape Shape, QPen Pen) { QPoint p1, p2; foreach (var l in Shape.Lines) { if (projector.Project2DLine(l.P1, l.P2, out p1, out p2)) { DrawingTarget.DrawLine(Pen, p1, p2); } } }
public QSize MeasureText(string Text, QFont Font) { #if WPF System.Windows.Controls.TextBlock tb = new System.Windows.Controls.TextBlock(); tb.FontFamily = Font.FontFamily; tb.FontStyle = Font.IsItalic ? System.Windows.FontStyles.Italic : System.Windows.FontStyles.Normal; tb.Text = Text; tb.Measure(new System.Windows.Size(double.PositiveInfinity, double.PositiveInfinity)); return(new QSize(tb.DesiredSize.Width + 6, tb.DesiredSize.Height + 4)); // roughly equivalent with GDI+ version #else var size = DrawingTarget.MeasureString(Text, Font.Font); return(new QSize(size.Width, size.Height)); #endif }
private void renderBody(CelestialBody Body, CaptionMode CaptionMode, double Zoom) { if (projector.PositionNearlyLocked && projector.BodyWithCamera.Equals(Body) && projector.ViewMode != ViewMode.TopDown) { return; } float radiusInPixels; double subtendedAngle = Body.AngleSubtendedFromDistance(Body.DistanceFromCamera) / 2.0; radiusInPixels = (float)Math.Abs(projector.Zoom * subtendedAngle); if (Body.RenderPoint.X < -radiusInPixels || Body.RenderPoint.Y < -radiusInPixels || Body.RenderPoint.X > this.ScreenSize.Width + radiusInPixels || Body.RenderPoint.Y > this.ScreenSize.Height + radiusInPixels) { return; } #if DEBUG if (Body.RenderPoint.IsZero) { throw new Exception(); } #endif bool caption; switch (CaptionMode) { case SolarMax.CaptionMode.Auto: caption = projector.BodyBeingViewed.Equals(Body) || radiusInPixels > AUTO_CAPTION_THRESHOLD || Zoom > Body.CaptionZoomThreshold; break; case SolarMax.CaptionMode.DynamicOnly: caption = projector.BodyBeingViewed.Equals(Body) || (Body.BodyType == CelestialBodyType.Dynamic && (radiusInPixels > AUTO_CAPTION_THRESHOLD || Zoom > Body.CaptionZoomThreshold)); break; default: caption = false; break; } if (caption) { DrawString(Body.DisplayName, new QPoint(Body.RenderPoint.X + radiusInPixels, Body.RenderPoint.Y + radiusInPixels), Body == projector.BodyBeingViewed ? QPen.White : Body.CaptionPen, this.SmallFont); } if (this.WireFrameBodyRender && radiusInPixels > 7 && Body.HasShape) { var shape = (radiusInPixels > 80) ? Body.ShapeBig : (radiusInPixels > 30) ? Body.ShapeMedium : Body.ShapeSmall; shape.Reset(); if (Body.HasDynamicShape) { shape.RotateAbout(Body.Axis, Body.AngleSnapshot); } shape.Move(Body.PositionSnapshot); QPoint p1, p2; double distSqr = projector.Position.DistanceToSquared(Body.PositionSnapshot); bool highlightSun = HighlightSunlitAreas && Body is Orbiter; double distSqrSun = highlightSun ? CelestialBody.Sun.PositionSnapshot.DistanceToSquared(Body.PositionSnapshot) : double.MaxValue; // Draw back of object foreach (var l in shape.Lines) { l.IsInFront = l.P1.DistanceToSquared(projector.Position) < distSqr || l.P2.DistanceToSquared(projector.Position) < distSqr; if (!l.IsInFront) { if (projector.Project2DLine(l.P1, l.P2, out p1, out p2)) { DrawingTarget.DrawLine(l.LineType == LineType.Special ? primeMeridianDarkPen : Body.BackPen, p1, p2); } } } // Draw axis if (radiusInPixels > DRAW_AXIS_THRESHOLD) { if (projector.Project2DLine(Body.PositionSnapshot + Body.Axis * Body.Radius * AXIS_SCALE, Body.PositionSnapshot - Body.Axis * Body.Radius * AXIS_SCALE, out p1, out p2)) { DrawingTarget.DrawLine(planetAxisPen, p1, p2); } } //Draw front of object foreach (var l in shape.Lines) { if (l.IsInFront) { if (projector.Project2DLine(l.P1, l.P2, out p1, out p2)) { if (highlightSun && l.LineType != LineType.Special && (l.P1.DistanceToSquared(CelestialBody.Sun.PositionSnapshot) < distSqrSun || l.P2.DistanceToSquared(CelestialBody.Sun.PositionSnapshot) < distSqrSun)) { DrawingTarget.DrawLine(sunlitArea, p1, p2); } else { DrawingTarget.DrawLine(l.LineType == LineType.Special ? primeMeridianPen : Body.FrontPen, p1, p2); } } } } } else { radiusInPixels += Body.RadiusEnhancement; if (radiusInPixels > 1f) { DrawingTarget.FillCircle(Body.Pen, Body.RenderPoint.X, Body.RenderPoint.Y, radiusInPixels); } else { DrawingTarget.SetPixel(Body.Pen, Body.RenderPoint.X, Body.RenderPoint.Y); } } RenderLocations[NumRenderLocations++] = Body; }
public void FillRectangle(QPoint Location, QSize Size, QPen FillPen, QPen BorderPen) { this.FillRectangle(Location, Size, FillPen); DrawingTarget.DrawRectangle(BorderPen, Location, Size); }
public void FillRectangle(QPoint Location, QSize Size, QPen Pen) { DrawingTarget.FillRectangle(Pen, Location, Size); }
public void FillRectangle(QRectangle Rectangle, QPen FillPen, QPen BorderPen) { DrawingTarget.FillRectangle(FillPen, Rectangle); DrawingTarget.DrawRectangle(BorderPen, Rectangle); }
public void DrawRectangle(QRectangle Rectangle, QPen Pen) { DrawingTarget.DrawRectangle(Pen, Rectangle.Location, Rectangle.Size); }
public void DrawCircle(QPoint Center, float Radius, QPen Pen) { DrawingTarget.DrawCircle(Pen, Center, Radius); }
public void DrawEllipse(QPoint Center, QSize Size, QPen Pen) { DrawingTarget.DrawEllipse(Pen, Center, Size); }
public void DrawLine(QPen Pen, float X1, float Y1, float X2, float Y2) { DrawingTarget.DrawLine(Pen.Pen, X1, Y1, X2, Y2); }
public void DrawLine(QPen Pen, QPoint P1, QPoint P2) { DrawingTarget.DrawLine(Pen.Pen, P1.X, P1.Y, P2.X, P2.Y); }