Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
- {
- FormattedText text = new FormattedText(OverlayedText, Thread.CurrentThread.CurrentUICulture,
- FlowDirection.LeftToRight, Typeface, FontSize, ForeGround);
- Point textPoint = startPoint;
- if (DesiredSize.Height > 0 && DesiredSize.Width > 0 && text.Width > 0)
- {
- textPoint.X = DesiredSize.Width / 2 - text.Width/2;
- textPoint.Y = DesiredSize.Height / 2;
- }
- drawingContext.DrawText(text, textPoint);
- drawingContext.DrawRectangle(Color, Border, new Rect(startPoint, DesiredSize));
- Uri oUri = new Uri("pack://application:,,,/DisplayTimeManager.WPF;component/Resources/Icons/loadgif.gif", UriKind.RelativeOrAbsolute);
- ImageSource lockImage = new BitmapImage(oUri);
- int imgSize = 64;
- Rect targetRect = new Rect(textPoint.X+ imgSize/2, textPoint.Y+ imgSize/2, imgSize ,imgSize);
- //animacion
- DoubleAnimation doubleAnimation = new DoubleAnimation();
- doubleAnimation.From = 0;
- doubleAnimation.To = 360;
- doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(1));
- doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
- AnimationClock myClockAngle = doubleAnimation.CreateClock();
- //y dibujamos
- var drawingGroup = new DrawingGroup();
- //drawingGroup.Transform.
- drawingGroup.Transform = new RotateTransform();
- drawingGroup.Transform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);
- ImageDrawing imagedrawing = new ImageDrawing(lockImage, new Rect(imgSize / 2 * (-1), imgSize / 2 * (-1), imgSize, imgSize));
- //ImageDrawing imagedrawing = new ImageDrawing(lockImage,targetRect );
- drawingGroup.Children.Add(imagedrawing);
- drawingContext.DrawDrawing(drawingGroup);
- base.OnRender(drawingContext);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement