Пример #1
0
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            List <ISendableConfig> configList = new List <ISendableConfig>();

            configList.AddRange(ReceiverList);
            if (!Settings.Default.EnableDBMode)
            {
                configList.AddRange(MeasureList);
            }
            configList.AddRange(RecoderList);
            try
            {
                using (FileStream fStream = new FileStream("Config.dat", FileMode.Create))
                {
                    foreach (var conf in configList)
                    {
                        ConfigPacket packet = Packing(conf);
                        packet.Write(fStream);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (SelectedReceiver != null)
            {
                SelectedReceiver.Stop();
                SelectedReceiver = null;
            }

            if (RecoderList.Count > 0)
            {
                foreach (var recoder in RecoderList)
                {
                    recoder.Stop();
                }
            }
            SQLRepository.Close();
        }