protected float CalculateLabelsWidth()
 {
     if (ColumnsList != null)
     {
         var mixedCount = ColumnsList.Count(x => x.Type == ColumnType.DeltaorSplitTime || x.Type == ColumnType.SegmentDeltaorSegmentTime);
         var deltaCount = ColumnsList.Count(x => x.Type == ColumnType.Delta || x.Type == ColumnType.SegmentDelta);
         var timeCount  = ColumnsList.Count(x => x.Type == ColumnType.SplitTime || x.Type == ColumnType.SegmentTime);
         return((mixedCount * (Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth) + 5))
                + (deltaCount * (MeasureDeltaLabel.ActualWidth + 5))
                + (timeCount * (MeasureTimeLabel.ActualWidth + 5)));
     }
     return(0f);
 }
 protected void RecreateLabels()
 {
     if (ColumnsList != null && LabelsList.Count != ColumnsList.Count())
     {
         LabelsList.Clear();
         foreach (var column in ColumnsList)
         {
             LabelsList.Add(new SimpleLabel
             {
                 HorizontalAlignment = StringAlignment.Far
             });
         }
     }
 }
Beispiel #3
0
        public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            UpdateAll(state);

            Cache.Restart();
            Cache["ColumnsCount"] = ColumnsList.Count();
            foreach (var label in LabelsList)
            {
                Cache["Columns" + LabelsList.IndexOf(label) + "Text"] = label.Text;
            }

            if (invalidator != null && Cache.HasChanged || FrameCount > 1)
            {
                invalidator.Invalidate(0, 0, width, height);
            }
        }
        public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            if (Split != null)
            {
                UpdateAll(state);
                NeedUpdateAll = false;

                IsActive = (state.CurrentPhase == TimerPhase.Running ||
                            state.CurrentPhase == TimerPhase.Paused) &&
                           state.CurrentSplit == Split;

                Cache.Restart();
                Cache["Icon"] = Split.Icon;
                if (Cache.HasChanged)
                {
                    if (Split.Icon == null)
                    {
                        FrameCount = 0;
                    }
                    else
                    {
                        FrameCount = Split.Icon.GetFrameCount(new FrameDimension(Split.Icon.FrameDimensionsList[0]));
                    }
                }
                Cache["DisplayIcon"]  = DisplayIcon;
                Cache["SplitName"]    = NameLabel.Text;
                Cache["IsActive"]     = IsActive;
                Cache["NameColor"]    = NameLabel.ForeColor.ToArgb();
                Cache["ColumnsCount"] = ColumnsList.Count();
                foreach (var label in LabelsList)
                {
                    Cache["Columns" + LabelsList.IndexOf(label) + "Text"]  = label.Text;
                    Cache["Columns" + LabelsList.IndexOf(label) + "Color"] = label.ForeColor.ToArgb();
                }

                if (invalidator != null && Cache.HasChanged || FrameCount > 1)
                {
                    invalidator.Invalidate(0, 0, width, height);
                }
            }
        }
