예제 #1
0
        void Advance()
        {
            alpha -= 0.01;
            if (alpha < 0)
            {
                alpha = 0;
            }

            if (brush == null)
            {
                brush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
            }

            if (label == null)
            {
                label = FallingThings.MakeSimpleLabel(text, new Rect(0, 0, 0, 0), brush);
            }

            brush.Opacity    = Math.Pow(alpha, 1.5);
            label.Foreground = brush;
            fontSize        += fontGrow;
            label.FontSize   = fontSize;
            Rect rRendered = new Rect(label.RenderSize);

            label.SetValue(Canvas.LeftProperty, center.X - rRendered.Width / 2);
            label.SetValue(Canvas.TopProperty, center.Y - rRendered.Height / 2);
        }
예제 #2
0
        private Label GetLabel()
        {
            if (brush == null)
            {
                brush = new SolidColorBrush(color);
            }

            if (label == null)
            {
                label = FallingThings.MakeSimpleLabel(text, boundsRect, brush);
                if (doScroll)
                {
                    label.FontSize = Math.Max(20, boundsRect.Height / 30);
                    label.Width    = 10000;
                }
                else
                {
                    label.FontSize = Math.Min(Math.Max(10, boundsRect.Width * 2 / text.Length),
                                              Math.Max(10, boundsRect.Height / 20));
                }
                label.VerticalContentAlignment   = VerticalAlignment.Bottom;
                label.HorizontalContentAlignment = (doScroll) ? HorizontalAlignment.Left : HorizontalAlignment.Center;
                label.SetValue(Canvas.LeftProperty, offset * boundsRect.Width);
            }

            renderedRect = new Rect(label.RenderSize);

            if (doScroll)
            {
                offset -= 0.0015;
                if (offset * boundsRect.Width < boundsRect.Left - 10000)
                {
                    return(null);
                }
                label.SetValue(Canvas.LeftProperty, offset * boundsRect.Width + boundsRect.Left);
            }
            return(label);
        }