private void rawTextToolStripMenuItem_Click(object sender, EventArgs e) { if (_Result.Count == 0) { MessageBox.Show("List is empty", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } string Path = ""; using (SaveFileDialog sfd = new SaveFileDialog() { AddExtension = true, CheckPathExists = true, Filter = "Text file|*.txt", FilterIndex = 0 }) { if (sfd.ShowDialog() != DialogResult.OK) { return; } Path = sfd.FileName; } try { using (StreamWriter sw = new StreamWriter(Path, false)) { StopType prevStop = StopType.Ctrl; foreach (var stop in _Result) { if (stop.Type == StopType.Ctrl) { sw.WriteLine(StopsFactory.SeparatorToString(stop)); } else if (prevStop == stop.Type) { sw.WriteLine(string.Format("\t{0}", StopsFactory.GetStopName(stop))); } else { prevStop = stop.Type; sw.WriteLine(string.Format("{0}:\t{1}", StopsFactory.StopTypeToString(stop.Type), StopsFactory.GetStopName(stop))); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void WriteText(List <Stop> ResSW, List <Stop> ResGT, List <Stop> ResPD, List <Stop> ResCP, string Text = null) { int id = 0; bool Stop = false; while (true) { Stop = true; string[] buf = new string[5]; if (Text.IsNotNullAndNotEmpty()) { buf[0] = Text; Text = null; Stop = false; } if (id < ResSW.Count) { buf[2] = StopsFactory.GetStopName(ResSW[id]); Stop = false; } if (id < ResGT.Count) { buf[1] = StopsFactory.GetStopName(ResGT[id]); Stop = false; } if (id < ResPD.Count) { buf[3] = StopsFactory.GetStopName(ResPD[id]); Stop = false; } if (id < ResCP.Count) { buf[4] = StopsFactory.GetStopName(ResCP[id]); Stop = false; } if (Stop) { break; } else { listView1.Items.Add(new ListViewItem(buf)); } id++; } }