Exemple #1
0
        private void Parse()
        {
            Reader rd = null;

            if (_Path.ToLower().EndsWith(".cps"))
            {
                rd = new CPSReader();
            }
            else
            {
                rd = new DATReader();
            }
            rd.ReOpen(_Path);
            bool flag = rd.Reset();

            _Result.Clear();
            while (!rd.IsEnd(_MaxM) && flag)
            {
                if (!_ParseEmptyBlocks && rd.IsEmpty())
                {
                    flag = rd.Next();
                    continue;
                }
                _Result.Add(StopsFactory.CreateSeparator(rd.M, rd.P));
                rd.GetSW(_Result);
                rd.GetGT(_Result);
                rd.GetPD(_Result);
                rd.GetCP(_Result);
                flag = rd.Next();
            }
            rd.Close();
        }
Exemple #2
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);
        }
Exemple #3
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);
            }
        }
Exemple #4
0
        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++;
            }
        }