internal static void SaveCaptureProperties(string filename, CaptureProperties properties)
 {
     XmlSerializer ser = new XmlSerializer(typeof(CaptureProperties));
     using (FileStream fs = File.Create(filename))
     {
         ser.Serialize(fs, properties);
     }
 }
Beispiel #2
0
        internal static void SaveCaptureProperties(string filename, CaptureProperties properties)
        {
            XmlSerializer ser = new XmlSerializer(typeof(CaptureProperties));

            using (FileStream fs = File.Create(filename))
            {
                ser.Serialize(fs, properties);
            }
        }
Beispiel #3
0
        private void InitializeCaptureProperties()
        {
            properties = CapturePropertiesUtils.CreateDefaultCaptureProperties();
            if (!String.IsNullOrEmpty(filename))
            {
                LoadProperties(filename);
            }

            UpdateTitle();
        }
 internal static CaptureProperties CreateDefaultCaptureProperties()
 {
     CaptureProperties prop = new CaptureProperties();
     prop.MinFrequency = 40;
     prop.MaxFrequency = 2000;
     prop.Palette = DisplayPalette.Green;
     prop.FrequencyMarks.Add(
         new FrequencyMark() { Frequency = 440, ColorName = "Blue", Label = "A4" }
     );
     return prop;
 }
Beispiel #5
0
        private void LoadProperties(string filename)
        {
            try
            {
                properties = CapturePropertiesUtils.LoadCaptureProperties(filename);

                this.filename = filename;
                modified      = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Load failed: " + ex.Message);
            }
        }
        private void SetFields(CaptureProperties props)
        {
            // general
            minFreqTextBox.Text = props.MinFrequency.ToString();
            maxFreqTextBox.Text = props.MaxFrequency.ToString();

            timeMarksCheckBox.Checked = props.IsSecondsMarked;
            markIntervalUpDown.Value  = props.SecondMarkEvery;

            // values
            paletteComboBox.SelectedIndex = Array.IndexOf(
                PaletteComboBoxItems, props.Palette);

            if (props.DisplayMethod is LinearDisplayMethodFactory)
            {
                LinearDisplayMethodFactory dm = (LinearDisplayMethodFactory)props.DisplayMethod;
                linearRadioButton.Checked = true;
                linearScaleTextBox.Text   = dm.Scale.ToString();
                linearOffsetTextBox.Text  = dm.Offset.ToString();
            }
            else
            {
                Log10DisplayMethodFactory dm = props.DisplayMethod as Log10DisplayMethodFactory;
                if (dm == null)
                {
                    dm = new Log10DisplayMethodFactory();
                }

                log10RadioButton.Checked  = true;
                log10MinOrderTextBox.Text = dm.MinOrder.ToString();
                log10MaxOrderTextBox.Text = dm.MaxOrder.ToString();
            }
            UpdateValueMethodView();

            // marks
            marksListView.Items.Clear();
            foreach (FrequencyMark mark in props.FrequencyMarks)
            {
                ListViewItem item = new ListViewItem();
                item.Text = mark.Frequency.ToString();
                item.SubItems.Add(mark.ColorName);
                item.SubItems.Add(mark.Label);
                marksListView.Items.Add(item);
            }

            // capture
            sampleRateComboBox.Text = props.SampleRate.ToString();
            windowTextBox.Text      = props.Window.ToString();
            intervalTextBox.Text    = props.Delta.ToString();
        }
Beispiel #7
0
        private void newSpectrogramToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!EnsureNotBusy())
            {
                return;
            }

            properties = CapturePropertiesUtils.CreateDefaultCaptureProperties();
            EditProperties();

            modified = true;
            filename = null;

            UpdateTitle();
        }
Beispiel #8
0
        internal static CaptureProperties CreateDefaultCaptureProperties()
        {
            CaptureProperties prop = new CaptureProperties();

            prop.MinFrequency = 40;
            prop.MaxFrequency = 2000;
            prop.Palette      = DisplayPalette.Green;
            prop.FrequencyMarks.Add(
                new FrequencyMark()
            {
                Frequency = 440, ColorName = "Blue", Label = "A4"
            }
                );
            return(prop);
        }
