예제 #1
0
        public void DrawUnscaled(Graphics g, LiveSplitState state, float width, float height)
        {
            BigTextLabel.ShadowColor    = state.LayoutSettings.ShadowsColor;
            BigTextLabel.OutlineColor   = state.LayoutSettings.TextOutlineColor;
            BigTextLabel.HasShadow      = state.LayoutSettings.DropShadows;
            SmallTextLabel.ShadowColor  = state.LayoutSettings.ShadowsColor;
            SmallTextLabel.OutlineColor = state.LayoutSettings.TextOutlineColor;
            SmallTextLabel.HasShadow    = state.LayoutSettings.DropShadows;

            UpdateTimeFormat();

            var smallFont           = TimerDecimalPlacesFont;
            var bigFont             = TimerFont;
            var sizeMultiplier      = bigFont.Size / bigFont.FontFamily.GetEmHeight(bigFont.Style);
            var smallSizeMultiplier = smallFont.Size / bigFont.FontFamily.GetEmHeight(bigFont.Style);
            var ascent      = sizeMultiplier * bigFont.FontFamily.GetCellAscent(bigFont.Style);
            var descent     = sizeMultiplier * bigFont.FontFamily.GetCellDescent(bigFont.Style);
            var smallAscent = smallSizeMultiplier * smallFont.FontFamily.GetCellAscent(smallFont.Style);
            var shift       = (height - ascent - descent) / 2f;

            BigTextLabel.X        = width - 499 - SmallTextLabel.ActualWidth;
            SmallTextLabel.X      = width - SmallTextLabel.ActualWidth - 6;
            BigTextLabel.Y        = shift;
            SmallTextLabel.Y      = shift + ascent - smallAscent;
            BigTextLabel.Height   = 150f;
            SmallTextLabel.Height = 150f;

            BigTextLabel.IsMonospaced   = true;
            SmallTextLabel.IsMonospaced = true;

            if (Settings.ShowGradient && BigTextLabel.Brush is SolidBrush)
            {
                var    originalColor = (BigTextLabel.Brush as SolidBrush).Color;
                double h, s, v;
                originalColor.ToHSV(out h, out s, out v);

                var bottomColor = ColorExtensions.FromHSV(h, s, 0.8 * v);
                var topColor    = ColorExtensions.FromHSV(h, 0.5 * s, Math.Min(1, 1.5 * v + 0.1));

                var bigTimerGradiantBrush = new LinearGradientBrush(
                    new PointF(BigTextLabel.X, BigTextLabel.Y),
                    new PointF(BigTextLabel.X, BigTextLabel.Y + ascent + descent),
                    topColor,
                    bottomColor);
                var smallTimerGradiantBrush = new LinearGradientBrush(
                    new PointF(SmallTextLabel.X, SmallTextLabel.Y),
                    new PointF(SmallTextLabel.X, SmallTextLabel.Y + ascent + descent + smallFont.Size - bigFont.Size),
                    topColor,
                    bottomColor);

                BigTextLabel.Brush   = bigTimerGradiantBrush;
                SmallTextLabel.Brush = smallTimerGradiantBrush;
            }

            BigTextLabel.Draw(g);
            SmallTextLabel.Draw(g);
        }
예제 #2
0
        private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height)
        {
            DrawBackground(g, TimerColor, Settings.BackgroundColor, Settings.BackgroundColor2, width, height, Settings.BackgroundGradient);

            if (state.LayoutSettings.TimerFont != TimerFont || Settings.DecimalsSize != PreviousDecimalsSize)
            {
                TimerFont = state.LayoutSettings.TimerFont;
                TimerDecimalPlacesFont = new Font(TimerFont.FontFamily.Name, (TimerFont.Size / 50f) * (Settings.DecimalsSize), TimerFont.Style, GraphicsUnit.Pixel);
                PreviousDecimalsSize   = Settings.DecimalsSize;
            }

            BigTextLabel.Font     = BigMeasureLabel.Font = TimerFont;
            DeathsLabel.Font      = MeasureDeathsLabel.Font = SmallTextLabel.Font = TimerDecimalPlacesFont;
            DeathsLabel.DeathIcon = state.Settings.DeathIcon;

            BigMeasureLabel.SetActualWidth(g);
            SmallTextLabel.SetActualWidth(g);
            MeasureDeathsLabel.SetActualWidth(g);
            MeasureDeathsLabel.DeathIcon    = state.Settings.DeathIcon;
            MeasureDeathsLabel.ActualWidth += state.Settings.DeathIcon.Width;

            var oldMatrix      = g.Transform;
            var unscaledWidth  = Math.Max(10, MeasureDeathsLabel.ActualWidth + BigMeasureLabel.ActualWidth + SmallTextLabel.ActualWidth + 17);
            var unscaledHeight = 45f;
            var widthFactor    = (width - 14) / (unscaledWidth - 14);
            var heightFactor   = height / unscaledHeight;
            var adjustValue    = !Settings.CenterTimer ? 7f : 0f;
            var scale          = Math.Min(widthFactor, heightFactor);
            var deathsWidth    = (DeathsLabelVisible && Settings.ShowDeathCount) ? DeathsLabel.ActualWidth : 0;

            g.TranslateTransform(width - adjustValue, height / 2);
            g.ScaleTransform(scale, scale);
            g.TranslateTransform(-unscaledWidth + adjustValue, -0.5f * unscaledHeight);
            if (Settings.CenterTimer)
            {
                g.TranslateTransform((-(width - unscaledWidth * scale) / 2f) / scale, 0);
            }
            DrawUnscaled(g, state, unscaledWidth, unscaledHeight, oldMatrix);
            ActualWidth = scale * (SmallTextLabel.ActualWidth + BigTextLabel.ActualWidth + deathsWidth);
        }
