public void Draw(ICanvasAnimatedControl sender, CanvasTimingInformation timingInformation, CanvasDrawingSession ds) { ds.DrawCachedGeometry(clockFaceCachedFill, backgroundBrush); double fractionSecond; int seconds; if (sender.IsFixedTimeStep) { double updatesPerSecond = 1000.0 / sender.TargetElapsedTime.TotalMilliseconds; seconds = (int)((timingInformation.UpdateCount / updatesPerSecond) % 10); double updates = (double)timingInformation.UpdateCount; fractionSecond = (updates / updatesPerSecond) % 1.0; } else { double totalMilliseconds = timingInformation.TotalTime.TotalMilliseconds; double millisecondsThisIteration = totalMilliseconds % 1000; fractionSecond = millisecondsThisIteration / 1000.0f; seconds = (int)timingInformation.TotalTime.TotalSeconds % 10; } hueRotationEffect.Angle = (float)Math.PI * (seconds / 10.0f) * 2.0f; using (var timeSegmentGeometry = CreateTimeSegmentGeometry(ds, fractionSecond)) { ds.FillGeometry(timeSegmentGeometry, foregroundBrush); DrawSecondsText(ds, new Vector2(center), seconds); ds.DrawGeometry(timeSegmentGeometry, Colors.White, 1, hairlineStrokeStyle); } ds.DrawCachedGeometry(clockFaceCachedStroke18, Colors.White); ds.DrawCachedGeometry(clockFaceCachedStroke16, Colors.Black); }
/// <summary> /// user needs to call "ds.Clear(Colors.Transparent);" before this function if necessary /// </summary> /// <param name="ds"></param> /// <param name="lineColor"></param> /// <param name="lineWidth"></param> /// <param name="fillColor"></param> /// <param name="m"></param> public void Draw(CanvasDrawingSession ds, Color lineColor, float lineWidth, Color fillColor, Matrix3x2 m) { /*if (m != null) _cg = _cg.Transform(m); if (!(lineColor == Colors.Transparent)) { ds.DrawGeometry(_cg, lineColor, lineWidth); } if (fillColor != null) ds.FillGeometry(_cg, fillColor);//*/ ds.Transform = m; if (_ccgStroke != null && lineColor != Colors.Transparent) ds.DrawCachedGeometry(_ccgStroke, lineColor); if (_ccgFill != null && fillColor != Colors.Transparent) ds.DrawCachedGeometry(_ccgFill, fillColor); ds.Transform = Matrix3x2.Identity; }