Beispiel #9
0
        private void EditProperties()
        {
            using (PropertiesForm form = new PropertiesForm())
            {
                form.CaptureProperties = properties;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    properties = form.CaptureProperties;

                    modified = true;
                    UpdateTitle();

                    SetupDisplay();
                }
            }
        }
        private CaptureProperties GetFields()
        {
            CaptureProperties props = new CaptureProperties();

            // general
            Double.TryParse(minFreqTextBox.Text, out props.MinFrequency);
            Double.TryParse(maxFreqTextBox.Text, out props.MaxFrequency);
            props.IsSecondsMarked = timeMarksCheckBox.Checked;
            props.SecondMarkEvery = (int)markIntervalUpDown.Value;

            // values
            props.Palette = PaletteComboBoxItems[paletteComboBox.SelectedIndex];
            if (linearRadioButton.Checked)
            {
                LinearDisplayMethodFactory dm = new LinearDisplayMethodFactory();
                Double.TryParse(linearScaleTextBox.Text, out dm.Scale);
                Double.TryParse(linearOffsetTextBox.Text, out dm.Offset);
                props.DisplayMethod = dm;
            }
            else
            {
                Log10DisplayMethodFactory dm = new Log10DisplayMethodFactory();
                Double.TryParse(log10MinOrderTextBox.Text, out dm.MinOrder);
                Double.TryParse(log10MaxOrderTextBox.Text, out dm.MaxOrder);
                props.DisplayMethod = dm;
            }

            // marks
            foreach (ListViewItem item in marksListView.Items)
            {
                FrequencyMark mark = new FrequencyMark();
                Double.TryParse(item.Text, out mark.Frequency);
                mark.ColorName = item.SubItems[1].Text;
                mark.Label     = item.SubItems[2].Text;
                props.FrequencyMarks.Add(mark);
            }

            // capture
            Int32.TryParse(sampleRateComboBox.Text, out props.SampleRate);
            Int32.TryParse(windowTextBox.Text, out props.Window);
            Int32.TryParse(intervalTextBox.Text, out props.Delta);

            return(props);
        }
        private CaptureProperties GetFields()
        {
            CaptureProperties props = new CaptureProperties();
            // general
            Double.TryParse(minFreqTextBox.Text, out props.MinFrequency);
            Double.TryParse(maxFreqTextBox.Text, out props.MaxFrequency);
            props.IsSecondsMarked = timeMarksCheckBox.Checked;
            props.SecondMarkEvery = (int)markIntervalUpDown.Value;

            // values
            props.Palette = PaletteComboBoxItems[paletteComboBox.SelectedIndex];
            if (linearRadioButton.Checked)
            {
                LinearDisplayMethodFactory dm = new LinearDisplayMethodFactory();
                Double.TryParse(linearScaleTextBox.Text, out dm.Scale);
                Double.TryParse(linearOffsetTextBox.Text, out dm.Offset);
                props.DisplayMethod = dm;
            }
            else
            {
                Log10DisplayMethodFactory dm = new Log10DisplayMethodFactory();
                Double.TryParse(log10MinOrderTextBox.Text, out dm.MinOrder);
                Double.TryParse(log10MaxOrderTextBox.Text, out dm.MaxOrder);
                props.DisplayMethod = dm;
            }

            // marks
            foreach (ListViewItem item in marksListView.Items)
            {
                FrequencyMark mark = new FrequencyMark();
                Double.TryParse(item.Text, out mark.Frequency);
                mark.ColorName = item.SubItems[1].Text;
                mark.Label = item.SubItems[2].Text;
                props.FrequencyMarks.Add(mark);
            }

            // capture
            Int32.TryParse(sampleRateComboBox.Text, out props.SampleRate);
            Int32.TryParse(windowTextBox.Text, out props.Window);
            Int32.TryParse(intervalTextBox.Text, out props.Delta);

            return props;
        }
        private void SetFields(CaptureProperties props)
        {
            // general
            minFreqTextBox.Text = props.MinFrequency.ToString();
            maxFreqTextBox.Text = props.MaxFrequency.ToString();

            timeMarksCheckBox.Checked = props.IsSecondsMarked;
            markIntervalUpDown.Value = props.SecondMarkEvery;

            // values
            paletteComboBox.SelectedIndex = Array.IndexOf(
                PaletteComboBoxItems, props.Palette);

            if (props.DisplayMethod is LinearDisplayMethodFactory)
            {
                LinearDisplayMethodFactory dm = (LinearDisplayMethodFactory)props.DisplayMethod;
                linearRadioButton.Checked = true;
                linearScaleTextBox.Text = dm.Scale.ToString();
                linearOffsetTextBox.Text = dm.Offset.ToString();
            }
            else
            {
                Log10DisplayMethodFactory dm = props.DisplayMethod as Log10DisplayMethodFactory;
                if (dm == null) dm = new Log10DisplayMethodFactory();

                log10RadioButton.Checked = true;
                log10MinOrderTextBox.Text = dm.MinOrder.ToString();
                log10MaxOrderTextBox.Text = dm.MaxOrder.ToString();
            }
            UpdateValueMethodView();

            // marks
            marksListView.Items.Clear();
            foreach (FrequencyMark mark in props.FrequencyMarks)
            {
                ListViewItem item = new ListViewItem();
                item.Text = mark.Frequency.ToString();
                item.SubItems.Add(mark.ColorName);
                item.SubItems.Add(mark.Label);
                marksListView.Items.Add(item);
            }

            // capture
            sampleRateComboBox.Text = props.SampleRate.ToString();
            windowTextBox.Text = props.Window.ToString();
            intervalTextBox.Text = props.Delta.ToString();
        }
Beispiel #13
0
        private void newSpectrogramToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!EnsureNotBusy()) return;

            properties = CapturePropertiesUtils.CreateDefaultCaptureProperties();
            EditProperties();

            modified = true;
            filename = null;

            UpdateTitle();
        }
Beispiel #14
0
        private void LoadProperties(string filename)
        {
            try
            {
                properties = CapturePropertiesUtils.LoadCaptureProperties(filename);

                this.filename = filename;
                modified = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Load failed: " + ex.Message);
            }
        }
Beispiel #15
0
        private void InitializeCaptureProperties()
        {
            properties = CapturePropertiesUtils.CreateDefaultCaptureProperties();
            if (!String.IsNullOrEmpty(filename))
            {
                LoadProperties(filename);
            }

            UpdateTitle();
        }
Beispiel #16
0
        private void EditProperties()
        {
            using (PropertiesForm form = new PropertiesForm())
            {
                form.CaptureProperties = properties;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    properties = form.CaptureProperties;

                    modified = true;
                    UpdateTitle();

                    SetupDisplay();
                }
            }
        }