Beispiel #5
0
        private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            if (Settings.BackgroundGradient == ExtendedGradientType.Alternating)
            {
                g.FillRectangle(new SolidBrush(
                                    Settings.BackgroundColor
                                    ), 0, 0, width, height);
            }

            MeasureTimeLabel.Text  = TimeFormatter.Format(new TimeSpan(24, 0, 0));
            MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0));

            MeasureTimeLabel.Font          = state.LayoutSettings.TimesFont;
            MeasureTimeLabel.IsMonospaced  = true;
            MeasureDeltaLabel.Font         = state.LayoutSettings.TimesFont;
            MeasureDeltaLabel.IsMonospaced = true;

            MeasureTimeLabel.SetActualWidth(g);
            MeasureDeltaLabel.SetActualWidth(g);

            if (Settings.SplitTimesAccuracy != CurrentAccuracy)
            {
                TimeFormatter   = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy);
                CurrentAccuracy = Settings.SplitTimesAccuracy;
            }
            if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals)
            {
                DeltaTimeFormatter   = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals);
                CurrentDeltaAccuracy = Settings.DeltasAccuracy;
                CurrentDropDecimals  = Settings.DropDecimals;
            }

            foreach (var label in LabelsList)
            {
                label.ShadowColor = state.LayoutSettings.ShadowsColor;
                label.Y           = 0;
                label.Height      = height;
            }
            MinimumWidth = 10f;

            if (ColumnsList.Count() == LabelsList.Count)
            {
                var curX = width - 7;
                foreach (var label in LabelsList.Reverse())
                {
                    var column = ColumnsList.ElementAt(LabelsList.IndexOf(label));

                    var labelWidth = 0f;
                    if (column.Type == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime)
                    {
                        labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth);
                    }
                    else if (column.Type == ColumnType.Delta || column.Type == ColumnType.SegmentDelta)
                    {
                        labelWidth = MeasureDeltaLabel.ActualWidth;
                    }
                    else
                    {
                        labelWidth = MeasureTimeLabel.ActualWidth;
                    }
                    curX       -= labelWidth + 5;
                    label.Width = labelWidth;
                    label.X     = curX + 5;

                    label.Font      = state.LayoutSettings.TextFont;
                    label.HasShadow = state.LayoutSettings.DropShadows;
                    label.Draw(g);
                }
            }
        }
        private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            if (NeedUpdateAll)
            {
                UpdateAll(state);
            }

            int splitIndex = state.Run.IndexOf(Split) % 7;

            if (IsActive)
            {
                switch (splitIndex)
                {
                case 0:
                    img = Properties.Resources.row_0_s;
                    break;

                case 1:
                    img = Properties.Resources.row_1_s;
                    break;

                case 2:
                    img = Properties.Resources.row_2_s;
                    break;

                case 3:
                    img = Properties.Resources.row_3_s;
                    break;

                case 4:
                    img = Properties.Resources.row_4_s;
                    break;

                case 5:
                    img = Properties.Resources.row_5_s;
                    break;

                case 6:
                    img = Properties.Resources.row_6_s;
                    break;

                default:
                    img = Properties.Resources.row_0_s;
                    break;
                }
            }
            else
            {
                switch (splitIndex)
                {
                case 0:
                    img = Properties.Resources.row_0;
                    break;

                case 1:
                    img = Properties.Resources.row_1;
                    break;

                case 2:
                    img = Properties.Resources.row_2;
                    break;

                case 3:
                    img = Properties.Resources.row_3;
                    break;

                case 4:
                    img = Properties.Resources.row_4;
                    break;

                case 5:
                    img = Properties.Resources.row_5;
                    break;

                case 6:
                    img = Properties.Resources.row_6;
                    break;

                default:
                    img = Properties.Resources.row_0;
                    break;
                }
            }

            g.DrawImage(img, 0, 0, width, height);

            MeasureTimeLabel.Text  = TimeFormatter.Format(new TimeSpan(24, 0, 0));
            MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0));

            MeasureTimeLabel.Font          = state.LayoutSettings.TimesFont;
            MeasureTimeLabel.IsMonospaced  = true;
            MeasureDeltaLabel.Font         = state.LayoutSettings.TimesFont;
            MeasureDeltaLabel.IsMonospaced = true;

            MeasureTimeLabel.SetActualWidth(g);
            MeasureDeltaLabel.SetActualWidth(g);

            NameLabel.ShadowColor  = state.LayoutSettings.ShadowsColor;
            NameLabel.OutlineColor = state.LayoutSettings.TextOutlineColor;
            foreach (var label in LabelsList)
            {
                label.ShadowColor  = state.LayoutSettings.ShadowsColor;
                label.OutlineColor = state.LayoutSettings.TextOutlineColor;
            }

            if (Settings.SplitTimesAccuracy != CurrentAccuracy)
            {
                TimeFormatter   = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy);
                CurrentAccuracy = Settings.SplitTimesAccuracy;
            }
            if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals)
            {
                DeltaTimeFormatter   = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals);
                CurrentDeltaAccuracy = Settings.DeltasAccuracy;
                CurrentDropDecimals  = Settings.DropDecimals;
            }

            if (Split != null)
            {
                if (mode == LayoutMode.Vertical)
                {
                    NameLabel.VerticalAlignment = StringAlignment.Center;
                    NameLabel.Y      = 0;
                    NameLabel.Height = height;
                    foreach (var label in LabelsList)
                    {
                        label.VerticalAlignment = StringAlignment.Center;
                        label.Y      = 0;
                        label.Height = height;
                    }
                }
                else
                {
                    NameLabel.VerticalAlignment = StringAlignment.Near;
                    NameLabel.Y      = 0;
                    NameLabel.Height = 50;
                    foreach (var label in LabelsList)
                    {
                        label.VerticalAlignment = StringAlignment.Far;
                        label.Y      = height - 50;
                        label.Height = 50;
                    }
                }

                if (IsActive)
                {
                    g.DrawImage(SplitCursor, 2, ((height - 24f) / 2.0f), 30f, 24f);
                }

                NameLabel.Font      = state.LayoutSettings.TextFont;
                NameLabel.X         = IsActive ? 35 : 5;
                NameLabel.HasShadow = state.LayoutSettings.DropShadows;

                if (ColumnsList.Count() == LabelsList.Count)
                {
                    var curX  = width - 12;
                    var nameX = width - 7;
                    foreach (var label in LabelsList.Reverse())
                    {
                        var column = ColumnsList.ElementAt(LabelsList.IndexOf(label));

                        var labelWidth = 0f;
                        if (column.Type == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime)
                        {
                            labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth);
                        }
                        else if (column.Type == ColumnType.Delta || column.Type == ColumnType.SegmentDelta)
                        {
                            labelWidth = MeasureDeltaLabel.ActualWidth;
                        }
                        else
                        {
                            labelWidth = MeasureTimeLabel.ActualWidth;
                        }

                        label.Width = labelWidth + 20;
                        curX       -= labelWidth + 5;
                        label.X     = curX - 15;

                        label.Font         = state.LayoutSettings.TimesFont;
                        label.HasShadow    = state.LayoutSettings.DropShadows;
                        label.OutlineColor = state.LayoutSettings.TextOutlineColor;

                        label.IsMonospaced = true;
                        label.Draw(g);

                        if (!string.IsNullOrEmpty(label.Text))
                        {
                            nameX = curX + labelWidth + 5 - label.ActualWidth;
                        }
                    }

                    NameLabel.Width = (mode == LayoutMode.Horizontal ? width - 10 : width * 0.4f);
                    NameLabel.Draw(g);
                }
            }
        }
        private void DrawGeneral(Graphics g, LiveSplitState state, float width, float height, LayoutMode mode)
        {
            if (NeedUpdateAll)
            {
                UpdateAll(state);
            }

            if (Settings.BackgroundGradient == ExtendedGradientType.Alternating)
            {
                g.FillRectangle(new SolidBrush(
                                    state.Run.IndexOf(Split) % 2 + (Settings.ShowColumnLabels ? 1 : 0) == 1
                    ? Settings.BackgroundColor2
                    : Settings.BackgroundColor
                                    ), 0, 0, width, height);
            }

            MeasureTimeLabel.Text  = TimeFormatter.Format(new TimeSpan(24, 0, 0));
            MeasureDeltaLabel.Text = DeltaTimeFormatter.Format(new TimeSpan(0, 9, 0, 0));

            MeasureTimeLabel.Font          = state.LayoutSettings.TimesFont;
            MeasureTimeLabel.IsMonospaced  = true;
            MeasureDeltaLabel.Font         = state.LayoutSettings.TimesFont;
            MeasureDeltaLabel.IsMonospaced = true;

            MeasureTimeLabel.SetActualWidth(g);
            MeasureDeltaLabel.SetActualWidth(g);

            NameLabel.ShadowColor = state.LayoutSettings.ShadowsColor;
            foreach (var label in LabelsList)
            {
                label.SetActualWidth(g);
                label.ShadowColor = state.LayoutSettings.ShadowsColor;
            }
            MinimumWidth  = CalculateLabelsWidth() + IconWidth + 10;
            MinimumHeight = 0.85f * (g.MeasureString("A", state.LayoutSettings.TimesFont).Height + g.MeasureString("A", state.LayoutSettings.TextFont).Height);

            if (Settings.SplitTimesAccuracy != CurrentAccuracy)
            {
                TimeFormatter   = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy);
                CurrentAccuracy = Settings.SplitTimesAccuracy;
            }
            if (Settings.DeltasAccuracy != CurrentDeltaAccuracy || Settings.DropDecimals != CurrentDropDecimals)
            {
                DeltaTimeFormatter   = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals);
                CurrentDeltaAccuracy = Settings.DeltasAccuracy;
                CurrentDropDecimals  = Settings.DropDecimals;
            }

            if (Split != null)
            {
                if (mode == LayoutMode.Vertical)
                {
                    NameLabel.VerticalAlignment = StringAlignment.Center;
                    NameLabel.Y      = 0;
                    NameLabel.Height = height;
                    foreach (var label in LabelsList)
                    {
                        label.VerticalAlignment = StringAlignment.Center;
                        label.Y      = 0;
                        label.Height = height;
                    }
                }
                else
                {
                    NameLabel.VerticalAlignment = StringAlignment.Near;
                    NameLabel.Y      = 0;
                    NameLabel.Height = 50;
                    foreach (var label in LabelsList)
                    {
                        label.VerticalAlignment = StringAlignment.Far;
                        label.Y      = height - 50;
                        label.Height = 50;
                    }
                }

                if (IsActive)
                {
                    var currentSplitBrush = new LinearGradientBrush(
                        new PointF(0, 0),
                        Settings.CurrentSplitGradient == GradientType.Horizontal
                        ? new PointF(width, 0)
                        : new PointF(0, height),
                        Settings.CurrentSplitTopColor,
                        Settings.CurrentSplitGradient == GradientType.Plain
                        ? Settings.CurrentSplitTopColor
                        : Settings.CurrentSplitBottomColor);
                    g.FillRectangle(currentSplitBrush, 0, 0, width, height);
                }

                if (DisplayIcon)
                {
                    var icon   = Split.Icon ?? NoIconImage;
                    var shadow = (Split.Icon != null) ? ShadowImage : NoIconShadow;

                    /*if (DateTime.Now.Date.Month == 4 && DateTime.Now.Date.Day == 1)
                     * {
                     *  icon = LiveSplit.Web.Share.TwitchEmoteResolver.Resolve("Kappa", true, false, false);
                     *  shadow = null;
                     * }*/

                    if (OldImage != icon)
                    {
                        ImageAnimator.Animate(icon, (s, o) => { });
                        ImageAnimator.Animate(shadow, (s, o) => { });
                        OldImage = icon;
                    }

                    var drawWidth    = Settings.IconSize;
                    var drawHeight   = Settings.IconSize;
                    var shadowWidth  = Settings.IconSize * (5 / 4f);
                    var shadowHeight = Settings.IconSize * (5 / 4f);
                    if (icon.Width > icon.Height)
                    {
                        var ratio = icon.Height / (float)icon.Width;
                        drawHeight   *= ratio;
                        shadowHeight *= ratio;
                    }
                    else
                    {
                        var ratio = icon.Width / (float)icon.Height;
                        drawWidth   *= ratio;
                        shadowWidth *= ratio;
                    }

                    ImageAnimator.UpdateFrames(shadow);
                    if (Settings.IconShadows && shadow != null)
                    {
                        g.DrawImage(
                            shadow,
                            7 + (Settings.IconSize * (5 / 4f) - shadowWidth) / 2 - 0.7f,
                            (height - Settings.IconSize) / 2.0f + (Settings.IconSize * (5 / 4f) - shadowHeight) / 2 - 0.7f,
                            shadowWidth,
                            shadowHeight);
                    }

                    ImageAnimator.UpdateFrames(icon);

                    g.DrawImage(
                        icon,
                        7 + (Settings.IconSize - drawWidth) / 2,
                        (height - Settings.IconSize) / 2.0f + (Settings.IconSize - drawHeight) / 2,
                        drawWidth,
                        drawHeight);
                }

                NameLabel.Font      = state.LayoutSettings.TextFont;
                NameLabel.X         = 5 + IconWidth;
                NameLabel.HasShadow = state.LayoutSettings.DropShadows;

                if (ColumnsList.Count() == LabelsList.Count)
                {
                    var curX  = width - 7;
                    var nameX = width - 7;
                    foreach (var label in LabelsList.Reverse())
                    {
                        var column = ColumnsList.ElementAt(LabelsList.IndexOf(label));

                        var labelWidth = 0f;
                        if (column.Type == ColumnType.DeltaorSplitTime || column.Type == ColumnType.SegmentDeltaorSegmentTime)
                        {
                            labelWidth = Math.Max(MeasureDeltaLabel.ActualWidth, MeasureTimeLabel.ActualWidth);
                        }
                        else if (column.Type == ColumnType.Delta || column.Type == ColumnType.SegmentDelta)
                        {
                            labelWidth = MeasureDeltaLabel.ActualWidth;
                        }
                        else
                        {
                            labelWidth = MeasureTimeLabel.ActualWidth;
                        }
                        label.Width = labelWidth + 20;
                        curX       -= labelWidth + 5;
                        label.X     = curX - 15;

                        label.Font         = state.LayoutSettings.TimesFont;
                        label.HasShadow    = state.LayoutSettings.DropShadows;
                        label.IsMonospaced = true;
                        label.Draw(g);

                        if (!String.IsNullOrEmpty(label.Text))
                        {
                            nameX = curX + labelWidth + 5 - label.ActualWidth;
                        }
                    }
                    NameLabel.Width = (mode == LayoutMode.Horizontal ? width - 10 : nameX) - IconWidth;
                    NameLabel.Draw(g);
                }
            }
            else
            {
                DisplayIcon = Settings.DisplayIcons;
            }
        }