コード例 #1
0
        /// <summary>
        /// Cохраняет текстовый файл по пути, и в случае если путь - дубликат, добавляет соотвествующую цифорку
        /// </summary>
        /// <param name="path"></param>
        public static string saveTextFile(string path, SerialPort port, TwoCordLinkedList listOfPoints)
        {
            string s = Parsing.GetData(port, listOfPoints);

            try
            {
                using (StreamWriter file = new StreamWriter(path))
                {
                    file.Write(s);
                    file.Close();
                }
            }
            catch (System.IO.DirectoryNotFoundException) { MessageBox.Show("System.IO.DirectoryNotFoundException"); }
            return(path);
        }
コード例 #2
0
        /// <summary>
        /// Writes everything from TwoCoordLinkedList to a string. As a result we should get string with all recorded data
        /// </summary>
        /// <param name="port">Port through which transfer is happening, it is required so that GetData wont fire if the port isn't open.</param>
        /// <param name="listOfPoints">Linked list with recieved data</param>
        /// <returns>String containing data from Linked List in a specific form, every node is transformed </returns>
        public static string GetData(SerialPort port, TwoCordLinkedList listOfPoints)
        {
            string s = "";

            if (port != null && port.IsOpen)
            {
                TwoCordLinkedList.Node temp = listOfPoints.Head.Prev; //Ставим ссылку на элемент перед головным.
                while (temp.Prev != listOfPoints.Head)
                {
                    s   += "N = " + temp.X + " " + "F = " + temp.Y + " \r\n";
                    temp = temp.Prev; //Почемуму до последнего?
                }
            }
            return(s);
        }