public void Save(IRun run, Stream stream) { var regularTimeFormatter = new RegularTimeFormatter(TimeAccuracy.Hundredths); var shortTimeFormatter = new ShortTimeFormatter(); var writer = new StreamWriter(stream); if (!string.IsNullOrEmpty(run.GameName)) { writer.Write(Escape(run.GameName)); if (!string.IsNullOrEmpty(run.CategoryName)) writer.Write(" - "); } writer.Write(Escape(run.CategoryName)); writer.Write(','); writer.WriteLine(Escape(run.AttemptCount.ToString())); foreach (var segment in run) { writer.Write(Escape(segment.Name)); writer.Write(','); writer.Write(Escape(regularTimeFormatter.Format(segment.PersonalBestSplitTime.RealTime))); writer.Write(','); writer.WriteLine(Escape(shortTimeFormatter.Format(segment.BestSegmentTime.RealTime))); } writer.Flush(); }
public string Format(TimeSpan?time) { var formatter = new ShortTimeFormatter(); if (time == null) { return("-"); } else { var timeString = formatter.Format(time); if (Accuracy == TimeAccuracy.Hundredths) { return(timeString); } else if (Accuracy == TimeAccuracy.Tenths) { return(timeString.Substring(0, timeString.Length - 1)); } else { return(timeString.Substring(0, timeString.Length - 3)); } } }
private static string formatTime(Time time) { var formatter = new ShortTimeFormatter(); if (time.RealTime.HasValue && !time.GameTime.HasValue) return formatter.Format(time.RealTime); if (!time.RealTime.HasValue && time.GameTime.HasValue) return formatter.Format(time.GameTime); return formatter.Format(time.RealTime) + " / " + formatter.Format(time.GameTime); }
public VideoSettings() { InitializeComponent(); TimeFormatter = new ShortTimeFormatter(); VideoPath = ""; Width = 200; Height = 200; Offset = TimeSpan.Zero; txtVideoPath.DataBindings.Add("Text", this, "VideoPath", false, DataSourceUpdateMode.OnPropertyChanged); txtOffset.DataBindings.Add("Text", this, "OffsetString"); }
public string Format (TimeSpan? time) { if (time == null) { return "-"; } else { var shortTime = new ShortTimeFormatter().Format(time); if (Accuracy == TimeAccuracy.Hundredths) return shortTime; else if (Accuracy == TimeAccuracy.Tenths) return shortTime.Substring(0, shortTime.IndexOf('.') + 2); else return shortTime.Substring(0, shortTime.IndexOf('.')); } }
public string Format(TimeSpan? time) { var formatter = new ShortTimeFormatter(); if (time == null) return "-"; else { var timeString = formatter.Format(time); if (Accuracy == TimeAccuracy.Hundredths) return timeString; else if (Accuracy == TimeAccuracy.Tenths) return timeString.Substring(0, timeString.Length - 1); else return timeString.Substring(0, timeString.Length - 3); } }
public string Format(TimeSpan?time) { if (time == null) { return(TimeFormatConstants.DASH); } else { var shortTime = new ShortTimeFormatter().Format(time); if (Accuracy == TimeAccuracy.Hundredths) { return(shortTime); } else if (Accuracy == TimeAccuracy.Tenths) { return(shortTime.Substring(0, shortTime.IndexOf('.') + 2)); } else { return(shortTime.Substring(0, shortTime.IndexOf('.'))); } } }
private void cleanSumOfBestToolStripMenuItem_Click(object sender, EventArgs e) { var alwaysCancel = false; var pastResponses = new Dictionary<string, bool>(); SumOfBest.CleanUpCallback callback = parameters => { if (!alwaysCancel) { var formatter = new ShortTimeFormatter(); var messageText = formatter.Format(parameters.timeBetween) + " between " + (parameters.startingSegment != null ? parameters.startingSegment.Name : "the start of the run") + " and " + parameters.endingSegment.Name + (parameters.combinedSumOfBest != null ? ", which is faster than the Combined Best Segments of " + formatter.Format(parameters.combinedSumOfBest) : ""); if (parameters.attempt.Ended.HasValue) { messageText += " in a run on " + parameters.attempt.Ended.Value.Time.ToLocalTime().ToString("M/d/yyyy"); } if (!pastResponses.ContainsKey(messageText)) { var result = MessageBox.Show(this, "You had a " + (parameters.method == TimingMethod.RealTime ? "Real Time" : "Game Time") + " segment time of " + messageText + ". Do you think that this segment time is inaccurate and should be removed?", "Remove Time From Segment History?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { pastResponses.Add(messageText, true); return true; } else if (result == System.Windows.Forms.DialogResult.No) { pastResponses.Add(messageText, false); return false; } alwaysCancel = true; } else return pastResponses[messageText]; } return false; }; SumOfBest.Clean(Run, callback); RaiseRunEdited(); }
public RunEditorDialog(LiveSplitState state) { InitializeComponent(); CurrentState = state; Run = state.Run; Run.PropertyChanged += Run_PropertyChanged; PreviousPersonalBestTime = Run.Last().PersonalBestSplitTime; metadataControl.Metadata = Run.Metadata; metadataControl.MetadataChanged += metadataControl_MetadataChanged; CurrentSplitIndexOffset = 0; AllowChangingSegments = false; ImagesToDispose = new List<Image>(); SegmentTimeList = new List<TimeSpan?>(); TimeFormatter = new ShortTimeFormatter(); SegmentList = new BindingList<ISegment>(Run); SegmentList.AllowNew = true; SegmentList.AllowRemove = true; SegmentList.AllowEdit = true; SegmentList.ListChanged += SegmentList_ListChanged; runGrid.AutoGenerateColumns = false; runGrid.AutoSize = true; runGrid.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; runGrid.DataSource = SegmentList; runGrid.CellDoubleClick += runGrid_CellDoubleClick; runGrid.CellFormatting += runGrid_CellFormatting; runGrid.CellParsing += runGrid_CellParsing; runGrid.CellValidating += runGrid_CellValidating; runGrid.CellEndEdit += runGrid_CellEndEdit; runGrid.SelectionChanged += runGrid_SelectionChanged; var iconColumn = new DataGridViewImageColumn() { ImageLayout = DataGridViewImageCellLayout.Zoom }; iconColumn.DataPropertyName = "Icon"; iconColumn.Name = "Icon"; iconColumn.Width = 50; iconColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; iconColumn.DefaultCellStyle.NullValue = new Bitmap(1, 1); runGrid.Columns.Add(iconColumn); var column = new DataGridViewTextBoxColumn(); column.DataPropertyName = "Name"; column.Name = "Segment Name"; column.MinimumWidth = 120; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); column = new DataGridViewTextBoxColumn(); column.Name = "Split Time"; column.Width = 100; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); column = new DataGridViewTextBoxColumn(); column.Name = "Segment Time"; column.Width = 100; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); column = new DataGridViewTextBoxColumn(); column.Name = "Best Segment"; column.Width = 100; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); runGrid.EditingControlShowing += runGrid_EditingControlShowing; cbxGameName.DataBindings.Add("Text", this, "GameName"); cbxRunCategory.DataBindings.Add("Text", this, "CategoryName"); tbxTimeOffset.DataBindings.Add("Text", this, "Offset"); tbxAttempts.DataBindings.Add("Text", this, "AttemptCount"); picGameIcon.Image = GameIcon; removeIconToolStripMenuItem.Enabled = state.Run.GameIcon != null; cbxGameName.GetAllItemsForText = x => new string[0]; Task.Factory.StartNew(() => { try { gameNames = CompositeGameList.Instance.GetGameNames().ToArray(); abbreviations = gameNames .Select(x => x.GetAbbreviations() .Select(y => new KeyValuePair<string, string>(x, y))) .SelectMany(x => x) .GroupBy(x => x.Value, x => x.Key); cbxGameName.GetAllItemsForText = x => SearchForGameName(x); this.InvokeIfRequired(() => { try { cbxGameName.Items.AddRange(gameNames); } catch (Exception ex) { Log.Error(ex); } }); } catch (Exception ex) { Log.Error(ex); } }); cbxRunCategory.AutoCompleteSource = AutoCompleteSource.ListItems; cbxRunCategory.Items.AddRange(new[] { "Any%", "Low%", "100%" }); cbxRunCategory.AutoCompleteMode = AutoCompleteMode.SuggestAppend; SelectedMethod = state.CurrentTimingMethod; RefreshCategoryAutoCompleteList(); UpdateSegmentList(); RefreshAutoSplittingUI(); SetClickEvents(this); }
public RunEditorDialog(LiveSplitState state) { InitializeComponent(); CurrentState = state; Run = state.Run; CurrentSplitIndexOffset = 0; AllowChangingSegments = false; SegmentTimeList = new List<TimeSpan?>(); TimeFormatter = new ShortTimeFormatter(); SegmentList = new BindingList<ISegment>(Run); SegmentList.AllowNew = true; SegmentList.AllowRemove = true; SegmentList.AllowEdit = true; SegmentList.AddingNew += SegmentList_AddingNew; SegmentList.ListChanged += SegmentList_ListChanged; runGrid.AutoGenerateColumns = false; runGrid.AutoSize = true; runGrid.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False; runGrid.DataSource = SegmentList; runGrid.CellValueChanged += runGrid_CellValueChanged; runGrid.CellDoubleClick += runGrid_CellDoubleClick; runGrid.CellFormatting += runGrid_CellFormatting; runGrid.CellParsing += runGrid_CellParsing; runGrid.CellValidating += runGrid_CellValidating; runGrid.CellEndEdit += runGrid_CellEndEdit; runGrid.UserDeletingRow += runGrid_UserDeletingRow; runGrid.UserDeletedRow += runGrid_UserDeletedRow; runGrid.SelectionChanged += runGrid_SelectionChanged; var iconColumn = new DataGridViewImageColumn() { ImageLayout = DataGridViewImageCellLayout.Zoom }; iconColumn.DataPropertyName = "Icon"; iconColumn.Name = "Icon"; iconColumn.Width = 50; iconColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; iconColumn.DefaultCellStyle.NullValue = Properties.Resources.DefaultSplitIcon; runGrid.Columns.Add(iconColumn); var column = new DataGridViewTextBoxColumn(); column.DataPropertyName = "Name"; column.Name = "Segment Name"; column.MinimumWidth = 120; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); column = new DataGridViewTextBoxColumn(); column.Name = "Split Time"; column.Width = 100; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); column = new DataGridViewTextBoxColumn(); column.Name = "Segment Time"; column.Width = 100; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); column = new DataGridViewTextBoxColumn(); column.Name = "Best Segment"; column.Width = 100; column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; column.SortMode = DataGridViewColumnSortMode.NotSortable; runGrid.Columns.Add(column); runGrid.EditingControlShowing += runGrid_EditingControlShowing; cbxGameName.DataBindings.Add("Text", this, "GameName"); cbxRunCategory.DataBindings.Add("Text", this, "CategoryName"); tbxTimeOffset.DataBindings.Add("Text", this, "Offset"); tbxAttempts.DataBindings.Add("Text", this, "AttemptCount"); picGameIcon.DataBindings.Add("Image", this, "GameIcon"); cbxGameName.AutoCompleteSource = AutoCompleteSource.ListItems; Task.Factory.StartNew(() => { try { var gameNames = SpeedrunCom.Instance.GetGameNames().ToArray(); Action invokation = () => { try { cbxGameName.Items.AddRange(gameNames); } catch (Exception ex) { Log.Error(ex); } }; if (InvokeRequired) Invoke(invokation); else invokation(); } catch (Exception ex) { Log.Error(ex); } }); cbxGameName.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cbxRunCategory.AutoCompleteSource = AutoCompleteSource.ListItems; cbxRunCategory.Items.AddRange(new[] { "Any%", "Low%", "100%" }); cbxRunCategory.AutoCompleteMode = AutoCompleteMode.SuggestAppend; RefreshCategoryAutoCompleteList(); UpdateSegmentList(); RefreshAutoSplittingUI(); }
public Timer() { BigTextLabel = new SimpleLabel() { HorizontalAlignment = StringAlignment.Far, VerticalAlignment = StringAlignment.Near, Width = 493, Text = "0", }; SmallTextLabel = new SimpleLabel() { HorizontalAlignment = StringAlignment.Near, VerticalAlignment = StringAlignment.Near, Width = 257, Text = "0", }; BigMeasureLabel = new SimpleLabel() { Text = "88:88:88", IsMonospaced = true }; Formatter = new ShortTimeFormatter(); Settings = new TimerSettings(); UpdateTimeFormat(); Cache = new GraphicsCache(); }