private void DrawSegmentTimer(Graphics graphics) { TextFormatFlags segmentTimeFlags = TextFormatFlags.Left | TextFormatFlags.Bottom | TextFormatFlags.WordEllipsis; TextFormatFlags segmentBestTimeFlags = TextFormatFlags.Left | TextFormatFlags.Top | TextFormatFlags.WordEllipsis; Rectangle segmentTimeRectangle = new Rectangle(0, watchRectangle.Y + watchRectangle.Height, DEFAULT_WIDTH / 2, DEFAULT_HEIGHT / 2); Rectangle segmentBestimeRectangle = new Rectangle(0, segmentTimeRectangle.Y + segmentTimeRectangle.Height, DEFAULT_WIDTH / 2, DEFAULT_HEIGHT / 2); Rectangle segmentTimerRectangle = new Rectangle(DEFAULT_WIDTH / 2, watchRectangle.Y + watchRectangle.Height, DEFAULT_WIDTH / 2, DEFAULT_HEIGHT); graphics.FillRectangle(new SolidBrush(Settings.Default.SegmentTimerBackgroundColor), segmentTimeRectangle); graphics.FillRectangle(new SolidBrush(Settings.Default.SegmentTimerBackgroundColor), segmentBestimeRectangle); graphics.FillRectangle(new SolidBrush(Settings.Default.SegmentTimerBackgroundColor), segmentTimerRectangle); String segmentTime = (this.split.RunStatus == RunStatus.ON_GOING) ? FaceSplitUtils.TimeFormat(this.split.CurrentSegment.BackupSegmentTime) : FaceSplitUtils.TimeFormat(this.split.Segments.Last().BackupSegmentTime); String segmentBestTime = (this.split.RunStatus == RunStatus.ON_GOING) ? FaceSplitUtils.TimeFormat(this.split.CurrentSegment.BackupBestSegmentTime) : FaceSplitUtils.TimeFormat(this.split.Segments.Last().BackupBestSegmentTime); String segmentTimerString; segmentTimerString = (this.split.RunStatus == RunStatus.DONE) ? segmentTimeOnCompletionPause.ToString() : FaceSplitUtils.TimeFormat((Math.Truncate(this.segmentWatch.Elapsed.TotalSeconds * 100) / 100) + timeElapsedSinceSplit); TextRenderer.DrawText(graphics, "PB: " + segmentTime, Settings.Default.SegmentTimerPBFont, segmentTimeRectangle, Settings.Default.SegmentTimerPBColor, segmentTimeFlags); TextRenderer.DrawText(graphics, "BEST: " + segmentBestTime, Settings.Default.SegmentTimerBestFont, segmentBestimeRectangle, Settings.Default.SegmentTimerBestColor, segmentBestTimeFlags); TextRenderer.DrawText(graphics, segmentTimerString, Settings.Default.SegmentTimerFont, segmentTimerRectangle, segmentWatchColor); }
public String GetPossibleTimeSave() { if (this.split.SegmentHasPossibleTimeSave()) { Double possibleTimeSave = this.split.GetPossibleTimeSave(); String possibleTimeSaveString = FaceSplitUtils.TimeFormat(possibleTimeSave); possibleTimeSaveString = FaceSplitUtils.CutDecimals(possibleTimeSaveString, 2); return(possibleTimeSaveString); } return("-"); }
public String GetSOB() { Double sob = this.split.GetSOB(); String sobString = "-"; if (sob != 0.0) { sobString = FaceSplitUtils.TimeFormat(sob); } sobString = FaceSplitUtils.CutDecimals(sobString, 2); return(sobString); }
public String GetPredictedTime() { Double predictedTime = this.split.GetPredictedTime(); String predictedTimeString = "-"; if (predictedTime != 0.0) { predictedTimeString = FaceSplitUtils.TimeFormat(predictedTime); } predictedTimeString = FaceSplitUtils.CutDecimals(predictedTimeString, 2); return(predictedTimeString); }
/// <summary> /// Fill the rows in the table with the split information. /// </summary> private void FillSegmentRows() { for (int i = 0; i < this.split.Segments.Count; ++i) { if (i >= this.segmentsGridView.Rows.Count) { AddRow(); } this.segmentsGridView.Rows[i].Cells[0].Value = this.split.Segments.ElementAt(i).SegmentName; this.segmentsGridView.Rows[i].Cells[1].Value = FaceSplitUtils.TimeFormat(this.split.Segments.ElementAt(i).SplitTime); this.segmentsGridView.Rows[i].Cells[2].Value = FaceSplitUtils.TimeFormat(this.split.Segments.ElementAt(i).SegmentTime); this.segmentsGridView.Rows[i].Cells[3].Value = FaceSplitUtils.TimeFormat(this.split.Segments.ElementAt(i).BestSegmentTime); } }
/// <summary> /// Fill the rows in the table with the split information. /// </summary> private void FillSegmentRows() { for (int i = 0; i < split.Segments.Count; ++i) { if (i >= segmentsGridView.Rows.Count) { AddRow(); } segmentsGridView.Rows[i].Cells[SEGMENT_NAME_ROW].Value = split.Segments.ElementAt(i).SegmentName; segmentsGridView.Rows[i].Cells[SEGMENT_SPLIT_TIME_ROW].Value = FaceSplitUtils.TimeFormat(split.Segments.ElementAt(i).SplitTime); segmentsGridView.Rows[i].Cells[SEGMENT_TIME_ROW].Value = FaceSplitUtils.TimeFormat(split.Segments.ElementAt(i).SegmentTime); segmentsGridView.Rows[i].Cells[SEGMENT_BEST_TIME_ROW].Value = FaceSplitUtils.TimeFormat(split.Segments.ElementAt(i).BestSegmentTime); segmentsGridView.Rows[i].Cells[SEGMENT_ICON_ROW].Value = split.Segments.ElementAt(i).Icon; icons.ElementAt(i).Icon = split.Segments.ElementAt(i).Icon; icons.ElementAt(i).IconPath = split.Segments.ElementAt(i).IconPath; } }
private void FillOnlySegmentTimeColumn(List <double> segmentsTime) { int index = 0; foreach (DataGridViewRow rows in this.segmentsGridView.Rows) { DataGridViewCell cellSegmentTime = rows.Cells[2]; if (segmentsTime.ElementAt(index) != INVALID_VALUE) { cellSegmentTime.Value = FaceSplitUtils.TimeFormat(segmentsTime.ElementAt(index)); } else { cellSegmentTime.Value = ""; } index++; } }
/// <summary> /// Fill the segment cells in the table with the segments time from the list. /// </summary> /// <param name="segmentsTime">The list we use to fill the cells.</param> private void FillSegmentColumns(List <double> segmentsTime) { int index = 0; foreach (DataGridViewRow rows in segmentsGridView.Rows) { DataGridViewCell cellSegmentTime = rows.Cells[SEGMENT_TIME_ROW]; DataGridViewCell cellBestSegmentTime = rows.Cells[SEGMENT_BEST_TIME_ROW]; if (segmentsTime.ElementAt(index) != INVALID_VALUE) { cellSegmentTime.Value = FaceSplitUtils.TimeFormat(segmentsTime.ElementAt(index)); cellBestSegmentTime.Value = FaceSplitUtils.TimeFormat(segmentsTime.ElementAt(index)); } else { cellSegmentTime.Value = ""; cellBestSegmentTime.Value = ""; } index++; } }
private String GetPreviousSegmentDeltaString() { String segmentDeltaString; double segmentDelta; Boolean lostTime; Boolean bestSegment = false; double timeElapsed = (Math.Truncate(this.segmentWatch.Elapsed.TotalSeconds * 100) / 100) + this.timeElapsedSinceSplit; if (this.split.LiveIndex > 0) { bestSegment = this.split.PreviousSegmentIsBestSegment(); } if (this.split.CurrentSegmentHasLiveDelta(timeElapsed)) { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].PrimaryText = "Live segment: "; segmentDelta = this.split.GetLiveSegmentDelta(timeElapsed); segmentDeltaString = FaceSplitUtils.TimeFormat(Math.Abs(segmentDelta)); lostTime = (segmentDelta > 0); if (lostTime) { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].SecondaryTextColor = Settings.Default.PreviousSegmentDeltaLostColor; segmentDeltaString = segmentDeltaString.Insert(0, "+"); this.segmentWatchColor = Settings.Default.SegmentTimerLosingTimeColor; } else { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].SecondaryTextColor = Settings.Default.PreviousSegmentDeltaSavedColor; segmentDeltaString = segmentDeltaString.Insert(0, "-"); } } else if (this.split.PreviousSegmentHasSegmentDelta()) { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].PrimaryText = "Previous segment: "; segmentDelta = this.split.GetPreviousSegmentDelta(); segmentDeltaString = FaceSplitUtils.TimeFormat(Math.Abs(segmentDelta)); lostTime = (segmentDelta > 0); if (bestSegment) { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].SecondaryTextColor = Settings.Default.PreviousSegmentDeltaBestSegmentColor; segmentDeltaString = segmentDeltaString.Insert(0, "-"); } else { if (lostTime) { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].SecondaryTextColor = Settings.Default.PreviousSegmentDeltaLostColor; segmentDeltaString = segmentDeltaString.Insert(0, "+"); } else { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].SecondaryTextColor = Settings.Default.PreviousSegmentDeltaSavedColor; segmentDeltaString = segmentDeltaString.Insert(0, "-"); } } this.split.SetPreviousSegmentColor(bestSegment, lostTime); } else { this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].PrimaryText = "Previous segment: "; this.informations[(int)InformationIndexs.PREVIOUS_SEGMENT].SecondaryTextColor = Settings.Default.PreviousSegmentDeltaNoDeltaColor; segmentDeltaString = "-"; } segmentDeltaString = FaceSplitUtils.CutDecimals(segmentDeltaString, 2); return(segmentDeltaString); }
/// <summary> /// Fetch the run delta for each split with the index. /// Returns it into a string. /// </summary> /// <param name="index">The index of the split.</param> /// <returns>The run delta into a string.</returns> private String GetRunDeltaString(int index) { Boolean lostTime; double runDelta; Double timeElapsed = (Math.Truncate(this.segmentWatch.Elapsed.TotalSeconds * 100) / 100) + this.timeElapsedSinceSplit; String runDeltaString = ""; if (index < this.split.LiveIndex) { //Done mean we are after the last split but we still have the possiblity of going back. if ((this.split.RunStatus == RunStatus.ON_GOING || this.split.RunStatus == RunStatus.DONE) && !this.split.FirstSplit() && this.split.SegmentHasRunDelta(index)) { runDelta = this.split.GetRunDelta(index); lostTime = (runDelta > 0); runDeltaString = FaceSplitUtils.TimeFormat(Math.Abs(runDelta)); if (lostTime) { runDeltaString = runDeltaString.Insert(0, "+"); } else { runDeltaString = runDeltaString.Insert(0, "-"); } } } else if (index == this.split.LiveIndex && this.split.SegmentHasRunDelta(index)) { runDelta = this.split.GetLiveRunDelta(Math.Truncate(this.watch.Elapsed.TotalSeconds * 100) / 100); lostTime = (runDelta > 0); runDeltaString = FaceSplitUtils.TimeFormat(Math.Abs(runDelta)); if (lostTime) { runDeltaString = runDeltaString.Insert(0, "+"); if ((index == 0) || (index > 0 && runDelta > this.split.GetRunDelta(index - 1))) { this.split.SetCurrentSegmentColor(Settings.Default.SplitDeltasBehindLosingColor); } else { this.split.SetCurrentSegmentColor(Settings.Default.SplitDeltasBehindSavingColor); } this.watchColor = Settings.Default.TimerBehindColor; } else if ((index > 0 && runDelta > this.split.GetRunDelta(index - 1))) { runDeltaString = runDeltaString.Insert(0, "-"); this.split.SetCurrentSegmentColor(Settings.Default.SplitDeltasAheadLosingColor); } else if (this.split.CurrentSegmentHasLiveDelta(timeElapsed)) { runDeltaString = runDeltaString.Insert(0, "-"); this.split.SetCurrentSegmentColor(Settings.Default.SplitDeltasAheadSavingColor); } else { runDeltaString = ""; this.watchColor = Settings.Default.TimerRunningColor; } } return(runDeltaString); }
/// <summary> /// Draw the list of segments. /// </summary> /// <param name="graphics"></param> private void DrawSegments(Graphics graphics) { String segmentName; String segmentSplitTime; String runDeltaString = ""; TextFormatFlags nameFlags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.WordEllipsis; TextFormatFlags splitTimeFlags = TextFormatFlags.Right | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak; TextFormatFlags runDeltaFlags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak; Rectangle segmentNameRectangle; Rectangle segmentSplitTimeRectangle; Color rectangleColor = Settings.Default.SplitsBackgroundColor; for (int i = 0; i < segmentsRectangles.Count; ++i) { rectangleColor = (i == this.split.LiveIndex) ? Settings.Default.CurrentSegmentColor : Settings.Default.SplitsBackgroundColor; segmentName = this.split.Segments.ElementAt(i).SegmentName; segmentSplitTime = (this.split.Segments.ElementAt(i).SplitTime == 0) ? "-" : FaceSplitUtils.TimeFormat(this.split.Segments.ElementAt(i).SplitTime); segmentSplitTime = FaceSplitUtils.CutDecimals(segmentSplitTime, 2); runDeltaString = GetRunDeltaString(i); //if (i == this.split.LiveIndex && (runDeltaString.IndexOf("+") == -1 && runDeltaString.IndexOf("-") == -1)) //{ // runDeltaString = ""; //} runDeltaString = FaceSplitUtils.CutDecimals(runDeltaString, 2); segmentNameRectangle = segmentsRectangles.ElementAt(i); segmentNameRectangle.Width /= 2; segmentSplitTimeRectangle = segmentsRectangles.ElementAt(i); segmentSplitTimeRectangle.Width /= 2; segmentSplitTimeRectangle.X = segmentNameRectangle.Width; graphics.FillRectangle(new SolidBrush(rectangleColor), segmentsRectangles.ElementAt(i)); TextRenderer.DrawText(graphics, segmentName, Settings.Default.SplitNamesFont, segmentNameRectangle, Settings.Default.SplitNamesColor, nameFlags); TextRenderer.DrawText(graphics, segmentSplitTime, Settings.Default.SplitTimesFont, segmentSplitTimeRectangle, Settings.Default.SplitTimesColor, splitTimeFlags); if (!String.IsNullOrEmpty(runDeltaString.Trim())) { TextRenderer.DrawText(graphics, runDeltaString, Settings.Default.SplitDeltasFont, segmentSplitTimeRectangle, this.split.GetSegmentColor(i), runDeltaFlags); } } }
/// <summary> /// Draw the list of segments. /// </summary> /// <param name="graphics"></param> private void DrawSegments(Graphics graphics) { string segmentName; string segmentSplitTime; string runDeltaString = ""; Bitmap segmentIcon; TextFormatFlags nameFlags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.WordEllipsis; TextFormatFlags splitTimeFlags = TextFormatFlags.Right | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak; TextFormatFlags runDeltaFlags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak; Rectangle segmentIconRectangle; Rectangle segmentNameRectangle; Rectangle segmentSplitTimeRectangle; Color rectangleColor = SettingsLayout.Default.SplitsBackgroundColor; for (int i = 0; i < segmentsRectangles.Count; ++i) { rectangleColor = (i == split.LiveIndex) ? SettingsLayout.Default.CurrentSegmentColor : SettingsLayout.Default.SplitsBackgroundColor; segmentName = split.Segments.ElementAt(i).SegmentName; segmentSplitTime = (split.Segments.ElementAt(i).SplitTime == 0) ? "-" : FaceSplitUtils.TimeFormat(split.Segments.ElementAt(i).SplitTime); segmentSplitTime = FaceSplitUtils.CutDecimals(segmentSplitTime, 2); segmentIcon = split.Segments.ElementAt(i).Icon; runDeltaString = GetRunDeltaString(i); runDeltaString = FaceSplitUtils.CutDecimals(runDeltaString, 2); segmentNameRectangle = segmentsRectangles.ElementAt(i); segmentNameRectangle.Width /= 2; segmentNameRectangle.X = 17; segmentSplitTimeRectangle = segmentsRectangles.ElementAt(i); segmentSplitTimeRectangle.Width /= 2; segmentSplitTimeRectangle.X = segmentNameRectangle.Width; segmentIconRectangle = new Rectangle(0, segmentNameRectangle.Y, 16, 16); graphics.FillRectangle(new SolidBrush(rectangleColor), segmentsRectangles.ElementAt(i)); graphics.DrawImage(segmentIcon, segmentIconRectangle); TextRenderer.DrawText(graphics, segmentName, SettingsLayout.Default.SplitNamesFont, segmentNameRectangle, SettingsLayout.Default.SplitNamesColor, nameFlags); TextRenderer.DrawText(graphics, segmentSplitTime, SettingsLayout.Default.SplitTimesFont, segmentSplitTimeRectangle, SettingsLayout.Default.SplitTimesColor, splitTimeFlags); if (!string.IsNullOrEmpty(runDeltaString.Trim())) { TextRenderer.DrawText(graphics, runDeltaString, SettingsLayout.Default.SplitDeltasFont, segmentSplitTimeRectangle, split.GetSegmentColor(i), runDeltaFlags); } } }