public RunEditor(Split split) { InitializeComponent(); this.txtAttemptsCount.Text = "0"; rowHeight = this.segmentsGridView.RowTemplate.Height; AddRow(); if (split != null) { this.split = split; this.txtRunTitle.Text = this.split.RunTitle; this.txtRunGoal.Text = this.split.RunGoal; this.txtAttemptsCount.Text = this.split.AttemptsCount.ToString(); FillSegmentRows(); } }
/// <summary> /// Save split with the information in the editor. /// </summary> private void SaveSplit() { this.split = new Split(); this.split.RunTitle = this.txtRunTitle.Text; this.split.RunGoal = this.txtRunGoal.Text; this.split.AttemptsCount = (String.IsNullOrEmpty(txtAttemptsCount.Text.Trim())) ? 0 : Int32.Parse(txtAttemptsCount.Text); FillSplitSegments(); }
private void mnuImportFromLivesplit_Click(object sender, EventArgs e) { String fileName = ""; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog = new OpenFileDialog(); openFileDialog.DefaultExt = ".lss"; openFileDialog.Filter = "LiveSplit split file (*.lss)|*.lss"; openFileDialog.AddExtension = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { fileName = openFileDialog.FileName; LiveSplitXMLReader liveSplitXmlReader = new LiveSplitXMLReader(); this.split = liveSplitXmlReader.ReadSplit(fileName); this.ResetDataGridView(); if (this.split != null) { this.txtRunTitle.Text = this.split.RunTitle; this.txtAttemptsCount.Text = this.split.AttemptsCount.ToString(); FillSegmentRows(); FillSegmentTimeAfterImportFromLiveSplit(); } else { MessageBox.Show("The import from livesplit has failed."); } } }
private void mnuEditRun_Click(object sender, EventArgs e) { String splitFile = (this.split == null) ? null : this.split.File; int runsCompleted = (this.split == null) ? 0 : this.split.RunsCompleted; RunEditor runEditor = new RunEditor(this.split); runEditor.ShowDialog(); if (runEditor.DialogResult == DialogResult.OK) { String runTitle = runEditor.Split.RunTitle; String runGoal = runEditor.Split.RunGoal; int attemptsCount = runEditor.Split.AttemptsCount; List<Segment> segments = runEditor.Split.Segments; this.split = new Split(runTitle, runGoal, attemptsCount, segments); this.split.File = splitFile; this.split.RunsCompleted = runsCompleted; this.informations.Clear(); FillInformations(); CreateSegmentsRectangles(); this.displayMode = DisplayMode.SEGMENTS; } }
private void mnuCloseSplit_Click(object sender, EventArgs e) { this.split = null; this.displayMode = DisplayMode.TIMER_ONLY; this.watchRectangle.Y = ZERO; this.Height = DEFAULT_HEIGHT; }
private void LoadFile(String fileName) { String[] lines = File.ReadAllLines(fileName); String runTitle = ""; String runGoal = ""; int runCount = 0; int runsCompleted = 0; String segmentName = ""; String segmentSplitTime = ""; String segmentTime = ""; String segmentBestTime = ""; List<Segment> segments = new List<Segment>(); try { runTitle = lines.ElementAt(0); runGoal = lines.ElementAt(1); runCount = Int32.Parse(lines.ElementAt(2)); runsCompleted = Int32.Parse(lines.ElementAt(3)); for (int i = 4; i < lines.Length; ++i) { segmentName = lines.ElementAt(i).Split('-').ElementAt(0); segmentSplitTime = lines.ElementAt(i).Split('-').ElementAt(1); segmentTime = lines.ElementAt(i).Split('-').ElementAt(2); segmentBestTime = lines.ElementAt(i).Split('-').ElementAt(3); segments.Add(new Segment(segmentName, FaceSplitUtils.TimeParse(segmentSplitTime), FaceSplitUtils.TimeParse(segmentTime), FaceSplitUtils.TimeParse(segmentBestTime))); } this.split = new Split(runTitle, runGoal, runCount, segments); this.split.RunsCompleted = runsCompleted; this.split.File = fileName; this.informations.Clear(); FillInformations(); CreateSegmentsRectangles(); this.displayMode = DisplayMode.SEGMENTS; } catch (FormatException fe) { MessageBox.Show("This file was not recognize as a FaceSplit split file."); } catch (IndexOutOfRangeException iore) { MessageBox.Show("This file was not recognize as a FaceSplit split file."); } }