Ejemplo n.º 1
0
        private void DrawText()
        {
            List <Stop> ResGT = new List <Stop>();
            List <Stop> ResSW = new List <Stop>();
            List <Stop> ResPD = new List <Stop>();
            List <Stop> ResCP = new List <Stop>();
            string      Text  = null;

            for (int i = 0; i < _Result.Count;)
            {
                while (i < _Result.Count)
                {
                    var Cur = _Result[i];
                    switch (Cur.Type)
                    {
                    case StopType.Swell:
                    case StopType.SwellDAT:
                        ResSW.Add(Cur);
                        break;

                    case StopType.Great:
                    case StopType.GreatDAT:
                        ResGT.Add(Cur);
                        break;

                    case StopType.Pedal:
                    case StopType.PedalDAT:
                        ResPD.Add(Cur);
                        break;

                    case StopType.CP:
                        ResCP.Add(Cur);
                        break;
                    }
                    if (Cur.Type == StopType.Ctrl && (Cur.id1 & StopsFactory.SeparatorFlag) != 0)
                    {
                        if (i != 0)
                        {
                            WriteText(ResSW, ResGT, ResPD, ResCP, Text);
                            ResSW.Clear();
                            ResGT.Clear();
                            ResPD.Clear();
                            ResCP.Clear();
                            DrawHR();
                        }
                        Text = StopsFactory.SeparatorToString(Cur);
                    }
                    i++;
                }
            }
            WriteText(ResSW, ResGT, ResPD, ResCP, Text);
        }
Ejemplo n.º 2
0
        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);
            }
        }