コード例 #1
0
        private void loading_file(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Текстовый файл (*.txt)|*.txt|Звуковой файл (*.wav)|*.wav|Dat-файл (*.dat)|*.dat";
            if (openFileDialog.ShowDialog() == true)
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                data_all = File.ReadAllLines(openFileDialog.FileName);

                // Важные переменные
                channel_num = Convert.ToInt32(data_all[1]);
                samples_num = Convert.ToInt32(data_all[3]);
                double k = Double.Parse(data_all[5]);
                sampling_rate  = Convert.ToInt32(k);
                start_date     = data_all[7];
                start_time     = data_all[9];
                channels_names = data_all[11];
                string[] date_channel = new string[samples_num];
                Array.Copy(data_all, 12, date_channel, 0, samples_num);

                ChannelAnalyzer analyzer = new ChannelAnalyzer(channel_num, samples_num, date_channel, channels_names);
                analyzer.Show();
            }
        }
コード例 #2
0
        private void loading_file(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Текстовый файл (*.txt)|*.txt|Звуковой файл (*.wav)|*.wav|Dat-файл (*.dat)|*.dat";
            if (openFileDialog.ShowDialog() == true)
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                data_all = File.ReadAllLines(openFileDialog.FileName, Encoding.UTF8);

                // Важные переменные
                channel_num = Convert.ToInt32(data_all[1]);
                samples_num = Convert.ToInt32(data_all[3]);
                double k = Double.Parse(data_all[5]);
                sampling_rate  = Convert.ToInt32(k);
                start_date     = data_all[7];
                start_time     = data_all[9];
                channels_names = data_all[11];
                string[] date_channel = new string[samples_num];
                Array.Copy(data_all, 12, date_channel, 0, samples_num);

                //Ахуительное решение 10 из 10
                if (samples_num > 400000)
                {
                    a = samples_num / 300;
                }
                if (samples_num > 212000)
                {
                    a = samples_num / 1000;
                }
                if (samples_num > 104000)
                {
                    a = samples_num / 419;
                }
                if (samples_num > 41000)
                {
                    a = samples_num / 466;
                }
                if (samples_num > 15000)
                {
                    a = samples_num / 524;
                }
                if (samples_num > 1200)
                {
                    a = samples_num / 404;
                }

                date_channels = new string[channel_num + 1];
                for (int i = 0; i < samples_num; i += a)
                {
                    string[] tmp = date_channel[i].Split(' ');
                    for (int j = 0; j < channel_num; j++)
                    {
                        date_channels[j] += tmp[j] + ',';
                    }
                }

                names = channels_names.Split(';');

                ChannelAnalyzer analyzer = new ChannelAnalyzer(channel_num, date_channels, names);

                // добавление подменю каналов
                oscillograms.Items.Clear();


                // фиксирование размера и положения окна
                // Owner - определяет окно как дочернее
                analyzer.Owner     = this;
                analyzer.MaxHeight = 85 * channel_num;
                analyzer.MinHeight = analyzer.MaxHeight;
                analyzer.Top       = this.Top + 60;
                analyzer.Left      = this.Left + 4;

                analyzer.Show();

                // фиксирование дочернего окна при перемещении главного
                LocationChanged += new EventHandler((object sender, EventArgs e) => {
                    foreach (Window win in this.OwnedWindows)
                    {
                        win.Top  = this.Top + 60;
                        win.Left = this.Left + 4;
                    }
                });
            }
        }