public DualTimer(LiveSplitState state) { InternalComponent = new Timer(); AlternateTimer = new AlternateTimer(); Settings = new DualTimerSettings() { CurrentState = state }; Cache = new GraphicsCache(); }
public void DrawHorizontal(Graphics g, LiveSplitState state, float height, Region clipRegion) { DrawGeneral(g, state, HorizontalWidth, height); var oldMatrix = g.Transform; InternalComponent.Settings.TimerWidth = HorizontalWidth; InternalComponent.DrawHorizontal(g, state, height * ((100f - Settings.AlternateTimerSizeRatio) / 100f), clipRegion); g.Transform = oldMatrix; g.TranslateTransform(0, height * ((100f - Settings.AlternateTimerSizeRatio) / 100f)); AlternateTimer.DrawHorizontal(g, state, height * (Settings.AlternateTimerSizeRatio / 100f), clipRegion); AlternateTimer.Settings.TimerWidth = HorizontalWidth; g.Transform = oldMatrix; }
public void DrawVertical(Graphics g, LiveSplitState state, float width, Region clipRegion) { DrawGeneral(g, state, width, VerticalHeight); var oldMatrix = g.Transform; InternalComponent.Settings.TimerHeight = (VerticalHeight - 7f) * ((100f - Settings.AlternateTimerSizeRatio) / 100f); InternalComponent.DrawVertical(g, state, width, clipRegion); g.Transform = oldMatrix; g.TranslateTransform(0, (VerticalHeight - 7f) * ((100f - Settings.AlternateTimerSizeRatio) / 100f)); AlternateTimer.Settings.TimerHeight = VerticalHeight * (Settings.AlternateTimerSizeRatio / 100f); AlternateTimer.DrawVertical(g, state, width, clipRegion); g.Transform = oldMatrix; }
public void Update(IInvalidator invalidator, LiveSplitState state, float width, float height, LayoutMode mode) { var timingMethod = state.CurrentTimingMethod; if (Settings.TimingMethod == "Real Time") { timingMethod = TimingMethod.RealTime; } else if (Settings.TimingMethod == "Game Time") { timingMethod = TimingMethod.GameTime; } var formatter = new AlternateTimeFormatter(Settings.AlternateTimeAccuracy); TimeSpan?altTime = null; if (AlternateTimer != null) { altTime = AlternateTimer.GetTime(state, timingMethod); } AlternateTimer.Settings.TimingMethod = Settings.TimingMethod; InternalComponent.Settings.TimingMethod = Settings.TimingMethod; AlternateTimer.Update(null, state, width, height, mode); InternalComponent.Update(null, state, width, height, mode); Cache.Restart(); Cache["AlternateTimerText"] = AlternateTimer.BigTextLabel.Text + AlternateTimer.SmallTextLabel.Text; Cache["InternalComponentText"] = InternalComponent.BigTextLabel.Text + InternalComponent.SmallTextLabel.Text; if (InternalComponent.BigTextLabel.Brush != null && invalidator != null) { if (InternalComponent.BigTextLabel.Brush is LinearGradientBrush) { Cache["TimerColor"] = ((LinearGradientBrush)InternalComponent.BigTextLabel.Brush).LinearColors.First().ToArgb(); } else { Cache["TimerColor"] = InternalComponent.BigTextLabel.ForeColor.ToArgb(); } } if (invalidator != null && (Cache.HasChanged)) //|| FrameCount > 1)) { invalidator.Invalidate(0, 0, width, height); } }