public StreamSourceEditorDialog(RadioLog.Common.SignalSource src)
        {
            if (src == null)
            {
                throw new ArgumentNullException();
            }

            InitializeComponent();

            _src = src;

            RadioLog.WPFCommon.BrushSelectionHolder[] colors = RadioLog.WPFCommon.ColorHelper.GetBrushSelectionItems();
            System.Collections.ObjectModel.ObservableCollection <RadioLog.WPFCommon.BrushSelectionHolder> colorList = new System.Collections.ObjectModel.ObservableCollection <WPFCommon.BrushSelectionHolder>(colors);
            colorList.Insert(0, new WPFCommon.BrushSelectionHolder("Default", null));
            cbSourceColor.ItemsSource = colorList;
            if (string.IsNullOrEmpty(_src.SourceColor))
            {
                cbSourceColor.SelectedIndex = 0;
            }
            else
            {
                cbSourceColor.SelectedValue = _src.SourceColor;
            }

            tbSourceName.Text           = _src.SourceName;
            tbStreamURL.Text            = _src.SourceLocation;
            sRecordingKickTime.Value    = _src.RecordingKickTime;
            tsRecordingEnabled.IsOn     = _src.RecordAudio;
            tsPriority.IsOn             = _src.IsPriority;
            cbDecodeMDC1200.IsChecked   = _src.DecodeMDC1200;
            cbDecodeGEStar.IsChecked    = _src.DecodeGEStar;
            cbDecodeFleetSync.IsChecked = _src.DecodeFleetSync;
            cbRemoveNoise.IsChecked     = _src.RemoveNoise;
            sDisplayOrder.Value         = _src.DisplayOrder;

            LoadDeviceLists();
            cbNoiseFloor.ItemsSource   = _noiseFloorList;
            cbNoiseFloor.SelectedValue = _src.NoiseFloor;
            sCustomNoiseFloor.Value    = _src.CustomNoiseFloor;
            cbWaveOutDev.ItemsSource   = _waveOutList;
            if (_waveOutList.Count > 0 && !string.IsNullOrWhiteSpace(_src.WaveOutDeviceName))
            {
                cbWaveOutDev.SelectedItem = (_waveOutList.FirstOrDefault(l => l.DeviceName == _src.WaveOutDeviceName));
            }
            if (string.IsNullOrWhiteSpace(_src.WaveOutDeviceName) || cbWaveOutDev.SelectedIndex < 0)
            {
                cbWaveOutDev.SelectedIndex = 0;
            }

            switch (_src.RecordingType)
            {
            case Common.SignalRecordingType.Fixed: cbRecordingStyle.SelectedIndex = 1; break;

            default: cbRecordingStyle.SelectedIndex = 0; break;
            }
            UpdateForSelectedRecordingStyle();

            DisplayQRCode(_src.SourceLocation);
        }
        public StreamSourceEditorDialog(RadioLog.Common.SignalSource src)
        {
            if (src == null)
                throw new ArgumentNullException();

            InitializeComponent();

            _src = src;

            RadioLog.WPFCommon.BrushSelectionHolder[] colors = RadioLog.WPFCommon.ColorHelper.GetBrushSelectionItems();
            System.Collections.ObjectModel.ObservableCollection<RadioLog.WPFCommon.BrushSelectionHolder> colorList = new System.Collections.ObjectModel.ObservableCollection<WPFCommon.BrushSelectionHolder>(colors);
            colorList.Insert(0, new WPFCommon.BrushSelectionHolder("Default", null));
            cbSourceColor.ItemsSource = colorList;
            if (string.IsNullOrEmpty(_src.SourceColor))
                cbSourceColor.SelectedIndex = 0;
            else
                cbSourceColor.SelectedValue = _src.SourceColor;

            tbSourceName.Text = _src.SourceName;
            tbStreamURL.Text = _src.SourceLocation;
            sRecordingKickTime.Value = _src.RecordingKickTime;
            tsRecordingEnabled.IsChecked = _src.RecordAudio;
            tsPriority.IsChecked = _src.IsPriority;
            cbDecodeMDC1200.IsChecked = _src.DecodeMDC1200;
            cbDecodeGEStar.IsChecked = _src.DecodeGEStar;
            cbDecodeFleetSync.IsChecked = _src.DecodeFleetSync;
            cbRemoveNoise.IsChecked = _src.RemoveNoise;
            sDisplayOrder.Value = _src.DisplayOrder;

            LoadDeviceLists();
            cbNoiseFloor.ItemsSource = _noiseFloorList;
            cbNoiseFloor.SelectedValue = _src.NoiseFloor;
            sCustomNoiseFloor.Value = _src.CustomNoiseFloor;
            cbWaveOutDev.ItemsSource = _waveOutList;
            if (_waveOutList.Count > 0 && !string.IsNullOrWhiteSpace(_src.WaveOutDeviceName))
            {
                cbWaveOutDev.SelectedItem = (_waveOutList.FirstOrDefault(l => l.DeviceName == _src.WaveOutDeviceName));
            }
            if (string.IsNullOrWhiteSpace(_src.WaveOutDeviceName) || cbWaveOutDev.SelectedIndex < 0)
            {
                cbWaveOutDev.SelectedIndex = 0;
            }

            switch (_src.RecordingType)
            {
                case Common.SignalRecordingType.Fixed: cbRecordingStyle.SelectedIndex = 1; break;
                default: cbRecordingStyle.SelectedIndex = 0; break;
            }
            UpdateForSelectedRecordingStyle();

            DisplayQRCode(_src.SourceLocation);
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (!VerifySourceInputs())
            {
                return;
            }
            string colorName = string.Empty;

            if (cbSourceColor.SelectedIndex > 0)
            {
                colorName = cbSourceColor.SelectedValue as string;
            }
            int displayOrder = (int)sDisplayOrder.Value;

            RadioLog.Common.SignalSource newSrc = null;
            switch (SelectedSourceType)
            {
            case Common.SignalingSourceType.File:
            {
                //newSrc.SourceURL
                break;
            }

            case Common.SignalingSourceType.WaveInChannel:
            {
                newSrc = new Common.SignalSource()
                {
                    SourceName     = tbSourceName.Text,
                    SourceType     = Common.SignalingSourceType.WaveInChannel,
                    IsEnabled      = true,
                    SourceLocation = _channelList[cbMultiLineIn.SelectedIndex].DeviceName,
                    SourceChannel  = ((int)(nudChannelNumber.Value ?? 1) - 1)
                };
                break;
            }

            case Common.SignalingSourceType.Streaming:
            {
                string url;
                if (GetCorrectedStreamURL(tbStreamURL.Text, out url))
                {
                    newSrc = new Common.SignalSource()
                    {
                        SourceName     = tbSourceName.Text,
                        SourceType     = Common.SignalingSourceType.Streaming,
                        IsEnabled      = true,
                        SourceLocation = url
                    };
                }
                break;
            }
            }
            if (newSrc != null)
            {
                newSrc.SourceColor      = colorName;
                newSrc.DisplayOrder     = displayOrder;
                newSrc.NoiseFloor       = Common.NoiseFloor.Normal;
                newSrc.CustomNoiseFloor = 20;
                newSrc.RemoveNoise      = true;
                newSrc.Volume           = 50;
                newSrc.MaxVolume        = 100;
                if (cbGroup.SelectedValue != null)
                {
                    newSrc.GroupId = (Guid)cbGroup.SelectedValue;
                }
                RadioLog.Common.AppSettings.Instance.AddNewSignalSource(newSrc);
                Cinch.Mediator.Instance.NotifyColleagues <RadioLog.Common.SignalSource>("NEW_SIGNAL_SOURCE", newSrc);
                DialogResult = true;
            }
        }