예제 #3
0
        public void DrawUnscaled(Graphics g, LiveSplitState state, float width, float height, Matrix oldMatrix)
        {
            BigTextLabel.ShadowColor    = state.LayoutSettings.ShadowsColor;
            BigTextLabel.OutlineColor   = state.LayoutSettings.TextOutlineColor;
            BigTextLabel.HasShadow      = state.LayoutSettings.DropShadows;
            SmallTextLabel.ShadowColor  = state.LayoutSettings.ShadowsColor;
            SmallTextLabel.OutlineColor = state.LayoutSettings.TextOutlineColor;
            SmallTextLabel.HasShadow    = state.LayoutSettings.DropShadows;
            DeathsLabel.ShadowColor     = state.LayoutSettings.ShadowsColor;
            DeathsLabel.OutlineColor    = state.LayoutSettings.TextOutlineColor;
            DeathsLabel.HasShadow       = state.LayoutSettings.DropShadows;

            UpdateTimeFormat();

            var smallFont           = TimerDecimalPlacesFont;
            var bigFont             = TimerFont;
            var sizeMultiplier      = bigFont.Size / bigFont.FontFamily.GetEmHeight(bigFont.Style);
            var smallSizeMultiplier = smallFont.Size / bigFont.FontFamily.GetEmHeight(bigFont.Style);
            var ascent      = sizeMultiplier * bigFont.FontFamily.GetCellAscent(bigFont.Style);
            var descent     = sizeMultiplier * bigFont.FontFamily.GetCellDescent(bigFont.Style);
            var smallAscent = smallSizeMultiplier * smallFont.FontFamily.GetCellAscent(smallFont.Style);
            var shift       = (height - ascent - descent) / 2f;

            BigTextLabel.X        = width - 499 - SmallTextLabel.ActualWidth;
            SmallTextLabel.X      = width - SmallTextLabel.ActualWidth - 6;
            DeathsLabel.X         = 8;
            BigTextLabel.Y        = shift;
            SmallTextLabel.Y      = shift + ascent - smallAscent;
            DeathsLabel.Y         = shift + ascent - smallAscent - 1;
            BigTextLabel.Height   = 150f;
            SmallTextLabel.Height = 150f;
            DeathsLabel.Height    = 37f;

            BigTextLabel.IsMonospaced   = true;
            SmallTextLabel.IsMonospaced = true;
            DeathsLabel.IsMonospaced    = true;

            if (Settings.ShowGradient && BigTextLabel.Brush is SolidBrush && DeathsLabel.Brush is SolidBrush)
            {
                Color topColor;
                Color bottomColor;

                var originalTimeColor = (BigTextLabel.Brush as SolidBrush).Color;
                GetGradientColors(originalTimeColor, out topColor, out bottomColor);
                var bigTimerGradiantBrush = new LinearGradientBrush(
                    new PointF(BigTextLabel.X, BigTextLabel.Y),
                    new PointF(BigTextLabel.X, BigTextLabel.Y + ascent + descent),
                    topColor,
                    bottomColor);
                var smallTimerGradiantBrush = new LinearGradientBrush(
                    new PointF(SmallTextLabel.X, SmallTextLabel.Y),
                    new PointF(SmallTextLabel.X, SmallTextLabel.Y + ascent + descent + smallFont.Size - bigFont.Size),
                    topColor,
                    bottomColor);

                BigTextLabel.Brush   = bigTimerGradiantBrush;
                SmallTextLabel.Brush = smallTimerGradiantBrush;

                var originalDeathsColor = (DeathsLabel.Brush as SolidBrush).Color;
                GetGradientColors(originalDeathsColor, out topColor, out bottomColor);
                var deathsGradientBrush = new LinearGradientBrush(
                    new PointF(DeathsLabel.X, DeathsLabel.Y),
                    new PointF(DeathsLabel.X, DeathsLabel.Y + ascent + descent + smallFont.Size - bigFont.Size),
                    topColor,
                    bottomColor);

                DeathsLabel.Brush = deathsGradientBrush;
            }

            BigTextLabel.Draw(g);
            SmallTextLabel.Draw(g);
            g.TranslateTransform(-g.Transform.OffsetX / g.Transform.Elements[0], 0);
            if (DeathsLabelVisible && Settings.ShowDeathCount)
            {
                DeathsLabel.Draw(g);
            }
            g.Transform = oldMatrix;
        }