Advertisement
Guest User

Untitled

a guest
May 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
  2. {
  3. FormattedText text = new FormattedText(OverlayedText, Thread.CurrentThread.CurrentUICulture,
  4. FlowDirection.LeftToRight, Typeface, FontSize, ForeGround);
  5. Point textPoint = startPoint;
  6. if (DesiredSize.Height > 0 && DesiredSize.Width > 0 && text.Width > 0)
  7. {
  8. textPoint.X = DesiredSize.Width / 2 - text.Width/2;
  9. textPoint.Y = DesiredSize.Height / 2;
  10. }
  11. drawingContext.DrawText(text, textPoint);
  12. drawingContext.DrawRectangle(Color, Border, new Rect(startPoint, DesiredSize));
  13.  
  14. Uri oUri = new Uri("pack://application:,,,/DisplayTimeManager.WPF;component/Resources/Icons/loadgif.gif", UriKind.RelativeOrAbsolute);
  15. ImageSource lockImage = new BitmapImage(oUri);
  16. int imgSize = 64;
  17. Rect targetRect = new Rect(textPoint.X+ imgSize/2, textPoint.Y+ imgSize/2, imgSize ,imgSize);
  18.  
  19. //animacion
  20. DoubleAnimation doubleAnimation = new DoubleAnimation();
  21. doubleAnimation.From = 0;
  22. doubleAnimation.To = 360;
  23. doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
  24. doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
  25. AnimationClock myClockAngle = doubleAnimation.CreateClock();
  26. //y dibujamos
  27.  
  28. var drawingGroup = new DrawingGroup();
  29. //drawingGroup.Transform.
  30. drawingGroup.Transform = new RotateTransform();
  31. drawingGroup.Transform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);
  32. ImageDrawing imagedrawing = new ImageDrawing(lockImage, new Rect(imgSize / 2 * (-1), imgSize / 2 * (-1), imgSize, imgSize));
  33. //ImageDrawing imagedrawing = new ImageDrawing(lockImage,targetRect );
  34. drawingGroup.Children.Add(imagedrawing);
  35. drawingContext.DrawDrawing(drawingGroup);
  36.  
  37. base.OnRender(drawingContext);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement