private void btnExportData_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = ScreenManagerLang.DataAnalysis_ExportData; saveFileDialog.Filter = FilesystemHelper.SaveCSVFilter(); saveFileDialog.FilterIndex = 1; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() != DialogResult.OK || string.IsNullOrEmpty(saveFileDialog.FileName)) { return; } string separator = CultureInfo.CurrentCulture.TextInfo.ListSeparator; using (StreamWriter w = File.CreateText(saveFileDialog.FileName)) { string unit = UnitHelper.LengthAbbreviation(metadata.CalibrationHelper.LengthUnit); w.WriteLine(string.Format("t (ms){0}x ({1}){0}y ({1})", separator, unit)); foreach (TimedPoint point in points) { string time = metadata.TimeCodeBuilder(point.T, TimeType.UserOrigin, TimecodeFormat.Milliseconds, false); PointF p = metadata.CalibrationHelper.GetPointAtTime(point.Point, point.T); w.WriteLine(string.Format("{0}{3}{1}{3}{2}", time, p.X, p.Y, separator)); } } }
public void WriteXml(XmlWriter w, SerializationFilter filter) { if (ShouldSerializeCore(filter)) { w.WriteElementString("Position", XmlHelper.WritePointF(mainBackground.Rectangle.Location)); w.WriteStartElement("Values"); w.WriteElementString("Visible", (visibleTimestamp == long.MaxValue) ? "-1" : visibleTimestamp.ToString()); w.WriteElementString("StartCounting", (startCountingTimestamp == long.MaxValue) ? "-1" : startCountingTimestamp.ToString()); w.WriteElementString("StopCounting", (stopCountingTimestamp == long.MaxValue) ? "-1" : stopCountingTimestamp.ToString()); w.WriteElementString("Invisible", (invisibleTimestamp == long.MaxValue) ? "-1" : invisibleTimestamp.ToString()); w.WriteElementString("Countdown", countdown.ToString().ToLower()); if (ShouldSerializeAll(filter)) { // Spreadsheet support string userDuration = "0"; if (startCountingTimestamp != long.MaxValue && stopCountingTimestamp != long.MaxValue) { userDuration = parentMetadata.TimeCodeBuilder(stopCountingTimestamp - startCountingTimestamp, TimeType.Duration, TimecodeFormat.Unknown, false); } w.WriteElementString("UserDuration", userDuration); } // </values> w.WriteEndElement(); } if (ShouldSerializeStyle(filter)) { // Label w.WriteStartElement("Label"); w.WriteElementString("Text", label); w.WriteElementString("Show", showLabel.ToString().ToLower()); w.WriteEndElement(); w.WriteStartElement("DrawingStyle"); style.WriteXml(w); w.WriteEndElement(); } }
public void WriteXml(XmlWriter w) { w.WriteStartElement("Position"); if (metadata.TimeCodeBuilder != null) { string userTime = metadata.TimeCodeBuilder(position, TimeType.UserOrigin, TimecodeFormat.Unknown, false); w.WriteAttributeString("UserTime", userTime); } w.WriteString(position.ToString()); w.WriteEndElement(); if (!string.IsNullOrEmpty(Title)) { w.WriteElementString("Title", Title); } if (!string.IsNullOrEmpty(comments)) { w.WriteElementString("Comment", comments); } if (drawings.Count == 0) { return; } // Drawings are written in reverse order to match order of addition. w.WriteStartElement("Drawings"); for (int i = drawings.Count - 1; i >= 0; i--) { IKvaSerializable serializableDrawing = drawings[i] as IKvaSerializable; if (serializableDrawing == null) { continue; } DrawingSerializer.Serialize(w, serializableDrawing, SerializationFilter.All); } w.WriteEndElement(); }