private void Button_Click(object sender, RoutedEventArgs e) { var dlg = new OpenFileDialog() { DefaultExt = "iso", Filter = "Cnc iso file |*.iso" }; var b = dlg.ShowDialog(); if (b.HasValue && b.Value) { IsoParser.Parse(dlg.FileName, true); } }
private void LoadStepsCommandImplementation() { var dlg = MVMIoc.SimpleIoc <IFileDialog> .GetInstance("OpenFile"); var data = MVMIoc.SimpleIoc <IStepsContainer> .GetInstance(); dlg.AddExtension = true; dlg.DefaultExt = "msteps"; dlg.Filter = "Machine steps |*.msteps|Cnc iso file |*.iso|Cnc iso file |*.i"; var b = dlg.ShowDialog(); if (b.HasValue && b.Value) { var extension = System.IO.Path.GetExtension(dlg.FileName).Replace(".", ""); if (string.Compare(extension, "msteps", true) == 0) { var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MachineStepsDocument)); using (var reader = new System.IO.StreamReader(dlg.FileName)) { var doc = (MachineStepsDocument)serializer.Deserialize(reader); if (doc != null) { LoadDataSteps(data, doc); data.SourceName = dlg.FileName; } } } else if ((string.Compare(extension, "iso", true) == 0) || (string.Compare(extension, "i", true) == 0)) { var doc = IsoParser.Parse(dlg.FileName, true, GetLinkLimits, GetLinearLinkCount, GetLinearLinksIds); if (doc != null) { LoadDataSteps(data, doc); data.SourceName = dlg.FileName; } } } }
public static MachineStepsDocument LoadAndParse(string fileName, bool traceOut = false, Func<int, Tuple<double, double>> getLinkLimits = null, Func<int> getLinearLinksCount = null) { return IsoParser.Parse(fileName, traceOut, getLinkLimits, getLinearLinksCount); }