public LabelsComponent(SplitsSettings settings, IEnumerable<ColumnData> columns) { Settings = settings; MinimumHeight = 31; MeasureTimeLabel = new SimpleLabel(); MeasureDeltaLabel = new SimpleLabel(); TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); Cache = new GraphicsCache(); LabelsList = new List<SimpleLabel>(); ColumnsList = columns; }
public SplitComponent(SplitsSettings settings, IEnumerable<ColumnData> columnsList) { NameLabel = new SimpleLabel() { HorizontalAlignment = StringAlignment.Near, X = 8, }; MeasureTimeLabel = new SimpleLabel(); MeasureDeltaLabel = new SimpleLabel(); Settings = settings; ColumnsList = columnsList; TimeFormatter = new RegularSplitTimeFormatter(Settings.SplitTimesAccuracy); DeltaTimeFormatter = new DeltaSplitTimeFormatter(Settings.DeltasAccuracy, Settings.DropDecimals); MinimumHeight = 31; NeedUpdateAll = true; IsActive = false; Cache = new GraphicsCache(); LabelsList = new List<SimpleLabel>(); }
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.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); } var icon = Split.Icon; if (DisplayIcon && icon != null) { var shadow = ShadowImage; 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; }
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); } } }