protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { System.Windows.Media.Media3D.Size3D size = (agentBase as BusAgent).Size; drawingContext.PushTransform(new TranslateTransform(Location.X - size.X / 4 , Location.Y)); drawingContext.PushTransform(new RotateTransform((agentBase as BusAgent).Angle)); drawingContext.DrawRectangle(GetGroupColor(agentBase.Group), null, new Rect(-size.X / 4, -size.Y / 2, size.X, size.Y)); drawingContext.DrawRectangle(Brushes.LightBlue, null, new Rect(size.X / 4 * 3 - 2, -size.Y / 2, 2, size.Y)); drawingContext.Pop(); drawingContext.Pop(); }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { System.Windows.Media.Media3D.Size3D size = (agentBase as TrainAgent).Size; for (int i = 0; i < (agentBase as TrainAgent).Positions.Length; i++) { if ((agentBase as TrainAgent).NeedDraw[i] == true) { Point position = (agentBase as TrainAgent).Positions[i]; drawingContext.PushTransform(new TranslateTransform(position.X, position.Y)); drawingContext.PushTransform(new RotateTransform((agentBase as TrainAgent).Angles[i])); drawingContext.DrawRectangle(GetGroupColor(agentBase.Group), null, new Rect(-size.X / 2, -size.Y / 2, size.X, size.Y)); drawingContext.Pop(); drawingContext.Pop(); } } }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { Rotary rotary = Visual as Rotary; if (rotary != null) { drawingContext.PushTransform(new RotateTransform(rotary.KnobRotation, _center.X, _center.Y)); drawingContext.DrawImage(_image, _imageRect); drawingContext.Pop(); } }
public override void Draw(System.Windows.Media.DrawingContext dc) { var formattedText = GetFormattedText(Text, Thickness); if (Orientation == Orientation.Hor) { dc.DrawText(formattedText, new System.Windows.Point(StartPoint.X - formattedText.Width/2, StartPoint.Y)); } else { var rotate = new RotateTransform(); rotate.Angle = 90; dc.PushTransform(rotate); dc.DrawText(formattedText, new System.Windows.Point(StartPoint.Y, -StartPoint.X)); dc.Pop(); } }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { drawingContext.PushTransform(new ScaleTransform(_scaleX, _scaleY)); drawingContext.DrawEllipse(Brushes.Black, null, _center, 187d, 187d); if (_rwr != null && _rwr.IsOn) { bool primary = DateTime.Now.Millisecond < 500; // Draw heart beat lines drawingContext.DrawLine(_scopePen, new Point(160d, 193.5), new Point(180d, 193.5d)); drawingContext.DrawLine(_scopePen, new Point(220d, 193.5), new Point(240d, 193.5d)); drawingContext.DrawLine(_scopePen, new Point(200d, 153.5), new Point(200d, 173.5)); drawingContext.DrawLine(_scopePen, new Point(200d, 213.5), new Point(200d, 233.5)); if (primary) { drawingContext.DrawLine(_scopePen, new Point(220d, 193.5d), new Point(220d, 203.5d)); } else { drawingContext.DrawLine(_scopePen, new Point(220d, 183.5d), new Point(220d, 193.5d)); } if (_rwr.Contacts != null) { foreach (RadarContact contact in _rwr.Contacts) { if (contact.Visible) { double y = 0.0f; if (contact.Lethality > 1f) { y = -((2.0f - contact.Lethality) * 178.0d); } else { y = -((1.0f - contact.Lethality) * 178.0d); } drawingContext.PushTransform(new RotateTransform(contact.RelativeBearing)); drawingContext.PushTransform(new TranslateTransform(0d, y)); drawingContext.PushTransform(new RotateTransform(-contact.RelativeBearing)); if (contact.NewDetection && !primary) { _format.FontSize = 24; } else { _format.FontSize = 22; } DrawContactSymbol(drawingContext, contact, primary); if (contact.Selected) { drawingContext.DrawLine(_scopePen, new Point(200d, 168.5d), new Point(225d, 193.5d)); drawingContext.DrawLine(_scopePen, new Point(225d, 193.5d), new Point(200d, 218.5d)); drawingContext.DrawLine(_scopePen, new Point(200d, 218.5d), new Point(175d, 193.5d)); drawingContext.DrawLine(_scopePen, new Point(175d, 193.5d), new Point(200d, 168.5d)); } if ((contact.MissileActivity && !contact.MissileLaunch) || (contact.MissileActivity && contact.MissileLaunch && _rwr.Flash4Hz)) { drawingContext.DrawEllipse(null, _scopePen, _center, 25, 25); } drawingContext.Pop(); drawingContext.Pop(); drawingContext.Pop(); } } } } if (_bezelBrush != null) { drawingContext.DrawRectangle(_bezelBrush, null, _bezelRect); } drawingContext.Pop(); }
protected override void OnDraw(System.Windows.Media.DrawingContext g) { if (Rotation != 0) { g.PushTransform(new System.Windows.Media.RotateTransform(-(Rotation / (Math.PI) * 180f), CurrentRotationCenter.X, CurrentRotationCenter.Y)); } }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { if (_editor.SelectedItems.Count > 0) { Pen rectPen = _drawFocus ? SelectionRectPen : SelectionRectPenNoFocus; Brush circleBrush = _drawFocus ? SelectionResizeBrush : SelectionResizeBrushNoFocus; if (_isline) { Point start; Point end; drawingContext.PushTransform(new ScaleTransform(_editor.ZoomFactor, _editor.ZoomFactor)); if (_editor.SnapManager.Action == SnapAction.LineStart || _editor.SnapManager.Action == SnapAction.LineEnd) { drawingContext.PushTransform(new TranslateTransform(_tempLine.Left, _tempLine.Top)); _tempLine.Renderer.Render(drawingContext); drawingContext.Pop(); start = _tempLine.Start; end = _tempLine.End; } else { Helios.Controls.LineDecoration line = _editor.SelectedItems[0] as Helios.Controls.LineDecoration; start = line.Start; end = line.End; if (_editor.SnapManager.Action == SnapAction.Move) { start += _editor.SnapManager.LocationOffset; end += _editor.SnapManager.LocationOffset; _tempLine.Clone(line); drawingContext.PushTransform(new TranslateTransform(_tempLine.Left + _editor.SnapManager.LocationOffset.X, _tempLine.Top + _editor.SnapManager.LocationOffset.Y)); _tempLine.Renderer.Render(drawingContext); drawingContext.Pop(); } } drawingContext.Pop(); start.X *= _editor.ZoomFactor; start.Y *= _editor.ZoomFactor; end.X *= _editor.ZoomFactor; end.Y *= _editor.ZoomFactor; drawingContext.DrawEllipse(circleBrush, rectPen, start, ResizeRadius, ResizeRadius); drawingContext.DrawEllipse(circleBrush, rectPen, end, ResizeRadius, ResizeRadius); } else { foreach (HeliosVisual visual in _editor.SelectedItems) { Rect visualRect = visual.DisplayRectangle; visualRect.Scale(_editor.ZoomFactor, _editor.ZoomFactor); drawingContext.DrawRectangle(null, SelectionBorderPen, visualRect); } Rect selectionRect = (_editor.SnapManager.Action != SnapAction.None && _editor.SnapManager.Action != SnapAction.Drop && _editor.SnapManager.IsValidDrag) ? _editor.SnapManager.NewRectangle : _editor.SelectedItems.Rectangle; selectionRect.Scale(_editor.ZoomFactor, _editor.ZoomFactor); drawingContext.DrawRectangle(null, rectPen, selectionRect); drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.TopLeft, ResizeRadius, ResizeRadius); drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.TopRight, ResizeRadius, ResizeRadius); drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.BottomLeft, ResizeRadius, ResizeRadius); drawingContext.DrawEllipse(circleBrush, rectPen, selectionRect.BottomRight, ResizeRadius, ResizeRadius); } } }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { TransformGroup transform = new TransformGroup(); transform.Children.Add(new TranslateTransform((-_center.X + HorizontalOffset) * _xScale, (-_center.Y + VerticalOffset) * _yScale)); transform.Children.Add(new RotateTransform(_rotation + _baseRotation)); transform.Children.Add(new TranslateTransform(_location.X * _xScale, _location.Y * _yScale)); drawingContext.PushTransform(transform); drawingContext.DrawImage(_image, _rectangle); drawingContext.Pop(); }