Exemplo n.º 1
0
        private void DataSend_ExportBtn_Click(object sender, EventArgs e)
        {
            /* --------------------- Create Variable --------------------- */

            Int32 item_counter = SerialPort_SendDataListBox.Items.Count; /* Variable for count items */

            /* --------------------- Create Object --------------------- */

            SaveFileDialog file_info = new SaveFileDialog(); /* Create object for get directory addres - "folderaddresopen" is the name of object */

            /* --------------------- Object config --------------------- */

            file_info.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; /* Set format filter */
            file_info.FilterIndex      = 1;                                             /* Select first index */
            file_info.RestoreDirectory = true;                                          /* Change directory to the previously location before close */

            /* --------------------------------------------------------- */

            if (file_info.ShowDialog() == DialogResult.OK) /* Check status */
            {
                /* --------------------- Create Object --------------------- */

                TextWriter file = new StreamWriter(file_info.OpenFile()); /* Object for create and write in txt file */

                /* --------------------------------------------------------- */

                for (int i = 0; i < item_counter; i++)                              /* Loop for write to txt file */
                {
                    file.WriteLine(SerialPort_SendDataListBox.Items[i].ToString()); /* Write items to txt file */
                }

                file.Close(); /* Close the TextWriter Object(file) */

                /* ---------------------------------------- */

                CustomForm.ShowCustomMessage(Color.FromArgb(247, 247, 247), Properties.Resources.Ok_1, "Exported"); /* Show message */
            }
            else
            {
                CancelForm.ShowCanceledMessage(); /* Show message */
            }

            /* Function end */
        }
        public static void ShowCanceledMessage()
        {
            CancelForm CanceledMessage = new CancelForm(); /* Create object */

            CanceledMessage.ShowDialog();                  /* Show message */
        }