public void RegularSplitTimeFormatterFormatsTimeAsDash_WhenTimeIsNullRegardlessOfAccuracy(TimeAccuracy timeAccuracy) { var sut = new RegularSplitTimeFormatter(timeAccuracy); var formattedTime = sut.Format(null); Assert.Equal(TimeFormatConstants.DASH, formattedTime); }
public void RegularSplitTimeFormatterFormatsTimeCorrectly_WhenTimeIsValid(string timespanText, TimeAccuracy timeAccuracy, string expectedTime) { var sut = new RegularSplitTimeFormatter(timeAccuracy); var time = TimeSpan.Parse(timespanText); var formattedTime = sut.Format(time); Assert.Equal(expectedTime, formattedTime); }
public RivaTunerComponent(LiveSplitState state) { State = state; Settings = new RivaTunerSettings(); TimeFormatter = new RegularTimeFormatter(TimeAccuracy.Hundredths); SplitTimeFormatter = new RegularSplitTimeFormatter(TimeAccuracy.Seconds); DeltaFormatter = new DeltaSplitTimeFormatter(TimeAccuracy.Tenths, true); ShortFormatter = new ShortTimeFormatter(); PossibleTimeSaveFormatter = new PossibleTimeSaveFormatter(); }
public void TestRegularSplitTimeFormatter(string timespanText, TimeAccuracy timeAccuracy, string expected) { var formatter = new RegularSplitTimeFormatter(timeAccuracy); TimeSpan?time = null; if (timespanText != null) { time = TimeSpan.Parse(timespanText); } string formatted = formatter.Format(time); Assert.AreEqual(expected, formatted); }
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>(); IEnumerable <ColumnData> splitsLabel = new ColumnData[] { new ColumnData(Settings.SplitsLabel, ColumnType.SplitsLabel, null, null) }; ColumnsList = splitsLabel.Concat(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 = 25; VerticalHeight = 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); } 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) { g.DrawImage(LabelBackground, 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.OutlineColor = state.LayoutSettings.TextOutlineColor; label.Y = 0; label.Height = height; } MinimumWidth = 10f; if (ColumnsList.Count() == LabelsList.Count) { var curX = width - 12; 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; } if (column.Type == ColumnType.SplitsLabel) { label.Width = curX; label.HorizontalAlignment = StringAlignment.Near; curX = 0; } else { curX -= labelWidth + 5; label.Width = labelWidth; } label.X = curX + 5; label.Font = state.LayoutSettings.TextFont; label.HasShadow = state.LayoutSettings.DropShadows; label.Draw(g); } } }